Replaced FastLED by Adafruit Neopixel

This commit is contained in:
Marcel Peterkau 2023-03-02 22:30:42 +01:00
parent cb3d49ad13
commit 34c50df2e9
6 changed files with 335 additions and 160 deletions

View File

@ -33,9 +33,8 @@
<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" 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_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_fwupdate">Update</a></li>
@ -55,6 +54,7 @@
<h3 class="pt-3">KTM CAN Chain Lube</h3>
</div>
</div>
<!-- Div Group Tank remain -->
<hr />
<p>
<h4>Tankinhalt verbleibend</h4>
@ -65,13 +65,17 @@
</div>
</div>
</p>
<!-- Div Group Tank remain -->
<!-- Div Group current Mode -->
<hr />
<p>
<h4>aktueller Modus</h4>
<input class="form-control" type="text" placeholder="%SYSTEM_STATUS%" readonly>
</p>
<hr />
<!-- Div Group current Mode -->
<!-- Div Group DTC Table -->
<div %SHOW_DTC_TABLE%>
<hr />
<p>
<h4>Fehlercodes</h4>
<table class="table">
@ -86,13 +90,124 @@
</tbody>
</table>
</p>
<hr />
</div>
<!-- Div Group DTC Table -->
</div>
<!-- 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 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">
<h3>Wegstreckenerfassung</h3>
<h3>Einstellungen</h3>
<!-- Div Group Signal Source -->
<hr />
<p>
<h4>Signalquelle</h4>
@ -120,7 +235,8 @@
</div>
</form>
</p>
<!-- Div Source:Impulse Settings-->
<!-- Div Group Signal Source -->
<!-- Div Group Source:Impulse Settings-->
<div %SHOW_IMPULSE_SETTINGS%>
<hr />
<p>
@ -181,10 +297,9 @@
</div>
</form>
</p>
<hr />
</div>
<!-- Div Source:Impulse Settings-->
<!-- Div Source:CAN Settings-->
<!-- Div Group Source:Impulse Settings-->
<!-- Div Group Source:CAN Settings-->
<div %SHOW_CAN_SETTINGS%>
<hr />
<p>
@ -205,10 +320,9 @@
</div>
</form>
</p>
<hr />
</div>
<!-- Div Source:CAN Settings-->
<!-- Div Source:GPS Settings-->
<!-- Div Group Source:CAN Settings-->
<!-- Div Group Source:GPS Settings-->
<div %SHOW_GPS_SETTINGS%>
<hr />
<p>
@ -229,14 +343,9 @@
</div>
</form>
</p>
<hr />
</div>
<!-- Div Source:GPS Settings-->
</div>
<!-- Div Tab Source Settings-->
<!-- Div Tab Lube -->
<div id="tab_lube" class="tab-pane fade" role="tabpanel">
<h3>Schmierung</h3>
<!-- Div Group Source:GPS Settings-->
<!-- Div Group Lube Settings-->
<hr />
<p>
<h4>Dosierung</h4>
@ -272,15 +381,11 @@
</div>
</form>
</p>
<hr />
</div>
<!-- Div Tab Lube -->
<!-- Div Tab Maintenance -->
<div id="tab_maintenance" class="tab-pane fade" role="tabpanel">
<h3>Wartung</h3>
<!-- Div Group Lube Settings-->
<!-- Div Group Oiltank Settings -->
<hr />
<p>
<h4>&Ouml;lvorrat</h4>
<h4>&Ouml;ltank</h4>
<form action="post.htm" method="POST" class="form-horizontal">
<div class="form-group row">
<label for="tankcap" class="control-label col-4">Tankkapazität</label>
@ -318,104 +423,63 @@
</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="col text-center">
<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>
</form>
</p>
<!-- Div Group Oiltank Settings -->
<!-- Div Group LED Settings-->
<hr />
<p>
<h4>Entl&uuml;ftung</h4>
<h4>LED Einstellungen</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>
<label for="ledmodeflash" class="control-label col-4">LED Modus blinken</label>
<div class="col-8">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="ledmodeflash" id="ledmodeflash" %LEDFLASHCHECKED%>
<label class="form-check-label" for="ledmodeflash">
LED blinken
</label>
</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="purgepulse" name="purgepulse" value="%BLEEDING_PULSES%" type="text" class="form-control">
<div class="input-group-append">
<span class="input-group-text">Pulse</span>
<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="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>
<button name="ledsave" type="submit" class="btn btn-outline-primary">Speichern</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 Group Lube Settings-->
</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>
<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 Tab Maintenance -->
<!-- Div Tab Settings -->
<!-- Div Tab SystemInfo -->
<div id="tab_sysinfo" class="tab-pane fade" role="tabpanel">
<h3>Systeminfo</h3>
<!-- Div Group Sysinfo:Settings -->
<hr />
<p>
<h4>Einstellungen</h4>
@ -481,6 +545,22 @@
<td>CANSource</td>
<td>%CAN_SOURCE%</td>
</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>
<td>Checksum</td>
<td>%CONFIG_CHECKSUM%</td>
@ -488,6 +568,8 @@
</tbody>
</table>
</p>
<!-- Div Group Sysinfo:Settings -->
<!-- Div Group Sysinfo:Persistance -->
<hr />
<p>
<h4>Betriebsdaten</h4>
@ -523,6 +605,8 @@
</tr>
</table>
</p>
<!-- Div Group Sysinfo:Persistance -->
<!-- Div Group LiveDebug -->
<hr />
<p>
<h4>Live Debug</h4>
@ -536,12 +620,14 @@
</div>
</div>
</p>
<hr />
<!-- Div Group LiveDebug -->
</div>
<!-- Div Tab SystemInfo -->
<!-- Div Tab Firmware Update-->
<div id="tab_fwupdate" class="tab-pane fade" role="tabpanel">
<h3>Firmware</h3>
<!-- Div Group VersionInfo -->
<hr />
<p>
<h4>Version-Info</h4>
@ -561,6 +647,8 @@
</tr>
</table>
</p>
<!-- Div Group VersionInfo -->
<!-- Div Group EEPROM Backup -->
<hr />
<p>
<h4>EEPROM-Backup</h4>
@ -570,6 +658,8 @@
</div>
</div>
</p>
<!-- Div Group EEPROM Backup -->
<!-- Div Group EEPROM Restore -->
<hr />
<p>
<h4>EEPROM-Restore</h4>
@ -588,6 +678,8 @@
</div>
</form>
</p>
<!-- Div Group EEPROM Restore -->
<!-- Div Group Firmware Update -->
<hr />
<p>
<h4>Firmware-Update</h4>
@ -606,7 +698,7 @@
</div>
</form>
</p>
<hr />
<!-- Div Group Firmware Update -->
</div>
<!-- Div Tab Firmware Update-->
</div>

