Compare commits

..

No commits in common. "6221262dbf705f86f1c98051d4545e1455ef89c3" and "fb366b497680e9c5959671dd46f1bfad1073f935" have entirely different histories.

14 changed files with 187 additions and 529 deletions

View File

@ -33,8 +33,9 @@
<ul class="navbar-nav nav mr-auto mt-2 mt-lg-0"> <ul class="navbar-nav nav mr-auto mt-2 mt-lg-0">
<li class="nav-item"><a class="nav-link active" role="tab" data-toggle="tab" href="#tab_home">Home</a></li> <li class="nav-item"><a class="nav-link active" role="tab" data-toggle="tab" href="#tab_home">Home</a></li>
<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_source">Wegstrecke</a></li>
<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_lube">Schmierung</a></li>
<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_maintenance">Wartung</a></li> <li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_maintenance">Wartung</a></li>
<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_source">Einstellungen</a></li>
<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_sysinfo">Systeminfo</a></li> <li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_sysinfo">Systeminfo</a></li>
<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_fwupdate">Update</a></li> <li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_fwupdate">Update</a></li>
@ -54,7 +55,6 @@
<h3 class="pt-3">KTM CAN Chain Lube</h3> <h3 class="pt-3">KTM CAN Chain Lube</h3>
</div> </div>
</div> </div>
<!-- Div Group Tank remain -->
<hr /> <hr />
<p> <p>
<h4>Tankinhalt verbleibend</h4> <h4>Tankinhalt verbleibend</h4>
@ -65,17 +65,13 @@
</div> </div>
</div> </div>
</p> </p>
<!-- Div Group Tank remain -->
<!-- Div Group current Mode -->
<hr /> <hr />
<p> <p>
<h4>aktueller Modus</h4> <h4>aktueller Modus</h4>
<input class="form-control" type="text" placeholder="%SYSTEM_STATUS%" readonly> <input class="form-control" type="text" placeholder="%SYSTEM_STATUS%" readonly>
</p> </p>
<!-- Div Group current Mode --> <hr />
<!-- Div Group DTC Table -->
<div %SHOW_DTC_TABLE%> <div %SHOW_DTC_TABLE%>
<hr />
<p> <p>
<h4>Fehlercodes</h4> <h4>Fehlercodes</h4>
<table class="table"> <table class="table">
@ -90,152 +86,13 @@
</tbody> </tbody>
</table> </table>
</p> </p>
<hr />
</div> </div>
<!-- Div Group DTC Table -->
</div> </div>
<!-- Div Tab Home--> <!-- Div Tab Home-->
<!-- Div Tab Source Settings-->
<!-- Div Tab Maintenance -->
<div id="tab_maintenance" class="tab-pane fade" role="tabpanel">
<h3>Wartung</h3>
<!-- Div Group Tank remain -->
<hr />
<p>
<h4>&Ouml;lvorrat</h4>
<form action="post.htm" method="POST" class="form-horizontal">
<div class="form-group row">
<label for="tankremain_maint" class="control-label col-4">Tankinhalt verbleibend</label>
<div class="col-8">
<div class="progress">
<div id="tankremain_maint" class="progress-bar text-light" role="progressbar"
aria-valuenow="%TANK_REMAIN_CAPACITY%" aria-valuemin="0" aria-valuemax="100"
style="width: %TANK_REMAIN_CAPACITY%&#37;">
%TANK_REMAIN_CAPACITY%&#37;
</div>
</div>
</div>
</div>
<div class="form-group row">
<div class="col text-center">
<button name="resettank" type="submit" class="btn btn-outline-primary ml-2">Tank zurücksetzen</button>
</div>
</div>
</form>
</p>
<!-- Div Group Tank remain -->
<!-- Div Group Purging -->
<hr />
<p>
<h4>Entl&uuml;ftung</h4>
<form action="post.htm" method="POST" class="form-horizontal">
<div class="form-group row">
<label for="purgepulse" class="control-label col-4">Entl&uuml;ftung Dosierung</label>
<div class="col-8">
<div class="input-group">
<input id="purgepulse" name="purgepulse" value="%BLEEDING_PULSES%" type="text" class="form-control">
<div class="input-group-append">
<span class="input-group-text">Pulse</span>
</div>
</div>
</div>
</div>
<div class="form-group row">
<div class="col text-center">
<button name="maintsave" type="submit" class="btn btn-outline-primary">Speichern</button>
<button name="purgenow" type="submit" class="btn btn-outline-primary ml-2">Entlüftung starten</button>
</div>
</div>
</form>
</p>
<!-- Div Group Purging -->
<!-- Div Group Measure -->
<div %SHOW_IMPULSE_SETTINGS%>
<hr />
<p>
<h4>Einmessen</h4>
<form action="post.htm" method="POST" class="form-horizontal">
<div class="form-group row">
<label for="measuredpulses" class="control-label col-4">erfasste Pulse</label>
<div class="col-8">
<div class="input-group">
<input id="measuredpulses" name="measuredpulses" value="%MEASURED_PULSES%" type="text" readonly
class="form-control">
<div class="input-group-append">
<span class="input-group-text">Pulse</span>
</div>
</div>
</div>
</div>
<div class="form-group row">
<div class="col text-center">
<button name="measurestartstop" type="submit" class="btn btn-outline-primary">%MEASURE_BTN%</button>
<button name="measurereset" type="submit" class="btn btn-outline-primary ml-2">Reset</button>
</div>
</div>
</form>
</p>
</div>
<!-- Div Group Purging -->
<!-- Div Group EEPROM formatting -->
<hr />
<p>
<h4>EEPROM formatieren</h4>
<div class="alert alert-primary alert-dismissable show fade" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<strong>Achtung!</strong><br>
Das Formatieren der EEPROM-Bereiche sollte nur ausgeführt werden wenn es unbedingt erforderlich ist!
Hierdurch werden alle Einstellungen zurück gesetzt bzw. alle Betriebsdaten gehen verloren.
Folgende Situationen erfordern unter anderem eine Formatierung:
- Erstinitialisierung (bei neu aufgebautem Gerät)
- Firmware-Update (nur wenn es die Release-Notes fordern)
</div>
<form action="post.htm" method="POST" class="form-horizontal">
<div class="form-group row">
<div class="offset-4 col-8">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="reset_ee_cfg" id="reset_ee_cfg">
<label class="form-check-label" for="reset_ee_cfg">
Bereich "CFG"
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="reset_ee_pds" id="reset_ee_pds">
<label class="form-check-label" for="reset_ee_pds">
Bereich "PDS"
</label>
</div>
</div>
</div>
<div class="form-group row">
<div class="col text-center">
<button name="reset_ee_btn" type="submit" class="btn btn-outline-primary">EEPROM formatieren</button>
</div>
</div>
</form>
</p>
<!-- Div Group EEPROM formatting -->
<!-- Div Group Device Reboot -->
<hr />
<p>
<h4>Ger&auml;t neustarten</h4>
<form action="post.htm" method="POST" class="form-horizontal">
<div class="form-group row">
<div class="col text-center">
<button name="reboot" type="submit" class="btn btn-outline-primary">Reboot</button>
</div>
</div>
</form>
</p>
<!-- Div Group Device Reboot -->
</div>
<!-- Div Tab Maintenance -->
<!-- Div Tab Settings-->
<div id="tab_source" class="tab-pane fade" role="tabpanel"> <div id="tab_source" class="tab-pane fade" role="tabpanel">
<h3>Einstellungen</h3> <h3>Wegstreckenerfassung</h3>
<!-- Div Group Signal Source -->
<hr /> <hr />
<p> <p>
<h4>Signalquelle</h4> <h4>Signalquelle</h4>
@ -263,8 +120,7 @@
</div> </div>
</form> </form>
</p> </p>
<!-- Div Group Signal Source --> <!-- Div Source:Impulse Settings-->
<!-- Div Group Source:Impulse Settings-->
<div %SHOW_IMPULSE_SETTINGS%> <div %SHOW_IMPULSE_SETTINGS%>
<hr /> <hr />
<p> <p>
@ -325,9 +181,10 @@
</div> </div>
</form> </form>
</p> </p>
<hr />
</div> </div>
<!-- Div Group Source:Impulse Settings--> <!-- Div Source:Impulse Settings-->
<!-- Div Group Source:CAN Settings--> <!-- Div Source:CAN Settings-->
<div %SHOW_CAN_SETTINGS%> <div %SHOW_CAN_SETTINGS%>
<hr /> <hr />
<p> <p>
@ -348,9 +205,10 @@
</div> </div>
</form> </form>
</p> </p>
<hr />
</div> </div>
<!-- Div Group Source:CAN Settings--> <!-- Div Source:CAN Settings-->
<!-- Div Group Source:GPS Settings--> <!-- Div Source:GPS Settings-->
<div %SHOW_GPS_SETTINGS%> <div %SHOW_GPS_SETTINGS%>
<hr /> <hr />
<p> <p>
@ -371,9 +229,14 @@
</div> </div>
</form> </form>
</p> </p>
<hr />
</div> </div>
<!-- Div Group Source:GPS Settings--> <!-- Div Source:GPS Settings-->
<!-- Div Group Lube Settings--> </div>
<!-- Div Tab Source Settings-->
<!-- Div Tab Lube -->
<div id="tab_lube" class="tab-pane fade" role="tabpanel">
<h3>Schmierung</h3>
<hr /> <hr />
<p> <p>
<h4>Dosierung</h4> <h4>Dosierung</h4>
@ -409,11 +272,15 @@
</div> </div>
</form> </form>
</p> </p>
<!-- Div Group Lube Settings--> <hr />
<!-- Div Group Oiltank Settings --> </div>
<!-- Div Tab Lube -->
<!-- Div Tab Maintenance -->
<div id="tab_maintenance" class="tab-pane fade" role="tabpanel">
<h3>Wartung</h3>
<hr /> <hr />
<p> <p>
<h4>&Ouml;ltank</h4> <h4>&Ouml;lvorrat</h4>
<form action="post.htm" method="POST" class="form-horizontal"> <form action="post.htm" method="POST" class="form-horizontal">
<div class="form-group row"> <div class="form-group row">
<label for="tankcap" class="control-label col-4">Tankkapazität</label> <label for="tankcap" class="control-label col-4">Tankkapazität</label>
@ -451,63 +318,104 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group row">
<label for="tankremain_maint" class="control-label col-4">Tankinhalt verbleibend</label>
<div class="col-8">
<div class="progress">
<div id="tankremain_maint" class="progress-bar text-light" role="progressbar"
aria-valuenow="%TANK_REMAIN_CAPACITY%" aria-valuemin="0" aria-valuemax="100"
style="width: %TANK_REMAIN_CAPACITY%&#37;">
%TANK_REMAIN_CAPACITY%&#37;
</div>
</div>
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<div class="col text-center"> <div class="col text-center">
<button name="oilsave" type="submit" class="btn btn-outline-primary">Speichern</button> <button name="oilsave" type="submit" class="btn btn-outline-primary">Speichern</button>
<button name="resettank" type="submit" class="btn btn-outline-primary ml-2">Tank zurücksetzen</button>
</div> </div>
</div> </div>
</form> </form>
</p> </p>
<!-- Div Group Oiltank Settings -->
<!-- Div Group LED Settings-->
<hr /> <hr />
<p> <p>
<h4>LED Einstellungen</h4> <h4>Entl&uuml;ftung</h4>
<form action="post.htm" method="POST" class="form-horizontal"> <form action="post.htm" method="POST" class="form-horizontal">
<div class="form-group row"> <div class="form-group row">
<label for="ledmodeflash" class="control-label col-4">LED Modus blinken</label> <label for="purgepulse" class="control-label col-4">Entl&uuml;ftung Dosierung</label>
<div class="col-8"> <div class="col-8">
<div class="input-group">
<input id="purgepulse" name="purgepulse" value="%BLEEDING_PULSES%" type="text" class="form-control">
<div class="input-group-append">
<span class="input-group-text">Pulse</span>
</div>
</div>
</div>
</div>
<div class="form-group row">
<div class="col text-center">
<button name="maintsave" type="submit" class="btn btn-outline-primary">Speichern</button>
<button name="purgenow" type="submit" class="btn btn-outline-primary ml-2">Entlüftung starten</button>
</div>
</div>
</form>
</p>
<hr />
<p>
<h4>EEPROM formatieren</h4>
<div class="alert alert-primary alert-dismissable show fade" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<strong>Achtung!</strong><br>
Das Formatieren der EEPROM-Bereiche sollte nur ausgeführt werden wenn es unbedingt erforderlich ist!
Hierdurch werden alle Einstellungen zurück gesetzt bzw. alle Betriebsdaten gehen verloren.
Folgende Situationen erfordern unter anderem eine Formatierung:
- Erstinitialisierung (bei neu aufgebautem Gerät)
- Firmware-Update (nur wenn es die Release-Notes fordern)
</div>
<form action="post.htm" method="POST" class="form-horizontal">
<div class="form-group row">
<div class="offset-4 col-8">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="checkbox" name="ledmodeflash" id="ledmodeflash" %LEDFLASHCHECKED%> <input class="form-check-input" type="checkbox" name="reset_ee_cfg" id="reset_ee_cfg">
<label class="form-check-label" for="ledmodeflash"> <label class="form-check-label" for="reset_ee_cfg">
LED blinken Bereich "CFG"
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="reset_ee_pds" id="reset_ee_pds">
<label class="form-check-label" for="reset_ee_pds">
Bereich "PDS"
</label> </label>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group row">
<label for="ledmaxbrightness" class="control-label col-4">Max Helligkeit</label>
<div class="col-8">
<div class="input-group">
<input id="ledmaxbrightness" name="ledmaxbrightness" value="%LED_MAX_BRIGHTNESS%" type="text"
class="form-control" required="required">
</div>
</div>
</div>
<div class="form-group row">
<label for="ledminbrightness" class="control-label col-4">Min Helligkeit</label>
<div class="col-8">
<div class="input-group">
<input id="ledminbrightness" name="ledminbrightness" value="%LED_MIN_BRIGHTNESS%" type="text"
class="form-control" required="required">
</div>
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<div class="col text-center"> <div class="col text-center">
<button name="ledsave" type="submit" class="btn btn-outline-primary">Speichern</button> <button name="reset_ee_btn" type="submit" class="btn btn-outline-primary">EEPROM formatieren</button>
</div> </div>
</div> </div>
</form> </form>
</p> </p>
<!-- Div Group Lube Settings--> <hr />
<p>
<h4>Ger&auml;t neustarten</h4>
<form action="post.htm" method="POST" class="form-horizontal">
<div class="form-group row">
<div class="col text-center">
<button name="reboot" type="submit" class="btn btn-outline-primary">Reboot</button>
</div>
</div>
</form>
</p>
<hr />
</div> </div>
<!-- Div Tab Settings --> <!-- Div Tab Maintenance -->
<!-- Div Tab SystemInfo --> <!-- Div Tab SystemInfo -->
<div id="tab_sysinfo" class="tab-pane fade" role="tabpanel"> <div id="tab_sysinfo" class="tab-pane fade" role="tabpanel">
<h3>Systeminfo</h3> <h3>Systeminfo</h3>
<!-- Div Group Sysinfo:Settings -->
<hr /> <hr />
<p> <p>
<h4>Einstellungen</h4> <h4>Einstellungen</h4>
@ -573,22 +481,6 @@
<td>CANSource</td> <td>CANSource</td>
<td>%CAN_SOURCE%</td> <td>%CAN_SOURCE%</td>
</tr> </tr>
<tr>
<td>LED Mode Flash</td>
<td>%LED_MODE_FLASH%</td>
</tr>
<tr>
<td>LED Max Brightness</td>
<td>%LED_MAX_BRIGHTNESS%</td>
</tr>
<tr>
<td>LED Min Brightness</td>
<td>%LED_MIN_BRIGHTNESS%</td>
</tr>
<tr>
<td>EEPROM Version</td>
<td>%EEPROM_VERSION%</td>
</tr>
<tr> <tr>
<td>Checksum</td> <td>Checksum</td>
<td>%CONFIG_CHECKSUM%</td> <td>%CONFIG_CHECKSUM%</td>
@ -596,8 +488,6 @@
</tbody> </tbody>
</table> </table>
</p> </p>
<!-- Div Group Sysinfo:Settings -->
<!-- Div Group Sysinfo:Persistance -->
<hr /> <hr />
<p> <p>
<h4>Betriebsdaten</h4> <h4>Betriebsdaten</h4>
@ -633,29 +523,25 @@
</tr> </tr>
</table> </table>
</p> </p>
<!-- Div Group Sysinfo:Persistance -->
<!-- Div Group LiveDebug -->
<hr /> <hr />
<p> <p>
<h4>Live Debug</h4> <h4>Live Debug</h4>
<div class="form-group row"> <div class="form-group row">
<textarea class="form-control" spellcheck="false" id="livedebug-out" rows="3" readonly></textarea> <textarea class="form-control" spellcheck="false" id="livedebug-out" rows="3" readonly></textarea>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<div class="col text-center"> <div class="col text-center">
<button id="btn-ws-start" class="btn btn-outline-primary">Start</button> <button id="btn-ws-start" class="btn btn-outline-primary">Start</button>
<button id="btn-ws-stop" class="btn btn-outline-primary ml-2">Stop</button> <button id="btn-ws-stop" class="btn btn-outline-primary ml-2">Stop</button>
</div> </div>
</div> </div>
</p> </p>
<!-- Div Group LiveDebug --> <hr />
</div> </div>
<!-- Div Tab SystemInfo --> <!-- Div Tab SystemInfo -->
<!-- Div Tab Firmware Update--> <!-- Div Tab Firmware Update-->
<div id="tab_fwupdate" class="tab-pane fade" role="tabpanel"> <div id="tab_fwupdate" class="tab-pane fade" role="tabpanel">
<h3>Firmware</h3> <h3>Firmware</h3>
<!-- Div Group VersionInfo -->
<hr /> <hr />
<p> <p>
<h4>Version-Info</h4> <h4>Version-Info</h4>
@ -673,14 +559,8 @@
<td>Flash Version</td> <td>Flash Version</td>
<td>%FS_VERSION%</td> <td>%FS_VERSION%</td>
</tr> </tr>
<tr>
<td>Git Revision</td>
<td>%GIT_REV%</td>
</tr>
</table> </table>
</p> </p>
<!-- Div Group VersionInfo -->
<!-- Div Group EEPROM Backup -->
<hr /> <hr />
<p> <p>
<h4>EEPROM-Backup</h4> <h4>EEPROM-Backup</h4>
@ -690,8 +570,6 @@
</div> </div>
</div> </div>
</p> </p>
<!-- Div Group EEPROM Backup -->
<!-- Div Group EEPROM Restore -->
<hr /> <hr />
<p> <p>
<h4>EEPROM-Restore</h4> <h4>EEPROM-Restore</h4>
@ -710,8 +588,6 @@
</div> </div>
</form> </form>
</p> </p>
<!-- Div Group EEPROM Restore -->
<!-- Div Group Firmware Update -->
<hr /> <hr />
<p> <p>
<h4>Firmware-Update</h4> <h4>Firmware-Update</h4>
@ -730,7 +606,7 @@
</div> </div>
</form> </form>
</p> </p>
<!-- Div Group Firmware Update --> <hr />
</div> </div>
<!-- Div Tab Firmware Update--> <!-- Div Tab Firmware Update-->
</div> </div>

