Add a reset feature to mobile app which allows the device to be reset to the default settings (direction forward, exposure 630 and delay 0).

This commit is contained in:
mmcwilliams 2018-02-07 19:07:38 -05:00
parent 42580c46b9
commit a37c58d791
3 changed files with 31 additions and 0 deletions

View File

@ -80,6 +80,12 @@
<button id="wifi" class="" onclick="mobile.setWifi();">CONNECT</button>
<button id="wifiRefresh" class="" onclick="mobile.getWifi();">REFRESH WIFI</button>
</div>
<div class="ble">
<br />
<button id="reset" onclick="mobile.reset();">RESET</button>
<button id="restart" onclick="mobile.restart();">RESTART</button>
<button id="update" onclick="mobile.update();">UPDATE</button>
</div>
</div>
<!--<div id="mscript" class="page">
<h2>MSCRIPT</h2>

View File

@ -412,3 +412,7 @@ span.pos{
body.mobile footer{
display: block;
}
#reset{
margin-top: 60px;
}

View File

@ -289,9 +289,11 @@ mobile.sequence = function () {
stringToBytes(JSON.stringify(opts)), //check length?
mobile.sequenceSuccess,
mobile.ble.onError);
if (!elem.classList.contains('focus')) {
elem.classList.add('focus');
}
mobile.ble.active = true;
};
@ -596,6 +598,25 @@ mobile.EV = function (fstop, shutter) {
return Math.log(square / sec);
};
mobile.reset = function () {
const reset = confirm(`Reset INTVAL3 to default settings?`);
if (!reset) return false;
let opts = {
type : 'reset'
};
ble.write(mobile.ble.device.id,
mobile.ble.SERVICE_ID,
mobile.ble.CHAR_ID,
stringToBytes(JSON.stringify(opts)),
mobile.resetSuccess,
mobile.ble.onError);
};
mobile.resetSuccess = function () {
console.log('Reset to default settings');
mobile.getState();
};
/**
* Mobile helper functions
*/