Compare commits

..

2 Commits

Author SHA1 Message Date
a6ae30d655 WebUI-improvements 2022-08-19 00:15:40 +02:00
01af8cba3c Improved Feature Control 2022-08-19 00:10:42 +02:00
7 changed files with 65 additions and 26 deletions

View File

@ -33,8 +33,12 @@ build_flags =
-DWIFI_AP_IP_GW=10,0,0,1 -DWIFI_AP_IP_GW=10,0,0,1
-DFEATURE_ENABLE_WIFI_CLIENT -DFEATURE_ENABLE_WIFI_CLIENT
-DFEATURE_ENABLE_REMOTE_DEBUG -DFEATURE_ENABLE_REMOTE_DEBUG
;-DFEATURE_ENABLE_OLED
;-DFEATURE_ENABLE_CAN ;-DFEATURE_ENABLE_CAN
;-DFEATURE_ENABLE_GPS ;-DFEATURE_ENABLE_GPS
-DPCB_REV=2
build_type = debug
board_build.filesystem = littlefs board_build.filesystem = littlefs

View File

@ -4,11 +4,25 @@
#define Q(x) #x #define Q(x) #x
#define QUOTE(x) Q(x) #define QUOTE(x) Q(x)
#define GPIO_BUTTON D4 #ifndef PCB_REV
#define GPIO_LED D3 #error "You must define PCB_REV"
#define GPIO_TRIGGER D6 #elif PCB_REV == 2
#define GPIO_PUMP D0 #define GPIO_BUTTON D7
#define GPIO_CS_CAN D8 #define GPIO_LED D8
#define GPIO_TRIGGER D6
#define GPIO_PUMP D5
#elif PCB_REV == 1 || PCB_REV == 3
#define GPIO_BUTTON D5
#define GPIO_LED D6
#define GPIO_TRIGGER D4
#define GPIO_PUMP D3
#elif PCB_REV >= 4
#define GPIO_BUTTON D4
#define GPIO_LED D3
#define GPIO_TRIGGER D6
#define GPIO_PUMP D0
#define GPIO_CS_CAN D8
#endif
#ifndef HOST_NAME #ifndef HOST_NAME
#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

View File

@ -54,6 +54,11 @@ void EEPROM_Process()
GetPersistence_EEPROM(); GetPersistence_EEPROM();
globals.requestEEAction = EE_IDLE; globals.requestEEAction = EE_IDLE;
break; break;
case EE_ALL_SAVE:
StorePersistence_EEPROM();
StoreConfig_EEPROM();
globals.requestEEAction = EE_IDLE;
break;
case EE_IDLE: case EE_IDLE:
default: default:
globals.requestEEAction = EE_IDLE; globals.requestEEAction = EE_IDLE;

View File

@ -19,7 +19,8 @@ typedef enum eEERequest
EE_CFG_SAVE, EE_CFG_SAVE,
EE_CFG_LOAD, EE_CFG_LOAD,
EE_PDS_SAVE, EE_PDS_SAVE,
EE_PDS_LOAD EE_PDS_LOAD,
EE_ALL_SAVE
} tEERequest; } tEERequest;
typedef struct Globals_s typedef struct Globals_s

View File

@ -81,22 +81,22 @@ void RunLubeApp(uint32_t add_milimeters)
switch (globals.systemStatus) switch (globals.systemStatus)
{ {
case sysStat_Normal: case sysStat_Normal:
strcpy(globals.systemStatustxt, PSTR("Normal")); strcpy_P(globals.systemStatustxt, PSTR("Normal"));
break; break;
case sysStat_Purge: case sysStat_Purge:
strcpy(globals.systemStatustxt, PSTR("Purge")); strcpy_P(globals.systemStatustxt, PSTR("Purge"));
break; break;
case sysStat_Rain: case sysStat_Rain:
strcpy(globals.systemStatustxt, PSTR("Rain")); strcpy_P(globals.systemStatustxt, PSTR("Rain"));
break; break;
case sysStat_Startup: case sysStat_Startup:
strcpy(globals.systemStatustxt, PSTR("Startup")); strcpy_P(globals.systemStatustxt, PSTR("Startup"));
break; break;
case sysStat_Error: case sysStat_Error:
strcpy(globals.systemStatustxt, PSTR("Error")); strcpy_P(globals.systemStatustxt, PSTR("Error"));
break; break;
case sysStat_Shutdown: case sysStat_Shutdown:
strcpy(globals.systemStatustxt, PSTR("Shutdown")); strcpy_P(globals.systemStatustxt, PSTR("Shutdown"));
break; break;
} }