View File

@ -1 +1 @@
1.04 1.3

View File

@ -32,13 +32,13 @@ build_flags =
-DWIFI_AP_PASSWORD=${wifi_cred.wifi_ap_password} -DWIFI_AP_PASSWORD=${wifi_cred.wifi_ap_password}
-DWIFI_AP_IP_GW=10,0,0,1 -DWIFI_AP_IP_GW=10,0,0,1
-DATOMIC_FS_UPDATE -DATOMIC_FS_UPDATE
;-DFEATURE_ENABLE_WIFI_CLIENT -DFEATURE_ENABLE_WIFI_CLIENT
-DFEATURE_ENABLE_OLED -DFEATURE_ENABLE_OLED
;-DFEATURE_ENABLE_TIMER
-DFEATURE_ENABLE_CAN -DFEATURE_ENABLE_CAN
;-DFEATURE_ENABLE_GPS ;-DFEATURE_ENABLE_GPS
-DFEATURE_ENABLE_WEBSOCKETS -DFEATURE_ENABLE_WEBSOCKETS
-DPCB_REV=3 -DPCB_REV=4
;-DNO_MODE_FLASH
;build_type = debug ;build_type = debug
@ -52,8 +52,7 @@ board_build.ldscript = eagle.flash.4m1m.ld
lib_ldf_mode = deep lib_ldf_mode = deep
lib_deps = lib_deps =
olikraus/U8g2 @ ^2.28.8 olikraus/U8g2 @ ^2.28.8
adafruit/Adafruit NeoPixel @ ^1.11.0 https://github.com/FastLED/FastLED.git#3d2ab78 ;fastled/FastLED @ ^3.5.0
;https://github.com/FastLED/FastLED.git#3d2ab78 ;fastled/FastLED @ ^3.5.0
sstaub/Ticker @ ^4.2.0 sstaub/Ticker @ ^4.2.0
coryjfowler/mcp_can @ ^1.5.0 coryjfowler/mcp_can @ ^1.5.0
robtillaart/I2C_EEPROM @ ^1.5.2 robtillaart/I2C_EEPROM @ ^1.5.2

