Compare commits
No commits in common. "8866177a37d6db223a5b3c7bf41e9978e79b1e33" and "45f22dea3e7c2afc788166dd52058a8ea8562145" have entirely different histories.
8866177a37
...
45f22dea3e
@ -3,38 +3,23 @@
|
|||||||
<head>
|
<head>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body
|
body {
|
||||||
{
|
display: flex;
|
||||||
display: flex;
|
min-height: 100vh;
|
||||||
min-height: 100vh;
|
flex-direction: column;
|
||||||
flex-direction: column;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
section
|
section {
|
||||||
{
|
flex: 1 0 auto;
|
||||||
flex: 1 0 auto;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.switch label input[type=checkbox]:checked+.lever
|
.switch label input[type=checkbox]:checked+.lever {
|
||||||
{
|
|
||||||
background-color: #fa3 !important;
|
background-color: #fa3 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.switch label input[type=checkbox]:checked+.lever:after
|
.switch label input[type=checkbox]:checked+.lever:after {
|
||||||
{
|
|
||||||
background-color: #f93 !important;
|
background-color: #f93 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode-img
|
|
||||||
{
|
|
||||||
width:40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cursorPointer:hover
|
|
||||||
{
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
@ -43,489 +28,160 @@
|
|||||||
<script src="rsrc/materialize.js"></script>
|
<script src="rsrc/materialize.js"></script>
|
||||||
<title>ESP8266 DASHBOARD</title>
|
<title>ESP8266 DASHBOARD</title>
|
||||||
</head>
|
</head>
|
||||||
<body onload="init();">
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<nav>
|
<nav>
|
||||||
<div class="nav-wrapper green accent-3">
|
<div class="nav-wrapper green accent-3">
|
||||||
<img onclick="sideNavinstance.open();" style="height:64px;" class="brand-logo left hoverable cursorPointer" src="rsrc/logo.png" alt="logo">
|
<a href="#" class="brand-logo hoverable left" style="padding: 0 10px 0 10px;"> logo</a>
|
||||||
<ul class="right" style="font-size:1.5em;">
|
<ul class="right" style="font-size:1.5em;">
|
||||||
<li class="hoverable tooltipped" data-position="bottom" data-tooltip="Browser time" style="margin:0 10px 0 10px;" id="browsertime_id">
|
<li class="hoverable" style="margin:0 10px; 0 10px;">
|
||||||
|
12:54:21
|
||||||
</li>
|
</li>
|
||||||
<li class="hoverable tooltipped" data-position="bottom" data-tooltip="Device time" style="margin:0 10px 0 10px;">
|
<li class="hoverable" style="margin:0 10px; 0 10px;">
|
||||||
<span id="rtcValue"></span>
|
17.25 °C
|
||||||
</li>
|
</li>
|
||||||
<li class="hoverable" style="margin:0 10px 0 10px;">
|
<li class="hoverable" style="margin:0 10px; 0 10px;">
|
||||||
<span id="temperature"></span>
|
90 %
|
||||||
</li>
|
</li>
|
||||||
<li class="hoverable tooltipped" data-position="bottom" data-tooltip="Link quality between the device and the router" style="margin:0 10px 0 10px;">
|
<li class="hoverable" style="margin:0 10px; 0 10px;">
|
||||||
<span id="sigStrengthPercent"></span> %
|
<img style="width:50px;vertical-align:middle;" id="imgSig1" src="rsrc/sigstr4.png" alt="sigstr4">
|
||||||
</li>
|
</li>
|
||||||
<li class="hoverable" style="margin:0 10px 0 10px;">
|
<li class="hoverable" style="margin:0 10px; 0 10px;">
|
||||||
<img style="width:50px;vertical-align:middle;" id="imgSig1" src="rsrc/sigstr1.png" alt="sigstr1">
|
-66 dBm
|
||||||
<img style="width:50px;vertical-align:middle;display:none;" id="imgSig2" src="rsrc/sigstr2.png" alt="sigstr2" >
|
|
||||||
<img style="width:50px;vertical-align:middle;display:none;" id="imgSig3" src="rsrc/sigstr3.png" alt="sigstr3" >
|
|
||||||
<img style="width:50px;vertical-align:middle;display:none;" id="imgSig4" src="rsrc/sigstr4.png" alt="sigstr4" >
|
|
||||||
<img style="width:50px;vertical-align:middle;display:none;" id="imgSig5" src="rsrc/sigstr5.png" alt="sigstr5" >
|
|
||||||
</li>
|
</li>
|
||||||
<li class="hoverable" style="margin:0 10px 0 10px;">
|
<li class="hoverable" style="margin:0 10px; 0 10px;">
|
||||||
<span id="sigStrength"></span> dBm
|
112 ms
|
||||||
</li>
|
</li>
|
||||||
<li class="hoverable tooltipped" data-position="bottom" data-tooltip="Device ping" style="margin:0 10px 0 10px;min-width:100px;">
|
<li class="hoverable" style="margin:0 10px; 0 10px;">
|
||||||
<span id="execTime"></span> ms
|
<img style="width:50px;vertical-align:middle;" id="imgDisco" src="rsrc/disco.png" alt="disconnected">
|
||||||
</li>
|
|
||||||
<li class="hoverable" style="margin:0 10px 0 10px;">
|
|
||||||
<img id="imgConn" src="rsrc/conn.png" alt="connected" style="width:50px;vertical-align:middle;display:none;"><img style="width:50px;vertical-align:middle;display:inline;" id="imgDisco" src="rsrc/disco.png" alt="disconnected">
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<ul id="slide-out" class="sidenav blue lighten-5" style="padding:0;">
|
<ul id="slide-out" class="sidenav teal darken-3">
|
||||||
<li style="border:1px #00695c solid;background-color:#00695c;"><h2 class="white-text center-align">Settings</h2></li>
|
<li><h2 class="white-text center-align">Settings</h2></li>
|
||||||
<hr>
|
<li></li>
|
||||||
<li class="cursorPointer hoverable" onclick="tabInstance.select('mainpage_id');"><p style="margin: 0 0 0 10px;font-size:1.3em;" class="black-text" >Back to the dashboard</p></li>
|
<li></li>
|
||||||
<li class="cursorPointer hoverable" onclick="tabInstance.select('settings_id');"><p style="margin: 0 0 0 10px;font-size:1.3em;" class="black-text" >General settings</p></li>
|
<li></li>
|
||||||
|
<li></li>
|
||||||
|
<li></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="fixed-action-btn">
|
<div class="fixed-action-btn">
|
||||||
<a style="font-size:2.5em;" data-target="slide-out" class="btn-floating btn-large red sidenav-trigger">
|
<a style="font-size:2.5em;" data-target="slide-out" class="btn-floating btn-large red sidenav-trigger">
|
||||||
⚙
|
⚙
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
<!-- Used to init the tab system -->
|
<section>
|
||||||
<ul class="tabs" style="display:none;" id="test">
|
|
||||||
<li class="tab col s3"><a class="active" href="#mainpage_id">Dashboard</a></li>
|
|
||||||
<li class="tab col s3"><a href="#settings_id">General settings</a></li>
|
|
||||||
</ul>
|
|
||||||
<!-- End of the tab system -->
|
|
||||||
<!-- Modal window definition -->
|
|
||||||
<!-- Modal Structure -->
|
|
||||||
<div id="modal1" class="modal">
|
|
||||||
<div class="modal-content">
|
|
||||||
<h4>Connection Lost</h4>
|
|
||||||
<p>It looks like the connection to the device has been lost.<br />We will try to reconnect in 5 seconds</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<a href="#!" class="modal-close waves-effect waves-green btn-flat">I understand</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- End of modal window definition -->
|
|
||||||
<section id="mainpage_id">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="row col m6">
|
<div class="col m6">
|
||||||
<div style="margin:10px;padding:5px 0 10px 0;" class="grey lighten-2 z-depth-3">
|
<div style="margin:10px;padding:5px 0 10px 0;" class="grey lighten-2 z-depth-3">
|
||||||
<h5 class="center-align">Connectivity</h5>
|
<h4 class="center-align">Connectivity</h4>
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<div class="card teal darken-1">
|
|
||||||
<div class="card-content white-text">
|
|
||||||
<span class="card-title center-align" style="font-weight:bold;">Access Point Mode</span>
|
|
||||||
</div>
|
|
||||||
<div class="card-action center-align">
|
|
||||||
<div class="switch">
|
|
||||||
<label class="white-text">
|
|
||||||
Disabled
|
|
||||||
<input type="checkbox">
|
|
||||||
<span class="lever"></span>
|
|
||||||
Enabled
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="row white-text left-align" style="font-size:1.2em;margin-top: 20px;margin-bottom: -40px;">
|
|
||||||
<div class="col m6">
|
|
||||||
Connected dev :
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
3
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<input placeholder="SSID" id="ssid" type="text" class="validate white-text">
|
|
||||||
<input onmouseleave="showHidePassword('pwd','hide')" onmouseover="showHidePassword('pwd','show');" value="somePassword" placeholder="Password" id="pwd" type="password" class="validate white-text">
|
|
||||||
</div>
|
|
||||||
<div class="card-action">
|
|
||||||
<button class="btn waves-effect waves-light green darken-3" type="submit" name="apply">
|
|
||||||
Apply ✔
|
|
||||||
</button>
|
|
||||||
<button class="btn waves-effect waves-light red darken-3" style="" type="submit" name="cancel">
|
|
||||||
Cancel ✘
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<div class="card teal darken-1">
|
|
||||||
<div class="card-content white-text">
|
|
||||||
<span class="card-title center-align" style="font-weight:bold;">Station Mode</span>
|
|
||||||
</div>
|
|
||||||
<div class="card-action center-align">
|
|
||||||
<div class="switch">
|
|
||||||
<label class="white-text">
|
|
||||||
Disabled
|
|
||||||
<input type="checkbox">
|
|
||||||
<span class="lever"></span>
|
|
||||||
Enabled
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="row white-text left-align" style="font-size:1.2em;margin-top: 20px;margin-bottom: -40px;">
|
|
||||||
<div class="col m6">
|
|
||||||
Local IP :
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<span id="localIP"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<select>
|
|
||||||
<option value="" disabled selected>Select a network</option>
|
|
||||||
<option value="1">Network 1</option>
|
|
||||||
<option value="2">Network 2</option>
|
|
||||||
<option value="3">Network 3</option>
|
|
||||||
</select>
|
|
||||||
<input placeholder="Password" id="pwd" type="password" class="validate white-text">
|
|
||||||
</div>
|
|
||||||
<div class="card-action">
|
|
||||||
<button class="btn waves-effect waves-light green darken-3" type="submit" name="apply">
|
|
||||||
Apply ✔
|
|
||||||
</button>
|
|
||||||
<button class="btn waves-effect waves-light red darken-3" style="" type="submit" name="cancel">
|
|
||||||
Cancel ✘
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row col m6">
|
</div>
|
||||||
<div style="margin:10px;padding:5px 0 10px 0;" class="grey lighten-2 z-depth-3">
|
<div class="col m6">
|
||||||
<h5 class="center-align">System Info</h5>
|
<div style="margin:10px;padding:5px 0 10px 0;" class="grey lighten-2 z-depth-3">
|
||||||
</div>
|
<h4 class="center-align">System Info</h4>
|
||||||
<div class="col m12">
|
|
||||||
<div class="card teal darken-1">
|
|
||||||
<div class="card-content white-text">
|
|
||||||
<span class="card-title center-align" style="font-weight:bold;">System State</span>
|
|
||||||
</div>
|
|
||||||
<div class="card-action white-text" style="font-size:1.2em;">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col m6">
|
|
||||||
Cpu frequency :
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<label style="margin: 0 10px 0 0;">
|
|
||||||
<input onchange="setCpuFrequ(80);" class="with-gap" id="cpufreq80_id" name="group1" type="radio" />
|
|
||||||
<span class="white-text">80 MHz</span>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input onchange="setCpuFrequ(160);" class="with-gap" id="cpufreq160_id" name="group1" type="radio" />
|
|
||||||
<span class="white-text" >160 MHz</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
Free RAM / Total RAM :
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<span id="ramInfo"></span> Bytes / 80 000 Bytes
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
Heap fragmentation :
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<span id="fragInfo"></span> %
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
Max contiguous chunk :
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<span id="blockInfo"></span> Bytes
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
Device up time :
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<span id="upTime"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col m3">
|
||||||
<div class="row" style="margin-top:-20px;">
|
<div class="card teal darken-1">
|
||||||
<div class="row col m3">
|
|
||||||
<div style="margin:10px;padding:5px 0 10px 0;" class="grey lighten-2 z-depth-3">
|
|
||||||
<h5 class="center-align">Clock</h5>
|
|
||||||
</div>
|
|
||||||
<div class="col m12">
|
|
||||||
<div class="card teal darken-1">
|
|
||||||
<div class="card-content white-text">
|
|
||||||
<span class="card-title center-align" style="font-weight:bold;">DS3231 RTC</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card-action" style="font-size:1.2em;">
|
|
||||||
<input type="text" class="datepicker" id="datepicker_id">
|
|
||||||
<input type="text" class="timepicker" id="timepicker_id">
|
|
||||||
</div>
|
|
||||||
<div class="card-action">
|
|
||||||
<button class="btn waves-effect waves-light green darken-3" onclick="setRtcTime();" name="apply">
|
|
||||||
Apply ✔
|
|
||||||
</button>
|
|
||||||
<button class="btn waves-effect waves-light green darken-3 tooltipped" onclick="setRtc2BrowserTime();" data-position="bottom" data-tooltip="Use the browser time to set the RTC time" name="browserTime">
|
|
||||||
Set browser time ✔
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row col m3">
|
|
||||||
<div style="margin:10px;padding:5px 0 10px 0;" class="grey lighten-2 z-depth-3">
|
|
||||||
<h5 class="center-align">Storage</h5>
|
|
||||||
</div>
|
|
||||||
<div class="col m12">
|
|
||||||
<div class="card teal darken-1">
|
|
||||||
<div class="card-content white-text">
|
<div class="card-content white-text">
|
||||||
<span class="card-title center-align" style="font-weight:bold;">SD Card</span>
|
<span class="card-title center-align" style="font-weight:bold;">Access Point Mode</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-action white-text center-align" style="font-size:1.2em;">
|
<div class="card-action center-align">
|
||||||
<div class="switch">
|
<div class="switch">
|
||||||
<label class="white-text">
|
<label class="white-text">
|
||||||
Unmounted
|
Disabled
|
||||||
<input type="checkbox" id="sdcardmounted_id" onchange="mountUnmountCard('sdcardmounted_id');">
|
<input type="checkbox">
|
||||||
<span class="lever"></span>
|
<span class="lever"></span>
|
||||||
Mounted
|
Enabled
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="row left-align">
|
<input placeholder="SSID" id="ssid" type="text" class="validate white-text">
|
||||||
<div class="col m6">
|
<input placeholder="PWD" id="pwd" type="password" class="validate white-text">
|
||||||
Size :
|
</div>
|
||||||
</div>
|
<div class="card-action">
|
||||||
<div class="col m6">
|
<button class="btn waves-effect waves-light green darken-3" type="submit" name="apply">
|
||||||
<span id="cardSize">NaN Gbytes</span>
|
Apply ✔
|
||||||
</div>
|
</button>
|
||||||
<div class="col m6">
|
<button class="btn waves-effect waves-light red darken-3" style="float:right;" type="submit" name="cancel">
|
||||||
Free :
|
Cancel ✘
|
||||||
</div>
|
</button>
|
||||||
<div class="col m6">
|
|
||||||
XX GBytes
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<div style="margin:10px;padding:5px 0 10px 0;" class="grey lighten-2 z-depth-3">
|
|
||||||
<h5 class="center-align">Services</h5>
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<div class="card teal darken-1">
|
|
||||||
<div class="card-content white-text">
|
|
||||||
<span class="card-title center-align" style="font-weight:bold;">Web Server</span>
|
|
||||||
</div>
|
|
||||||
<div class="card-action white-text center-align" style="font-size:1.2em;">
|
|
||||||
<div class="switch">
|
|
||||||
<label class="white-text">
|
|
||||||
Disabled
|
|
||||||
<input type="checkbox">
|
|
||||||
<span class="lever"></span>
|
|
||||||
Enabled
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td><label for="web_port" class="white-text" style="font-size:1em;">Port :</label></td>
|
|
||||||
<td><input class="validate white-text" id="web_port" type="number" min="0" max="65535" ></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col m6">
|
|
||||||
|
|
||||||
</div>
|
<div class="col m3">
|
||||||
<div class="col m6">
|
<div class="card teal darken-1">
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card-action">
|
|
||||||
<button class="btn waves-effect waves-light green darken-3" type="submit" name="apply">
|
|
||||||
Apply ✔
|
|
||||||
</button>
|
|
||||||
<button class="btn waves-effect waves-light red darken-3" style="" type="submit" name="cancel">
|
|
||||||
Cancel ✘
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col m6">
|
|
||||||
<div class="card teal darken-1">
|
|
||||||
<div class="card-content white-text">
|
|
||||||
<span class="card-title center-align" style="font-weight:bold;">FTP Server</span>
|
|
||||||
</div>
|
|
||||||
<div class="card-action white-text center-align" style="font-size:1.2em;">
|
|
||||||
<div class="switch">
|
|
||||||
<label class="white-text">
|
|
||||||
Disabled
|
|
||||||
<input type="checkbox">
|
|
||||||
<span class="lever"></span>
|
|
||||||
Enabled
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td><label for="ftp_port" class="white-text" style="font-size:1em;">Port :</label></td>
|
|
||||||
<td><input class="validate white-text" id="ftp_port" type="number" min="0" max="65535" ></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<input placeholder="Login" id="ssid" type="text" class="validate white-text">
|
|
||||||
<input placeholder="Password" id="pwd" type="password" class="validate white-text">
|
|
||||||
</div>
|
|
||||||
<div class="card-action">
|
|
||||||
<button class="btn waves-effect waves-light green darken-3" type="submit" name="apply">
|
|
||||||
Apply ✔
|
|
||||||
</button>
|
|
||||||
<button class="btn waves-effect waves-light red darken-3" style="" type="submit" name="cancel">
|
|
||||||
Cancel ✘
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row" style="margin-top:-20px;">
|
|
||||||
<div class="row col m12">
|
|
||||||
<div style="margin:10px;padding:5px 0 10px 0;" class="grey lighten-2 z-depth-3">
|
|
||||||
<h5 class="center-align">IO's Mode and State</h5>
|
|
||||||
</div>
|
|
||||||
<div class="card teal darken-1">
|
|
||||||
<div class="card-content white-text">
|
<div class="card-content white-text">
|
||||||
<span class="card-title center-align" style="font-weight:bold;">IO Expander</span>
|
<span class="card-title center-align" style="font-weight:bold;">Station Mode</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-action white-text center-align" style="font-size:1.2em;">
|
<div class="card-action center-align">
|
||||||
<table>
|
<div class="switch">
|
||||||
<tr>
|
<label class="white-text">
|
||||||
<td>
|
Disabled
|
||||||
|
<input type="checkbox">
|
||||||
</td>
|
<span class="lever"></span>
|
||||||
<td>
|
Enabled
|
||||||
<p>P0</p>
|
</label>
|
||||||
</td>
|
</div>
|
||||||
<td>
|
<select>
|
||||||
<p>P1</p>
|
<option value="" disabled selected>Select a network</option>
|
||||||
</td>
|
<option value="1">Network 1</option>
|
||||||
<td>
|
<option value="2">Network 2</option>
|
||||||
<p>P2</p>
|
<option value="3">Network 3</option>
|
||||||
</td>
|
</select>
|
||||||
<td>
|
<input placeholder="PWD" id="pwd" type="password" class="validate white-text">
|
||||||
<p>P3</p>
|
</div>
|
||||||
</td>
|
<div class="card-action">
|
||||||
<td>
|
<button class="btn waves-effect waves-light green darken-3" type="submit" name="apply">
|
||||||
<p>P4</p>
|
Apply ✔
|
||||||
</td>
|
</button>
|
||||||
<td>
|
<button class="btn waves-effect waves-light red darken-3" style="float:right;" type="submit" name="cancel">
|
||||||
<p>P5</p>
|
Cancel ✘
|
||||||
</td>
|
</button>
|
||||||
<td>
|
|
||||||
<p>P6</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<p>P7</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>MODE</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'OUTPUT');" id="P0_MODE_I" src="rsrc/in.png" alt="input" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'INPUT');" id="P0_MODE_O" src="rsrc/out.png" alt="output" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'OUTPUT');" id="P1_MODE_I" src="rsrc/in.png" alt="input" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'INPUT');" id="P1_MODE_O" src="rsrc/out.png" alt="output" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'OUTPUT');" id="P2_MODE_I" src="rsrc/in.png" alt="input" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'INPUT');" id="P2_MODE_O" src="rsrc/out.png" alt="output" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'OUTPUT');" id="P3_MODE_I" src="rsrc/in.png" alt="input" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'INPUT');" id="P3_MODE_O" src="rsrc/out.png" alt="output" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'OUTPUT');" id="P4_MODE_I" src="rsrc/in.png" alt="input" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'INPUT');" id="P4_MODE_O" src="rsrc/out.png" alt="output" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'OUTPUT');" id="P5_MODE_I" src="rsrc/in.png" alt="input" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'INPUT');" id="P5_MODE_O" src="rsrc/out.png" alt="output" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'OUTPUT');" id="P6_MODE_I" src="rsrc/in.png" alt="input" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'INPUT');" id="P6_MODE_O" src="rsrc/out.png" alt="output" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'OUTPUT');" id="P7_MODE_I" src="rsrc/in.png" alt="input" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoMode(this.id,'INPUT');" id="P7_MODE_O" src="rsrc/out.png" alt="output" >
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<p>LEVEL</p>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'LOW');" id="P0_LEVEL_H" src="rsrc/on.png" alt="on" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'HIGH');" id="P0_LEVEL_L" src="rsrc/off.png" alt="off" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'LOW');" id="P1_LEVEL_H" src="rsrc/on.png" alt="on" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'HIGH');" id="P1_LEVEL_L" src="rsrc/off.png" alt="off" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'LOW');" id="P2_LEVEL_H" src="rsrc/on.png" alt="on" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'HIGH');" id="P2_LEVEL_L" src="rsrc/off.png" alt="off" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'LOW');" id="P3_LEVEL_H" src="rsrc/on.png" alt="on" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'HIGH');" id="P3_LEVEL_L" src="rsrc/off.png" alt="off" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'LOW');" id="P4_LEVEL_H" src="rsrc/on.png" alt="on" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'HIGH');" id="P4_LEVEL_L" src="rsrc/off.png" alt="off" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'LOW');" id="P5_LEVEL_H" src="rsrc/on.png" alt="on" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'HIGH');" id="P5_LEVEL_L" src="rsrc/off.png" alt="off" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'LOW');" id="P6_LEVEL_H" src="rsrc/on.png" alt="on" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'HIGH');" id="P6_LEVEL_L" src="rsrc/off.png" alt="off" >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'LOW');" id="P7_LEVEL_H" src="rsrc/on.png" alt="on" >
|
|
||||||
<img class="mode-img" style="display:none;" onclick="setIoLevel(this.id,'HIGH');" id="P7_LEVEL_L" src="rsrc/off.png" alt="off" >
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col m6">
|
||||||
|
<div class="card teal darken-1">
|
||||||
|
<div class="card-content white-text">
|
||||||
|
<span class="card-title center-align" style="font-weight:bold;">System State</span>
|
||||||
|
</div>
|
||||||
|
<div class="card-action center-align">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section id="settings_id">
|
<footer class="page-footer blue-grey darken-4">
|
||||||
<div style="margin:10px;padding:5px 0 10px 0;" class="grey lighten-2 z-depth-3">
|
|
||||||
<h5 class="center-align">General settings</h5>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<footer class="page-footer blue-grey darken-4 center-align">
|
|
||||||
<p>Anatole SCHRAMM-HENRY, all right reserved | Hosted by the board itself<br /> 2019-2020</p>
|
|
||||||
</footer>
|
</footer>
|
||||||
<script src="rsrc/scriptV2.js"></script>
|
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function()
|
||||||
|
{
|
||||||
|
var elems = document.querySelectorAll('.sidenav');
|
||||||
|
var instances = M.Sidenav.init(elems);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function()
|
||||||
|
{
|
||||||
|
var elems = document.querySelectorAll('.tooltipped');
|
||||||
|
var instances = M.Tooltip.init(elems);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function()
|
||||||
|
{
|
||||||
|
var elems = document.querySelectorAll('select');
|
||||||
|
var instances = M.FormSelect.init(elems);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
2
sdCard_content/WWW/rsrc/materialize.css
vendored
2
sdCard_content/WWW/rsrc/materialize.css
vendored
File diff suppressed because one or more lines are too long
@ -260,7 +260,8 @@ function refreshSigStrength()
|
|||||||
document.getElementById('sigStrength').innerHTML = wifiStaObj.RSSI;
|
document.getElementById('sigStrength').innerHTML = wifiStaObj.RSSI;
|
||||||
document.getElementById('sigStrengthPercent').innerHTML = wifiStaObj.RSSI2;
|
document.getElementById('sigStrengthPercent').innerHTML = wifiStaObj.RSSI2;
|
||||||
document.getElementById('localIP').innerHTML = wifiStaObj['local IP'];
|
document.getElementById('localIP').innerHTML = wifiStaObj['local IP'];
|
||||||
setSigStrenthPicture(wifiStaObj.RSSI2);
|
setSigStrenthPicture(wifiStaObj.RSSI2
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,694 +0,0 @@
|
|||||||
/**
|
|
||||||
* JavaScript code for the dashboardV2 logic, refresh and other things
|
|
||||||
* Creation date : 01/02/2020
|
|
||||||
* Anatole SCHRAMM-HENRY - Th3maz1ng
|
|
||||||
**/
|
|
||||||
|
|
||||||
//Global variables
|
|
||||||
var App = new Object();
|
|
||||||
var tabInstance = null;
|
|
||||||
var sideNavinstance = null;
|
|
||||||
var modalInstance = null;
|
|
||||||
var connected = true;
|
|
||||||
|
|
||||||
var setFrequencyReq = null;
|
|
||||||
var setRTCReq = null;
|
|
||||||
var sdCardSizeReq = null;
|
|
||||||
var sdCardActionReq = null;
|
|
||||||
var setIoModeReq = null;
|
|
||||||
var setIoLevelReq = null;
|
|
||||||
|
|
||||||
//UI elements initialisation
|
|
||||||
document.addEventListener('DOMContentLoaded', function()
|
|
||||||
{
|
|
||||||
var elems = document.querySelectorAll('.sidenav');
|
|
||||||
var instances = M.Sidenav.init(elems);
|
|
||||||
|
|
||||||
sideNavinstance = M.Sidenav.getInstance(elems[0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function()
|
|
||||||
{
|
|
||||||
var elems = document.querySelectorAll('.tooltipped');
|
|
||||||
var instances = M.Tooltip.init(elems);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function()
|
|
||||||
{
|
|
||||||
var elems = document.querySelectorAll('select');
|
|
||||||
var instances = M.FormSelect.init(elems);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function()
|
|
||||||
{
|
|
||||||
var elems = document.querySelectorAll('.datepicker');
|
|
||||||
var options = {
|
|
||||||
'autoClose':true,
|
|
||||||
'format' : 'd-m-yyyy',
|
|
||||||
'defaultDate': new Date(),
|
|
||||||
'setDefaultDate':true,
|
|
||||||
};
|
|
||||||
var instances = M.Datepicker.init(elems, options);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function()
|
|
||||||
{
|
|
||||||
var elems = document.querySelectorAll('.timepicker');
|
|
||||||
var options = {
|
|
||||||
'twelveHour':false,
|
|
||||||
};
|
|
||||||
var instances = M.Timepicker.init(elems, options);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function()
|
|
||||||
{
|
|
||||||
var elems = document.querySelectorAll('.tooltipped');
|
|
||||||
var options = {};
|
|
||||||
var instances = M.Tooltip.init(elems, options);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function()
|
|
||||||
{
|
|
||||||
var elems = document.querySelectorAll('.tabs');
|
|
||||||
var options = {
|
|
||||||
//'swipeable':true,
|
|
||||||
};
|
|
||||||
var instances = M.Tabs.init(elems, options);
|
|
||||||
tabInstance = M.Tabs.getInstance(elems[0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function()
|
|
||||||
{
|
|
||||||
var elems = document.querySelectorAll('.modal');
|
|
||||||
var options = {
|
|
||||||
};
|
|
||||||
var instances = M.Modal.init(elems, options);
|
|
||||||
|
|
||||||
modalInstance = M.Modal.getInstance(elems[0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
//Dashboard logic initialisation
|
|
||||||
function init()
|
|
||||||
{
|
|
||||||
|
|
||||||
/*Setting default values and intervals*/
|
|
||||||
var browserTimeInt = setInterval(() => {browserTime();},1000);
|
|
||||||
let curDate = new Date();
|
|
||||||
let hours = curDate.getHours() < 10 ? '0'+curDate.getHours() : curDate.getHours();
|
|
||||||
let minutes = curDate.getMinutes() < 10 ? '0'+curDate.getMinutes() : curDate.getMinutes();
|
|
||||||
let day = curDate.getDate();
|
|
||||||
let month = curDate.getMonth()+1;
|
|
||||||
let year = curDate.getFullYear();
|
|
||||||
elemById('timepicker_id').value = hours+':'+minutes;
|
|
||||||
elemById('datepicker_id').value = day+'-'+month+'-'+year;
|
|
||||||
/*Initializing the App object*/
|
|
||||||
App.init();
|
|
||||||
App.registerAutomatedRequest({timeout:500, pollInterval: 1000, apiEndPoint:'/sab/rtc/get/datetime', gotResponse:(data) => {rtcRefreshHandler(data, 'OK');}, gotError:(e) => {rtcRefreshHandler(e, 'FAIL');}});
|
|
||||||
App.registerAutomatedRequest({timeout:500, pollInterval: 10000, apiEndPoint:'/sab/systeminfo', gotResponse:(data) => {sysInfoRefreshHandler(data, 'OK');}, gotError:(e) => {sysInfoRefreshHandler(e, 'FAIL');}});
|
|
||||||
App.registerAutomatedRequest({timeout:500, pollInterval: 1000, apiEndPoint:'/sab/wifi/stainfo', gotResponse:(data) => {staInfoRefreshHandler(data, 'OK');}, gotError:(e) => {staInfoRefreshHandler(e, 'FAIL');}});
|
|
||||||
App.registerAutomatedRequest({timeout:500, pollInterval: 5000, apiEndPoint:'/sab/io/get/mode', gotResponse:(data) => {ioModeRefreshHandler(data, 'OK');}, gotError:(e) => {ioModeRefreshHandler(e, 'FAIL');}});
|
|
||||||
App.registerAutomatedRequest({timeout:500, pollInterval: 1000, apiEndPoint:'/sab/io/get/level', gotResponse:(data) => {ioLevelRefreshHandler(data, 'OK');}, gotError:(e) => {ioLevelRefreshHandler(e, 'FAIL');}});
|
|
||||||
|
|
||||||
//All requests needing an UI action:
|
|
||||||
setFrequencyReq = App.buildXMLHttpRequest({timeout:500, gotResponse:(data) => {setFreqHandler(data, 'OK');}, gotError:(e) => {setFreqHandler(e, 'FAIL');}});
|
|
||||||
setRTCReq = App.buildXMLHttpRequest({timeout:500, gotResponse:(data) => {setRTCHandler(data, 'OK');}, gotError:(e) => {setRTCHandler(e, 'FAIL');}});
|
|
||||||
sdCardSizeReq = App.buildXMLHttpRequest({timeout:500, gotResponse:(data) => {getCardSizeHandler(data, 'OK');}, gotError:(e) => {getCardSizeHandler(e, 'FAIL');}});
|
|
||||||
sdCardActionReq = App.buildXMLHttpRequest({timeout:500, gotResponse:(data) => {CardActionHandler(data, 'OK');}, gotError:(e) => {CardActionHandler(e, 'FAIL');}});
|
|
||||||
setIoModeReq = App.buildXMLHttpRequest({timeout:500, gotResponse:(data) => {setIoModeHandler(data, 'OK');}, gotError:(e) => {setIoModeHandler(e, 'FAIL');}});
|
|
||||||
setIoLevelReq = App.buildXMLHttpRequest({timeout:500, gotResponse:(data) => {setIoLevelHandler(data, 'OK');}, gotError:(e) => {setIoLevelHandler(e, 'FAIL');}});
|
|
||||||
}
|
|
||||||
|
|
||||||
//Callback functions
|
|
||||||
function browserTime()
|
|
||||||
{
|
|
||||||
let curDate = new Date();
|
|
||||||
let hours = curDate.getHours() < 10 ? '0'+curDate.getHours() : curDate.getHours();
|
|
||||||
let minutes = curDate.getMinutes() < 10 ? '0'+curDate.getMinutes() : curDate.getMinutes();
|
|
||||||
let seconds = curDate.getSeconds() < 10 ? '0'+curDate.getSeconds() : curDate.getSeconds();
|
|
||||||
elemById('browsertime_id').innerHTML = hours+':'+minutes+':'+seconds;
|
|
||||||
}
|
|
||||||
//Helper functions and objects
|
|
||||||
function elemById(id)
|
|
||||||
{
|
|
||||||
return document.getElementById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function rtcRefreshHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind !== undefined)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
let rtcObj = JSON.parse(data);
|
|
||||||
elemById('rtcValue').innerHTML = rtcObj.time + ' ' + rtcObj.date;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
elemById('rtcValue').innerHTML = 'ERROR';
|
|
||||||
elemById('execTime').innerHTML = 'NaN';
|
|
||||||
connected = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function sysInfoRefreshHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
let systemInfoObj = JSON.parse(data);
|
|
||||||
elemById('temperature').innerHTML = systemInfoObj['temperature'].level + systemInfoObj['temperature'].unit;
|
|
||||||
elemById('ramInfo').innerHTML = systemInfoObj['free RAM'];
|
|
||||||
let cpuFreq = systemInfoObj['CPU freq'];
|
|
||||||
if(cpuFreq == 80)
|
|
||||||
{
|
|
||||||
elemById('cpufreq80_id').checked = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
elemById('cpufreq160_id').checked = true;
|
|
||||||
}
|
|
||||||
elemById('fragInfo').innerHTML = systemInfoObj['heap frag'];
|
|
||||||
elemById('blockInfo').innerHTML = systemInfoObj['max block'];
|
|
||||||
elemById('upTime').innerHTML = systemInfoObj['up time'].days + ' days ' + systemInfoObj['up time'].hours + ' hours ' + systemInfoObj['up time'].minutes + ' minutes ' + systemInfoObj['up time'].seconds + ' seconds ';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
elemById('temperature').innerHTML = 'NaN';
|
|
||||||
elemById('ramInfo').innerHTML = 'NaN';
|
|
||||||
elemById('fragInfo').innerHTML = 'NaN';
|
|
||||||
elemById('blockInfo').innerHTML = 'NaN';
|
|
||||||
elemById('upTime').innerHTML = 'NaN';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function staInfoRefreshHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
let wifiStaObj = JSON.parse(data);
|
|
||||||
elemById('sigStrength').innerHTML = wifiStaObj.RSSI;
|
|
||||||
elemById('sigStrengthPercent').innerHTML = wifiStaObj.RSSI2;
|
|
||||||
elemById('localIP').innerHTML = wifiStaObj['local IP'];
|
|
||||||
setSigStrenthPicture(wifiStaObj.RSSI2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
elemById('sigStrength').innerHTML = 'NaN';
|
|
||||||
elemById('sigStrengthPercent').innerHTML = 'NaN';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Handler pattern
|
|
||||||
/*function Handler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
function setIoLevelHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
var ioLevelObj = JSON.parse(data);
|
|
||||||
updateIoLevelImages(ioLevelObj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hideIoLevelImages();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setIoModeHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
var ioModeObj = JSON.parse(data);
|
|
||||||
updateIoModeImages(ioModeObj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hideIoModeImages();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ioLevelRefreshHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
var ioLevelObj = JSON.parse(data);
|
|
||||||
updateIoLevelImages(ioLevelObj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hideIoLevelImages();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ioModeRefreshHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
var ioModeObj = JSON.parse(data);
|
|
||||||
updateIoModeImages(ioModeObj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hideIoModeImages();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function CardActionHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
var sdCardObj = JSON.parse(data);
|
|
||||||
if(sdCardObj.status == 'ok')
|
|
||||||
{
|
|
||||||
//Finally we update the card size
|
|
||||||
sdCardSize();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(elemById('sdcardmounted_id').checked)
|
|
||||||
elemById('sdcardmounted_id').checked = false;
|
|
||||||
else
|
|
||||||
elemById('sdcardmounted_id').checked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setFreqHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(elemById('cpufreq80_id').checked)
|
|
||||||
elemById('cpufreq160_id').checked = true;
|
|
||||||
else
|
|
||||||
elemById('cpufreq80_id').checked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setRTCHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCardSizeHandler(data,kind)
|
|
||||||
{
|
|
||||||
if(kind === 'OK')
|
|
||||||
{
|
|
||||||
var sdCardObj = JSON.parse(data);
|
|
||||||
elemById('cardSize').innerHTML = sdCardObj.size == 0 ? 'NO CARD' : sdCardObj.size + 'GBytes';
|
|
||||||
elemById('sdcardmounted_id').checked = sdCardObj.size != 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
elemById('cardSize').innerHTML = 'NaN GBytes';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//All UI action functions are here
|
|
||||||
|
|
||||||
function setCpuFrequ(freq)
|
|
||||||
{
|
|
||||||
console.log('cpu frequ : '+freq);
|
|
||||||
setFrequencyReq.open('GET', '/sab/power/set/freq?FREQ='+freq);
|
|
||||||
setFrequencyReq.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function setRtc2BrowserTime()
|
|
||||||
{
|
|
||||||
let d = new Date();
|
|
||||||
let data = parseInt(d.getDate())+'_'+parseInt(d.getMonth()+1)+'_'+parseInt(d.getYear())+'_'+parseInt(d.getHours())+'_'+parseInt(d.getMinutes())+'_'+parseInt(d.getSeconds()+5);
|
|
||||||
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
setRTCReq.open('GET', '/sab/rtc/set/datetime?datetime='+data);
|
|
||||||
setRTCReq.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function setRtcTime()
|
|
||||||
{
|
|
||||||
let date = elemById('datepicker_id').value;
|
|
||||||
let time = elemById('timepicker_id').value;
|
|
||||||
|
|
||||||
//We split the date and time :
|
|
||||||
let dtArray = date.split('-');
|
|
||||||
let tiArray = time.split(':');
|
|
||||||
|
|
||||||
let data = parseInt(dtArray[0])+'_'+parseInt(dtArray[1])+'_'+parseInt(dtArray[2])+'_'+parseInt(tiArray[0])+'_'+parseInt(tiArray[1])+'_0';
|
|
||||||
|
|
||||||
console.log(data);
|
|
||||||
setRTCReq.open('GET', '/sab/rtc/set/datetime?datetime='+data);
|
|
||||||
setRTCReq.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function sdCardSize()
|
|
||||||
{
|
|
||||||
sdCardSizeReq.open('GET','/sab/sdcard/size');
|
|
||||||
sdCardSizeReq.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function mountUnmountCard(id)
|
|
||||||
{
|
|
||||||
if(elemById(id).checked) //We should mount the sd card
|
|
||||||
{
|
|
||||||
sdCardActionReq.open('GET','/sab/sdcard/action?action=mount');
|
|
||||||
sdCardActionReq.send();
|
|
||||||
}
|
|
||||||
else //We unmount it
|
|
||||||
{
|
|
||||||
sdCardActionReq.open('GET','/sab/sdcard/action?action=unmount');
|
|
||||||
sdCardActionReq.send();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setIoMode(pin,mode)
|
|
||||||
{
|
|
||||||
var pinOnly = pin.split('_')[0];
|
|
||||||
setIoModeReq.open('GET',"/sab/io/set/mode?"+pinOnly+'='+ (mode == 'OUTPUT' ? 'OUT' : 'IN'));
|
|
||||||
setIoModeReq.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function setIoLevel(pin,mode)
|
|
||||||
{
|
|
||||||
var pinOnly = pin.split('_')[0];
|
|
||||||
setIoLevelReq.open('GET',"/sab/io/set/level?"+pinOnly+'='+ (mode == 'HIGH' ? '1' : '0'));
|
|
||||||
setIoLevelReq.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
App = {
|
|
||||||
|
|
||||||
init:function()
|
|
||||||
{
|
|
||||||
if(this.heartBeat == null) //we set the heartBeat only once
|
|
||||||
{
|
|
||||||
console.log("Setting heartbeat");
|
|
||||||
let heartBeatAjx = this.buildXMLHttpRequest({timeout:500, apiEndPoint:'/sab/web/apitester', gotResponse:(data) => {console.log('Got heartbeat');connected = true;modalInstance.close();}});
|
|
||||||
this.heartBeat = setInterval(() => {
|
|
||||||
console.log('connected : '+connected);
|
|
||||||
if(!connected)
|
|
||||||
{
|
|
||||||
console.log('Sending heartbeat');
|
|
||||||
heartBeatAjx.open('GET', '/sab/web/apitester');
|
|
||||||
heartBeatAjx.send();
|
|
||||||
}
|
|
||||||
},5000);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onTimeout:function(e)
|
|
||||||
{
|
|
||||||
console.error("Request timed out");
|
|
||||||
elemById('imgConn').style.display = 'none';
|
|
||||||
elemById('imgDisco').style.display = 'inline';
|
|
||||||
setSigStrenthPicture(0);
|
|
||||||
connected = false;
|
|
||||||
modalInstance.open();
|
|
||||||
|
|
||||||
},
|
|
||||||
updateApp:function()
|
|
||||||
{
|
|
||||||
for(i = 0; i < this.requestMap.length; i++)
|
|
||||||
{
|
|
||||||
let reqObj = this.requestMap[i];
|
|
||||||
reqObj.ajaxObj.open('GET',reqObj.apiEndPoint);
|
|
||||||
reqObj.ajaxObj.send();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onConnected:function()
|
|
||||||
{
|
|
||||||
if(elemById('imgDisco').style.display == 'inline' && elemById('imgConn').style.display == 'none')
|
|
||||||
{
|
|
||||||
console.log("Connected to Swiss Army Board");
|
|
||||||
elemById('imgDisco').style.display = 'none';
|
|
||||||
elemById('imgConn').style.display = 'inline';
|
|
||||||
/*We need to update everything when we connect*/
|
|
||||||
this.updateApp();
|
|
||||||
sdCardSize();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
registerAutomatedRequest:function(param)
|
|
||||||
{
|
|
||||||
let interval = null;
|
|
||||||
let pollInterval = 1000; //Default to one second
|
|
||||||
|
|
||||||
if(param === undefined)
|
|
||||||
return interval;
|
|
||||||
|
|
||||||
if(!('apiEndPoint' in param))
|
|
||||||
return interval;
|
|
||||||
|
|
||||||
if('pollInterval' in param)
|
|
||||||
pollInterval = param.pollInterval;
|
|
||||||
|
|
||||||
let ajax = this.buildXMLHttpRequest(param);
|
|
||||||
|
|
||||||
|
|
||||||
interval = setInterval(() => {if(connected){ajax.open('GET', param.apiEndPoint); this.execTimeStart = new Date().getTime(); ajax.send();}},pollInterval);
|
|
||||||
|
|
||||||
this.intervalMap.push(interval);
|
|
||||||
this.requestMap.push({ajaxObj:ajax, apiEndPoint : param.apiEndPoint});
|
|
||||||
|
|
||||||
return interval;
|
|
||||||
},
|
|
||||||
buildXMLHttpRequest : function(param)
|
|
||||||
{
|
|
||||||
if(param === undefined)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
let that = this;
|
|
||||||
let ajaxObj = new XMLHttpRequest();
|
|
||||||
|
|
||||||
if('timeout' in param)
|
|
||||||
ajaxObj.timeout = param.timeout;
|
|
||||||
else
|
|
||||||
ajaxObj.timeout = 800;
|
|
||||||
|
|
||||||
ajaxObj.onreadystatechange = function()
|
|
||||||
{
|
|
||||||
switch(this.readyState)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
console.log("Connection established");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
console.log("Request received");
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
console.log("Processing request");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
console.log("Response is ready");
|
|
||||||
if(this.status != 0){that.onConnected(); elemById('execTime').innerHTML = new Date().getTime() - that.execTimeStart;}
|
|
||||||
if(this.status == 200)
|
|
||||||
{
|
|
||||||
console.log("Response : " + this.responseText);
|
|
||||||
if('gotResponse' in param)
|
|
||||||
param.gotResponse(this.responseText);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
console.log("Error, status is : " + this.status);
|
|
||||||
if('gotError' in param)
|
|
||||||
param.gotError(this.status);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.log("Unknown state");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.onTimeout !== null)
|
|
||||||
{
|
|
||||||
ajaxObj.ontimeout = this.onTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ajaxObj;
|
|
||||||
},
|
|
||||||
intervalMap:[],
|
|
||||||
requestMap:[],
|
|
||||||
heartBeat:null,
|
|
||||||
execTimeStart:0,
|
|
||||||
};
|
|
||||||
|
|
||||||
function showHidePassword(id, action)
|
|
||||||
{
|
|
||||||
if(action === 'show')elemById(id).type = 'text';
|
|
||||||
else if(action === 'hide')elemById(id).type = 'password';
|
|
||||||
};
|
|
||||||
|
|
||||||
function setSigStrenthPicture(value)
|
|
||||||
{
|
|
||||||
if(value < 5)
|
|
||||||
{
|
|
||||||
elemById('imgSig1').style.display = 'inline';
|
|
||||||
elemById('imgSig2').style.display = 'none';
|
|
||||||
elemById('imgSig3').style.display = 'none';
|
|
||||||
elemById('imgSig4').style.display = 'none';
|
|
||||||
elemById('imgSig5').style.display = 'none';
|
|
||||||
}
|
|
||||||
else if(value < 20)
|
|
||||||
{
|
|
||||||
elemById('imgSig1').style.display = 'none';
|
|
||||||
elemById('imgSig2').style.display = 'inline';
|
|
||||||
elemById('imgSig3').style.display = 'none';
|
|
||||||
elemById('imgSig4').style.display = 'none';
|
|
||||||
elemById('imgSig5').style.display = 'none';
|
|
||||||
}
|
|
||||||
else if(value < 40)
|
|
||||||
{
|
|
||||||
elemById('imgSig1').style.display = 'none';
|
|
||||||
elemById('imgSig2').style.display = 'none';
|
|
||||||
elemById('imgSig3').style.display = 'inline';
|
|
||||||
elemById('imgSig4').style.display = 'none';
|
|
||||||
elemById('imgSig5').style.display = 'none';
|
|
||||||
}
|
|
||||||
else if(value < 80)
|
|
||||||
{
|
|
||||||
elemById('imgSig1').style.display = 'none';
|
|
||||||
elemById('imgSig2').style.display = 'none';
|
|
||||||
elemById('imgSig3').style.display = 'none';
|
|
||||||
elemById('imgSig4').style.display = 'inline';
|
|
||||||
elemById('imgSig5').style.display = 'none';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
elemById('imgSig1').style.display = 'none';
|
|
||||||
elemById('imgSig2').style.display = 'none';
|
|
||||||
elemById('imgSig3').style.display = 'none';
|
|
||||||
elemById('imgSig4').style.display = 'none';
|
|
||||||
elemById('imgSig5').style.display = 'inline';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateIoModeImages(obj)
|
|
||||||
{
|
|
||||||
elemById('P0_MODE_I').style.display = obj.P0 == 'IN' ? 'block' : 'none';
|
|
||||||
elemById('P0_MODE_O').style.display = obj.P0 == 'IN' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P1_MODE_I').style.display = obj.P1 == 'IN' ? 'block' : 'none';
|
|
||||||
elemById('P1_MODE_O').style.display = obj.P1 == 'IN' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P2_MODE_I').style.display = obj.P2 == 'IN' ? 'block' : 'none';
|
|
||||||
elemById('P2_MODE_O').style.display = obj.P2 == 'IN' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P3_MODE_I').style.display = obj.P3 == 'IN' ? 'block' : 'none';
|
|
||||||
elemById('P3_MODE_O').style.display = obj.P3 == 'IN' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P4_MODE_I').style.display = obj.P4 == 'IN' ? 'block' : 'none';
|
|
||||||
elemById('P4_MODE_O').style.display = obj.P4 == 'IN' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P5_MODE_I').style.display = obj.P5 == 'IN' ? 'block' : 'none';
|
|
||||||
elemById('P5_MODE_O').style.display = obj.P5 == 'IN' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P6_MODE_I').style.display = obj.P6 == 'IN' ? 'block' : 'none';
|
|
||||||
elemById('P6_MODE_O').style.display = obj.P6 == 'IN' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P7_MODE_I').style.display = obj.P7 == 'IN' ? 'block' : 'none';
|
|
||||||
elemById('P7_MODE_O').style.display = obj.P7 == 'IN' ? 'none' : 'block';
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideIoModeImages()
|
|
||||||
{
|
|
||||||
elemById('P0_MODE_I').style.display = 'none';
|
|
||||||
elemById('P0_MODE_O').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P1_MODE_I').style.display = 'none';
|
|
||||||
elemById('P1_MODE_O').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P2_MODE_I').style.display = 'none';
|
|
||||||
elemById('P2_MODE_O').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P3_MODE_I').style.display = 'none';
|
|
||||||
elemById('P3_MODE_O').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P4_MODE_I').style.display = 'none';
|
|
||||||
elemById('P4_MODE_O').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P5_MODE_I').style.display = 'none';
|
|
||||||
elemById('P5_MODE_O').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P6_MODE_I').style.display = 'none';
|
|
||||||
elemById('P6_MODE_O').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P7_MODE_I').style.display = 'none';
|
|
||||||
elemById('P7_MODE_O').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateIoLevelImages(obj)
|
|
||||||
{
|
|
||||||
elemById('P0_LEVEL_H').style.display = obj.P0 == '1' ? 'block' : 'none';
|
|
||||||
elemById('P0_LEVEL_L').style.display = obj.P0 == '1' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P1_LEVEL_H').style.display = obj.P1 == '1' ? 'block' : 'none';
|
|
||||||
elemById('P1_LEVEL_L').style.display = obj.P1 == '1' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P2_LEVEL_H').style.display = obj.P2 == '1' ? 'block' : 'none';
|
|
||||||
elemById('P2_LEVEL_L').style.display = obj.P2 == '1' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P3_LEVEL_H').style.display = obj.P3 == '1' ? 'block' : 'none';
|
|
||||||
elemById('P3_LEVEL_L').style.display = obj.P3 == '1' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P4_LEVEL_H').style.display = obj.P4 == '1' ? 'block' : 'none';
|
|
||||||
elemById('P4_LEVEL_L').style.display = obj.P4 == '1' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P5_LEVEL_H').style.display = obj.P5 == '1' ? 'block' : 'none';
|
|
||||||
elemById('P5_LEVEL_L').style.display = obj.P5 == '1' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P6_LEVEL_H').style.display = obj.P6 == '1' ? 'block' : 'none';
|
|
||||||
elemById('P6_LEVEL_L').style.display = obj.P6 == '1' ? 'none' : 'block';
|
|
||||||
|
|
||||||
elemById('P7_LEVEL_H').style.display = obj.P7 == '1' ? 'block' : 'none';
|
|
||||||
elemById('P7_LEVEL_L').style.display = obj.P7 == '1' ? 'none' : 'block';
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideIoLevelImages()
|
|
||||||
{
|
|
||||||
elemById('P0_LEVEL_H').style.display = 'none';
|
|
||||||
elemById('P0_LEVEL_L').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P1_LEVEL_H').style.display = 'none';
|
|
||||||
elemById('P1_LEVEL_L').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P2_LEVEL_H').style.display = 'none';
|
|
||||||
elemById('P2_LEVEL_L').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P3_LEVEL_H').style.display = 'none';
|
|
||||||
elemById('P3_LEVEL_L').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P4_LEVEL_H').style.display = 'none';
|
|
||||||
elemById('P4_LEVEL_L').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P5_LEVEL_H').style.display = 'none';
|
|
||||||
elemById('P5_LEVEL_L').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P6_LEVEL_H').style.display = 'none';
|
|
||||||
elemById('P6_LEVEL_L').style.display = 'none';
|
|
||||||
|
|
||||||
elemById('P7_LEVEL_H').style.display = 'none';
|
|
||||||
elemById('P7_LEVEL_L').style.display = 'none';
|
|
||||||
}
|
|
@ -1,10 +1,5 @@
|
|||||||
#include "SAB.h"
|
#include "SAB.h"
|
||||||
|
|
||||||
//Initializing the static pointer to the RtcManager
|
|
||||||
//Ugly, but I don't know how to do it an other way
|
|
||||||
//This static member is used to declare the callback necessary to set the file system's time
|
|
||||||
RtcManager *SAB::_rtcManagerP = NULL;
|
|
||||||
|
|
||||||
SAB::SAB() : _sdCardManager(_boardConfig.getSPI_SDCard_cs(), _boardConfig.getSPISpeed()),
|
SAB::SAB() : _sdCardManager(_boardConfig.getSPI_SDCard_cs(), _boardConfig.getSPISpeed()),
|
||||||
_display(_boardConfig.getScreenWidth(),_boardConfig.getScreenHeight(), &Wire),
|
_display(_boardConfig.getScreenWidth(),_boardConfig.getScreenHeight(), &Wire),
|
||||||
_screenManager(_display, &_sdCardManager),
|
_screenManager(_display, &_sdCardManager),
|
||||||
@ -28,16 +23,8 @@ _error(0)
|
|||||||
//We initialize the pins for the I2C communication
|
//We initialize the pins for the I2C communication
|
||||||
Wire.begin(_boardConfig.getI2C_sda(), _boardConfig.getI2C_scl());
|
Wire.begin(_boardConfig.getI2C_sda(), _boardConfig.getI2C_scl());
|
||||||
if(!_rtc.begin()) _error |= RTC_BEGIN_ERR;
|
if(!_rtc.begin()) _error |= RTC_BEGIN_ERR;
|
||||||
else
|
|
||||||
{
|
|
||||||
SAB::_rtcManagerP = &_rtcManager;
|
|
||||||
}
|
|
||||||
if(!_display.begin(SSD1306_SWITCHCAPVCC, _boardConfig.getI2C_screenAddress())){ _error |= DISP_BEGIN_ERR; }
|
if(!_display.begin(SSD1306_SWITCHCAPVCC, _boardConfig.getI2C_screenAddress())){ _error |= DISP_BEGIN_ERR; }
|
||||||
if(!_sdCardManager.mountSD()){ _error |= SDCARD_INIT_ERR; Serial.print("Failed to init SDCard : SPI_SPEED : "); Serial.print(8000000); Serial.print(" CS PIN : "); Serial.println(_boardConfig.getSPI_SDCard_cs());}
|
if(!_sdCardManager.mountSD()){ _error |= SDCARD_INIT_ERR; Serial.print("Failed to init SDCard : SPI_SPEED : "); Serial.print(8000000); Serial.print(" CS PIN : "); Serial.println(_boardConfig.getSPI_SDCard_cs());}
|
||||||
else
|
|
||||||
{
|
|
||||||
_sdCardManager.setTimeCallback(&(SAB::myTimeCallback));
|
|
||||||
}
|
|
||||||
_screenManager.init();
|
_screenManager.init();
|
||||||
_connectivityManager = new ConnectivityManager(_sdCardManager);
|
_connectivityManager = new ConnectivityManager(_sdCardManager);
|
||||||
if(!_pcf.begin()){_error |= IO_INIT_ERR;}
|
if(!_pcf.begin()){_error |= IO_INIT_ERR;}
|
||||||
@ -68,16 +55,8 @@ _error(0)
|
|||||||
//We initialize the pins for the I2C communication
|
//We initialize the pins for the I2C communication
|
||||||
Wire.begin(_boardConfig.getI2C_sda(), _boardConfig.getI2C_scl());
|
Wire.begin(_boardConfig.getI2C_sda(), _boardConfig.getI2C_scl());
|
||||||
if(!_rtc.begin()) _error |= RTC_BEGIN_ERR;
|
if(!_rtc.begin()) _error |= RTC_BEGIN_ERR;
|
||||||
else
|
|
||||||
{
|
|
||||||
SAB::_rtcManagerP = &_rtcManager;
|
|
||||||
}
|
|
||||||
if(!_display.begin(SSD1306_SWITCHCAPVCC, _boardConfig.getI2C_screenAddress())) _error |= DISP_BEGIN_ERR;
|
if(!_display.begin(SSD1306_SWITCHCAPVCC, _boardConfig.getI2C_screenAddress())) _error |= DISP_BEGIN_ERR;
|
||||||
if(!_sdCardManager.mountSD()){ _error |= SDCARD_INIT_ERR; Serial.print("Failed to init SDCard : SPI_SPEED : "); Serial.print(8000000); Serial.print(" CS PIN : "); Serial.println(_boardConfig.getSPI_SDCard_cs());}
|
if(!_sdCardManager.mountSD()){ _error |= SDCARD_INIT_ERR; Serial.print("Failed to init SDCard : SPI_SPEED : "); Serial.print(8000000); Serial.print(" CS PIN : "); Serial.println(_boardConfig.getSPI_SDCard_cs());}
|
||||||
else
|
|
||||||
{
|
|
||||||
_sdCardManager.setTimeCallback(&(SAB::myTimeCallback));
|
|
||||||
}
|
|
||||||
_screenManager.init();
|
_screenManager.init();
|
||||||
_connectivityManager = new ConnectivityManager(_sdCardManager);
|
_connectivityManager = new ConnectivityManager(_sdCardManager);
|
||||||
if(!_pcf.begin()){_error |= IO_INIT_ERR;}
|
if(!_pcf.begin()){_error |= IO_INIT_ERR;}
|
||||||
@ -90,14 +69,6 @@ void SAB::initGPIO()
|
|||||||
pinMode(GPIO_0, INPUT);
|
pinMode(GPIO_0, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t SAB::myTimeCallback()
|
|
||||||
{
|
|
||||||
if(SAB::_rtcManagerP != NULL)
|
|
||||||
return SAB::_rtcManagerP->getDateTime().unixtime();
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScreenManager& SAB::getScreenManager()
|
ScreenManager& SAB::getScreenManager()
|
||||||
{
|
{
|
||||||
return _screenManager;
|
return _screenManager;
|
||||||
|
@ -47,15 +47,12 @@ class SAB
|
|||||||
unsigned char getError() const;
|
unsigned char getError() const;
|
||||||
private:
|
private:
|
||||||
void initGPIO();
|
void initGPIO();
|
||||||
static time_t myTimeCallback();
|
|
||||||
const BoardConfig _boardConfig;
|
const BoardConfig _boardConfig;
|
||||||
|
|
||||||
|
|
||||||
Adafruit_SSD1306 _display;
|
Adafruit_SSD1306 _display;
|
||||||
ScreenManager _screenManager;
|
ScreenManager _screenManager;
|
||||||
RTC_DS3231 _rtc;
|
RTC_DS3231 _rtc;
|
||||||
RtcManager _rtcManager;
|
RtcManager _rtcManager;
|
||||||
static RtcManager *_rtcManagerP;
|
|
||||||
SDCardManager _sdCardManager;
|
SDCardManager _sdCardManager;
|
||||||
ConnectivityManager *_connectivityManager;
|
ConnectivityManager *_connectivityManager;
|
||||||
//WEBServerManager _webServerManager;
|
//WEBServerManager _webServerManager;
|
||||||
|
@ -10,7 +10,7 @@ double SDCardManager::getSize(const SizeUnit sizeUnit)
|
|||||||
uint64_t numberOf512BytesChunks = blocksPerCluster() * totalClusters();//cardSize();
|
uint64_t numberOf512BytesChunks = blocksPerCluster() * totalClusters();//cardSize();
|
||||||
double result = 0;
|
double result = 0;
|
||||||
|
|
||||||
if(!isMounted()) return 0.0;
|
if(!isMounted()) return 0;
|
||||||
|
|
||||||
switch(sizeUnit)
|
switch(sizeUnit)
|
||||||
{
|
{
|
||||||
|
@ -251,13 +251,6 @@ void ScreenManager::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenManager::forceRefresh()
|
|
||||||
{
|
|
||||||
if(!_enabled) return;
|
|
||||||
_forceRefresh = true;
|
|
||||||
run();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean ScreenManager::displayView(const uint8_t UID)
|
boolean ScreenManager::displayView(const uint8_t UID)
|
||||||
{
|
{
|
||||||
if(!_enabled) return true;
|
if(!_enabled) return true;
|
||||||
|
@ -19,7 +19,6 @@ class ScreenManager
|
|||||||
boolean displayView(const uint8_t UID);
|
boolean displayView(const uint8_t UID);
|
||||||
void displayNextView();
|
void displayNextView();
|
||||||
void displayPreviousView();
|
void displayPreviousView();
|
||||||
void forceRefresh();
|
|
||||||
boolean applyCfgFromSD();
|
boolean applyCfgFromSD();
|
||||||
void invertDisplayColor(const boolean inverted);
|
void invertDisplayColor(const boolean inverted);
|
||||||
void orientDisplay(const Orientation orientation);
|
void orientDisplay(const Orientation orientation);
|
||||||
|
@ -82,9 +82,9 @@ class TCPServer
|
|||||||
{
|
{
|
||||||
T *clientPointer = createNewClient(wc);
|
T *clientPointer = createNewClient(wc);
|
||||||
_clientList.addFirst(clientPointer);
|
_clientList.addFirst(clientPointer);
|
||||||
#ifdef DEBUG_TCPS
|
//#ifdef DEBUG_TCPS
|
||||||
Serial.printf("TCPServer : New client accepted. Id : %u , Number of clients : %u, local port : %u, remote port : %u\n",clientPointer->_id, _clientList.count(),clientPointer->_client.localPort(),clientPointer->_client.remotePort());
|
Serial.printf("TCPServer : New client accepted. Id : %u , Number of clients : %u, local port : %u, remote port : %u\n",clientPointer->_id, _clientList.count(),clientPointer->_client.localPort(),clientPointer->_client.remotePort());
|
||||||
#endif
|
//#endif
|
||||||
greetClient(clientPointer);
|
greetClient(clientPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "SDCardManager.h"
|
#include "SDCardManager.h"
|
||||||
#include "HttpConstants.h"
|
#include "HttpConstants.h"
|
||||||
//#define DEBUG_WEBS
|
//#define DEBUG_WEBS
|
||||||
#define READ_WRITE_BUFFER_SIZE 2000
|
#define READ_WRITE_BUFFER_SIZE 2500
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class WEBServer : public TCPServer<T>, public HttpConstants
|
class WEBServer : public TCPServer<T>, public HttpConstants
|
||||||
@ -53,7 +53,7 @@ class WEBServer : public TCPServer<T>, public HttpConstants
|
|||||||
if(buffer != NULL)
|
if(buffer != NULL)
|
||||||
{
|
{
|
||||||
strcpy(buffer, content);
|
strcpy(buffer, content);
|
||||||
sprintf(header,"HTTP/1.1 200 OK\r\nContent-Type: %s\r\nContent-Length: %d\r\n\r\n%s",contentType,strlen(buffer), buffer);
|
sprintf(header,"HTTP/1.1 200 OK\r\nContent-Type: %s\r\nContent-Length: %lu\r\n\r\n%s",contentType,strlen(buffer), buffer);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,8 @@ void setup()
|
|||||||
sab.getWebServer().addApiRoutine("/sab/rtc/set/datetime", &(rtcSetTimeApi), &sab, WEBServer<WEBClient>::GET);
|
sab.getWebServer().addApiRoutine("/sab/rtc/set/datetime", &(rtcSetTimeApi), &sab, WEBServer<WEBClient>::GET);
|
||||||
sab.getWebServer().addApiRoutine("/sab/sdcard/size", &(sdCardSizeApi), &sab, WEBServer<WEBClient>::GET);
|
sab.getWebServer().addApiRoutine("/sab/sdcard/size", &(sdCardSizeApi), &sab, WEBServer<WEBClient>::GET);
|
||||||
sdCardApiPacket.pSab = &sab;sdCardApiPacket.pView = &v1p;
|
sdCardApiPacket.pSab = &sab;sdCardApiPacket.pView = &v1p;
|
||||||
sab.getWebServer().addApiRoutine("/sab/sdcard/action", &(sdCardActionApi), &sdCardApiPacket, WEBServer<WEBClient>::GET);
|
sab.getWebServer().addApiRoutine("/sab/sdcard/unmount", &(sdCardUnmountApi), &sdCardApiPacket, WEBServer<WEBClient>::GET);
|
||||||
|
sab.getWebServer().addApiRoutine("/sab/sdcard/mount", &(sdCardMountApi), &sdCardApiPacket, WEBServer<WEBClient>::GET);
|
||||||
|
|
||||||
sab.getWebServer().addApiRoutine("/esp/restart", &(espRestartApi), &sab, WEBServer<WEBClient>::GET);
|
sab.getWebServer().addApiRoutine("/esp/restart", &(espRestartApi), &sab, WEBServer<WEBClient>::GET);
|
||||||
sab.getWebServer().addApiRoutine("/esp/reset", &(espResetApi), &sab, WEBServer<WEBClient>::GET);
|
sab.getWebServer().addApiRoutine("/esp/reset", &(espResetApi), &sab, WEBServer<WEBClient>::GET);
|
||||||
@ -107,12 +108,8 @@ void loop()
|
|||||||
sab.getIoManager().getPcf().digitalReadAll(vio.ioState);
|
sab.getIoManager().getPcf().digitalReadAll(vio.ioState);
|
||||||
sab.getIoManager().getPcf().getPinModeAll(vio.ioMode);
|
sab.getIoManager().getPcf().getPinModeAll(vio.ioMode);
|
||||||
|
|
||||||
if(ioStateChange)
|
if(ioStateChange) Serial.println(F("ISR triggered"));
|
||||||
{
|
ioStateChange = false;
|
||||||
sab.getScreenManager().forceRefresh();
|
|
||||||
Serial.println(F("ISR triggered"));
|
|
||||||
ioStateChange = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(digitalRead(GPIO_0) == 0 && millis() - buttonMs > 500)
|
/*if(digitalRead(GPIO_0) == 0 && millis() - buttonMs > 500)
|
||||||
@ -155,7 +152,7 @@ void loop()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//Run the different services
|
//Run the differentes services
|
||||||
sab.run();
|
sab.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,5 @@
|
|||||||
#define SOFT_VERSION "1.6.1" //Reworked the ScreenManager in order to display previous views and did some code optimization
|
#define SOFT_VERSION "1.6.1" //Reworked the ScreenManager in order to display previous views and did some code optimization
|
||||||
#define SOFT_VERSION "1.6.2" //Added a run method to the screen manager and reworked the error system
|
#define SOFT_VERSION "1.6.2" //Added a run method to the screen manager and reworked the error system
|
||||||
#define SOFT_VERSION "1.6.3" //Added a new api call to get nearby wifi access points
|
#define SOFT_VERSION "1.6.3" //Added a new api call to get nearby wifi access points
|
||||||
#define SOFT_VERSION "1.6.4" //Added the forceRefresh() method to the ScreenManager Object
|
|
||||||
#define SOFT_VERSION "1.6.5" //Removed the sd card mount and unmount api calls, replaced with the sdCardAction api call which takes a parameter (does the same thing)
|
|
||||||
|
|
||||||
#endif //VERSIONS_H
|
#endif //VERSIONS_H
|
||||||
|
@ -124,50 +124,34 @@ boolean rtcSetTimeApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean sdCardActionApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
boolean sdCardUnmountApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
||||||
|
{
|
||||||
|
SdCardApiPacket *pV = (SdCardApiPacket*)pData;
|
||||||
|
SAB *p = (SAB *)pV->pSab;
|
||||||
|
float *sdCardSize = (float *) &pV->pView->sdCardSize;
|
||||||
|
char buffer[200];
|
||||||
|
p->getSdCardManager().unMountSD();
|
||||||
|
*sdCardSize = 0.0;
|
||||||
|
sprintf(buffer,"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"card\" : \"unmounted\" }");
|
||||||
|
wc->print(buffer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean sdCardMountApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *wc, void *pData)
|
||||||
{
|
{
|
||||||
SdCardApiPacket *pV = (SdCardApiPacket*)pData;
|
SdCardApiPacket *pV = (SdCardApiPacket*)pData;
|
||||||
SAB *p = (SAB *)pV->pSab;
|
SAB *p = (SAB *)pV->pSab;
|
||||||
float *sdCardSize = (float *) &pV->pView->sdCardSize;
|
float *sdCardSize = (float *) &pV->pView->sdCardSize;
|
||||||
char buffer[200];
|
char buffer[200];
|
||||||
|
|
||||||
//We first retrieve the parameter that indicates the action :
|
if(p->getSdCardManager().mountSD())
|
||||||
if(HRD.getParams.count() != 1)
|
|
||||||
{
|
{
|
||||||
strcpy_P(buffer, PSTR("{\"status\":\"error\",\"message\":\"One and only one parameter is expected\"}"));
|
sprintf(buffer,"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"card\" : \"mounted\" }");
|
||||||
|
*sdCardSize = p->getSdCardManager().getSize(GBYTE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
sprintf(buffer,"HTTP/1.1 500 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"error\", \"message\" : \"begin failed\" }");
|
||||||
if(HRD.getParams("action") != NULL)
|
|
||||||
{
|
|
||||||
if(strcmp_P(HRD.getParams("action")->getString(), PSTR("mount")) == 0)
|
|
||||||
{
|
|
||||||
if(p->getSdCardManager().mountSD())
|
|
||||||
{
|
|
||||||
strcpy_P(buffer, PSTR("{\"status\":\"ok\",\"card\":\"mounted\"}"));
|
|
||||||
*sdCardSize = p->getSdCardManager().getSize(GBYTE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
strcpy_P(buffer, PSTR("{\"status\":\"error\",\"message\":\"begin failed\"}"));
|
|
||||||
}
|
|
||||||
else if(strcmp_P(HRD.getParams("action")->getString(), PSTR("unmount")) == 0)
|
|
||||||
{
|
|
||||||
p->getSdCardManager().unMountSD();
|
|
||||||
*sdCardSize = 0.0;
|
|
||||||
strcpy_P(buffer, PSTR("{\"status\":\"ok\",\"card\":\"unmounted\"}"));
|
|
||||||
}
|
|
||||||
else //Error
|
|
||||||
{
|
|
||||||
strcpy_P(buffer, PSTR("{\"status\":\"error\",\"message\":\"Parameter 'action' should be mount or unmount\"}"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else //Error
|
|
||||||
{
|
|
||||||
strcpy_P(buffer, PSTR("{\"status\":\"error\",\"message\":\"Parameter should be 'action'\"}"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WEBServer<WEBClient>::injectApiHeader(buffer, "application/json", buffer);
|
|
||||||
wc->print(buffer);
|
wc->print(buffer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@ typedef struct sdCardApiPacket
|
|||||||
SAB *pSab;
|
SAB *pSab;
|
||||||
View1Packet *pView;
|
View1Packet *pView;
|
||||||
} SdCardApiPacket;
|
} SdCardApiPacket;
|
||||||
boolean sdCardActionApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
boolean sdCardUnmountApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
||||||
|
boolean sdCardMountApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
||||||
|
|
||||||
boolean apScannerApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
boolean apScannerApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
||||||
boolean staWifiInfoApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
boolean staWifiInfoApi(WEBServer<WEBClient>::HttpRequestData&, WiFiClient*, void*);
|
||||||
|
@ -97,10 +97,6 @@ public:
|
|||||||
return (boolean)SDFS.rename(pathFrom, pathTo);
|
return (boolean)SDFS.rename(pathFrom, pathTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool info64(FSInfo64& info) {
|
|
||||||
return (boolean)SDFS.info64(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t type() {
|
uint8_t type() {
|
||||||
sdfs::SDFSImpl* sd = static_cast<sdfs::SDFSImpl*>(SDFS.getImpl().get());
|
sdfs::SDFSImpl* sd = static_cast<sdfs::SDFSImpl*>(SDFS.getImpl().get());
|
||||||
return sd->type();
|
return sd->type();
|
||||||
|
Loading…
Reference in New Issue
Block a user