From 3d7e7983100c25f334d9f00bf9596b302d1d431f Mon Sep 17 00:00:00 2001 From: Marcel Peterkau <marcel@peterkau.de> Date: Mon, 25 Dec 2023 00:44:24 +0100 Subject: [PATCH] removed feature-defines for CAN and Websockets --- Software/include/config.h | 20 ------------------- Software/include/gps.h | 1 + Software/include/sanitycheck.h | 6 ------ Software/include/webui.h | 2 -- Software/platformio.ini | 12 +++++++++--- Software/src/can.cpp | 2 -- Software/src/config.cpp | 4 ---- Software/src/debugger.cpp | 4 ---- Software/src/gps.cpp | 8 ++------ Software/src/main.cpp | 35 +++++++++++++++------------------- 10 files changed, 27 insertions(+), 67 deletions(-) diff --git a/Software/include/config.h b/Software/include/config.h index a8e95e5..b19348a 100644 --- a/Software/include/config.h +++ b/Software/include/config.h @@ -20,12 +20,8 @@ typedef enum SpeedSource_e SOURCE_TIME, #endif SOURCE_IMPULSE, -#ifdef FEATURE_ENABLE_GPS SOURCE_GPS, -#endif -#if FEATURE_ENABLE_CAN SOURCE_CAN -#endif } SpeedSource_t; const char SpeedSourceString[][8] = { @@ -33,15 +29,10 @@ const char SpeedSourceString[][8] = { "Timer", #endif "Impuls", -#ifdef FEATURE_ENABLE_GPS "GPS", -#endif -#if FEATURE_ENABLE_CAN "CAN-Bus" -#endif }; -#ifdef FEATURE_ENABLE_GPS typedef enum GPSBaudRate_e { BAUD_9600, @@ -53,9 +44,7 @@ const char GPSBaudRateString[][7] = { "115200"}; const size_t GPSBaudRateString_Elements = sizeof(GPSBaudRateString) / sizeof(GPSBaudRateString[0]); -#endif -#ifdef FEATURE_ENABLE_CAN typedef enum CANSource_e { KTM_890_ADV_R_2021, @@ -67,7 +56,6 @@ const char CANSourceString[][30] = { "KTM 1290 Superduke R (2023)"}; const size_t CANSourceString_Elements = sizeof(CANSourceString) / sizeof(CANSourceString[0]); -#endif const size_t SpeedSourceString_Elements = sizeof(SpeedSourceString) / sizeof(SpeedSourceString[0]); @@ -96,12 +84,8 @@ typedef struct uint32_t DistancePerRevolution_mm = 2000; uint16_t BleedingPulses = 25; SpeedSource_t SpeedSource = SOURCE_IMPULSE; -#ifdef FEATURE_ENABLE_GPS GPSBaudRate_t GPSBaudRate = BAUD_115200; -#endif -#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; @@ -110,12 +94,8 @@ typedef struct const LubeConfig_t LubeConfig_defaults = { 0, 8000, 4000, 320, DEFAULT_PUMP_DOSE, 30, 1, 150, 70, 18, 2000, 25, SOURCE_IMPULSE, -#ifdef FEATURE_ENABLE_GPS BAUD_115200, -#endif -#ifdef FEATURE_ENABLE_CAN KTM_890_ADV_R_2021, -#endif false, 255, 5, diff --git a/Software/include/gps.h b/Software/include/gps.h index 6e83803..a3b66b0 100644 --- a/Software/include/gps.h +++ b/Software/include/gps.h @@ -5,6 +5,7 @@ #include "config.h" #include "common.h" #include "dtc.h" +#include "debugger.h" void Init_GPS(); uint32_t Process_GPS_WheelSpeed(); diff --git a/Software/include/sanitycheck.h b/Software/include/sanitycheck.h index 5304d70..6da5368 100644 --- a/Software/include/sanitycheck.h +++ b/Software/include/sanitycheck.h @@ -16,12 +16,6 @@ #endif #endif -#ifdef CAN_DEBUG_MESSAGE - #ifndef FEATURE_ENABLE_CAN - #error "You cannot enable CAN-Debug-Message without FEATURE_ENABLE_CAN" - #endif -#endif - #ifndef ADMIN_PASSWORD #error "You need to define ADMIN_PASSWORD for OTA-Update" #endif diff --git a/Software/include/webui.h b/Software/include/webui.h index 2552ad5..e708b91 100644 --- a/Software/include/webui.h +++ b/Software/include/webui.h @@ -20,8 +20,6 @@ void initWebUI(); void Webserver_Process(); -#ifdef FEATURE_ENABLE_WEBSOCKETS void Websocket_PushLiveDebug(String Message); -#endif #endif \ No newline at end of file diff --git a/Software/platformio.ini b/Software/platformio.ini index 4bf372d..adf3a43 100644 --- a/Software/platformio.ini +++ b/Software/platformio.ini @@ -18,6 +18,15 @@ platform = espressif8266 board = d1_mini framework = arduino +upload_speed = 921600 + +upload_protocol = espota +upload_port = 10.0.1.14 +upload_flags = + --port=8266 + --auth=${wifi_cred.admin_password} + + build_flags = !python git_rev_macro.py -DWIFI_SSID_CLIENT=${wifi_cred.wifi_ssid_client} @@ -52,10 +61,7 @@ build_flags = ${env.build_flags} ;-DFEATURE_ENABLE_WIFI_CLIENT ;-DFEATURE_ENABLE_TIMER - ;-DFEATURE_ENABLE_GPS -DFEATURE_ENABLE_OLED - -DFEATURE_ENABLE_WEBSOCKETS - -DFEATURE_ENABLE_CAN -DCAN_DEBUG_MESSAGE -DPCB_REV=${this.custom_pcb_revision} diff --git a/Software/src/can.cpp b/Software/src/can.cpp index 57d3db1..b5dadbc 100644 --- a/Software/src/can.cpp +++ b/Software/src/can.cpp @@ -1,4 +1,3 @@ -#ifdef FEATURE_ENABLE_CAN #include "can.h" MCP_CAN CAN0(GPIO_CS_CAN); @@ -148,5 +147,4 @@ void sendCANDebugMessage() DebugSendFailTimeout++; } } -#endif #endif \ No newline at end of file diff --git a/Software/src/config.cpp b/Software/src/config.cpp index dcc7d6b..b80a14a 100644 --- a/Software/src/config.cpp +++ b/Software/src/config.cpp @@ -347,22 +347,18 @@ uint32_t ConfigSanityCheck(bool autocorrect) LubeConfig.SpeedSource = LubeConfig_defaults.SpeedSource; } -#ifdef FEATURE_ENABLE_GPS if (!(LubeConfig.GPSBaudRate >= 0) || !(LubeConfig.GPSBaudRate < GPSBaudRateString_Elements)) { SET_BIT(setting_reset_bits, 12); if (autocorrect) LubeConfig.GPSBaudRate = LubeConfig_defaults.GPSBaudRate; } -#endif -#ifdef FEATURE_ENABLE_CAN if (!(LubeConfig.CANSource >= 0) || !(LubeConfig.CANSource < CANSourceString_Elements)) { SET_BIT(setting_reset_bits, 13); if (autocorrect) LubeConfig.CANSource = LubeConfig_defaults.CANSource; } -#endif return setting_reset_bits; } \ No newline at end of file diff --git a/Software/src/debugger.cpp b/Software/src/debugger.cpp index 88d30be..768db0e 100644 --- a/Software/src/debugger.cpp +++ b/Software/src/debugger.cpp @@ -242,12 +242,8 @@ void Debug_dumpConfig() Debug_pushMessage("DistancePerRevolution_mm: %d\n", LubeConfig.DistancePerRevolution_mm); Debug_pushMessage("BleedingPulses: %d\n", LubeConfig.BleedingPulses); Debug_pushMessage("SpeedSource: %d\n", LubeConfig.SpeedSource); -#ifdef FEATURE_ENABLE_GPS Debug_pushMessage("GPSBaudRate: %d\n", LubeConfig.GPSBaudRate); -#endif -#ifdef FEATURE_ENABLE_CAN Debug_pushMessage("CANSource: %d\n", LubeConfig.CANSource); -#endif Debug_pushMessage("checksum: 0x%08X\n", LubeConfig.checksum); } diff --git a/Software/src/gps.cpp b/Software/src/gps.cpp index 1e83905..c02c9a7 100644 --- a/Software/src/gps.cpp +++ b/Software/src/gps.cpp @@ -1,4 +1,3 @@ -#ifdef FEATURE_ENABLE_GPS #include "gps.h" TinyGPSPlus gps; @@ -50,10 +49,7 @@ uint32_t Process_GPS_WheelSpeed() lastRecTimestamp = millis(); } } - - MaintainDTC(DTC_NO_GPS_SERIAL,DTC_CRITICAL, (millis() > lastRecTimestamp + 10000)); + MaintainDTC(DTC_NO_GPS_SERIAL, (millis() > lastRecTimestamp + 10000)); return 0; -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/Software/src/main.cpp b/Software/src/main.cpp index 80e8e75..4161fcb 100644 --- a/Software/src/main.cpp +++ b/Software/src/main.cpp @@ -18,12 +18,8 @@ #include "config.h" #include "globals.h" #include "debugger.h" -#ifdef FEATURE_ENABLE_CAN #include "can.h" -#endif -#ifdef FEATURE_ENABLE_GPS #include "gps.h" -#endif #include "dtc.h" #include "led_colors.h" @@ -99,20 +95,24 @@ void setup() leds.begin(); Serial.print("\nLED-Init done"); - pinMode(GPIO_TRIGGER, INPUT_PULLUP); - attachInterrupt(digitalPinToInterrupt(GPIO_TRIGGER), trigger_ISR, FALLING); - Serial.print("\nPulse-Input Init done"); -#ifdef FEATURE_ENABLE_GPS - Init_GPS(); - Serial.print("\nGPS-Init done"); -#endif -#ifdef FEATURE_ENABLE_CAN - if (LubeConfig.SpeedSource != SOURCE_IMPULSE) + switch (LubeConfig.SpeedSource) { + case SOURCE_CAN: Init_CAN(); Serial.print("\nCAN-Init done"); + break; + case SOURCE_GPS: + Init_GPS(); + Serial.print("\nGPS-Init done"); + break; + case SOURCE_IMPULSE: + pinMode(GPIO_TRIGGER, INPUT_PULLUP); + attachInterrupt(digitalPinToInterrupt(GPIO_TRIGGER), trigger_ISR, FALLING); + Serial.print("\nPulse-Input Init done"); + break; + default: + break; } -#endif Serial.print("\nSource-Init done"); pinMode(GPIO_BUTTON, INPUT_PULLUP); @@ -167,32 +167,27 @@ void loop() case SOURCE_IMPULSE: wheelDistance = Process_Impulse_WheelSpeed(); break; -#ifdef FEATURE_ENABLE_CAN case SOURCE_CAN: wheelDistance = Process_CAN_WheelSpeed(); break; -#endif + #ifdef FEATURE_ENABLE_TIMER case SOURCE_TIME: break; #endif -#ifdef FEATURE_ENABLE_GPS case SOURCE_GPS: wheelDistance = Process_GPS_WheelSpeed(); break; -#endif } RunLubeApp(wheelDistance); #ifdef FEATURE_ENABLE_OLED Display_Process(); #endif -#ifdef FEATURE_ENABLE_CAN if (LubeConfig.SpeedSource != SOURCE_IMPULSE) { CAN_Process(); } -#endif Button_Process(); LED_Process(); EEPROM_Process();