View File

@ -4,22 +4,16 @@
#define Q(x) #x #define Q(x) #x
#define QUOTE(x) Q(x) #define QUOTE(x) Q(x)
#if PCB_REV == 1 #if PCB_REV == 2
#define GPIO_BUTTON D7 #define GPIO_BUTTON D7
#define GPIO_LED D8 #define GPIO_LED D8
#define GPIO_TRIGGER D6 #define GPIO_TRIGGER D6
#define GPIO_PUMP D5 #define GPIO_PUMP D5
#elif PCB_REV == 2 #elif PCB_REV == 1 || PCB_REV == 3
#define GPIO_BUTTON D7 #define GPIO_BUTTON D5
#define GPIO_LED D8 #define GPIO_LED D6
#define GPIO_TRIGGER D6 #define GPIO_TRIGGER D4
#define GPIO_PUMP D5 #define GPIO_PUMP D3
#elif PCB_REV == 3
#define GPIO_BUTTON D4
#define GPIO_LED D3
#define GPIO_TRIGGER D6
#define GPIO_PUMP D0
#define GPIO_CS_CAN D8
#elif PCB_REV == 4 #elif PCB_REV == 4
#define GPIO_BUTTON D4 #define GPIO_BUTTON D4
#define GPIO_LED D3 #define GPIO_LED D3
@ -32,6 +26,9 @@
#define HOST_NAME "ChainLube_%06X" // Use printf-Formatting - Chip-ID (uin32_t) will be added #define HOST_NAME "ChainLube_%06X" // Use printf-Formatting - Chip-ID (uin32_t) will be added
#endif #endif
#define SW_VERSION 1.4
#define FLASH_FS_VERSION 1.4
#ifndef OTA_DELAY #ifndef OTA_DELAY
#define OTA_DELAY 50 // ticks -> 10ms / tick #define OTA_DELAY 50 // ticks -> 10ms / tick
#endif #endif

