Improved Feature Control

This commit is contained in:
2022-08-19 00:10:42 +02:00
parent 4843cc15c9
commit 01af8cba3c
6 changed files with 57 additions and 22 deletions

View File

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