View File

@ -39,7 +39,6 @@ build_flags =
;-DFEATURE_ENABLE_GPS
-DFEATURE_ENABLE_WEBSOCKETS
-DPCB_REV=3
;-DNO_MODE_FLASH
;build_type = debug
@ -53,7 +52,8 @@ board_build.ldscript = eagle.flash.4m1m.ld
lib_ldf_mode = deep
lib_deps =
olikraus/U8g2 @ ^2.28.8
https://github.com/FastLED/FastLED.git#3d2ab78 ;fastled/FastLED @ ^3.5.0
adafruit/Adafruit NeoPixel @ ^1.11.0
;https://github.com/FastLED/FastLED.git#3d2ab78 ;fastled/FastLED @ ^3.5.0
sstaub/Ticker @ ^4.2.0
coryjfowler/mcp_can @ ^1.5.0
robtillaart/I2C_EEPROM @ ^1.5.2

View File

@ -100,6 +100,9 @@ typedef struct
#ifdef FEATURE_ENABLE_CAN
CANSource_t CANSource = KTM_890_ADV_R_2021;
#endif
bool LED_Mode_Flash = false;
uint8_t LED_Max_Brightness = 255;
uint8_t LED_Min_Brightness = 5;
uint32_t checksum = 0;
} LubeConfig_t;
@ -111,6 +114,9 @@ const LubeConfig_t LubeConfig_defaults = {
#ifdef FEATURE_ENABLE_CAN
KTM_890_ADV_R_2021,
#endif
false,
255,
5,
0};
void InitEEPROM();

34
Software/src/led_colors.h Normal file
View File

@ -0,0 +1,34 @@
#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
#endif /* _LED_COLORS_H_ */

View File