View File

@ -36,7 +36,7 @@ void EEPROM_Process()
case EE_CFG_FORMAT: case EE_CFG_FORMAT:
FormatConfig_EEPROM(); FormatConfig_EEPROM();
globals.requestEEAction = EE_IDLE; globals.requestEEAction = EE_IDLE;
GetConfig_EEPROM(); globals.systemStatus = sysStat_Shutdown;
Debug_pushMessage("Formated EEPROM CFG\n"); Debug_pushMessage("Formated EEPROM CFG\n");
break; break;
case EE_PDS_SAVE: case EE_PDS_SAVE:
@ -52,14 +52,11 @@ void EEPROM_Process()
case EE_PDS_FORMAT: case EE_PDS_FORMAT:
FormatPersistence_EEPROM(); FormatPersistence_EEPROM();
globals.requestEEAction = EE_IDLE; globals.requestEEAction = EE_IDLE;
GetPersistence_EEPROM();
Debug_pushMessage("Formated EEPROM PDS\n"); Debug_pushMessage("Formated EEPROM PDS\n");
break; break;
case EE_FORMAT_ALL: case EE_FORMAT_ALL:
FormatConfig_EEPROM(); FormatConfig_EEPROM();
FormatPersistence_EEPROM(); FormatPersistence_EEPROM();
GetConfig_EEPROM();
GetPersistence_EEPROM();
globals.requestEEAction = EE_IDLE; globals.requestEEAction = EE_IDLE;
Debug_pushMessage("Formated EEPROM ALL\n"); Debug_pushMessage("Formated EEPROM ALL\n");
break; break;

View File

@ -16,9 +16,7 @@
typedef enum SpeedSource_e typedef enum SpeedSource_e
{ {
#ifdef FEATURE_ENABLE_TIMER
SOURCE_TIME, SOURCE_TIME,
#endif
SOURCE_IMPULSE, SOURCE_IMPULSE,
#ifdef FEATURE_ENABLE_GPS #ifdef FEATURE_ENABLE_GPS
SOURCE_GPS, SOURCE_GPS,
@ -29,9 +27,7 @@ typedef enum SpeedSource_e
} SpeedSource_t; } SpeedSource_t;
const char SpeedSourceString[][8] = { const char SpeedSourceString[][8] = {
#ifdef FEATURE_ENABLE_TIMER
"Timer", "Timer",
#endif
"Impuls", "Impuls",
#ifdef FEATURE_ENABLE_GPS #ifdef FEATURE_ENABLE_GPS
"GPS", "GPS",
@ -100,9 +96,6 @@ typedef struct
#ifdef FEATURE_ENABLE_CAN #ifdef FEATURE_ENABLE_CAN
CANSource_t CANSource = KTM_890_ADV_R_2021; CANSource_t CANSource = KTM_890_ADV_R_2021;
#endif #endif
bool LED_Mode_Flash = false;
uint8_t LED_Max_Brightness = 255;
uint8_t LED_Min_Brightness = 5;
uint32_t checksum = 0; uint32_t checksum = 0;
} LubeConfig_t; } LubeConfig_t;
@ -114,9 +107,6 @@ const LubeConfig_t LubeConfig_defaults = {
#ifdef FEATURE_ENABLE_CAN #ifdef FEATURE_ENABLE_CAN
KTM_890_ADV_R_2021, KTM_890_ADV_R_2021,
#endif #endif
false,
255,
5,
0}; 0};
void InitEEPROM(); void InitEEPROM();

View File

@ -140,8 +140,8 @@ void RemotDebug_printSystemInfo()
: ideMode == FM_DOUT ? "DOUT" : ideMode == FM_DOUT ? "DOUT"
: "UNKNOWN")); : "UNKNOWN"));
Debug_pushMessage("OTA-Pass: %s", QUOTE(ADMIN_PASSWORD)); Debug_pushMessage("OTA-Pass: %s", QUOTE(ADMIN_PASSWORD));
Debug_pushMessage("Git-Revison: %s", constants.GitHash); Debug_pushMessage("Git-Revison: %s", GIT_REV);
Debug_pushMessage("Sw-Version: %d.%02d", constants.FW_Version_major, constants.FW_Version_minor); Debug_pushMessage("Sw-Version: %s", QUOTE(SW_VERSION));
} }
void Debug_dumpConfig() void Debug_dumpConfig()