View File

@ -1,6 +1,8 @@
#include <Arduino.h> #include <Arduino.h>
#include <Wire.h> #include <Wire.h>
#ifdef FEATURE_ENABLE_OLED
#include <U8g2lib.h> #include <U8g2lib.h>
#endif
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ArduinoOTA.h> #include <ArduinoOTA.h>
@ -45,13 +47,15 @@ Globals_t globals;
uint32_t TravelDistance_highRes; uint32_t TravelDistance_highRes;
volatile uint32_t wheel_pulse = 0; volatile uint32_t wheel_pulse = 0;
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(-1);
CRGB leds[1]; CRGB leds[1];
// Function-Prototypes // Function-Prototypes
void IRAM_ATTR trigger_ISR(); void IRAM_ATTR trigger_ISR();
void LED_Process(uint8_t override = false, CRGB setColor = CRGB::White); void LED_Process(uint8_t override = false, CRGB setColor = CRGB::White);
#ifdef FEATURE_ENABLE_OLED
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(-1);
void Display_Process(); void Display_Process();
#endif
void Button_Process(); void Button_Process();
void toggleWiFiAP(boolean shutdown = false); void toggleWiFiAP(boolean shutdown = false);
void SystemShutdown(); void SystemShutdown();
@ -105,11 +109,11 @@ void setup()
InitEEPROM(); InitEEPROM();
GetConfig_EEPROM(); GetConfig_EEPROM();
GetPersistence_EEPROM(); GetPersistence_EEPROM();
#ifdef FEATURE_ENABLE_OLED
u8x8.begin(); u8x8.begin();
u8x8.setFont(u8x8_font_chroma48medium8_r); u8x8.setFont(u8x8_font_chroma48medium8_r);
#endif
FastLED.addLeds<WS2811, GPIO_LED, GRB>(leds, 1); // GRB ordering is assumed FastLED.addLeds<WS2811, GPIO_LED, RGB>(leds, 1); // GRB ordering is assumed
switch (LubeConfig.SpeedSource) switch (LubeConfig.SpeedSource)
{ {
@ -154,7 +158,7 @@ void setup()
ArduinoOTA.setPort(8266); ArduinoOTA.setPort(8266);
ArduinoOTA.setHostname(globals.DeviceName); ArduinoOTA.setHostname(globals.DeviceName);
ArduinoOTA.setPassword(QUOTE(ADMIN_PASSWORD)); ArduinoOTA.setPassword(QUOTE(ADMIN_PASSWORD));
#ifdef FEATURE_ENABLE_OLED
ArduinoOTA.onStart([]() ArduinoOTA.onStart([]()
{ {
u8x8.clearDisplay(); u8x8.clearDisplay();
@ -180,12 +184,14 @@ void setup()
u8x8.clearDisplay(); u8x8.clearDisplay();
u8x8.drawString(0, 0, "OTA-Restart"); u8x8.drawString(0, 0, "OTA-Restart");
u8x8.refreshDisplay(); }); u8x8.refreshDisplay(); });
#endif
ArduinoOTA.begin(); ArduinoOTA.begin();
#ifdef FEATURE_ENABLE_OLED
u8x8.clearDisplay(); u8x8.clearDisplay();
u8x8.drawString(0, 0, "KTM ChainLube V1"); u8x8.drawString(0, 0, "KTM ChainLube V1");
u8x8.refreshDisplay(); u8x8.refreshDisplay();
#endif
initWebUI(); initWebUI();
initGlobals(); initGlobals();
@ -218,7 +224,9 @@ void loop()
RunLubeApp(wheelDistance); RunLubeApp(wheelDistance);
EEPROMCyclicPDSTicker.update(); EEPROMCyclicPDSTicker.update();
#ifdef FEATURE_ENABLE_OLED
Display_Process(); Display_Process();
#endif
Button_Process(); Button_Process();
LED_Process(); LED_Process();
EEPROM_Process(); EEPROM_Process();
@ -277,7 +285,7 @@ void processCmdRemoteDebug()
else if (lastCmd == "dumpPDS") else if (lastCmd == "dumpPDS")
RemoteDebug_dumpPersistance(); RemoteDebug_dumpPersistance();
else if (lastCmd == "saveEE") else if (lastCmd == "saveEE")
StoreConfig_EEPROM(); globals.requestEEAction == EE_ALL_SAVE;
else if (lastCmd == "showdtc") else if (lastCmd == "showdtc")
RemoteDebug_ShowDTCs(); RemoteDebug_ShowDTCs();
} }
@ -572,7 +580,7 @@ void LED_Process(uint8_t override, CRGB SetColor)
} }
FastLED.show(); FastLED.show();
} }
#ifdef FEATURE_ENABLE_OLED
void Display_Process() void Display_Process()
{ {
static tSystem_Status oldSysStatus = sysStat_Startup; static tSystem_Status oldSysStatus = sysStat_Startup;
@ -604,6 +612,7 @@ void Display_Process()
} }
u8x8.refreshDisplay(); u8x8.refreshDisplay();
} }
#endif
void Button_Process() void Button_Process()
{ {
@ -740,6 +749,7 @@ uint32_t Process_Impulse_WheelSpeed()
return add_milimeters; return add_milimeters;
} }
#ifdef FEATURE_ENABLE_REMOTE_DEBUG
void RemoteDebug_ShowDTCs() void RemoteDebug_ShowDTCs()
{ {
char buff_timestamp[16]; // Format: DD-hh:mm:ss:xxx char buff_timestamp[16]; // Format: DD-hh:mm:ss:xxx
@ -767,3 +777,4 @@ void RemoteDebug_ShowDTCs()
} }
} }
} }
#endif