@ -6,7 +6,7 @@
#include <ESP8266WiFi.h>
#include <ArduinoOTA.h>
#include <FastLED.h>
#include <Adafruit_NeoPixel.h>
#include <Ticker.h>
#include "common.h"
@ -25,6 +25,7 @@
#include "gps.h"
#endif
#include "dtc.h"
#include "led_colors.h"
#ifdef FEATURE_ENABLE_WIFI_CLIENT
#include <ESP8266WiFiMulti.h>
@ -39,11 +40,11 @@ ESP8266WiFiMulti wifiMulti;
bool startSetupMode = false;
volatile uint32_t wheel_pulse = 0;
CRGB leds[1];
Adafruit_NeoPixel leds(1, GPIO_LED, NEO_RGB + NEO_KHZ800);
// Function-Prototypes
void IRAM_ATTR trigger_ISR();
void LED_Process(uint8_t override = false, CRGB setColor = CRGB::White);
void LED_Process(uint8_t override = false, uint32_t setColor = LED_DEFAULT_COLOR);
#ifdef FEATURE_ENABLE_OLED
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(-1);
void Display_Process();
@ -88,7 +89,7 @@ void setup()
u8x8.begin();
u8x8.setFont(u8x8_font_chroma48medium8_r);
#endif
FastLED.addLeds<WS2811, GPIO_LED, RGB>(leds, 1); // GRB ordering is assumed
leds.begin();
switch (LubeConfig.SpeedSource)
{
@ -251,7 +252,7 @@ void trigger_ISR()
wheel_pulse++;
}
void LED_Process(uint8_t override, CRGB SetColor)
void LED_Process(uint8_t override, uint32_t SetColor)
{
typedef enum
{
@ -267,11 +268,12 @@ void LED_Process(uint8_t override, CRGB SetColor)
static tSystem_Status oldSysStatus = sysStat_Startup;
static tLED_Status LED_Status = LED_Startup;
static CRGB LED_override_color = 0;
static uint32_t LED_override_color = 0;
static tLED_Status LED_ResumeOverrideStatus = LED_Startup;
uint8_t color = 0;
uint32_t timer = 0;
uint32_t animtimer = 0;
static uint32_t timestamp = 0;
timer = millis();
@ -331,84 +333,91 @@ void LED_Process(uint8_t override, CRGB SetColor)
switch (LED_Status)
{
case LED_Startup:
FastLED.setBrightness(255);
leds.setBrightness(LubeConfig.LED_Max_Brightness);
if (globals.TankPercentage < LubeConfig.TankRemindAtPercentage)
leds[0] = CRGB::OrangeRed;
leds.setPixelColor(0, LED_STARTUP_TANKWARN);
else
leds[0] = CRGB::White;
leds.setPixelColor(0, LED_STARTUP_NORMAL);
break;
case LED_Confirm_Normal:
FastLED.setBrightness(255);
leds[0] = timer % 250 > 125 ? CRGB(0, 255, 0) : CRGB(0, 4, 0);
animtimer = timer % 500;
color = map(animtimer / 2, 0, 250, 0, LubeConfig.LED_Max_Brightness);
leds.setPixelColor(0, LED_NORMAL_COLOR);
if (animtimer < 250)
leds.setBrightness(color);
else
leds.setBrightness(LubeConfig.LED_Max_Brightness - color);
if (timestamp < timer)
{
LED_Status = LED_Normal;
FastLED.setBrightness(64);
Debug_pushMessage("LED_Status: Confirm -> Normal");
}
break;
case LED_Normal:
#ifndef NO_MODE_FLASH
if (timer % 2000 > 1950)
leds[0] = CRGB(0, 255, 0);
else if (WiFi.getMode() != WIFI_OFF && timer % 2000 > 1800 && timer % 2000 < 1850)
#else
if (WiFi.getMode() != WIFI_OFF && timer % 2000 > 1950)
#endif
leds[0] = CRGB(255, 128, 0);
else
leds[0] = CRGB(0, 4, 0);
leds.setBrightness(LubeConfig.LED_Min_Brightness);
leds.setPixelColor(0, LED_NORMAL_COLOR);
if (timer % 2000 > 1950 && LubeConfig.LED_Mode_Flash == true)
leds.setBrightness(LubeConfig.LED_Max_Brightness);
else if (timer % 2000 > 1500 && WiFi.getMode() != WIFI_OFF)
leds.setPixelColor(0, LED_WIFI_BLINK);
break;
case LED_Confirm_Rain:
FastLED.setBrightness(255);
leds[0] = timer % 250 > 125 ? CRGB(0, 0, 255) : CRGB(0, 0, 4);
animtimer = timer % 500;
color = map(animtimer / 2, 0, 250, 0, LubeConfig.LED_Max_Brightness);
leds.setPixelColor(0, LED_RAIN_COLOR);
if (animtimer < 250)
leds.setBrightness(color);
else
leds.setBrightness(LubeConfig.LED_Max_Brightness - color);
if (timestamp < timer)
{
LED_Status = LED_Rain;
FastLED.setBrightness(64);
Debug_pushMessage("LED_Status: Confirm -> Rain");
}
break;
case LED_Rain:
#ifndef NO_MODE_FLASH
if (timer % 2000 > 1950)
leds[0] = CRGB(0, 0, 255);
else if (WiFi.getMode() != WIFI_OFF && timer % 2000 > 1800 && timer % 2000 < 1850)
#else
if (WiFi.getMode() != WIFI_OFF && timer % 2000 > 1950)
#endif
leds[0] = CRGB(255, 128, 0);
else
leds[0] = CRGB(0, 0, 4);
leds.setBrightness(LubeConfig.LED_Min_Brightness);
leds.setPixelColor(0, LED_RAIN_COLOR);
if (timer % 2000 > 1950 && LubeConfig.LED_Mode_Flash == true)
leds.setBrightness(LubeConfig.LED_Max_Brightness);
else if (timer % 2000 > 1500 && WiFi.getMode() != WIFI_OFF)
leds.setPixelColor(0, LED_WIFI_BLINK);
break;
case LED_Purge:
timer = timer % 500;
color = timer / 2;
leds[0] = CRGB::DeepPink;
color = map(timer / 2, 0, 250, LubeConfig.LED_Min_Brightness, LubeConfig.LED_Max_Brightness);
leds.setPixelColor(0, LED_PURGE_COLOR);
if (timer < 250)
FastLED.setBrightness(color);
leds.setBrightness(color);
else
FastLED.setBrightness(250 - color);
leds.setBrightness(LubeConfig.LED_Max_Brightness - color);
break;
case LED_Error:
leds[0] = timer % 500 > 250 ? CRGB::Red : CRGB::Black;
leds.setBrightness(LubeConfig.LED_Max_Brightness);
leds.setPixelColor(0, timer % 500 > 250 ? LED_ERROR_BLINK : 0);
break;
case LED_Override:
leds[0] = LED_override_color;
leds.setBrightness(LubeConfig.LED_Max_Brightness);
leds.setPixelColor(0, LED_override_color);
break;
default:
break;
}
FastLED.show();
leds.show();
}
#ifdef FEATURE_ENABLE_OLED
void Display_Process()
@ -472,22 +481,22 @@ void Button_Process()
if (buttonTimestamp + BUTTON_ACTION_DELAY_NOTHING < millis())
{
LED_Process(1, CRGB::White);
LED_Process(1, COLOR_WARM_WHITE);
buttonAction = BTN_NOTHING;
}
else if (buttonTimestamp + BUTTON_ACTION_DELAY_WIFI < millis())
{
LED_Process(1, CRGB::Yellow);
LED_Process(1, LED_WIFI_BLINK);
buttonAction = BTN_TOGGLEWIFI;
}
else if (buttonTimestamp + BUTTON_ACTION_DELAY_PURGE < millis())
{
LED_Process(1, CRGB::DeepPink);
LED_Process(1, LED_PURGE_COLOR);
buttonAction = BTN_STARTPURGE;
}
else if (buttonTimestamp + BUTTON_ACTION_DELAY_TOGGLEMODE < millis())
{
CRGB color = globals.systemStatus == sysStat_Normal ? CRGB::Blue : CRGB::Green;
uint32_t color = globals.systemStatus == sysStat_Normal ? LED_RAIN_COLOR : LED_NORMAL_COLOR;
LED_Process(1, color);
buttonAction = BTN_TOGGLEMODE;
}

View File

@ -108,6 +108,16 @@ String processor(const String &var)
#else
return "Feature N/A";
#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")
{
char buffer[7];
@ -357,6 +367,26 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
globals.systemStatus = sysStat_Shutdown;
}
// 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
}
}
@ -440,6 +470,7 @@ void WebserverEERestore_Callback(AsyncWebServerRequest *request, const String &f
if (validext)
{
Debug_pushMessage("Restoring EEPROM-Stuff\n");
#warning "please implement EEPROM-Restore"
}
if (final)
@ -495,6 +526,9 @@ void WebServerEEJSON_Callback(AsyncWebServerRequest *request)
config["CANSource"] = LubeConfig.CANSource;
config["CANSource_Str"] = CANSourceString[LubeConfig.CANSource];
#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);
config["checksum"] = buffer;