View File

@ -116,7 +116,7 @@ void DTC_Process()
if (getlastDTC(false) < DTC_LAST_DTC) if (getlastDTC(false) < DTC_LAST_DTC)
{ {
globals.hasDTC = true; globals.hasDTC = true;
if (getlastDTC_Severity(true, DTC_CRITICAL) < DTC_LAST_DTC && globals.systemStatus != sysStat_Shutdown) if (getlastDTC_Severity(true, DTC_CRITICAL) < DTC_LAST_DTC)
{ {
if (globals.systemStatus != sysStat_Error) if (globals.systemStatus != sysStat_Error)
{ {

View File

@ -8,6 +8,4 @@ void initGlobals()
globals.requestEEAction = EE_IDLE; globals.requestEEAction = EE_IDLE;
globals.resumeStatus = sysStat_Normal; globals.resumeStatus = sysStat_Normal;
globals.systemStatus = sysStat_Startup; globals.systemStatus = sysStat_Startup;
globals.measurementActive = false;
globals.measuredPulses = 0;
} }

View File

@ -39,27 +39,10 @@ typedef struct Globals_s
uint16_t eePersistanceAdress; uint16_t eePersistanceAdress;
uint8_t TankPercentage; uint8_t TankPercentage;
bool hasDTC; bool hasDTC;
bool measurementActive;
uint32_t measuredPulses;
} Globals_t; } Globals_t;
extern Globals_t globals; extern Globals_t globals;
typedef struct Constants_s
{
uint8_t FW_Version_major;
uint8_t FW_Version_minor;
uint8_t Required_Flash_Version_major;
uint8_t Required_Flash_Version_minor;
char GitHash[11];
} Constants_t;
const Constants_t constants PROGMEM = {
1,4, // Firmware_Version
1,4, // Required Flash Version
GIT_REV // Git-Hash-String
};
void initGlobals(); void initGlobals();
#endif #endif

View File

@ -1,35 +0,0 @@
#ifndef _LED_COLORS_H_
#define _LED_COLORS_H_
#define COLOR_RED 0xFF0000
#define COLOR_GREEN 0x00FF00
#define COLOR_BLUE 0x0000FF
#define COLOR_YELLOW 0xFF9600
#define COLOR_ORANGE 0xFF2800
#define COLOR_TEAL 0x00FF78
#define COLOR_CYAN 0x00FFFF
#define COLOR_PURPLE 0xB400FF
#define COLOR_MAGENTA 0xFF0014
#define COLOR_WHITE 0xFFFFFF
#define COLOR_BLACK 0x000000
#define COLOR_GOLD 0xFFDE1E
#define COLOR_PINK 0xF25AFF
#define COLOR_AQUA 0x32FFFF
#define COLOR_JADE 0x00FF28
#define COLOR_AMBER 0xFF6400
#define COLOR_WARM_WHITE 0xFDF5E6
#define LED_DEFAULT_COLOR COLOR_WARM_WHITE
#define LED_STARTUP_NORMAL COLOR_WARM_WHITE
#define LED_STARTUP_TANKWARN COLOR_AMBER
#define LED_NORMAL_COLOR COLOR_GREEN
#define LED_RAIN_COLOR COLOR_BLUE
#define LED_WIFI_BLINK COLOR_YELLOW
#define LED_PURGE_COLOR COLOR_MAGENTA
#define LED_ERROR_BLINK COLOR_RED
#define LED_SHUTDOWN_BLINK COLOR_CYAN
#endif /* _LED_COLORS_H_ */

View File

@ -6,7 +6,7 @@
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ArduinoOTA.h> #include <ArduinoOTA.h>
#include <Adafruit_NeoPixel.h> #include <FastLED.h>
#include <Ticker.h> #include <Ticker.h>
#include "common.h" #include "common.h"
@ -25,7 +25,6 @@
#include "gps.h" #include "gps.h"
#endif #endif
#include "dtc.h" #include "dtc.h"
#include "led_colors.h"
#ifdef FEATURE_ENABLE_WIFI_CLIENT #ifdef FEATURE_ENABLE_WIFI_CLIENT
#include <ESP8266WiFiMulti.h> #include <ESP8266WiFiMulti.h>
@ -40,11 +39,11 @@ ESP8266WiFiMulti wifiMulti;
bool startSetupMode = false; bool startSetupMode = false;
volatile uint32_t wheel_pulse = 0; volatile uint32_t wheel_pulse = 0;
Adafruit_NeoPixel leds(1, GPIO_LED, NEO_RGB + NEO_KHZ800); CRGB leds[1];
// Function-Prototypes // Function-Prototypes
void IRAM_ATTR trigger_ISR(); void IRAM_ATTR trigger_ISR();
void LED_Process(uint8_t override = false, uint32_t setColor = LED_DEFAULT_COLOR); void LED_Process(uint8_t override = false, CRGB setColor = CRGB::White);
#ifdef FEATURE_ENABLE_OLED #ifdef FEATURE_ENABLE_OLED
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(-1); U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(-1);
void Display_Process(); void Display_Process();
@ -89,7 +88,7 @@ void setup()
u8x8.begin(); u8x8.begin();
u8x8.setFont(u8x8_font_chroma48medium8_r); u8x8.setFont(u8x8_font_chroma48medium8_r);
#endif #endif
leds.begin(); FastLED.addLeds<WS2811, GPIO_LED, RGB>(leds, 1); // GRB ordering is assumed
switch (LubeConfig.SpeedSource) switch (LubeConfig.SpeedSource)
{ {
@ -102,11 +101,9 @@ void setup()
Init_GPS(); Init_GPS();
break; break;
#endif #endif
#ifdef FEATURE_ENABLE_TIMER
case SOURCE_TIME: case SOURCE_TIME:
break; break;
#endif
#ifdef FEATURE_ENABLE_CAN #ifdef FEATURE_ENABLE_CAN
case SOURCE_CAN: case SOURCE_CAN:
Init_CAN(); Init_CAN();
@ -178,10 +175,8 @@ void loop()
wheelDistance = Process_CAN_WheelSpeed(); wheelDistance = Process_CAN_WheelSpeed();
break; break;
#endif #endif
#ifdef FEATURE_ENABLE_TIMER
case SOURCE_TIME: case SOURCE_TIME:
break; break;
#endif
#ifdef FEATURE_ENABLE_GPS #ifdef FEATURE_ENABLE_GPS
case SOURCE_GPS: case SOURCE_GPS:
wheelDistance = Process_GPS_WheelSpeed(); wheelDistance = Process_GPS_WheelSpeed();
@ -252,7 +247,7 @@ void trigger_ISR()
wheel_pulse++; wheel_pulse++;
} }
void LED_Process(uint8_t override, uint32_t SetColor) void LED_Process(uint8_t override, CRGB SetColor)
{ {
typedef enum typedef enum
{ {
@ -263,18 +258,16 @@ void LED_Process(uint8_t override, uint32_t SetColor)
LED_Confirm_Rain, LED_Confirm_Rain,
LED_Purge, LED_Purge,
LED_Error, LED_Error,
LED_Shutdown,
LED_Override LED_Override
} tLED_Status; } tLED_Status;
static tSystem_Status oldSysStatus = sysStat_Startup; static tSystem_Status oldSysStatus = sysStat_Startup;
static tLED_Status LED_Status = LED_Startup; static tLED_Status LED_Status = LED_Startup;
static uint32_t LED_override_color = 0; static CRGB LED_override_color = 0;
static tLED_Status LED_ResumeOverrideStatus = LED_Startup; static tLED_Status LED_ResumeOverrideStatus = LED_Startup;
uint8_t color = 0; uint8_t color = 0;
uint32_t timer = 0; uint32_t timer = 0;
uint32_t animtimer = 0;
static uint32_t timestamp = 0; static uint32_t timestamp = 0;
timer = millis(); timer = millis();
@ -325,9 +318,6 @@ void LED_Process(uint8_t override, uint32_t SetColor)
Debug_pushMessage("sysStat: Error"); Debug_pushMessage("sysStat: Error");
break; break;
case sysStat_Shutdown: case sysStat_Shutdown:
LED_Status = LED_Shutdown;
Debug_pushMessage("sysStat: Shutdown");
break;
default: default:
break; break;
} }
@ -337,105 +327,84 @@ void LED_Process(uint8_t override, uint32_t SetColor)
switch (LED_Status) switch (LED_Status)
{ {
case LED_Startup: case LED_Startup:
leds.setBrightness(LubeConfig.LED_Max_Brightness); FastLED.setBrightness(255);
if (globals.TankPercentage < LubeConfig.TankRemindAtPercentage) if (globals.TankPercentage < LubeConfig.TankRemindAtPercentage)
leds.setPixelColor(0, LED_STARTUP_TANKWARN); leds[0] = CRGB::OrangeRed;
else else
leds.setPixelColor(0, LED_STARTUP_NORMAL); leds[0] = CRGB::White;
break; break;
case LED_Confirm_Normal: case LED_Confirm_Normal:
animtimer = timer % 500; FastLED.setBrightness(255);
color = map(animtimer / 2, 0, 250, 0, LubeConfig.LED_Max_Brightness); leds[0] = timer % 250 > 125 ? CRGB(0, 255, 0) : CRGB(0, 4, 0);
leds.setPixelColor(0, LED_NORMAL_COLOR);
if (animtimer < 250)
leds.setBrightness(color);
else
leds.setBrightness(LubeConfig.LED_Max_Brightness - color);
if (timestamp < timer) if (timestamp < timer)
{ {
LED_Status = LED_Normal; LED_Status = LED_Normal;
FastLED.setBrightness(64);
Debug_pushMessage("LED_Status: Confirm -> Normal"); Debug_pushMessage("LED_Status: Confirm -> Normal");
} }
break; break;
case LED_Normal: case LED_Normal:
leds.setBrightness(LubeConfig.LED_Min_Brightness); #ifndef NO_MODE_FLASH
leds.setPixelColor(0, LED_NORMAL_COLOR); if (timer % 2000 > 1950)
leds[0] = CRGB(0, 255, 0);
if (timer % 2000 > 1950 && LubeConfig.LED_Mode_Flash == true) else if (WiFi.getMode() != WIFI_OFF && timer % 2000 > 1800 && timer % 2000 < 1850)
leds.setBrightness(LubeConfig.LED_Max_Brightness); #else
else if (timer % 2000 > 1500 && WiFi.getMode() != WIFI_OFF) if (WiFi.getMode() != WIFI_OFF && timer % 2000 > 1950)
leds.setPixelColor(0, LED_WIFI_BLINK); #endif
leds[0] = CRGB(255, 128, 0);
else
leds[0] = CRGB(0, 4, 0);
break; break;
case LED_Confirm_Rain: case LED_Confirm_Rain:
animtimer = timer % 500; FastLED.setBrightness(255);
color = map(animtimer / 2, 0, 250, 0, LubeConfig.LED_Max_Brightness); leds[0] = timer % 250 > 125 ? CRGB(0, 0, 255) : CRGB(0, 0, 4);
leds.setPixelColor(0, LED_RAIN_COLOR);
if (animtimer < 250)
leds.setBrightness(color);
else
leds.setBrightness(LubeConfig.LED_Max_Brightness - color);
if (timestamp < timer) if (timestamp < timer)
{ {
LED_Status = LED_Rain; LED_Status = LED_Rain;
FastLED.setBrightness(64);
Debug_pushMessage("LED_Status: Confirm -> Rain"); Debug_pushMessage("LED_Status: Confirm -> Rain");
} }
break; break;
case LED_Rain: case LED_Rain:
leds.setBrightness(LubeConfig.LED_Min_Brightness); #ifndef NO_MODE_FLASH
leds.setPixelColor(0, LED_RAIN_COLOR); if (timer % 2000 > 1950)
leds[0] = CRGB(0, 0, 255);
if (timer % 2000 > 1950 && LubeConfig.LED_Mode_Flash == true) else if (WiFi.getMode() != WIFI_OFF && timer % 2000 > 1800 && timer % 2000 < 1850)
leds.setBrightness(LubeConfig.LED_Max_Brightness); #else
else if (timer % 2000 > 1500 && WiFi.getMode() != WIFI_OFF) if (WiFi.getMode() != WIFI_OFF && timer % 2000 > 1950)
leds.setPixelColor(0, LED_WIFI_BLINK); #endif
leds[0] = CRGB(255, 128, 0);
else
leds[0] = CRGB(0, 0, 4);
break; break;
case LED_Purge: case LED_Purge:
timer = timer % 500; timer = timer % 500;
color = map(timer / 2, 0, 250, LubeConfig.LED_Min_Brightness, LubeConfig.LED_Max_Brightness); color = timer / 2;
leds.setPixelColor(0, LED_PURGE_COLOR); leds[0] = CRGB::DeepPink;
if (timer < 250) if (timer < 250)
leds.setBrightness(color); FastLED.setBrightness(color);
else else
leds.setBrightness(LubeConfig.LED_Max_Brightness - color); FastLED.setBrightness(250 - color);
break; break;
case LED_Error: case LED_Error:
leds.setBrightness(LubeConfig.LED_Max_Brightness); leds[0] = timer % 500 > 250 ? CRGB::Red : CRGB::Black;
leds.setPixelColor(0, timer % 500 > 250 ? LED_ERROR_BLINK : 0);
break;
case LED_Shutdown:
timer = timer % 600;
leds.setPixelColor(0, LED_SHUTDOWN_BLINK);
if (timer < 500)
{
color = map(timer, 0, 500, LubeConfig.LED_Max_Brightness, LubeConfig.LED_Min_Brightness);
leds.setBrightness(color);
}
else
{
leds.setBrightness(LubeConfig.LED_Min_Brightness);
}
break; break;
case LED_Override: case LED_Override:
leds.setBrightness(LubeConfig.LED_Max_Brightness); leds[0] = LED_override_color;
leds.setPixelColor(0, LED_override_color);
break; break;
default: default:
break; break;
} }
leds.show(); FastLED.show();
} }
#ifdef FEATURE_ENABLE_OLED #ifdef FEATURE_ENABLE_OLED
void Display_Process() void Display_Process()
@ -499,22 +468,22 @@ void Button_Process()
if (buttonTimestamp + BUTTON_ACTION_DELAY_NOTHING < millis()) if (buttonTimestamp + BUTTON_ACTION_DELAY_NOTHING < millis())
{ {
LED_Process(1, COLOR_WARM_WHITE); LED_Process(1, CRGB::White);
buttonAction = BTN_NOTHING; buttonAction = BTN_NOTHING;
} }
else if (buttonTimestamp + BUTTON_ACTION_DELAY_WIFI < millis()) else if (buttonTimestamp + BUTTON_ACTION_DELAY_WIFI < millis())
{ {
LED_Process(1, LED_WIFI_BLINK); LED_Process(1, CRGB::Yellow);
buttonAction = BTN_TOGGLEWIFI; buttonAction = BTN_TOGGLEWIFI;
} }
else if (buttonTimestamp + BUTTON_ACTION_DELAY_PURGE < millis()) else if (buttonTimestamp + BUTTON_ACTION_DELAY_PURGE < millis())
{ {
LED_Process(1, LED_PURGE_COLOR); LED_Process(1, CRGB::DeepPink);
buttonAction = BTN_STARTPURGE; buttonAction = BTN_STARTPURGE;
} }
else if (buttonTimestamp + BUTTON_ACTION_DELAY_TOGGLEMODE < millis()) else if (buttonTimestamp + BUTTON_ACTION_DELAY_TOGGLEMODE < millis())
{ {
uint32_t color = globals.systemStatus == sysStat_Normal ? LED_RAIN_COLOR : LED_NORMAL_COLOR; CRGB color = globals.systemStatus == sysStat_Normal ? CRGB::Blue : CRGB::Green;
LED_Process(1, color); LED_Process(1, color);
buttonAction = BTN_TOGGLEMODE; buttonAction = BTN_TOGGLEMODE;
} }
@ -612,11 +581,8 @@ uint32_t Process_Impulse_WheelSpeed()
uint32_t add_milimeters; uint32_t add_milimeters;
// Calculate traveled Distance in mm // Calculate traveled Distance in mm
add_milimeters = (wheel_pulse * (LubeConfig.DistancePerRevolution_mm / LubeConfig.PulsePerRevolution)); add_milimeters = (wheel_pulse * (LubeConfig.DistancePerRevolution_mm / LubeConfig.PulsePerRevolution));
if (globals.measurementActive == true)
globals.measuredPulses = globals.measuredPulses + wheel_pulse;
wheel_pulse = 0; wheel_pulse = 0;
return add_milimeters; return add_milimeters;
} }