View File

@ -98,20 +98,24 @@ String processor(const String &var)
} }
if (var == "SHOW_IMPULSE_SETTINGS") if (var == "SHOW_IMPULSE_SETTINGS")
return LubeConfig.SpeedSource == SOURCE_IMPULSE ? "" : "hidden"; return LubeConfig.SpeedSource == SOURCE_IMPULSE ? "" : "hidden";
#ifdef FEATURE_ENABLE_CAN
if (var == "SHOW_CAN_SETTINGS") if (var == "SHOW_CAN_SETTINGS")
#ifdef FEATURE_ENABLE_CAN
return LubeConfig.SpeedSource == SOURCE_CAN ? "" : "hidden"; return LubeConfig.SpeedSource == SOURCE_CAN ? "" : "hidden";
#else
return "hidden";
#endif #endif
#ifdef FEATURE_ENABLE_GPS
if (var == "SHOW_GPS_SETTINGS") if (var == "SHOW_GPS_SETTINGS")
#ifdef FEATURE_ENABLE_GPS
return LubeConfig.SpeedSource == SOURCE_GPS ? "" : "hidden"; return LubeConfig.SpeedSource == SOURCE_GPS ? "" : "hidden";
#else
return "hidden";
#endif #endif
if (var == "SHOW_DTC_TABLE") if (var == "SHOW_DTC_TABLE")
return globals.systemStatus == sysStat_Error ? "" : "hidden"; return globals.systemStatus == sysStat_Error ? "" : "hidden";
if (var == "DTC_TABLE") if (var == "DTC_TABLE")
{ {
String temp; String temp = "";
char buff_timestamp[16]; // Format: DD-hh:mm:ss:xxx char buff_timestamp[16]; // Format: DD-hh:mm:ss:xxx
for (uint32_t i = 0; i < MAX_DTC_STORAGE; i++) for (uint32_t i = 0; i < MAX_DTC_STORAGE; i++)
@ -125,7 +129,7 @@ String processor(const String &var)
DTCStorage[i].timestamp / 1000 % 60, // Seconds DTCStorage[i].timestamp / 1000 % 60, // Seconds
DTCStorage[i].timestamp % 1000); // milliseconds DTCStorage[i].timestamp % 1000); // milliseconds
temp = "<tr><td>" + String(buff_timestamp); temp = temp + "<tr><td>" + String(buff_timestamp);
temp = temp + "</td><td>" + String(DTCStorage[i].Number) + "</td><td>"; temp = temp + "</td><td>" + String(DTCStorage[i].Number) + "</td><td>";
if (DTCStorage[i].active == DTC_ACTIVE) if (DTCStorage[i].active == DTC_ACTIVE)