View File

@ -8,11 +8,11 @@
#error "Unsupported PCB-Revision" #error "Unsupported PCB-Revision"
#endif #endif
#if PCB_REV < 3 && defined(FEATURE_ENABLE_CAN) #if PCB_REV < 4 && defined(FEATURE_ENABLE_CAN)
#error "CAN-Feature unsupported with this PCB-Rev" #error "CAN-Feature unsupported with this PCB-Rev"
#endif #endif
#if PCB_REV < 4 && defined(DFEATURE_ENABLE_GPS) #if PCB_REV < 4 && defined(DFEATURE_ENABLE_GPS)
#error "GPS-Feature unsupported with this PCB-Rev" #error "CAN-Feature unsupported with this PCB-Rev"
#endif #endif
#endif #endif

View File

@ -33,9 +33,7 @@ void initWebUI()
GetFlashVersion(globals.FlashVersion, sizeof(globals.FlashVersion)); GetFlashVersion(globals.FlashVersion, sizeof(globals.FlashVersion));
char buffer[6]; if (strcmp(globals.FlashVersion, QUOTE(FLASH_FS_VERSION)))
snprintf(buffer, sizeof(buffer), "%d.%02d", constants.Required_Flash_Version_major, constants.Required_Flash_Version_minor);
if (strcmp(globals.FlashVersion, buffer))
{ {
MaintainDTC(DTC_FLASHFS_VERSION_ERROR, DTC_WARN, true); MaintainDTC(DTC_FLASHFS_VERSION_ERROR, DTC_WARN, true);
} }
@ -110,16 +108,6 @@ String processor(const String &var)
#else #else
return "Feature N/A"; return "Feature N/A";
#endif #endif
if (var == "LED_MODE_FLASH")
return String(LubeConfig.LED_Mode_Flash);
if (var == "LEDFLASHCHECKED")
return String(LubeConfig.LED_Mode_Flash == true ? "checked" : "");
if (var == "LED_MAX_BRIGHTNESS")
return String(LubeConfig.LED_Max_Brightness);
if (var == "LED_MIN_BRIGHTNESS")
return String(LubeConfig.LED_Min_Brightness);
if (var == "EEPROM_VERSION")
return String(LubeConfig.EEPROM_Version);
if (var == "CONFIG_CHECKSUM") if (var == "CONFIG_CHECKSUM")
{ {
char buffer[7]; char buffer[7];
@ -246,26 +234,13 @@ String processor(const String &var)
if (var == "SYSTEM_STATUS") if (var == "SYSTEM_STATUS")
return String(globals.systemStatustxt); return String(globals.systemStatustxt);
if (var == "SW_VERSION") if (var == "SW_VERSION")
{ {
char buffer[6]; return String(QUOTE(SW_VERSION));
snprintf(buffer, sizeof(buffer), "%d.%02d", constants.FW_Version_major, constants.FW_Version_minor);
return String(buffer);
} }
if (var == "FS_VERSION") if (var == "FS_VERSION")
return String(globals.FlashVersion); return String(globals.FlashVersion);
if (var == "GIT_REV")
return String(constants.GitHash);
if (var == "MEASURED_PULSES")
return String(globals.measuredPulses);
if (var == "MEASURE_BTN")
return String(globals.measurementActive == true ? "Stop" : "Start");
if (var == "PLACEHOLDER") if (var == "PLACEHOLDER")
return "placeholder"; return "placeholder";
@ -382,32 +357,6 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
globals.systemStatus = sysStat_Shutdown; globals.systemStatus = sysStat_Shutdown;
} }
// end: POST Form Maintenance // end: POST Form Maintenance
// begin: POST Form LED Settings
if (p->name() == "ledmaxbrightness")
LubeConfig.LED_Max_Brightness = p->value().toInt();
if (p->name() == "ledminbrightness")
LubeConfig.LED_Min_Brightness = p->value().toInt();
if (p->name() == "ledsave")
{
if (request->hasParam("ledmodeflash", true))
{
AsyncWebParameter *param = request->getParam("ledmodeflash", true);
if (param->value() == "on")
LubeConfig.LED_Mode_Flash = true;
}
else
{
LubeConfig.LED_Mode_Flash = false;
}
globals.requestEEAction = EE_CFG_SAVE;
}
// end: POST Form LED SEttings
// begin: POST Form Measure Pulses
if (p->name() == "measurereset")
globals.measuredPulses = 0;
if (p->name() == "measurestartstop")
globals.measurementActive = !globals.measurementActive;
// end: POST Form Measure Pulses
} }
} }
@ -477,84 +426,28 @@ void WebserverFirmwareUpdate_Callback(AsyncWebServerRequest *request, const Stri
void WebserverEERestore_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) void WebserverEERestore_Callback(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final)
{ {
bool ee_done = false; bool ee_done = false;
static bool validext = false; bool validext = false;
static char *buffer = NULL;
static uint32_t read_ptr = 0;
DeserializationError error;
if (!index) if (!index)
{ {
Debug_pushMessage("EEPROM restore\n");
// size_t content_len = request->contentLength();
validext = (filename.indexOf(".ee.json") > -1); validext = (filename.indexOf(".ee.json") > -1);
if (validext)
{
buffer = (char *)malloc(1536);
read_ptr = 0;
if (buffer == NULL)
Debug_pushMessage("malloc() failed for EEPROM-Restore");
}
} }
if (buffer != NULL) if (validext)
{ {
memcpy(buffer + read_ptr, data, len); Debug_pushMessage("Restoring EEPROM-Stuff\n");
read_ptr = read_ptr + len;
} }
if (final) if (final)
{ {
if (buffer != NULL)
{
Serial.print(buffer);
StaticJsonDocument<1536> doc;
error = deserializeJson(doc, buffer);
if (error)
{
Debug_pushMessage("deserializeJson() failed: %s\n", error.f_str());
}
else
{
LubeConfig.DistancePerLube_Default = doc["config"]["DistancePerLube_Default"].as<uint32_t>();
LubeConfig.DistancePerLube_Rain = doc["config"]["DistancePerLube_Rain"].as<uint32_t>();
LubeConfig.tankCapacity_ml = doc["config"]["tankCapacity_ml"].as<uint32_t>();
LubeConfig.amountPerDose_microL = doc["config"]["amountPerDose_microL"].as<uint32_t>();
LubeConfig.TankRemindAtPercentage = doc["config"]["TankRemindAtPercentage"].as<uint8_t>();
LubeConfig.PulsePerRevolution = doc["config"]["PulsePerRevolution"].as<uint8_t>();
LubeConfig.TireWidth_mm = doc["config"]["TireWidth_mm"].as<uint32_t>();
LubeConfig.TireWidthHeight_Ratio = doc["config"]["TireWidthHeight_Ratio"].as<uint32_t>();
LubeConfig.RimDiameter_Inch = doc["config"]["RimDiameter_Inch"].as<uint32_t>();
LubeConfig.DistancePerRevolution_mm = doc["config"]["DistancePerRevolution_mm"].as<uint32_t>();
LubeConfig.BleedingPulses = doc["config"]["BleedingPulses"].as<uint16_t>();
LubeConfig.SpeedSource = (SpeedSource_t)doc["config"]["SpeedSource"].as<int>();
#ifdef FEATURE_ENABLE_GPS
LubeConfig.GPSBaudRate = (GPSBaudRate_t)doc["config"]["GPSBaudRate"].as<int>();
#endif
#ifdef FEATURE_ENABLE_CAN
LubeConfig.CANSource = (CANSource_t)doc["config"]["CANSource"].as<int>();
#endif
LubeConfig.LED_Mode_Flash = doc["config"]["LED_Mode_Flash"].as<bool>();
LubeConfig.LED_Max_Brightness = doc["config"]["LED_Max_Brightness"].as<uint8_t>();
LubeConfig.LED_Min_Brightness = doc["config"]["LED_Min_Brightness"].as<uint8_t>();
PersistenceData.writeCycleCounter = doc["persis"]["writeCycleCounter"].as<uint16_t>();
PersistenceData.tankRemain_microL = doc["persis"]["tankRemain_microL"].as<uint32_t>();
PersistenceData.TravelDistance_highRes_mm = doc["persis"]["TravelDistance_highRes_mm"].as<uint32_t>();
PersistenceData.odometer_mm = doc["persis"]["odometer_mm"].as<uint32_t>();
PersistenceData.odometer = doc["persis"]["odometer"].as<uint32_t>();
PersistenceData.checksum = doc["persis"]["checksum"].as<uint32_t>();
ee_done = true;
}
}
free(buffer);
AsyncWebServerResponse *response = request->beginResponse(302, "text/plain", "Please wait while the device reboots"); AsyncWebServerResponse *response = request->beginResponse(302, "text/plain", "Please wait while the device reboots");
response->addHeader("Refresh", "20"); response->addHeader("Refresh", "20");
response->addHeader("Location", "/"); response->addHeader("Location", "/");
request->send(response); request->send(response);
if (ee_done) if (ee_done)
{ {
Debug_pushMessage("Update complete"); Debug_pushMessage("Update complete");
@ -575,11 +468,8 @@ void WebServerEEJSON_Callback(AsyncWebServerRequest *request)
char buffer[16]; char buffer[16];
fwinfo["DeviceName"] = globals.DeviceName; fwinfo["DeviceName"] = globals.DeviceName;
sprintf(buffer, "%d.%02d", constants.Required_Flash_Version_major, constants.Required_Flash_Version_minor); fwinfo["FW-Version"] = QUOTE(SW_VERSION);
fwinfo["FW-Version"] = buffer;
fwinfo["FS-Version"] = globals.FlashVersion; fwinfo["FS-Version"] = globals.FlashVersion;
snprintf_P(buffer, sizeof(buffer), "%s", constants.GitHash);
fwinfo["Git-Hash"] = buffer;
JsonObject config = json.createNestedObject("config"); JsonObject config = json.createNestedObject("config");
@ -605,9 +495,6 @@ void WebServerEEJSON_Callback(AsyncWebServerRequest *request)
config["CANSource"] = LubeConfig.CANSource; config["CANSource"] = LubeConfig.CANSource;
config["CANSource_Str"] = CANSourceString[LubeConfig.CANSource]; config["CANSource_Str"] = CANSourceString[LubeConfig.CANSource];
#endif #endif
config["LED_Mode_Flash"] = LubeConfig.LED_Mode_Flash;
config["LED_Max_Brightness"] = LubeConfig.LED_Max_Brightness;
config["LED_Min_Brightness"] = LubeConfig.LED_Min_Brightness;
sprintf(buffer, "0x%08X", LubeConfig.checksum); sprintf(buffer, "0x%08X", LubeConfig.checksum);
config["checksum"] = buffer; config["checksum"] = buffer;