diff --git a/config_allfeatures.cmake b/config_allfeatures.cmake index 62fa563..a830f2b 100644 --- a/config_allfeatures.cmake +++ b/config_allfeatures.cmake @@ -16,71 +16,65 @@ add_definitions( ) set(BOBBYCAR_BUILDFLAGS - -DFEATURE_ADC_IN - -DPINS_GAS=34 - -DPINS_BREMS=35 - -DDEFAULT_SWAPSCREENBYTES=false - -DFEATURE_CAN -# -DFEATURE_SERIAL -# -DPINS_RX1=4 -# -DPINS_TX1=5 -# -DPINS_RX2=22 -# -DPINS_TX2=23 - -DDEFAULT_INVERTFRONTLEFT=false - -DDEFAULT_INVERTFRONTRIGHT=true - -DDEFAULT_INVERTBACKLEFT=false - -DDEFAULT_INVERTBACKRIGHT=true - -DDEFAULT_WHEELDIAMETER=200 -# -DFEATURE_MOSFETS -# -DPINS_MOSFET0=18 -# -DPINS_MOSFET1=19 -# -DPINS_MOSFET2=21 - -DDEFAULT_IMOTMAX=28 - -DDEFAULT_IDCMAX=30 - -DDEFAULT_NMOTMAX=2000 - -DDEFAULT_FIELDWEAKMAX=7 - -DDEFAULT_FIELDADVMAX=40 - -DFEATURE_WEBSERVER - -DFEATURE_OTA -# -DFEATURE_DPAD_5WIRESW -# -DPINS_DPAD_5WIRESW_OUT=4 -# -DPINS_DPAD_5WIRESW_IN1=5 -# -DPINS_DPAD_5WIRESW_IN2=27 -# -DPINS_DPAD_5WIRESW_IN3=18 -# -DPINS_DPAD_5WIRESW_IN4=19 -# -DPINS_DPAD_EXTRASW_IN5=25 - -DFEATURE_DPAD_6WIRESW - -DPINS_DPAD_6WIRESW_OUT=4 - -DPINS_DPAD_6WIRESW_IN1=5 - -DPINS_DPAD_6WIRESW_IN2=27 - -DPINS_DPAD_6WIRESW_IN3=18 - -DPINS_DPAD_6WIRESW_IN4=19 - -DPINS_DPAD_6WIRESW_IN5=26 - -DFEATURE_GSCHISSENE_DIODE - -DFEATURE_BLE -# -DFEATURE_BLUETOOTH -# -DFEATURE_BMS -# -DFEATURE_GAMETRAK -# -DPINS_GAMETRAKX=34 -# -DPINS_GAMETRAKY=39 -# -DPINS_GAMETRAKDIST=36 - -DFEATURE_POWERSUPPLY - -DFEATURE_CLOUD - -DFEATURE_UDPCLOUD - -DFEATURE_LEDBACKLIGHT - -DPINS_LEDBACKLIGHT=23 - -DLEDBACKLIGHT_INVERTED - -DFEATURE_GARAGE - -DFEATURE_NTP - -DFEATURE_WIRELESS_CONFIG - -DFEATURE_LEDSTRIP - -DPINS_LEDSTRIP=33 - -DHEAP_LRGST_CRASH_TEXT_FIX - -DLEDSTRIP_WRONG_DIRECTION - -DLEDSTRIP_ANIMATION_DEFAULT=1 - -DLEDS_PER_METER=144 - -DOLD_NVS - -DFEATURE_DNS_NS - -DSWITCH_BLINK - -DFEATURE_ESPNOW +# Pins + -DPINS_GAS=34 + -DPINS_BREMS=35 +# -DFEATURE_JOYSTICK +# -DPINS_RX1=4 +# -DPINS_TX1=5 +# -DPINS_RX2=22 +# -DPINS_TX2=23 +# -DPINS_MOSFET0=18 +# -DPINS_MOSFET1=19 +# -DPINS_MOSFET2=21 +# -DPINS_GAMETRAKX=34 +# -DPINS_GAMETRAKY=39 +# -DPINS_GAMETRAKDIST=36 + -DPINS_LEDBACKLIGHT=23 + -DPINS_LEDSTRIP=33 + +# Config flags + -DFEATURE_ADC_IN + -DFEATURE_CAN +# -DFEATURE_SERIAL +# -DFEATURE_MOSFETS +# -DFEATURE_BLUETOOTH +# -DFEATURE_BMS +# -DFEATURE_GAMETRAK + -DFEATURE_POWERSUPPLY + -DFEATURE_LEDBACKLIGHT + + -DLEDBACKLIGHT_INVERTED + -DLEDSTRIP_WRONG_DIRECTION + -DHEAP_LRGST_CRASH_TEXT_FIX + +# Default values + -DDEFAULT_SWAPSCREENBYTES=false + -DDEFAULT_INVERTFRONTLEFT=false + -DDEFAULT_INVERTFRONTRIGHT=true + -DDEFAULT_INVERTBACKLEFT=false + -DDEFAULT_INVERTBACKRIGHT=true + -DDEFAULT_WHEELDIAMETER=200 + -DDEFAULT_IMOTMAX=28 + -DDEFAULT_IDCMAX=30 + -DDEFAULT_NMOTMAX=2000 + -DDEFAULT_FIELDWEAKMAX=7 + -DDEFAULT_FIELDADVMAX=40 + +# DPAD +# -DFEATURE_DPAD_5WIRESW +# -DPINS_DPAD_5WIRESW_OUT=4 +# -DPINS_DPAD_5WIRESW_IN1=5 +# -DPINS_DPAD_5WIRESW_IN2=27 +# -DPINS_DPAD_5WIRESW_IN3=18 +# -DPINS_DPAD_5WIRESW_IN4=19 +# -DPINS_DPAD_EXTRASW_IN5=25 + -DFEATURE_DPAD_6WIRESW + -DPINS_DPAD_6WIRESW_OUT=4 + -DPINS_DPAD_6WIRESW_IN1=5 + -DPINS_DPAD_6WIRESW_IN2=27 + -DPINS_DPAD_6WIRESW_IN3=18 + -DPINS_DPAD_6WIRESW_IN4=19 + -DPINS_DPAD_6WIRESW_IN5=26 + -DFEATURE_GSCHISSENE_DIODE ) diff --git a/config_comred.cmake b/config_comred.cmake index f88ed80..a06e50c 100644 --- a/config_comred.cmake +++ b/config_comred.cmake @@ -16,67 +16,67 @@ add_definitions( ) set(BOBBYCAR_BUILDFLAGS - -DFEATURE_ADC_IN - -DPINS_GAS=34 - -DPINS_BREMS=35 - -DDEFAULT_SWAPSCREENBYTES=false - -DFEATURE_CAN -# -DFEATURE_SERIAL -# -DPINS_RX1=4 -# -DPINS_TX1=5 -# -DPINS_RX2=22 -# -DPINS_TX2=23 - -DDEFAULT_INVERTFRONTLEFT=false - -DDEFAULT_INVERTFRONTRIGHT=true - -DDEFAULT_INVERTBACKLEFT=false - -DDEFAULT_INVERTBACKRIGHT=true - -DDEFAULT_WHEELDIAMETER=200 -# -DFEATURE_MOSFETS -# -DPINS_MOSFET0=18 -# -DPINS_MOSFET1=19 -# -DPINS_MOSFET2=21 - -DDEFAULT_IMOTMAX=28 - -DDEFAULT_IDCMAX=30 - -DDEFAULT_NMOTMAX=2000 - -DDEFAULT_FIELDWEAKMAX=7 - -DDEFAULT_FIELDADVMAX=40 - -DFEATURE_WEBSERVER - -DFEATURE_OTA - -DFEATURE_DPAD_6WIRESW - -DPINS_DPAD_6WIRESW_OUT=4 - -DPINS_DPAD_6WIRESW_IN1=5 - -DPINS_DPAD_6WIRESW_IN2=27 - -DPINS_DPAD_6WIRESW_IN3=18 - -DPINS_DPAD_6WIRESW_IN4=19 - -DPINS_DPAD_6WIRESW_IN5=26 - -DFEATURE_GSCHISSENE_DIODE - -DFEATURE_BLE -# -DFEATURE_BLUETOOTH -# -DFEATURE_BMS -# -DFEATURE_GAMETRAK -# -DPINS_GAMETRAKX=34 -# -DPINS_GAMETRAKY=39 -# -DPINS_GAMETRAKDIST=36 -# -DFEATURE_POWERSUPPLY -# -DFEATURE_CLOUD - -DFEATURE_UDPCLOUD - -DFEATURE_LEDBACKLIGHT - -DPINS_LEDBACKLIGHT=23 - -DLEDBACKLIGHT_INVERTED - -DFEATURE_GARAGE -# -DFEATURE_NTP - -DFEATURE_WIRELESS_CONFIG - -DFEATURE_LEDSTRIP - -DPINS_LEDSTRIP=33 - -DHEAP_LRGST_CRASH_TEXT_FIX -# -DLEDSTRIP_WRONG_DIRECTION - -DLEDSTRIP_ANIMATION_DEFAULT=1 - -DLEDS_PER_METER=144 - -DOLD_NVS - -DFEATURE_DNS_NS - -DSWITCH_BLINK - -DFEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - -DFEATURE_ESPNOW +# Pins + -DPINS_GAS=34 + -DPINS_BREMS=35 +# -DFEATURE_JOYSTICK +# -DPINS_RX1=4 +# -DPINS_TX1=5 +# -DPINS_RX2=22 +# -DPINS_TX2=23 +# -DPINS_MOSFET0=18 +# -DPINS_MOSFET1=19 +# -DPINS_MOSFET2=21 +# -DPINS_GAMETRAKX=34 +# -DPINS_GAMETRAKY=39 +# -DPINS_GAMETRAKDIST=36 + -DPINS_LEDBACKLIGHT=23 + -DPINS_LEDSTRIP=33 + +# Config flags + -DFEATURE_ADC_IN + -DFEATURE_CAN +# -DFEATURE_SERIAL +# -DFEATURE_MOSFETS +# -DFEATURE_BLUETOOTH +# -DFEATURE_BMS +# -DFEATURE_GAMETRAK +# -DFEATURE_POWERSUPPLY + -DFEATURE_LEDBACKLIGHT + + -DLEDBACKLIGHT_INVERTED +# -DLEDSTRIP_WRONG_DIRECTION + -DHEAP_LRGST_CRASH_TEXT_FIX + +# Default values + -DDEFAULT_SWAPSCREENBYTES=false + -DDEFAULT_INVERTFRONTLEFT=false + -DDEFAULT_INVERTFRONTRIGHT=true + -DDEFAULT_INVERTBACKLEFT=false + -DDEFAULT_INVERTBACKRIGHT=true + -DDEFAULT_WHEELDIAMETER=200 + -DDEFAULT_IMOTMAX=28 + -DDEFAULT_IDCMAX=30 + -DDEFAULT_NMOTMAX=2000 + -DDEFAULT_FIELDWEAKMAX=17 + -DDEFAULT_FIELDADVMAX=40 + +# DPAD +# -DFEATURE_DPAD_5WIRESW +# -DPINS_DPAD_5WIRESW_OUT=4 +# -DPINS_DPAD_5WIRESW_IN1=5 +# -DPINS_DPAD_5WIRESW_IN2=27 +# -DPINS_DPAD_5WIRESW_IN3=18 +# -DPINS_DPAD_5WIRESW_IN4=19 +# -DPINS_DPAD_EXTRASW_IN5=25 + -DFEATURE_DPAD_6WIRESW + -DPINS_DPAD_6WIRESW_OUT=4 + -DPINS_DPAD_6WIRESW_IN1=5 + -DPINS_DPAD_6WIRESW_IN2=27 + -DPINS_DPAD_6WIRESW_IN3=18 + -DPINS_DPAD_6WIRESW_IN4=19 + -DPINS_DPAD_6WIRESW_IN5=26 + -DFEATURE_GSCHISSENE_DIODE ) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake") diff --git a/config_feedc0de.cmake b/config_feedc0de.cmake index 7675821..2fe6b8a 100644 --- a/config_feedc0de.cmake +++ b/config_feedc0de.cmake @@ -16,63 +16,64 @@ add_definitions( ) set(BOBBYCAR_BUILDFLAGS - -DFEATURE_ADC_IN - -DPINS_GAS=34 - -DPINS_BREMS=35 - -DDEFAULT_SWAPSCREENBYTES=false - -DFEATURE_CAN -# -DFEATURE_SERIAL -# -DPINS_RX1=4 -# -DPINS_TX1=5 -# -DPINS_RX2=22 -# -DPINS_TX2=23 - -DDEFAULT_INVERTFRONTLEFT=false - -DDEFAULT_INVERTFRONTRIGHT=true - -DDEFAULT_INVERTBACKLEFT=false - -DDEFAULT_INVERTBACKRIGHT=true - -DDEFAULT_WHEELDIAMETER=255 - -DFEATURE_MOSFETS - -DPINS_MOSFET0=4 - -DPINS_MOSFET1=5 - -DPINS_MOSFET2=25 - -DDEFAULT_IMOTMAX=40 - -DDEFAULT_IDCMAX=42 - -DDEFAULT_NMOTMAX=2000 - -DDEFAULT_FIELDWEAKMAX=17 - -DDEFAULT_FIELDADVMAX=40 - -DFEATURE_WEBSERVER - -DFEATURE_OTA - -DFEATURE_DPAD_5WIRESW_2OUT - -DPINS_DPAD_5WIRESW_OUT1=18 - -DPINS_DPAD_5WIRESW_OUT2=19 - -DPINS_DPAD_5WIRESW_IN1=27 - -DPINS_DPAD_5WIRESW_IN2=32 - -DPINS_DPAD_5WIRESW_IN3=33 - -DFEATURE_BLE -# -DFEATURE_BLUETOOTH -# -DFEATURE_BMS -# -DFEATURE_GAMETRAK -# -DPINS_GAMETRAKX=34 -# -DPINS_GAMETRAKY=39 -# -DPINS_GAMETRAKDIST=36 - -DFEATURE_POWERSUPPLY - -DFEATURE_CLOUD - -DFEATURE_UDPCLOUD - -DFEATURE_LEDBACKLIGHT - -DPINS_LEDBACKLIGHT=23 - -DLEDBACKLIGHT_INVERTED -# -DFEATURE_GARAGE - -DFEATURE_NTP - -DFEATURE_WIRELESS_CONFIG - -DFEATURE_LEDSTRIP - -DPINS_LEDSTRIP=26 -# -DHEAP_LRGST_CRASH_TEXT_FIX -# -DLEDSTRIP_WRONG_DIRECTION - -DLEDSTRIP_ANIMATION_DEFAULT=0 - -DLEDS_PER_METER=144 - -DOLD_NVS - -DFEATURE_DNS_NS -# -DSWITCH_BLINK -# -DFEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET -# -DFEATURE_ESPNOW +# Pins + -DPINS_GAS=34 + -DPINS_BREMS=35 +# -DFEATURE_JOYSTICK +# -DPINS_RX1=4 +# -DPINS_TX1=5 +# -DPINS_RX2=22 +# -DPINS_TX2=23 + -DPINS_MOSFET0=4 + -DPINS_MOSFET1=5 + -DPINS_MOSFET2=25 +# -DPINS_GAMETRAKX=34 +# -DPINS_GAMETRAKY=39 +# -DPINS_GAMETRAKDIST=36 + -DPINS_LEDBACKLIGHT=23 + -DPINS_LEDSTRIP=26 + +# Config flags + -DFEATURE_ADC_IN + -DFEATURE_CAN +# -DFEATURE_SERIAL + -DFEATURE_MOSFETS +# -DFEATURE_BLUETOOTH +# -DFEATURE_BMS +# -DFEATURE_GAMETRAK + -DFEATURE_POWERSUPPLY + -DFEATURE_LEDBACKLIGHT + + -DLEDBACKLIGHT_INVERTED +# -DLEDSTRIP_WRONG_DIRECTION +# -DHEAP_LRGST_CRASH_TEXT_FIX + +# Default values + -DDEFAULT_SWAPSCREENBYTES=false + -DDEFAULT_INVERTFRONTLEFT=false + -DDEFAULT_INVERTFRONTRIGHT=true + -DDEFAULT_INVERTBACKLEFT=false + -DDEFAULT_INVERTBACKRIGHT=true + -DDEFAULT_WHEELDIAMETER=255 + -DDEFAULT_IMOTMAX=40 + -DDEFAULT_IDCMAX=42 + -DDEFAULT_NMOTMAX=2000 + -DDEFAULT_FIELDWEAKMAX=17 + -DDEFAULT_FIELDADVMAX=40 + +# DPAD + -DFEATURE_DPAD_5WIRESW_2OUT + -DPINS_DPAD_5WIRESW_OUT1=18 + -DPINS_DPAD_5WIRESW_OUT2=19 + -DPINS_DPAD_5WIRESW_IN1=27 + -DPINS_DPAD_5WIRESW_IN2=32 + -DPINS_DPAD_5WIRESW_IN3=33 +# -DFEATURE_DPAD_6WIRESW +# -DPINS_DPAD_6WIRESW_OUT=4 +# -DPINS_DPAD_6WIRESW_IN1=5 +# -DPINS_DPAD_6WIRESW_IN2=27 +# -DPINS_DPAD_6WIRESW_IN3=18 +# -DPINS_DPAD_6WIRESW_IN4=19 +# -DPINS_DPAD_6WIRESW_IN5=26 +# -DFEATURE_GSCHISSENE_DIODE ) diff --git a/config_greyhash.cmake b/config_greyhash.cmake index 22b9627..d9c8227 100644 --- a/config_greyhash.cmake +++ b/config_greyhash.cmake @@ -16,65 +16,58 @@ add_definitions( ) set(BOBBYCAR_BUILDFLAGS - -DFEATURE_ADC_IN - -DPINS_GAS=34 - -DPINS_BREMS=35 - -DDEFAULT_SWAPSCREENBYTES=false - -DFEATURE_CAN - # -DFEATURE_SERIAL - # -DPINS_RX1=4 - # -DPINS_TX1=5 - # -DPINS_RX2=22 - # -DPINS_TX2=23 - -DDEFAULT_INVERTFRONTLEFT=false - -DDEFAULT_INVERTFRONTRIGHT=true - -DDEFAULT_INVERTBACKLEFT=false - -DDEFAULT_INVERTBACKRIGHT=true - -DDEFAULT_WHEELDIAMETER=200 - # -DFEATURE_MOSFETS - # -DPINS_MOSFET0=18 - # -DPINS_MOSFET1=19 - # -DPINS_MOSFET2=21 - -DDEFAULT_IMOTMAX=28 - -DDEFAULT_IDCMAX=30 - -DDEFAULT_NMOTMAX=2000 - -DDEFAULT_FIELDWEAKMAX=7 - -DDEFAULT_FIELDADVMAX=40 - -DFEATURE_WEBSERVER - -DFEATURE_OTA - -DFEATURE_DPAD_5WIRESW_2OUT - -DPINS_DPAD_5WIRESW_OUT1=5 - -DPINS_DPAD_5WIRESW_OUT2=4 - -DPINS_DPAD_5WIRESW_IN1=27 - -DPINS_DPAD_5WIRESW_IN2=19 - -DPINS_DPAD_5WIRESW_IN3=18 - -DFEATURE_BLE -# -DFEATURE_BLUETOOTH -# -DFEATURE_BMS -# -DFEATURE_GAMETRAK -# -DPINS_GAMETRAKX=34 -# -DPINS_GAMETRAKY=39 -# -DPINS_GAMETRAKDIST=36 -# -DFEATURE_POWERSUPPLY -# -DFEATURE_CLOUD - -DFEATURE_UDPCLOUD - -DFEATURE_LEDBACKLIGHT - -DPINS_LEDBACKLIGHT=23 - -DLEDBACKLIGHT_INVERTED - -DFEATURE_GARAGE -# -DFEATURE_NTP - -DFEATURE_WIRELESS_CONFIG - -DFEATURE_LEDSTRIP - -DPINS_LEDSTRIP=33 -# -DHEAP_LRGST_CRASH_TEXT_FIX -# -DLEDSTRIP_WRONG_DIRECTION - -DLEDSTRIP_ANIMATION_DEFAULT=2 - -DLEDS_PER_METER=144 - -DOLD_NVS - -DFEATURE_DNS_NS -# -DSWITCH_BLINK -# -DFEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - -DFEATURE_ESPNOW +# Pins + -DPINS_GAS=34 + -DPINS_BREMS=35 +# -DFEATURE_JOYSTICK +# -DPINS_RX1=4 +# -DPINS_TX1=5 +# -DPINS_RX2=22 +# -DPINS_TX2=23 +# -DPINS_MOSFET0=18 +# -DPINS_MOSFET1=19 +# -DPINS_MOSFET2=21 +# -DPINS_GAMETRAKX=34 +# -DPINS_GAMETRAKY=39 +# -DPINS_GAMETRAKDIST=36 + -DPINS_LEDBACKLIGHT=23 + -DPINS_LEDSTRIP=33 + +# Config flags + -DFEATURE_ADC_IN + -DFEATURE_CAN +# -DFEATURE_SERIAL +# -DFEATURE_MOSFETS +# -DFEATURE_BLUETOOTH +# -DFEATURE_BMS +# -DFEATURE_GAMETRAK +# -DFEATURE_POWERSUPPLY + -DFEATURE_LEDBACKLIGHT + + -DLEDBACKLIGHT_INVERTED +# -DLEDSTRIP_WRONG_DIRECTION + -DHEAP_LRGST_CRASH_TEXT_FIX + +# Default values + -DDEFAULT_SWAPSCREENBYTES=false + -DDEFAULT_INVERTFRONTLEFT=false + -DDEFAULT_INVERTFRONTRIGHT=true + -DDEFAULT_INVERTBACKLEFT=false + -DDEFAULT_INVERTBACKRIGHT=true + -DDEFAULT_WHEELDIAMETER=200 + -DDEFAULT_IMOTMAX=28 + -DDEFAULT_IDCMAX=30 + -DDEFAULT_NMOTMAX=2000 + -DDEFAULT_FIELDWEAKMAX=17 + -DDEFAULT_FIELDADVMAX=40 + +# DPAD + -DFEATURE_DPAD_5WIRESW_2OUT + -DPINS_DPAD_5WIRESW_OUT1=5 + -DPINS_DPAD_5WIRESW_OUT2=4 + -DPINS_DPAD_5WIRESW_IN1=27 + -DPINS_DPAD_5WIRESW_IN2=19 + -DPINS_DPAD_5WIRESW_IN3=18 ) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake") diff --git a/config_mick.cmake b/config_mick.cmake index 2ea366d..f28ce5e 100644 --- a/config_mick.cmake +++ b/config_mick.cmake @@ -16,61 +16,66 @@ add_definitions( ) set(BOBBYCAR_BUILDFLAGS - -DFEATURE_ADC_IN - -DPINS_GAS=34 - -DPINS_BREMS=35 - -DDEFAULT_SWAPSCREENBYTES=false - -DFEATURE_CAN -# -DFEATURE_SERIAL -# -DPINS_RX1=4 -# -DPINS_TX1=5 -# -DPINS_RX2=22 -# -DPINS_TX2=23 - -DDEFAULT_INVERTFRONTLEFT=false - -DDEFAULT_INVERTFRONTRIGHT=true - -DDEFAULT_INVERTBACKLEFT=false - -DDEFAULT_INVERTBACKRIGHT=true - -DDEFAULT_WHEELDIAMETER=200 -# -DFEATURE_MOSFETS -# -DPINS_MOSFET0=18 -# -DPINS_MOSFET1=19 -# -DPINS_MOSFET2=21 - -DDEFAULT_IMOTMAX=28 - -DDEFAULT_IDCMAX=30 - -DDEFAULT_NMOTMAX=2000 - -DDEFAULT_FIELDWEAKMAX=7 - -DDEFAULT_FIELDADVMAX=40 - -DFEATURE_WEBSERVER - -DFEATURE_OTA - -DFEATURE_DPAD_5WIRESW_2OUT - -DPINS_DPAD_5WIRESW_OUT1=5 - -DPINS_DPAD_5WIRESW_OUT2=19 - -DPINS_DPAD_5WIRESW_IN1=4 - -DPINS_DPAD_5WIRESW_IN2=18 - -DPINS_DPAD_5WIRESW_IN3=27 - -DFEATURE_BLE -# -DFEATURE_BLUETOOTH -# -DFEATURE_BMS -# -DFEATURE_GAMETRAK -# -DPINS_GAMETRAKX=34 -# -DPINS_GAMETRAKY=39 -# -DPINS_GAMETRAKDIST=36 -# -DFEATURE_POWERSUPPLY -# -DFEATURE_CLOUD - -DFEATURE_UDPCLOUD - -DFEATURE_LEDBACKLIGHT - -DPINS_LEDBACKLIGHT=23 - -DLEDBACKLIGHT_INVERTED -# -DFEATURE_GARAGE -# -DFEATURE_NTP - -DFEATURE_WIRELESS_CONFIG - -DFEATURE_LEDSTRIP - -DPINS_LEDSTRIP=33 -# -DLEDSTRIP_WRONG_DIRECTION - -DLEDSTRIP_ANIMATION_DEFAULT=0 - -DOLD_NVS - -DFEATURE_DNS_NS - -DFEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET +# Pins + -DPINS_GAS=34 + -DPINS_BREMS=35 +# -DFEATURE_JOYSTICK +# -DPINS_RX1=4 +# -DPINS_TX1=5 +# -DPINS_RX2=22 +# -DPINS_TX2=23 +# -DPINS_MOSFET0=18 +# -DPINS_MOSFET1=19 +# -DPINS_MOSFET2=21 +# -DPINS_GAMETRAKX=34 +# -DPINS_GAMETRAKY=39 +# -DPINS_GAMETRAKDIST=36 + -DPINS_LEDBACKLIGHT=23 + -DPINS_LEDSTRIP=33 + +# Config flags + -DFEATURE_ADC_IN + -DFEATURE_CAN +# -DFEATURE_SERIAL +# -DFEATURE_MOSFETS +# -DFEATURE_BLUETOOTH +# -DFEATURE_BMS +# -DFEATURE_GAMETRAK + -DFEATURE_POWERSUPPLY + -DFEATURE_LEDBACKLIGHT + + -DLEDBACKLIGHT_INVERTED +# -DLEDSTRIP_WRONG_DIRECTION +# -DHEAP_LRGST_CRASH_TEXT_FIX + +# Default values + -DDEFAULT_SWAPSCREENBYTES=false + -DDEFAULT_INVERTFRONTLEFT=false + -DDEFAULT_INVERTFRONTRIGHT=true + -DDEFAULT_INVERTBACKLEFT=false + -DDEFAULT_INVERTBACKRIGHT=true + -DDEFAULT_WHEELDIAMETER=200 + -DDEFAULT_IMOTMAX=28 + -DDEFAULT_IDCMAX=30 + -DDEFAULT_NMOTMAX=2000 + -DDEFAULT_FIELDWEAKMAX=7 + -DDEFAULT_FIELDADVMAX=40 + +# DPAD + -DFEATURE_DPAD_5WIRESW_2OUT + -DPINS_DPAD_5WIRESW_OUT1=18 + -DPINS_DPAD_5WIRESW_OUT2=19 + -DPINS_DPAD_5WIRESW_IN1=4 + -DPINS_DPAD_5WIRESW_IN2=5 + -DPINS_DPAD_5WIRESW_IN3=27 +# -DFEATURE_DPAD_6WIRESW +# -DPINS_DPAD_6WIRESW_OUT=4 +# -DPINS_DPAD_6WIRESW_IN1=5 +# -DPINS_DPAD_6WIRESW_IN2=27 +# -DPINS_DPAD_6WIRESW_IN3=18 +# -DPINS_DPAD_6WIRESW_IN4=19 +# -DPINS_DPAD_6WIRESW_IN5=26 +# -DFEATURE_GSCHISSENE_DIODE ) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake") diff --git a/config_nofeatures.cmake b/config_nofeatures.cmake index 8caccb9..53eae44 100644 --- a/config_nofeatures.cmake +++ b/config_nofeatures.cmake @@ -16,72 +16,64 @@ add_definitions( ) set(BOBBYCAR_BUILDFLAGS - -DFEATURE_ADC_IN - -DPINS_GAS=34 - -DPINS_BREMS=35 - -DDEFAULT_SWAPSCREENBYTES=false - -DFEATURE_CAN -# -DFEATURE_SERIAL -# -DPINS_RX1=4 -# -DPINS_TX1=5 -# -DPINS_RX2=22 -# -DPINS_TX2=23 - -DDEFAULT_INVERTFRONTLEFT=false - -DDEFAULT_INVERTFRONTRIGHT=true - -DDEFAULT_INVERTBACKLEFT=false - -DDEFAULT_INVERTBACKRIGHT=true - -DDEFAULT_WHEELDIAMETER=200 -# -DFEATURE_MOSFETS -# -DPINS_MOSFET0=18 -# -DPINS_MOSFET1=19 -# -DPINS_MOSFET2=21 - -DDEFAULT_IMOTMAX=28 - -DDEFAULT_IDCMAX=30 - -DDEFAULT_NMOTMAX=2000 - -DDEFAULT_FIELDWEAKMAX=7 - -DDEFAULT_FIELDADVMAX=40 -# -DFEATURE_WEBSERVER -# -DFEATURE_OTA -# -DFEATURE_DPAD_5WIRESW -# -DPINS_DPAD_5WIRESW_OUT=4 -# -DPINS_DPAD_5WIRESW_IN1=5 -# -DPINS_DPAD_5WIRESW_IN2=27 -# -DPINS_DPAD_5WIRESW_IN3=18 -# -DPINS_DPAD_5WIRESW_IN4=19 -# -DPINS_DPAD_EXTRASW_IN5=25 - -DFEATURE_DPAD_6WIRESW - -DPINS_DPAD_6WIRESW_OUT=4 - -DPINS_DPAD_6WIRESW_IN1=5 - -DPINS_DPAD_6WIRESW_IN2=27 - -DPINS_DPAD_6WIRESW_IN3=18 - -DPINS_DPAD_6WIRESW_IN4=19 - -DPINS_DPAD_6WIRESW_IN5=26 -# -DFEATURE_GSCHISSENE_DIODE -# -DFEATURE_BLE -# -DFEATURE_BLUETOOTH -# -DFEATURE_BMS -# -DFEATURE_GAMETRAK -# -DPINS_GAMETRAKX=34 -# -DPINS_GAMETRAKY=39 -# -DPINS_GAMETRAKDIST=36 -# -DFEATURE_POWERSUPPLY -# -DFEATURE_CLOUD -# -DFEATURE_UDPCLOUD -# -DFEATURE_LEDBACKLIGHT -# -DPINS_LEDBACKLIGHT=23 -# -DLEDBACKLIGHT_INVERTED -# -DFEATURE_GARAGE -# -DFEATURE_NTP -# -DFEATURE_WIRELESS_CONFIG -# -DFEATURE_LEDSTRIP -# -DPINS_LEDSTRIP=33 -# -DHEAP_LRGST_CRASH_TEXT_FIX -# -DLEDSTRIP_WRONG_DIRECTION -# -DLEDSTRIP_ANIMATION_DEFAULT=1 -# -DLEDS_PER_METER=144 - -DOLD_NVS -# -DFEATURE_DNS_NS -# -DSWITCH_BLINK - -DFEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET -# -DFEATURE_ESPNOW +# Pins + -DPINS_GAS=34 + -DPINS_BREMS=35 +# -DFEATURE_JOYSTICK +# -DPINS_RX1=4 +# -DPINS_TX1=5 +# -DPINS_RX2=22 +# -DPINS_TX2=23 +# -DPINS_MOSFET0=18 +# -DPINS_MOSFET1=19 +# -DPINS_MOSFET2=21 +# -DPINS_GAMETRAKX=34 +# -DPINS_GAMETRAKY=39 +# -DPINS_GAMETRAKDIST=36 + -DPINS_LEDBACKLIGHT=23 + -DPINS_LEDSTRIP=33 + +# Config flags +# -DFEATURE_ADC_IN +# -DFEATURE_CAN +# -DFEATURE_SERIAL +# -DFEATURE_MOSFETS +# -DFEATURE_BLUETOOTH +# -DFEATURE_BMS +# -DFEATURE_GAMETRAK +# -DFEATURE_POWERSUPPLY +# -DFEATURE_LEDBACKLIGHT + +# -DLEDBACKLIGHT_INVERTED +# -DLEDSTRIP_WRONG_DIRECTION +# -DHEAP_LRGST_CRASH_TEXT_FIX + +# Default values + -DDEFAULT_SWAPSCREENBYTES=false + -DDEFAULT_INVERTFRONTLEFT=false + -DDEFAULT_INVERTFRONTRIGHT=true + -DDEFAULT_INVERTBACKLEFT=false + -DDEFAULT_INVERTBACKRIGHT=true + -DDEFAULT_WHEELDIAMETER=255 + -DDEFAULT_IMOTMAX=28 + -DDEFAULT_IDCMAX=30 + -DDEFAULT_NMOTMAX=2000 + -DDEFAULT_FIELDWEAKMAX=7 + -DDEFAULT_FIELDADVMAX=40 + +# DPAD +# -DFEATURE_DPAD_5WIRESW_2OUT +# -DPINS_DPAD_5WIRESW_OUT1=18 +# -DPINS_DPAD_5WIRESW_OUT2=19 +# -DPINS_DPAD_5WIRESW_IN1=4 +# -DPINS_DPAD_5WIRESW_IN2=5 +# -DPINS_DPAD_5WIRESW_IN3=27 +# -DFEATURE_DPAD_6WIRESW +# -DPINS_DPAD_6WIRESW_OUT=4 +# -DPINS_DPAD_6WIRESW_IN1=5 +# -DPINS_DPAD_6WIRESW_IN2=27 +# -DPINS_DPAD_6WIRESW_IN3=18 +# -DPINS_DPAD_6WIRESW_IN4=19 +# -DPINS_DPAD_6WIRESW_IN5=26 +# -DFEATURE_GSCHISSENE_DIODE ) diff --git a/config_peter.cmake b/config_peter.cmake index beff0e5..aef497e 100644 --- a/config_peter.cmake +++ b/config_peter.cmake @@ -16,65 +16,66 @@ add_definitions( ) set(BOBBYCAR_BUILDFLAGS - -DFEATURE_ADC_IN - -DPINS_GAS=34 - -DPINS_BREMS=35 - -DDEFAULT_SWAPSCREENBYTES=false - -DFEATURE_CAN - # -DFEATURE_SERIAL - # -DPINS_RX1=4 - # -DPINS_TX1=5 - # -DPINS_RX2=22 - # -DPINS_TX2=23 - -DDEFAULT_INVERTFRONTLEFT=false - -DDEFAULT_INVERTFRONTRIGHT=true - -DDEFAULT_INVERTBACKLEFT=false - -DDEFAULT_INVERTBACKRIGHT=true - -DDEFAULT_WHEELDIAMETER=200 - # -DFEATURE_MOSFETS - # -DPINS_MOSFET0=18 - # -DPINS_MOSFET1=19 - # -DPINS_MOSFET2=21 - -DDEFAULT_IMOTMAX=28 - -DDEFAULT_IDCMAX=30 - -DDEFAULT_NMOTMAX=2000 - -DDEFAULT_FIELDWEAKMAX=7 - -DDEFAULT_FIELDADVMAX=40 - -DFEATURE_WEBSERVER - -DFEATURE_OTA - -DFEATURE_DPAD_5WIRESW_2OUT - -DPINS_DPAD_5WIRESW_OUT1=18 - -DPINS_DPAD_5WIRESW_OUT2=19 - -DPINS_DPAD_5WIRESW_IN1=4 - -DPINS_DPAD_5WIRESW_IN2=5 - -DPINS_DPAD_5WIRESW_IN3=27 - -DFEATURE_BLE -# -DFEATURE_BLUETOOTH -# -DFEATURE_BMS -# -DFEATURE_GAMETRAK -# -DPINS_GAMETRAKX=34 -# -DPINS_GAMETRAKY=39 -# -DPINS_GAMETRAKDIST=36 -# -DFEATURE_POWERSUPPLY -# -DFEATURE_CLOUD - -DFEATURE_UDPCLOUD - -DFEATURE_LEDBACKLIGHT - -DPINS_LEDBACKLIGHT=23 - -DLEDBACKLIGHT_INVERTED - -DFEATURE_GARAGE -# -DFEATURE_NTP - -DFEATURE_WIRELESS_CONFIG - -DFEATURE_LEDSTRIP - -DPINS_LEDSTRIP=33 -# -DHEAP_LRGST_CRASH_TEXT_FIX -# -DLEDSTRIP_WRONG_DIRECTION - -DLEDSTRIP_ANIMATION_DEFAULT=2 - -DLEDS_PER_METER=144 - -DOLD_NVS - -DFEATURE_DNS_NS -# -DSWITCH_BLINK - -DFEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - -DFEATURE_ESPNOW +# Pins + -DPINS_GAS=34 + -DPINS_BREMS=35 +# -DFEATURE_JOYSTICK +# -DPINS_RX1=4 +# -DPINS_TX1=5 +# -DPINS_RX2=22 +# -DPINS_TX2=23 +# -DPINS_MOSFET0=18 +# -DPINS_MOSFET1=19 +# -DPINS_MOSFET2=21 +# -DPINS_GAMETRAKX=34 +# -DPINS_GAMETRAKY=39 +# -DPINS_GAMETRAKDIST=36 + -DPINS_LEDBACKLIGHT=23 + -DPINS_LEDSTRIP=33 + +# Config flags + -DFEATURE_ADC_IN + -DFEATURE_CAN +# -DFEATURE_SERIAL +# -DFEATURE_MOSFETS +# -DFEATURE_BLUETOOTH +# -DFEATURE_BMS +# -DFEATURE_GAMETRAK + -DFEATURE_POWERSUPPLY + -DFEATURE_LEDBACKLIGHT + + -DLEDBACKLIGHT_INVERTED +# -DLEDSTRIP_WRONG_DIRECTION +# -DHEAP_LRGST_CRASH_TEXT_FIX + +# Default values + -DDEFAULT_SWAPSCREENBYTES=false + -DDEFAULT_INVERTFRONTLEFT=false + -DDEFAULT_INVERTFRONTRIGHT=true + -DDEFAULT_INVERTBACKLEFT=false + -DDEFAULT_INVERTBACKRIGHT=true + -DDEFAULT_WHEELDIAMETER=255 + -DDEFAULT_IMOTMAX=28 + -DDEFAULT_IDCMAX=30 + -DDEFAULT_NMOTMAX=2000 + -DDEFAULT_FIELDWEAKMAX=7 + -DDEFAULT_FIELDADVMAX=40 + +# DPAD + -DFEATURE_DPAD_5WIRESW_2OUT + -DPINS_DPAD_5WIRESW_OUT1=18 + -DPINS_DPAD_5WIRESW_OUT2=19 + -DPINS_DPAD_5WIRESW_IN1=4 + -DPINS_DPAD_5WIRESW_IN2=5 + -DPINS_DPAD_5WIRESW_IN3=27 +# -DFEATURE_DPAD_6WIRESW +# -DPINS_DPAD_6WIRESW_OUT=4 +# -DPINS_DPAD_6WIRESW_IN1=5 +# -DPINS_DPAD_6WIRESW_IN2=27 +# -DPINS_DPAD_6WIRESW_IN3=18 +# -DPINS_DPAD_6WIRESW_IN4=19 +# -DPINS_DPAD_6WIRESW_IN5=26 +# -DFEATURE_GSCHISSENE_DIODE ) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake") diff --git a/config_seatbot.cmake b/config_seatbot.cmake index b16f286..59d4ead 100644 --- a/config_seatbot.cmake +++ b/config_seatbot.cmake @@ -1,4 +1,4 @@ -set(BOBBY_APP_NAME seatbot) +set(BOBBY_APP_NAME bobbyquad_seatbot) add_definitions( -DUSER_SETUP_LOADED=1 @@ -16,68 +16,62 @@ add_definitions( ) set(BOBBYCAR_BUILDFLAGS - -DFEATURE_ADC_IN - -DPINS_GAS=34 - -DPINS_BREMS=35 +# Pins + -DPINS_GAS=34 + -DPINS_BREMS=35 + -DFEATURE_JOYSTICK +# -DPINS_RX1=4 +# -DPINS_TX1=5 +# -DPINS_RX2=22 +# -DPINS_TX2=23 +# -DPINS_MOSFET0=18 +# -DPINS_MOSFET1=19 +# -DPINS_MOSFET2=21 +# -DPINS_GAMETRAKX=34 +# -DPINS_GAMETRAKY=39 +# -DPINS_GAMETRAKDIST=36 + -DPINS_LEDBACKLIGHT=23 + -DPINS_LEDSTRIP=33 - -DFEATURE_JOYSTICK +# Config flags + -DFEATURE_ADC_IN + -DFEATURE_CAN +# -DFEATURE_SERIAL +# -DFEATURE_MOSFETS +# -DFEATURE_BLUETOOTH +# -DFEATURE_BMS +# -DFEATURE_GAMETRAK +# -DFEATURE_POWERSUPPLY + -DFEATURE_LEDBACKLIGHT - -DDEFAULT_SWAPSCREENBYTES=false - -DFEATURE_CAN -# -DFEATURE_SERIAL -# -DPINS_RX1=4 -# -DPINS_TX1=5 -# -DPINS_RX2=22 -# -DPINS_TX2=23 - -DDEFAULT_INVERTFRONTLEFT=false - -DDEFAULT_INVERTFRONTRIGHT=true - -DDEFAULT_INVERTBACKLEFT=false - -DDEFAULT_INVERTBACKRIGHT=true - -DDEFAULT_WHEELDIAMETER=200 -# -DFEATURE_MOSFETS -# -DPINS_MOSFET0=18 -# -DPINS_MOSFET1=19 -# -DPINS_MOSFET2=21 - -DDEFAULT_IMOTMAX=28 - -DDEFAULT_IDCMAX=30 - -DDEFAULT_NMOTMAX=2000 - -DDEFAULT_FIELDWEAKMAX=7 - -DDEFAULT_FIELDADVMAX=40 - -DFEATURE_WEBSERVER - -DFEATURE_OTA -# -DFEATURE_DPAD_6WIRESW -# -DPINS_DPAD_6WIRESW_OUT=4 -# -DPINS_DPAD_6WIRESW_IN1=5 -# -DPINS_DPAD_6WIRESW_IN2=27 -# -DPINS_DPAD_6WIRESW_IN3=18 -# -DPINS_DPAD_6WIRESW_IN4=19 -# -DPINS_DPAD_6WIRESW_IN5=26 - -DFEATURE_DPAD_5WIRESW_2OUT - -DPINS_DPAD_5WIRESW_OUT1=4 - -DPINS_DPAD_5WIRESW_OUT2=5 - -DPINS_DPAD_5WIRESW_IN1=18 - -DPINS_DPAD_5WIRESW_IN2=19 - -DPINS_DPAD_5WIRESW_IN3=27 - -DFEATURE_BLE - -DFEATURE_UDPCLOUD - -DFEATURE_LEDBACKLIGHT - -DPINS_LEDBACKLIGHT=23 - -DLEDBACKLIGHT_INVERTED - -DFEATURE_GARAGE - -DFEATURE_WIRELESS_CONFIG - -DFEATURE_LEDSTRIP - -DPINS_LEDSTRIP=33 - -DHEAP_LRGST_CRASH_TEXT_FIX - -DLEDSTRIP_ANIMATION_DEFAULT=1 - -DLEDS_PER_METER=144 - -DOLD_NVS -# -DFEATURE_DNS_NS - -DSWITCH_BLINK - -DFEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - -DFEATURE_ESPNOW + -DLEDBACKLIGHT_INVERTED +# -DLEDSTRIP_WRONG_DIRECTION + -DHEAP_LRGST_CRASH_TEXT_FIX + +# Default values + -DDEFAULT_SWAPSCREENBYTES=false + -DDEFAULT_INVERTFRONTLEFT=false + -DDEFAULT_INVERTFRONTRIGHT=true + -DDEFAULT_INVERTBACKLEFT=false + -DDEFAULT_INVERTBACKRIGHT=true + -DDEFAULT_WHEELDIAMETER=200 + -DDEFAULT_IMOTMAX=28 + -DDEFAULT_IDCMAX=30 + -DDEFAULT_NMOTMAX=2000 + -DDEFAULT_FIELDWEAKMAX=17 + -DDEFAULT_FIELDADVMAX=40 + +# DPAD + -DFEATURE_DPAD_5WIRESW_2OUT + -DPINS_DPAD_5WIRESW_OUT1=4 + -DPINS_DPAD_5WIRESW_OUT2=5 + -DPINS_DPAD_5WIRESW_IN1=18 + -DPINS_DPAD_5WIRESW_IN2=19 + -DPINS_DPAD_5WIRESW_IN3=27 ) #if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake") # include("${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake") # message(WARNING "Including plugins") #endif() + diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index cff3d00..8eba682 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -43,6 +43,7 @@ set(headers bobbyerrorhandler.h bobbyquickactions.h bobbytypesafeenum.h + bobbyschedulertask.h buildserver.h can.h changevaluedisplay_bluetoothmode.h @@ -96,6 +97,7 @@ set(headers displays/menus/espnowmenu.h displays/menus/espnowsettingsmenu.h displays/menus/extrabuttoncalibratemenu.h + displays/menus/featureflagsmenu.h displays/menus/feedbackdebugmenu.h displays/menus/gametrakmodesettingsmenu.h displays/menus/garagenmenu.h @@ -325,6 +327,7 @@ set(sources displays/menus/espnowmenu.cpp displays/menus/espnowsettingsmenu.cpp displays/menus/extrabuttoncalibratemenu.cpp + displays/menus/featureflagsmenu.cpp displays/menus/feedbackdebugmenu.cpp displays/menus/gametrakmodesettingsmenu.cpp displays/menus/garagenmenu.cpp diff --git a/main/accessors/settingsaccessors.h b/main/accessors/settingsaccessors.h index 7351226..c964b0c 100644 --- a/main/accessors/settingsaccessors.h +++ b/main/accessors/settingsaccessors.h @@ -38,27 +38,21 @@ struct FieldWeakMaxAccessor : public RefAccessorSaveSettings { int16_t struct PhaseAdvMaxAccessor : public RefAccessorSaveSettings { int16_t &getRef() const override { return profileSettings.limits.phaseAdvMax; } }; // Bluetooth Low Energy -#ifdef FEATURE_BLE struct BleEnabledAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.bleSettings.bleEnabled; } }; -#endif // Cloud -#ifdef FEATURE_CLOUD struct CloudEnabledAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.cloudSettings.cloudEnabled; } }; struct CloudTransmitTimeoutAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.cloudSettings.cloudTransmitTimeout; } }; -#endif // Time //struct TimezoneOffsetAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.timezoneOffset; } }; struct TimezoneOffsetAccessor : public NewSettingsChronoAdaptorAccessor { ConfigWrapper &getConfig() const override { return configs.timezoneOffset; } }; struct DaylightSavingModeAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.timeDst; } }; -#ifdef FEATURE_NTP struct TimeServerEnabledAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.timeServerEnabled; } }; struct TimeServerAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.timeServer; } }; struct TimeSyncModeAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.timeSyncMode; } }; //struct TimeSyncIntervalAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.timeSyncInterval; } }; struct TimeSyncIntervalAccessor : public NewSettingsChronoAdaptorAccessor { ConfigWrapper &getConfig() const override { return configs.timeSyncInterval; } }; -#endif // Controller Hardware struct FrontLeftEnabledAccessor : public RefAccessorSaveSettings { bool &getRef() const override { return profileSettings.controllerHardware.enableFrontLeft; } }; @@ -126,17 +120,13 @@ struct GametrakDistMaxAccessor : public NewSettingsAccessor { ConfigWra struct StatsUpdateRateAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.boardcomputerHardware.timersSettings.statsUpdateRate; } }; // Cloud -#ifdef FEATURE_CLOUD struct CloudCollectRateAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.boardcomputerHardware.timersSettings.cloudCollectRate; } }; struct CloudSendRateAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.boardcomputerHardware.timersSettings.cloudSendRate; } }; -#endif -#ifdef FEATURE_UDPCLOUD struct UdpCloudSendIntervalAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.boardcomputerHardware.timersSettings.udpSendRateMs; } }; struct UdpCloudEnabledAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.udpCloudSettings.udpCloudEnabled; } }; struct CloudDebugEnableAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.udpCloudSettings.enableCloudDebug; } }; struct UdpUseStdStringAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.udpCloudSettings.udpUseStdString; } }; -#endif // DefaultMode struct DefaultModeModelModeAccessor : public RefAccessorSaveSettings { UnifiedModelMode &getRef() const override { return profileSettings.defaultMode.modelMode; } }; @@ -171,7 +161,6 @@ struct MotortestModeMultiplikatorAccessor : public RefAccessorSaveSettings { uint16_t &getRef() const override { return profileSettings.motortestMode.maxPwm; } }; // Ledstrip -#ifdef FEATURE_LEDSTRIP struct EnableLedAnimationAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.ledstrip.enableLedAnimation; } }; struct EnableBrakeLightsAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.ledstrip.enableBrakeLights; } }; struct LedsCountAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.ledstrip.ledsCount; } }; @@ -200,11 +189,8 @@ struct EnableLedstripStVOFrontlight : public NewSettingsAccessor { ConfigW struct AnimationMultiplierAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.ledstrip.animationMultiplier; } }; struct LedstripBrightnessAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.ledstrip.brightness; } }; struct LedstripEnableBlinkAnimationAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.ledstrip.enableAnimBlink; } }; -#ifdef FEATURE_OTA struct LedstripOtaAnimationAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.ledstrip.otaMode; } }; -#endif struct LedstripEnableVisualizeBlinkAnimationAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.ledstrip.enableVisualizeBlink; } }; -#endif // Battery struct BatterySeriesCellsAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.battery.cellsSeries; } }; @@ -226,11 +212,9 @@ struct HandbremsAutomaticAccessor : public NewSettingsAccessor { ConfigWra struct HandbremsVisualizeAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.handbremse.visualize; } }; // ESP Now -#ifdef FEATURE_ESPNOW struct ESPNowSyncTimeEnabledAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.espnow.syncTime; } }; struct ESPNowSyncTimeWithOthersEnabledAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.espnow.syncTimeWithOthers; } }; struct ESPNowSyncBlinkEnabledAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.espnow.syncBlink; } }; -#endif // Button Mapping accessors struct ButtonLeftAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.dpadMappingLeft; } }; diff --git a/main/actions/ledstripanimationactions.h b/main/actions/ledstripanimationactions.h index 8360721..6b7bd8e 100644 --- a/main/actions/ledstripanimationactions.h +++ b/main/actions/ledstripanimationactions.h @@ -9,7 +9,6 @@ #include "newsettings.h" #include "bobbyerrorhandler.h" -#ifdef FEATURE_LEDSTRIP template class LedStripSetAnimationActionStatic : public virtual espgui::ActionInterface { @@ -29,5 +28,3 @@ public: private: const LedstripAnimation m_animation; }; - -#endif diff --git a/main/actions/ledstripblinkactions.cpp b/main/actions/ledstripblinkactions.cpp index 8d903b8..f8c4b06 100644 --- a/main/actions/ledstripblinkactions.cpp +++ b/main/actions/ledstripblinkactions.cpp @@ -1,6 +1,5 @@ #include "ledstripblinkactions.h" -#ifdef FEATURE_LEDSTRIP #include "ledstrip.h" #include "ledstripdefines.h" @@ -39,4 +38,3 @@ void LedstripAnimationBlinkBothAction::triggered() { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH; } -#endif diff --git a/main/actions/ledstripblinkactions.h b/main/actions/ledstripblinkactions.h index 4ea7541..81770cd 100644 --- a/main/actions/ledstripblinkactions.h +++ b/main/actions/ledstripblinkactions.h @@ -1,6 +1,5 @@ #pragma once -#ifdef FEATURE_LEDSTRIP #include "actioninterface.h" class LedstripAnimationBlinkNoneAction : public virtual espgui::ActionInterface @@ -34,4 +33,3 @@ class LedstripAnimationBlinkBothAction : public virtual espgui::ActionInterface public: void triggered() override; }; -#endif diff --git a/main/ble_bobby.cpp b/main/ble_bobby.cpp index 1defdbe..4ef81d3 100644 --- a/main/ble_bobby.cpp +++ b/main/ble_bobby.cpp @@ -9,15 +9,12 @@ #include // local includes -#ifdef FEATURE_LEDSTRIP #include "ledstrip.h" -#endif #include "globals.h" #include "modes/remotecontrolmode.h" #include "utils.h" #include "newsettings.h" -#ifdef FEATURE_BLE namespace { constexpr const char * const TAG = "BOBBYBLE"; @@ -27,7 +24,6 @@ public: void onWrite(NimBLECharacteristic* pCharacteristic) override; }; -#ifdef FEATURE_WIRELESS_CONFIG class WirelessSettingsCallbacks : public NimBLECharacteristicCallbacks { public: @@ -39,7 +35,6 @@ class WiFiListCallbacks : public NimBLECharacteristicCallbacks public: void onRead(NimBLECharacteristic* pCharacteristic) override; }; -#endif // FEATURE_WIRELESS_CONFIG } // namespace @@ -47,18 +42,14 @@ BLEServer *pServer{}; BLEService *pService{}; BLECharacteristic *livestatsCharacteristic{}; BLECharacteristic *remotecontrolCharacteristic{}; -#ifdef FEATURE_WIRELESS_CONFIG BLECharacteristic *wirelessConfig{}; BLECharacteristic *getwifilist{}; -#endif // FEATURE_WIRELESS_CONFIG namespace { RemoteControlCallbacks bleRemoteCallbacks; -#ifdef FEATURE_WIRELESS_CONFIG WirelessSettingsCallbacks bleWirelessSettingsCallbacks; WiFiListCallbacks bleWiFiListCallbacks; -#endif // FEATURE_WIRELESS_CONFIG void createBle() { @@ -75,12 +66,11 @@ void createBle() livestatsCharacteristic = pService->createCharacteristic("a48321ea-329f-4eab-a401-30e247211524", NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY); remotecontrolCharacteristic = pService->createCharacteristic("4201def0-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::WRITE); remotecontrolCharacteristic->setCallbacks(&bleRemoteCallbacks); -#ifdef FEATURE_WIRELESS_CONFIG + wirelessConfig = pService->createCharacteristic("4201def1-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::WRITE); wirelessConfig->setCallbacks(&bleWirelessSettingsCallbacks); getwifilist = pService->createCharacteristic("4201def2-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::READ); getwifilist->setCallbacks(&bleWiFiListCallbacks); -#endif pService->start(); @@ -100,10 +90,8 @@ void destroyBle() pService = {}; livestatsCharacteristic = {}; remotecontrolCharacteristic = {}; -#ifdef FEATURE_WIRELESS_CONFIG wirelessConfig = {}; getwifilist = {}; -#endif } } // namespace @@ -116,6 +104,9 @@ void initBle() void handleBle() { + if (!configs.feature.ble.value) + return; + if (configs.bleSettings.bleEnabled.value) { if (!pServer) @@ -246,10 +237,11 @@ void RemoteControlCallbacks::onWrite(NimBLECharacteristic* pCharacteristic) return; } -#ifdef FEATURE_LEDSTRIP - auto newBlinkAnimation = doc["anim"].as(); - if (blinkAnimation != newBlinkAnimation) blinkAnimation = newBlinkAnimation; -#endif // FEATURE_LEDSTRIP + if (configs.feature.ledstrip.value) + { + const auto newBlinkAnimation = doc["anim"].as(); + if (blinkAnimation != newBlinkAnimation) blinkAnimation = newBlinkAnimation; + } const bool isInverted = (profileSettings.controllerHardware.invertFrontLeft && !profileSettings.controllerHardware.invertFrontRight); @@ -264,7 +256,6 @@ void RemoteControlCallbacks::onWrite(NimBLECharacteristic* pCharacteristic) } } -#ifdef FEATURE_WIRELESS_CONFIG void WirelessSettingsCallbacks::onWrite(NimBLECharacteristic* pCharacteristic) { const auto &val = pCharacteristic->getValue(); @@ -303,8 +294,4 @@ void WiFiListCallbacks::onRead(NimBLECharacteristic *pCharacteristic) serializeJson(responseDoc, json); pCharacteristic->setValue(json); } -#endif // FEATURE_WIRELESS_CONFIG - } // namespace - -#endif diff --git a/main/ble_bobby.h b/main/ble_bobby.h index 1ffb091..06cc769 100644 --- a/main/ble_bobby.h +++ b/main/ble_bobby.h @@ -1,7 +1,5 @@ #pragma once -#ifdef FEATURE_BLE - // esp-idf includes #include @@ -9,13 +7,9 @@ extern BLEServer *pServer; extern BLEService *pService; extern BLECharacteristic *livestatsCharacteristic; extern BLECharacteristic *remotecontrolCharacteristic; -#ifdef FEATURE_WIRELESS_CONFIG extern BLECharacteristic *wirelessConfig; extern BLECharacteristic *getwifilist; -#endif // FEATURE_WIRELESS_CONFIG void initBle(); void handleBle(); - -#endif diff --git a/main/bletexthelpers.h b/main/bletexthelpers.h index 359eb0a..4622c9d 100644 --- a/main/bletexthelpers.h +++ b/main/bletexthelpers.h @@ -4,7 +4,6 @@ #include "textinterface.h" #include "ble_bobby.h" -#ifdef FEATURE_BLE struct BleServerPeerDevicesText : public virtual espgui::TextInterface { public: std::string text() const override @@ -26,4 +25,3 @@ public: return text; } }; -#endif diff --git a/main/bobbybuttons.cpp b/main/bobbybuttons.cpp index f792164..dc345fb 100644 --- a/main/bobbybuttons.cpp +++ b/main/bobbybuttons.cpp @@ -6,10 +6,9 @@ // local includes #include "newsettings.h" #include "settingsutils.h" -#ifdef FEATURE_LEDSTRIP +#include "modes/defaultmode.h" #include "ledstripdefines.h" #include "ledstrip.h" -#endif #include "bobbyquickactions.h" diff --git a/main/bobbyquickactions.cpp b/main/bobbyquickactions.cpp index 2a643fc..5707f1a 100644 --- a/main/bobbyquickactions.cpp +++ b/main/bobbyquickactions.cpp @@ -1,9 +1,7 @@ #include "bobbyquickactions.h" // local includes -#ifdef FEATURE_ESPNOW #include "espnowfunctions.h" -#endif #include "newsettings.h" #include "wifi_bobbycar.h" @@ -30,10 +28,7 @@ void handle_bobby_quickaction(espgui::Button button) return; } - if (config) - { - switch(config->value) - { + switch (config->value) { case BobbyQuickActions::BLINK_LEFT: blink_left(); break; @@ -51,13 +46,14 @@ void handle_bobby_quickaction(espgui::Button button) break; default: return; - } } } void open_garage() { -#ifdef FEATURE_ESPNOW + if (!configs.feature.esp_now.value) + return; + if (!espnow::espnow_init_allowed()) return; for (const auto &config : configs.wireless_door_configs) @@ -68,7 +64,6 @@ void open_garage() continue; } } -#endif } void action_wifi_scan() @@ -82,7 +77,8 @@ void action_wifi_scan() void blink_left() { -#ifdef FEATURE_LEDSTRIP + if (configs.feature.ledstrip.value) + { if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to left { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKLEFT; @@ -95,12 +91,13 @@ void blink_left() { blinkAnimation = LEDSTRIP_OVERWRITE_NONE; } -#endif + } } void blink_right() { -#ifdef FEATURE_LEDSTRIP + if(configs.feature.ledstrip.value) + { if (blinkAnimation == LEDSTRIP_OVERWRITE_NONE) //transition from off to right { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKRIGHT; @@ -113,7 +110,7 @@ void blink_right() { blinkAnimation = LEDSTRIP_OVERWRITE_NONE; } -#endif + } } void handle_handbremse() diff --git a/main/bobbyschedulertask.h b/main/bobbyschedulertask.h new file mode 100644 index 0000000..38be85e --- /dev/null +++ b/main/bobbyschedulertask.h @@ -0,0 +1,13 @@ +#pragma once + +// 3rdparty lib includes +#include + +class BobbySchedulerTask : public espcpputils::SchedulerTask { +public: + using SchedulerTask::SchedulerTask; + void setup() const { SchedulerTask::setup(); m_wasInitialized = true; } + bool isInitialized() const { return m_wasInitialized; } +private: + mutable bool m_wasInitialized{false}; +}; diff --git a/main/buildserver.cpp b/main/buildserver.cpp index 8ea6dca..3c9e1c0 100644 --- a/main/buildserver.cpp +++ b/main/buildserver.cpp @@ -16,8 +16,6 @@ #include "globals.h" #include "newsettings.h" -#ifdef FEATURE_OTA - namespace buildserver { uint16_t count_available_buildserver() @@ -271,4 +269,3 @@ namespace buildserver { } } // namespace SelectBuild } // namespace buildserver -#endif diff --git a/main/buildserver.h b/main/buildserver.h index 99eb6d8..c45f2f5 100644 --- a/main/buildserver.h +++ b/main/buildserver.h @@ -6,7 +6,6 @@ #include #include -#ifdef FEATURE_OTA namespace buildserver { uint16_t count_available_buildserver(); @@ -48,4 +47,3 @@ namespace SelectBuild { bool get_request_running(); } // namespace SelectBuild } // namespace buildserver -#endif diff --git a/main/cloud.cpp b/main/cloud.cpp index 26ed792..f70a0f5 100644 --- a/main/cloud.cpp +++ b/main/cloud.cpp @@ -24,7 +24,6 @@ namespace { constexpr const char * const TAG = "BOBBYCLOUD"; } // namespace -#ifdef FEATURE_CLOUD espcpputils::websocket_client cloudClient; bool cloudStarted{}; @@ -53,6 +52,9 @@ void initCloud() void updateCloud() { + if (!configs.feature.cloud.value) + return; + const auto now = espchrono::millis_clock::now(); if (!lastCloudCollect || now - *lastCloudCollect >= std::chrono::milliseconds{configs.boardcomputerHardware.timersSettings.cloudCollectRate.value}) @@ -284,5 +286,3 @@ void destroyCloud() cloudClient = {}; cloudStarted = false; } - -#endif diff --git a/main/cloud.h b/main/cloud.h index a8f55ef..7ffb4c3 100644 --- a/main/cloud.h +++ b/main/cloud.h @@ -7,7 +7,6 @@ #include #include -#ifdef FEATURE_CLOUD extern espcpputils::websocket_client cloudClient; extern bool cloudStarted; extern espchrono::millis_clock::time_point lastCreateTry; @@ -22,4 +21,3 @@ void initCloud(); void updateCloud(); void cloudCollect(); void cloudSend(); -#endif diff --git a/main/cloudtexthelpers.cpp b/main/cloudtexthelpers.cpp index a103caa..f2ee868 100644 --- a/main/cloudtexthelpers.cpp +++ b/main/cloudtexthelpers.cpp @@ -6,7 +6,6 @@ // local includes #include "cloud.h" -#ifdef FEATURE_CLOUD std::string CloudCreatedText::text() const { return fmt::format("created: {}", cloudClient ? "true" : "false"); @@ -27,4 +26,3 @@ std::string CloudConnectedText::text() const text += cloudClient.is_connected() ? "true" : "false"; return text; } -#endif diff --git a/main/cloudtexthelpers.h b/main/cloudtexthelpers.h index ceeb687..2dce1ed 100644 --- a/main/cloudtexthelpers.h +++ b/main/cloudtexthelpers.h @@ -3,7 +3,6 @@ // local includes #include "textinterface.h" -#ifdef FEATURE_CLOUD struct CloudCreatedText : public virtual espgui::TextInterface { public: @@ -21,4 +20,3 @@ struct CloudConnectedText : public virtual espgui::TextInterface public: std::string text() const override; }; -#endif diff --git a/main/displays/ledstripcolorsdisplay.cpp b/main/displays/ledstripcolorsdisplay.cpp index f341df4..51a2da0 100644 --- a/main/displays/ledstripcolorsdisplay.cpp +++ b/main/displays/ledstripcolorsdisplay.cpp @@ -21,7 +21,6 @@ #include "globals.h" #include "displays/menus/ledstripmenu.h" -#ifdef FEATURE_LEDSTRIP namespace { constexpr char TEXT_LEDSTRIPCOLORMENU[] = "Customize Ledstrip"; @@ -30,15 +29,15 @@ int8_t selected_color; bool state_select_color{false}; bool last_state = {false}; -const std::array Colors = { - CRGB{0,0,0}, - CRGB{255,255,255}, - CRGB{255,0,0}, - CRGB{255,255,0}, - CRGB{0,255,0}, - CRGB{0,255,255}, - CRGB{0,0,255}, - CRGB{255,0,255} +const std::array Colors = { + CRGB_TO_UINT32(CRGB{0,0,0}), + CRGB_TO_UINT32(CRGB{255,255,255}), + CRGB_TO_UINT32(CRGB{255,0,0}), + CRGB_TO_UINT32(CRGB{255,255,0}), + CRGB_TO_UINT32(CRGB{0,255,0}), + CRGB_TO_UINT32(CRGB{0,255,255}), + CRGB_TO_UINT32(CRGB{0,0,255}), + CRGB_TO_UINT32(CRGB{255,0,255}) }; const std::array tft_colors = { @@ -119,7 +118,7 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button) } else { - ledstrip_custom_colors[selected_side] = Colors[selected_color]; + configs.ledstrip.custom_color[selected_side].write(configs.nvs_handle_user, Colors[selected_color]); // Uncomment to close select color menu on color select /* state_select_color = false; @@ -258,4 +257,3 @@ void LedstripColorsDisplay::drawSide(Bobbycar_Side side, unsigned int color) } // espgui::tft.fillCircle(espgui::tft.width() / 2, 140, 100, TFT_BLACK); } -#endif diff --git a/main/displays/ledstripcolorsdisplay.h b/main/displays/ledstripcolorsdisplay.h index 46ff229..2823d14 100644 --- a/main/displays/ledstripcolorsdisplay.h +++ b/main/displays/ledstripcolorsdisplay.h @@ -10,16 +10,6 @@ #include "bobbydisplaywithtitle.h" #include "ledstrip.h" -#ifdef FEATURE_LEDSTRIP -//extern int8_t selected_side; -//extern int8_t selected_color; -//extern bool state_select_color; -//extern bool last_state; - -//extern const std::array Colors; - -//extern const std::array tft_colors; - class LedstripColorsDisplay : public BobbyDisplayWithTitle { using Base = BobbyDisplayWithTitle; @@ -38,4 +28,3 @@ public: private: bool already_drew_circle{false}; }; -#endif diff --git a/main/displays/menus/aboutmenu.cpp b/main/displays/menus/aboutmenu.cpp index 535c7c3..02a5812 100644 --- a/main/displays/menus/aboutmenu.cpp +++ b/main/displays/menus/aboutmenu.cpp @@ -8,11 +8,9 @@ #include "esptexthelpers.h" #include "displays/menus/settingsmenu.h" -#ifdef FEATURE_OTA #include #include #include "fmt/core.h" -#endif namespace { constexpr char TEXT_ABOUT[] = "About"; @@ -23,17 +21,13 @@ class CurrentVersionText : public virtual espgui::TextInterface public: std::string text() const override { -#ifdef FEATURE_OTA if (const esp_app_desc_t *app_desc = esp_ota_get_app_description()) { return fmt::format("Version: {}", app_desc->version); } -#endif - return "Version: 1.0"; + return "Version: Unkown"; }; }; - -constexpr char TEXT_VERSION[] = "Version: 1.0"; } // namespace AboutMenu::AboutMenu() diff --git a/main/displays/menus/blesettingsmenu.cpp b/main/displays/menus/blesettingsmenu.cpp index 237e3e4..f42d95c 100644 --- a/main/displays/menus/blesettingsmenu.cpp +++ b/main/displays/menus/blesettingsmenu.cpp @@ -15,7 +15,6 @@ #include "displays/menus/settingsmenu.h" #include "bobbycheckbox.h" -#ifdef FEATURE_BLE namespace { constexpr char TEXT_BLESETTINGS[] = "BLE settings"; constexpr char TEXT_ENABLED[] = "Enabled"; @@ -51,4 +50,3 @@ void BleSettingsMenu::back() { espgui::switchScreen(); } -#endif diff --git a/main/displays/menus/blesettingsmenu.h b/main/displays/menus/blesettingsmenu.h index 0143c5e..2030627 100644 --- a/main/displays/menus/blesettingsmenu.h +++ b/main/displays/menus/blesettingsmenu.h @@ -3,8 +3,6 @@ // local includes #include "displays/bobbymenudisplay.h" -#ifdef FEATURE_BLE - class BleSettingsMenu : public BobbyMenuDisplay { public: @@ -14,4 +12,3 @@ public: void back() override; }; -#endif diff --git a/main/displays/menus/cloudsettingsmenu.cpp b/main/displays/menus/cloudsettingsmenu.cpp index d425baf..e937788 100644 --- a/main/displays/menus/cloudsettingsmenu.cpp +++ b/main/displays/menus/cloudsettingsmenu.cpp @@ -16,7 +16,6 @@ #include "displays/menus/settingsmenu.h" #include "bobbycheckbox.h" -#ifdef FEATURE_CLOUD namespace { constexpr char TEXT_CLOUDSETTINGS[] = "Cloud settings"; constexpr char TEXT_CLOUDENABLED[] = "Cloud enabled"; @@ -83,4 +82,3 @@ void CloudSettingsMenu::back() { switchScreen(); } -#endif diff --git a/main/displays/menus/cloudsettingsmenu.h b/main/displays/menus/cloudsettingsmenu.h index 5cb6118..99aedb1 100644 --- a/main/displays/menus/cloudsettingsmenu.h +++ b/main/displays/menus/cloudsettingsmenu.h @@ -3,7 +3,6 @@ // local includes #include "displays/bobbymenudisplay.h" -#ifdef FEATURE_CLOUD class CloudSettingsMenu : public BobbyMenuDisplay { public: @@ -13,4 +12,3 @@ public: void back() override; }; -#endif diff --git a/main/displays/menus/debugmenu.cpp b/main/displays/menus/debugmenu.cpp index b08cfca..1ffc389 100644 --- a/main/displays/menus/debugmenu.cpp +++ b/main/displays/menus/debugmenu.cpp @@ -63,14 +63,19 @@ DebugMenu::DebugMenu() { using namespace espgui; constructMenuItem, SwitchScreenAction>>(); +#ifdef FEATURE_CAN constructMenuItem, SwitchScreenAction>>(); +#endif constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::battery>>>(); -#ifdef FEATURE_UDPCLOUD - constructMenuItem, BobbyCheckbox, CloudDebugEnableAccessor>>(); -#endif + if (configs.feature.udpcloud.value) + { + constructMenuItem, BobbyCheckbox, CloudDebugEnableAccessor>>(); + } constructMenuItem, DisabledColor, DummyAction>>(); +#ifdef FEATURE_CAN constructMenuItem, DisabledColor, DummyAction>>(); +#endif constructMenuItem>(); constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction>>(); diff --git a/main/displays/menus/espnowmenu.cpp b/main/displays/menus/espnowmenu.cpp index 920c295..b886c08 100644 --- a/main/displays/menus/espnowmenu.cpp +++ b/main/displays/menus/espnowmenu.cpp @@ -1,6 +1,5 @@ #include "espnowmenu.h" -#ifdef FEATURE_ESPNOW // 3rdparty lib includes #include "actions/dummyaction.h" #include "actions/switchscreenaction.h" @@ -75,4 +74,3 @@ void EspNowMenu::back() { espgui::switchScreen(); } -#endif diff --git a/main/displays/menus/espnowmenu.h b/main/displays/menus/espnowmenu.h index 7ab2610..cc69737 100644 --- a/main/displays/menus/espnowmenu.h +++ b/main/displays/menus/espnowmenu.h @@ -1,7 +1,5 @@ #pragma once -#ifdef FEATURE_ESPNOW - // local includes #include "displays/bobbymenudisplay.h" @@ -14,5 +12,3 @@ public: void back() override; }; - -#endif diff --git a/main/displays/menus/espnowsettingsmenu.cpp b/main/displays/menus/espnowsettingsmenu.cpp index 2cbc4c3..ea286f9 100644 --- a/main/displays/menus/espnowsettingsmenu.cpp +++ b/main/displays/menus/espnowsettingsmenu.cpp @@ -1,7 +1,5 @@ #include "espnowsettingsmenu.h" -#ifdef FEATURE_ESPNOW - // 3rdparty lib includes #include "actions/dummyaction.h" #include "actions/switchscreenaction.h" @@ -46,4 +44,3 @@ void EspNowSettingsMenu::back() { espgui::switchScreen(); } -#endif diff --git a/main/displays/menus/espnowsettingsmenu.h b/main/displays/menus/espnowsettingsmenu.h index b7fdd16..0e4eaaf 100644 --- a/main/displays/menus/espnowsettingsmenu.h +++ b/main/displays/menus/espnowsettingsmenu.h @@ -1,7 +1,5 @@ #pragma once -#ifdef FEATURE_ESPNOW - // local includes #include "displays/bobbymenudisplay.h" @@ -14,5 +12,3 @@ public: void back() override; }; - -#endif diff --git a/main/displays/menus/featureflagsmenu.cpp b/main/displays/menus/featureflagsmenu.cpp new file mode 100644 index 0000000..279ce6b --- /dev/null +++ b/main/displays/menus/featureflagsmenu.cpp @@ -0,0 +1,79 @@ +#include "featureflagsmenu.h" + +// 3rdparty lib includes +#include +#include +#include +#include + +// local includes +#include "displays/bobbypopupdisplay.h" +#include "displays/menus/settingsmenu.h" +#include "bobbycheckbox.h" +#include "newsettings.h" + +using namespace espgui; + +namespace { +constexpr const char * const TAG = "FEATUREFLAGSMENU"; + +constexpr char TEXT_FEATUREFLAGS[] = "Feature Flags"; +constexpr char TEXT_BACK[] = "Back"; + +class FeatureFlagMenuItem : public MenuItem, public virtual BobbyErrorHandler { +public: + explicit FeatureFlagMenuItem(ConfigWrapper &config) : m_config{config} {} + std::string text() const override + { + std::string_view name = m_config.nvsName(); + constexpr const std::string_view prefix = "f_"; + if (cpputils::stringStartsWith(name, prefix)) { + name.remove_prefix(prefix.size()); + } + return std::string{name}; + } + + void triggered() override + { + if (auto result = m_config.write(configs.nvs_handle_user, !m_config.value); !result) + errorOccured(std::move(result).error()); + } + + const MenuItemIcon *icon() const override + { + return m_config.value ? &icons::checked : &icons::unchecked; + } +private: + ConfigWrapper &m_config; +}; + +// TODO: Replace SwitchScreenAction / switchScreen with this action. Needs: BobbyPopupDisplayWithCustomExitAction => pass SwitchScreenAction into it + +class ExitFeatureFlagsMenuAction : public virtual ActionInterface { +public: + void triggered() override { + auto newDisplay = std::make_unique(std::move("Please reboot if you have changed something"), std::move(espgui::currentDisplay)); + newDisplay->initOverlay(); + espgui::currentDisplay = std::move(newDisplay); + } +}; + +} // namespace + +FeatureFlagsMenu::FeatureFlagsMenu() +{ + configs.callForEveryFeature([&](ConfigWrapper &feature){ + constructMenuItem(feature); + }); + constructMenuItem, SwitchScreenAction>>(); +} + +std::string FeatureFlagsMenu::text() const +{ + return TEXT_FEATUREFLAGS; +} + +void FeatureFlagsMenu::back() +{ + switchScreen(); +} diff --git a/main/displays/menus/featureflagsmenu.h b/main/displays/menus/featureflagsmenu.h new file mode 100644 index 0000000..b2e72ba --- /dev/null +++ b/main/displays/menus/featureflagsmenu.h @@ -0,0 +1,14 @@ +#pragma once + +// local includes +#include "displays/menudisplaywithtime.h" + +class FeatureFlagsMenu : public bobbygui::MenuDisplayWithTime +{ +public: + FeatureFlagsMenu(); + + std::string text() const override; + + void back() override; +}; diff --git a/main/displays/menus/garagenmenu.cpp b/main/displays/menus/garagenmenu.cpp index df5baae..c9dde7a 100644 --- a/main/displays/menus/garagenmenu.cpp +++ b/main/displays/menus/garagenmenu.cpp @@ -1,4 +1,3 @@ -#if defined(FEATURE_GARAGE) && defined (FEATURE_ESPNOW) #include "garagenmenu.h" // 3rd party libs @@ -66,4 +65,3 @@ void SendEspNowMessageAction::triggered() } } } // namespace -#endif diff --git a/main/displays/menus/garagenmenu.h b/main/displays/menus/garagenmenu.h index dfad599..495141b 100644 --- a/main/displays/menus/garagenmenu.h +++ b/main/displays/menus/garagenmenu.h @@ -1,7 +1,5 @@ #pragma once -#if defined(FEATURE_GARAGE) && defined (FEATURE_ESPNOW) - // local includes #include "displays/bobbymenudisplay.h" @@ -14,4 +12,3 @@ public: void back() override; }; -#endif diff --git a/main/displays/menus/ledstripmenu.cpp b/main/displays/menus/ledstripmenu.cpp index 908f1a5..1c68458 100644 --- a/main/displays/menus/ledstripmenu.cpp +++ b/main/displays/menus/ledstripmenu.cpp @@ -1,6 +1,5 @@ #include "ledstripmenu.h" -#ifdef FEATURE_LEDSTRIP // 3rdparty lib includes #include #include @@ -127,7 +126,11 @@ class AllCustomLedsOffAction : public virtual espgui::ActionInterface public: void triggered() override { - std::fill(std::begin(ledstrip_custom_colors), std::end(ledstrip_custom_colors), CRGB{0, 0, 0}); + // std::fill(std::begin(ledstrip_custom_colors), std::end(ledstrip_custom_colors), CRGB{0, 0, 0}); + for (uint8_t i = 0; i < configs.ledstrip.custom_color.size(); i++) + { + configs.write_config(configs.ledstrip.custom_color[i], 0); + } } }; @@ -163,9 +166,8 @@ LedstripMenu::LedstripMenu() if (!simplified) { constructMenuItem, espgui::SwitchScreenAction>>(); } constructMenuItem, espgui::SwitchScreenAction>>(); -#ifdef FEATURE_OTA - if (!simplified) { constructMenuItem, espgui::SwitchScreenAction>>(); } -#endif + if (configs.feature.ota.value) + if (!simplified) { constructMenuItem, espgui::SwitchScreenAction>>(); } constructMenuItem, espgui::SwitchScreenAction>>(); if (!simplified) { constructMenuItem, espgui::SwitchScreenAction>>(); } if (!simplified) { constructMenuItem, espgui::SwitchScreenAction>>(); } @@ -185,4 +187,3 @@ void LedstripMenu::back() { espgui::switchScreen(); } -#endif diff --git a/main/displays/menus/ledstripmenu.h b/main/displays/menus/ledstripmenu.h index 8ea46ee..2b8dce0 100644 --- a/main/displays/menus/ledstripmenu.h +++ b/main/displays/menus/ledstripmenu.h @@ -3,7 +3,6 @@ // local includes #include "displays/menudisplaywithtime.h" -#ifdef FEATURE_LEDSTRIP class LedstripMenu : public bobbygui::MenuDisplayWithTime { public: @@ -13,4 +12,3 @@ public: void back() override; }; -#endif diff --git a/main/displays/menus/ledstripselectblinkmenu.cpp b/main/displays/menus/ledstripselectblinkmenu.cpp index 04bed23..fe0f1a4 100644 --- a/main/displays/menus/ledstripselectblinkmenu.cpp +++ b/main/displays/menus/ledstripselectblinkmenu.cpp @@ -1,7 +1,5 @@ #include "ledstripselectblinkmenu.h" -#ifdef FEATURE_LEDSTRIP - // 3rdparty lib includes #include "actions/dummyaction.h" #include "actions/switchscreenaction.h" @@ -83,4 +81,3 @@ std::string CurrentSelectedBlinkAnimationText::text() const } } // namespace -#endif diff --git a/main/displays/menus/ledstripselectblinkmenu.h b/main/displays/menus/ledstripselectblinkmenu.h index 577fc29..77cdcb6 100644 --- a/main/displays/menus/ledstripselectblinkmenu.h +++ b/main/displays/menus/ledstripselectblinkmenu.h @@ -3,7 +3,6 @@ // Local includes #include "displays/bobbymenudisplay.h" -#ifdef FEATURE_LEDSTRIP class LedstripSelectBlinkMenu : public BobbyMenuDisplay { public: @@ -12,4 +11,3 @@ public: std::string text() const override; void back() override; }; -#endif diff --git a/main/displays/menus/ledstripselectotamode.cpp b/main/displays/menus/ledstripselectotamode.cpp index 3c8e71f..81dd95a 100644 --- a/main/displays/menus/ledstripselectotamode.cpp +++ b/main/displays/menus/ledstripselectotamode.cpp @@ -10,7 +10,6 @@ #include "utils.h" #include "ledstripmenu.h" -#if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA) namespace { constexpr char TEXT_BLINKANIMATION[] = "Blink animation"; constexpr char TEXT_OTAANIM_NONE[] = "None"; @@ -47,4 +46,3 @@ void LedstripOtaAnimationChangeMenu::back() { espgui::switchScreen(); } -#endif diff --git a/main/displays/menus/ledstripselectotamode.h b/main/displays/menus/ledstripselectotamode.h index 3bf4132..982f02c 100644 --- a/main/displays/menus/ledstripselectotamode.h +++ b/main/displays/menus/ledstripselectotamode.h @@ -3,7 +3,6 @@ // local includes #include "displays/bobbymenudisplay.h" -#if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA) class LedstripOtaAnimationChangeMenu : public BobbyMenuDisplay { public: @@ -12,4 +11,3 @@ public: std::string text() const override; void back() override; }; -#endif diff --git a/main/displays/menus/mainmenu.cpp b/main/displays/menus/mainmenu.cpp index dc99b3e..4b8e520 100644 --- a/main/displays/menus/mainmenu.cpp +++ b/main/displays/menus/mainmenu.cpp @@ -21,9 +21,7 @@ #include "displays/menus/demosmenu.h" #include "displays/menus/greenpassmenu.h" #include "displays/lockscreen.h" -#if defined(FEATURE_GARAGE) && defined (FEATURE_ESPNOW) #include "displays/menus/garagenmenu.h" -#endif #include "displays/menus/otamenu.h" #include "displays/poweroffdisplay.h" #include "displays/menus/statisticsmenu.h" @@ -39,12 +37,8 @@ #include "icons/settings.h" #include "icons/lock.h" #include "icons/demos.h" -#ifdef FEATURE_OTA #include "icons/update.h" -#endif -#ifdef FEATURE_LEDSTRIP #include "icons/neopixel.h" -#endif #include "icons/poweroff.h" #include "icons/reboot.h" #include "icons/statistics.h" @@ -89,9 +83,10 @@ MainMenu::MainMenu() // constructMenuItem>>(); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); -#ifdef FEATURE_LEDSTRIP - constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::neopixel>>>(); -#endif + if (configs.feature.ledstrip.value) + { + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::neopixel>>>(); + } constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::statistics>>>(); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::modes>>>(); if (SHOWITEM) { constructMenuItem, ModeSettingsAction>>(); } @@ -99,12 +94,12 @@ MainMenu::MainMenu() if (SHOWITEM) { constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::settings>>>(); } constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::greenpass>>>(); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::lock>>>(); -#if defined(FEATURE_GARAGE) && defined (FEATURE_ESPNOW) - if (SHOWITEM) { constructMenuItem, SwitchScreenAction>>(); } -#endif -#ifdef FEATURE_OTA - if (SHOWITEM) { constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::update>>>(); } -#endif + if (configs.feature.garage.value && configs.feature.esp_now.value) + { + if (SHOWITEM) { constructMenuItem, SwitchScreenAction>>(); } + } + if (configs.feature.ota.value) + if (SHOWITEM) { constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::update>>>(); } if (SHOWITEM) { constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::graph>>>(); } #if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY) if (SHOWITEM) { constructMenuItem, SwitchScreenAction>>(); } diff --git a/main/displays/menus/otamenu.cpp b/main/displays/menus/otamenu.cpp index 007e6e4..64dceb3 100644 --- a/main/displays/menus/otamenu.cpp +++ b/main/displays/menus/otamenu.cpp @@ -15,7 +15,6 @@ #include "displays/menus/mainmenu.h" #include "displays/updatedisplay.h" -#ifdef FEATURE_OTA namespace { constexpr char TEXT_UPDATE[] = "Update"; constexpr char TEXT_UPDATENOW[] = "Update now"; @@ -44,4 +43,3 @@ void OtaMenu::back() { espgui::switchScreen(); } -#endif diff --git a/main/displays/menus/selectbuildserverbranch.cpp b/main/displays/menus/selectbuildserverbranch.cpp index 5412f84..931c8e3 100644 --- a/main/displays/menus/selectbuildserverbranch.cpp +++ b/main/displays/menus/selectbuildserverbranch.cpp @@ -1,4 +1,3 @@ -#ifdef FEATURE_OTA #include "selectbuildserverbranch.h" // 3rd party includes @@ -164,4 +163,3 @@ void SelectBuildserverBranchMenu::buildMenuRequestError(std::string error) item.setTitle(error); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); } -#endif diff --git a/main/displays/menus/selectbuildserverbranch.h b/main/displays/menus/selectbuildserverbranch.h index 92a4fd1..d0326f4 100644 --- a/main/displays/menus/selectbuildserverbranch.h +++ b/main/displays/menus/selectbuildserverbranch.h @@ -3,8 +3,6 @@ // local includes #include "displays/bobbymenudisplay.h" -#ifdef FEATURE_OTA - class SelectBuildserverBranchMenu : public BobbyMenuDisplay { using Base = espgui::MenuDisplay; @@ -17,5 +15,3 @@ public: void update() override; void back() override; }; - -#endif diff --git a/main/displays/menus/selectbuildservermenu.cpp b/main/displays/menus/selectbuildservermenu.cpp index 87f6786..87b84d0 100644 --- a/main/displays/menus/selectbuildservermenu.cpp +++ b/main/displays/menus/selectbuildservermenu.cpp @@ -15,8 +15,6 @@ #include "utils.h" #include "newsettings.h" -#ifdef FEATURE_OTA - using namespace buildserver::SelectBuild; namespace { @@ -84,4 +82,3 @@ void SelectBuildServerMenu::back() { espgui::switchScreen(); } -#endif diff --git a/main/displays/menus/selectbuildservermenu.h b/main/displays/menus/selectbuildservermenu.h index bb84d20..7a3b26e 100644 --- a/main/displays/menus/selectbuildservermenu.h +++ b/main/displays/menus/selectbuildservermenu.h @@ -5,8 +5,6 @@ // local includes #include "displays/bobbymenudisplay.h" -#ifdef FEATURE_OTA - class SelectBuildServerMenu : public BobbyMenuDisplay { public: @@ -16,4 +14,3 @@ public: void back() override; }; -#endif diff --git a/main/displays/menus/selectotabuildmenu.cpp b/main/displays/menus/selectotabuildmenu.cpp index 7853c76..caa706a 100644 --- a/main/displays/menus/selectotabuildmenu.cpp +++ b/main/displays/menus/selectotabuildmenu.cpp @@ -15,7 +15,6 @@ #include "globals.h" #include "newsettings.h" -#ifdef FEATURE_OTA #define MESSAGE(text) constructMenuItem, DefaultFont, StaticColor, DummyAction>>() using namespace espgui; @@ -151,4 +150,3 @@ void SelectBuildMenu::back() { switchScreen(); } -#endif diff --git a/main/displays/menus/selectotabuildmenu.h b/main/displays/menus/selectotabuildmenu.h index 4eedc55..1e3c153 100644 --- a/main/displays/menus/selectotabuildmenu.h +++ b/main/displays/menus/selectotabuildmenu.h @@ -3,8 +3,6 @@ // local includes #include "displays/bobbymenudisplay.h" -#ifdef FEATURE_OTA - class SelectBuildMenu : public BobbyMenuDisplay { using Base = BobbyMenuDisplay; @@ -21,4 +19,3 @@ private: void buildMenuFromJson(); void buildMenuRequestError(std::string error); }; -#endif diff --git a/main/displays/menus/settingsmenu.cpp b/main/displays/menus/settingsmenu.cpp index 8ee2aa0..a6fb9d2 100644 --- a/main/displays/menus/settingsmenu.cpp +++ b/main/displays/menus/settingsmenu.cpp @@ -10,9 +10,7 @@ // local includes #include "utils.h" #include "icons/wifi.h" -#if defined(FEATURE_BLUETOOTH) || defined(FEATURE_BLE) #include "icons/bluetooth.h" -#endif #include "icons/time.h" #include "icons/hardware.h" #include "icons/buzzer.h" @@ -25,12 +23,8 @@ #include "displays/menus/networksettingsmenu.h" #include "displays/menus/bluetoothsettingsmenu.h" #include "displays/menus/blesettingsmenu.h" -#ifdef FEATURE_CLOUD #include "displays/menus/cloudsettingsmenu.h" -#endif -#ifdef FEATURE_UDPCLOUD #include "displays/menus/udpcloudsettingsmenu.h" -#endif #include "displays/menus/espnowmenu.h" #include "displays/menus/selectbuildservermenu.h" #include "displays/menus/timesettingsmenu.h" @@ -41,6 +35,7 @@ #include "displays/menus/crashmenu.h" #include "displays/menus/aboutmenu.h" #include "displays/menus/mainmenu.h" +#include "displays/menus/featureflagsmenu.h" #include "bobbycheckbox.h" namespace { @@ -58,6 +53,7 @@ constexpr char TEXT_TIME[] = "Time"; constexpr char TEXT_MODESSETTINGS[] = "Modes settings"; constexpr char TEXT_CONTROLLERHARDWARESETTINGS[] = "Controller H/W settings"; constexpr char TEXT_BOARDCOMPUTERHARDWARESETTINGS[] = "Boardcomputer H/W settings"; +constexpr char TEXT_FEATUREFLAGS[] = "Feature flags"; constexpr char TEXT_AUTOCONNECTBMS[] = "Auto connect BMS"; constexpr char TEXT_BUZZER[] = "Buzzer"; constexpr char TEXT_FRONTLED[] = "Front LED"; @@ -88,28 +84,24 @@ SettingsMenu::SettingsMenu() constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::wifi>>>(); -#ifdef FEATURE_ESPNOW - constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::wifi>>>(); -#endif + if (configs.feature.esp_now.value) + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::wifi>>>(); #ifdef FEATURE_BLUETOOTH constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::bluetooth>>>(); #endif -#ifdef FEATURE_BLE - constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::bluetooth>>>(); -#endif -#ifdef FEATURE_CLOUD - constructMenuItem, SwitchScreenAction>>(); -#endif -#ifdef FEATURE_UDPCLOUD - constructMenuItem, SwitchScreenAction>>(); -#endif -#ifdef FEATURE_OTA - constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::update>>>(); -#endif + if (configs.feature.ble.value) + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::bluetooth>>>(); + if (configs.feature.cloud.value) + constructMenuItem, SwitchScreenAction>>(); + if (configs.feature.udpcloud.value) + constructMenuItem, SwitchScreenAction>>(); + if (configs.feature.ota.value) + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::update>>>(); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::time>>>(); constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::hardware>>>(); constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::hardware>>>(); + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&bobbyicons::demos>>>(); //#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS) // constructMenuItem, BobbyCheckbox, AutoConnectBmsAccessor>>(); //#endif diff --git a/main/displays/menus/timesettingsmenu.cpp b/main/displays/menus/timesettingsmenu.cpp index 5a37766..1a5951f 100644 --- a/main/displays/menus/timesettingsmenu.cpp +++ b/main/displays/menus/timesettingsmenu.cpp @@ -69,7 +69,6 @@ using DaylightSavingModeChangeDisplay = espgui::makeComponent< espgui::BackActionInterface> >; -#ifdef FEATURE_NTP using TimeServerChangeDisplay = espgui::makeComponent< BobbyChangeValueDisplay, espgui::StaticText, @@ -102,7 +101,6 @@ public: return fmt::format("Status: {}", espcpputils::toString(sntp_get_sync_status())); } }; -#endif } // namespace TimeSettingsMenu::TimeSettingsMenu() @@ -112,13 +110,14 @@ TimeSettingsMenu::TimeSettingsMenu() constructMenuItem, DummyAction>>(); constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction>>(); -#ifdef FEATURE_NTP - constructMenuItem, BobbyCheckbox, TimeServerEnabledAccessor>>(); - constructMenuItem, SwitchScreenAction>>(); - constructMenuItem, SwitchScreenAction>>(); - constructMenuItem, SwitchScreenAction>>(); - constructMenuItem>(); -#endif + if (configs.feature.ntp.value) + { + constructMenuItem, BobbyCheckbox, TimeServerEnabledAccessor>>(); + constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); + constructMenuItem>(); + } constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); } diff --git a/main/displays/menus/udpcloudsettingsmenu.cpp b/main/displays/menus/udpcloudsettingsmenu.cpp index 1e8a32b..ed5f801 100644 --- a/main/displays/menus/udpcloudsettingsmenu.cpp +++ b/main/displays/menus/udpcloudsettingsmenu.cpp @@ -14,7 +14,6 @@ #include "displays/menus/settingsmenu.h" #include "bobbycheckbox.h" -#ifdef FEATURE_UDPCLOUD namespace { constexpr char TEXT_UDPCLOUDSETTINGS[] = "UDP Cloud settings"; constexpr char TEXT_UDPCLOUDENABLED[] = "Udp Cloud enabled"; @@ -50,4 +49,3 @@ void UdpCloudSettingsMenu::back() { switchScreen(); } -#endif diff --git a/main/displays/menus/udpcloudsettingsmenu.h b/main/displays/menus/udpcloudsettingsmenu.h index b5698a6..9719e0a 100644 --- a/main/displays/menus/udpcloudsettingsmenu.h +++ b/main/displays/menus/udpcloudsettingsmenu.h @@ -3,7 +3,6 @@ // local includes #include "displays/bobbymenudisplay.h" -#ifdef FEATURE_UDPCLOUD class UdpCloudSettingsMenu : public BobbyMenuDisplay { public: @@ -13,4 +12,3 @@ public: void back() override; }; -#endif diff --git a/main/displays/statusdisplay.cpp b/main/displays/statusdisplay.cpp index 7886131..4776696 100644 --- a/main/displays/statusdisplay.cpp +++ b/main/displays/statusdisplay.cpp @@ -103,7 +103,8 @@ void StatusDisplay::redraw() tft.fillRect(0, tft.height()-6, tft.width(), 6, TFT_BLACK); } } -#ifdef FEATURE_LEDSTRIP + + if(configs.feature.ledstrip.value) { static bool blink_fill_with_black; if (configs.ledstrip.enableVisualizeBlink.value && (espchrono::utc_clock::now().time_since_epoch() % 750ms < 375ms) && (blinkAnimation > 0)) @@ -126,7 +127,6 @@ void StatusDisplay::redraw() m_progressBarGas.start(); } } -#endif tft.setTextFont(2); m_labelRawGas.redraw(raw_gas ? std::to_string(*raw_gas) : "?"); @@ -150,16 +150,18 @@ void StatusDisplay::redraw() m_backStatus.redraw(controllers.back); tft.setTextFont(2); -#ifdef FEATURE_UDPCLOUD - if(configs.udpCloudSettings.udpCloudEnabled.value && configs.udpCloudSettings.enableCloudDebug.value) + + if (configs.feature.udpcloud.value) { - tft.fillRect(125, 258, 8, 8, (visualSendUdpPacket) ? TFT_DARKGREY : TFT_BLACK); + if(configs.udpCloudSettings.udpCloudEnabled.value && configs.udpCloudSettings.enableCloudDebug.value) + { + tft.fillRect(125, 258, 8, 8, (visualSendUdpPacket) ? TFT_DARKGREY : TFT_BLACK); + } +// else // is not needed because of redraw +// { +// tft.fillRect(125, 258, 8, 8, TFT_BLACK); +// } } -// else // is not needed because of redraw -// { -// tft.fillRect(125, 258, 8, 8, TFT_BLACK); -// } -#endif const auto staStatus = wifi_stack::get_sta_status(); if (staStatus == wifi_stack::WiFiStaStatus::CONNECTED) diff --git a/main/displays/updatedisplay.cpp b/main/displays/updatedisplay.cpp index 9ab6075..31a1b5c 100644 --- a/main/displays/updatedisplay.cpp +++ b/main/displays/updatedisplay.cpp @@ -10,10 +10,8 @@ // 3rdparty lib includes #include #include -#ifdef FEATURE_OTA #include #include -#endif // local includes #include "globals.h" @@ -21,7 +19,6 @@ #include "displays/menus/otamenu.h" #include "newsettings.h" -#ifdef FEATURE_OTA void UpdateDisplay::initScreen() { Base::initScreen(); @@ -118,4 +115,3 @@ void UpdateDisplay::buttonPressed(espgui::Button button) default:; } } -#endif diff --git a/main/displays/updatedisplay.h b/main/displays/updatedisplay.h index b845f3b..6a7e9d6 100644 --- a/main/displays/updatedisplay.h +++ b/main/displays/updatedisplay.h @@ -7,7 +7,6 @@ // local includes #include "bobbydisplay.h" -#ifdef FEATURE_OTA class UpdateDisplay : public BobbyDisplay { using Base = BobbyDisplay; @@ -28,4 +27,3 @@ private: espgui::Label m_newVersionLabel{20, 275}; }; -#endif diff --git a/main/dnsannounce.cpp b/main/dnsannounce.cpp index db9bb4a..017471e 100644 --- a/main/dnsannounce.cpp +++ b/main/dnsannounce.cpp @@ -1,14 +1,16 @@ -// 3rd party -#ifdef FEATURE_DNS_NS +#include "dnsannounce.h" + +// system includes +#include "lwip/dns.h" + +// 3rdparty includes +#include #include #include +#include #include -// local -#include "dnsannounce.h" -#include "espwifistack.h" -#include "cpputils.h" -#include "lwip/dns.h" +// local includes #include "globals.h" #include "newsettings.h" @@ -22,7 +24,7 @@ void init_dns_announce() void handle_dns_announce() { - if (!configs.dns_announce_enabled.value) + if (!configs.feature.dnsannounce.value || !configs.dns_announce_enabled.value) return; if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED) @@ -113,4 +115,3 @@ void handle_dns_announce() dns_lastIpAddress_v6_global = "-"; } } -#endif diff --git a/main/dnsannounce.h b/main/dnsannounce.h index 96c5ea7..cbc26f4 100644 --- a/main/dnsannounce.h +++ b/main/dnsannounce.h @@ -3,11 +3,9 @@ // system includes #include -#ifdef FEATURE_DNS_NS extern std::string dns_lastIpAddress_v4; extern std::string dns_lastIpAddress_v6; extern std::string dns_lastIpAddress_v6_global; void init_dns_announce(); void handle_dns_announce(); -#endif diff --git a/main/dpad6wire.cpp b/main/dpad6wire.cpp index a360c6f..285cbd9 100644 --- a/main/dpad6wire.cpp +++ b/main/dpad6wire.cpp @@ -85,9 +85,10 @@ std::array Helper::read() result[7] = digitalRead(IN4); result[9] = digitalRead(IN5); -#ifdef FEATURE_GSCHISSENE_DIODE - if (result[8] && result[9]) result[9] = 0; -#endif + if (configs.feature.gschissene_diode.value && (result[8] && result[9])) + { + result[9] = 0; + } return result; } diff --git a/main/espnowfunctions.cpp b/main/espnowfunctions.cpp index 48940f0..fe6b562 100644 --- a/main/espnowfunctions.cpp +++ b/main/espnowfunctions.cpp @@ -1,4 +1,3 @@ -#ifdef FEATURE_ESPNOW #include "espnowfunctions.h" #include @@ -309,4 +308,3 @@ esp_err_t send_espnow_message(std::string_view message) } } // namespace espnow -#endif diff --git a/main/espnowfunctions.h b/main/espnowfunctions.h index fa0f5a8..87749ca 100644 --- a/main/espnowfunctions.h +++ b/main/espnowfunctions.h @@ -1,5 +1,4 @@ #pragma once -#ifdef FEATURE_ESPNOW #include #include #include @@ -29,4 +28,4 @@ void handle(); void onRecvTs(uint64_t millis, bool isFromBobbycar = false); esp_err_t send_espnow_message(std::string_view message); } // namespace espnow -#endif + diff --git a/main/esptexthelpers.h b/main/esptexthelpers.h index f744cba..ca3bf31 100644 --- a/main/esptexthelpers.h +++ b/main/esptexthelpers.h @@ -41,8 +41,10 @@ class HeapLargest32Text : public virtual espgui::TextInterface { public: std::st class LastRebootReasonText : public virtual espgui::TextInterface { public: std::string text() const override { return fmt::format("Last Reboot Reason: {}", espcpputils::toString(esp_reset_reason())); }}; +#ifdef FEATURE_CAN class CanIcCrashText : public virtual espgui::TextInterface { public: std::string text() const override { return fmt::format("CAN IC reseted: {}", can::can_total_error_cnt); }}; +#endif constexpr char TEXT_ESPCHIPREVISION[] = "Chip revision: "; using EspChipRevisionText = espgui::StaticText; //EspStatusTextHelper; diff --git a/main/globals.cpp b/main/globals.cpp index e1d7f48..542e3da 100644 --- a/main/globals.cpp +++ b/main/globals.cpp @@ -32,8 +32,6 @@ bool simplified = ProfileSettings profileSettings; SettingsPersister settingsPersister; -std::array ledstrip_custom_colors; - Controllers controllers; #ifdef FEATURE_BLUETOOTH diff --git a/main/globals.h b/main/globals.h index ab12846..6eb72af 100644 --- a/main/globals.h +++ b/main/globals.h @@ -55,8 +55,6 @@ extern bool simplified; extern ProfileSettings profileSettings; extern SettingsPersister settingsPersister; -extern std::array ledstrip_custom_colors; - class Controllers : public std::array { public: diff --git a/main/icons/bluetooth.cpp b/main/icons/bluetooth.cpp index a0a3e35..62f1721 100644 --- a/main/icons/bluetooth.cpp +++ b/main/icons/bluetooth.cpp @@ -1,7 +1,6 @@ #include "bluetooth.h" namespace bobbyicons { -#if defined(FEATURE_BLUETOOTH) || defined(FEATURE_BLE) const espgui::Icon<24, 24> bluetooth{{ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x120F, 0x1A50, 0x0000, 0x01CF, 0x2AB1, 0x3B12, 0x4333, 0x4333, 0x3AF2, 0x2AB1, 0x01EF, // 0x0010 (16) pixels 0x0000, 0x1A50, 0x1210, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1210, 0x018E, 0x0007, 0x2AB1, // 0x0020 (32) pixels @@ -40,5 +39,4 @@ const espgui::Icon<24, 24> bluetooth{{ 0x19ED, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0230 (560) pixels 0x00A6, 0x21EC, 0x2A6F, 0x32B1, 0x32B1, 0x2A6F, 0x19EC, 0x00A6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0240 (576) pixels }, "bluetooth"}; -#endif } // namespace bobbyicons diff --git a/main/icons/bluetooth.h b/main/icons/bluetooth.h index 75697e1..30dc125 100644 --- a/main/icons/bluetooth.h +++ b/main/icons/bluetooth.h @@ -3,7 +3,5 @@ #include "icon.h" namespace bobbyicons { -#if defined(FEATURE_BLUETOOTH) || defined(FEATURE_BLE) extern const espgui::Icon<24, 24> bluetooth; -#endif } // namespace bobbyicons diff --git a/main/ledstrip.cpp b/main/ledstrip.cpp index 600784c..38083ad 100644 --- a/main/ledstrip.cpp +++ b/main/ledstrip.cpp @@ -13,7 +13,6 @@ using namespace std::chrono_literals; -#ifdef FEATURE_LEDSTRIP std::vector leds; uint8_t gHue = 0; @@ -22,13 +21,19 @@ uint16_t blinkAnimation = LEDSTRIP_OVERWRITE_NONE; void initLedStrip() { - leds.resize(configs.ledstrip.ledsCount.value); - FastLED.addLeds(&*std::begin(leds), leds.size()) - .setCorrection(TypicalSMD5050); + if (configs.feature.ledstrip.value) + { + leds.resize(configs.ledstrip.ledsCount.value); + FastLED.addLeds(&*std::begin(leds), leds.size()) + .setCorrection(TypicalSMD5050); + } } void updateLedStrip() { + if(!configs.feature.ledstrip.value) + return; + EVERY_N_MILLISECONDS( 20 ) { gHue++; } static bool have_disabled_beeper = false; const bool enAnim = configs.ledstrip.enableAnimBlink.value; @@ -195,9 +200,7 @@ void showAnimation() { if (configs.ledstrip.enableLedAnimation.value && !simplified -#ifdef FEATURE_OTA && !(asyncOtaTaskStarted && configs.ledstrip.otaMode.value != OtaAnimationModes::None) -#endif ) { switch (configs.ledstrip.animationType.value) @@ -209,20 +212,17 @@ void showAnimation() default: showDefaultLedstrip(); } } -#ifdef FEATURE_OTA else if (asyncOtaTaskStarted && configs.ledstrip.otaMode.value != OtaAnimationModes::None) { // show ota animation showOtaAnimation(); } -#endif else { std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0}); } } -#ifdef FEATURE_OTA void showOtaAnimation() { std::fill(std::begin(leds), std::end(leds), CRGB{0,0,0}); @@ -251,7 +251,6 @@ void showOtaAnimation() } } } -#endif void showBetterRainbow() { @@ -280,12 +279,6 @@ void fill_rainbow_invert_at( struct CRGB * pFirstLED, int numToFill, int invertA void showSpeedSyncAnimation() { -#ifdef LEDS_PER_METER - const float leds_per_meter = LEDS_PER_METER; -#else - const float leds_per_meter = 144; -#endif - static auto last_interval = espchrono::millis_clock::now(); const auto difference_ms = espchrono::ago(last_interval) / 1ms; @@ -293,7 +286,7 @@ void showSpeedSyncAnimation() const float hue_per_led = 1. / std::max(uint8_t(1), uint8_t(configs.ledstrip.animationMultiplier.value)); const float meter_per_second = avgSpeedKmh / 3.6; - const float leds_per_second = meter_per_second * leds_per_meter; + const float leds_per_second = meter_per_second * configs.ledstrip.leds_per_meter.value; const float hue_per_second = leds_per_second * hue_per_led; hue_result += hue_per_second * difference_ms / 1000.f; @@ -320,32 +313,30 @@ void showCustomColor() const auto eighth_length = leds.size() / 8; const auto center = (std::begin(leds) + (leds.size() / 2) + configs.ledstrip.centerOffset.value); - std::fill(std::begin(leds), std::end(leds), ledstrip_custom_colors[int(Bobbycar_Side::FRONT)]); // Front - std::fill(center - (eighth_length / 2), center + (eighth_length / 2), ledstrip_custom_colors[int(Bobbycar_Side::BACK)]); // Back + std::fill(std::begin(leds), std::end(leds), configs.ledstrip.custom_color[int(Bobbycar_Side::FRONT)].value); // Front + std::fill(center - (eighth_length / 2), center + (eighth_length / 2), configs.ledstrip.custom_color[int(Bobbycar_Side::BACK)].value); // Back #ifdef LEDSTRIP_WRONG_DIRECTION - std::fill(center + (eighth_length / 2), center + (eighth_length / 2) + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::BACK_LEFT)]); // Back Left - std::fill(center - (eighth_length / 2) - eighth_length, center - (eighth_length / 2), ledstrip_custom_colors[int(Bobbycar_Side::BACK_RIGHT)]); // Back Right + std::fill(center + (eighth_length / 2), center + (eighth_length / 2) + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::BACK_LEFT)].value); // Back Left + std::fill(center - (eighth_length / 2) - eighth_length, center - (eighth_length / 2), configs.ledstrip.custom_color[int(Bobbycar_Side::BACK_RIGHT)].value); // Back Right #else - std::fill(center + (eighth_length / 2), center + (eighth_length / 2) + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::BACK_RIGHT)]); // Back Right - std::fill(center - (eighth_length / 2) - eighth_length, center - (eighth_length / 2), ledstrip_custom_colors[int(Bobbycar_Side::BACK_LEFT)]); // Back Left + std::fill(center + (eighth_length / 2), center + (eighth_length / 2) + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::BACK_RIGHT)].value); // Back Right + std::fill(center - (eighth_length / 2) - eighth_length, center - (eighth_length / 2), configs.ledstrip.custom_color[int(Bobbycar_Side::BACK_LEFT)].value); // Back Left #endif #ifdef LEDSTRIP_WRONG_DIRECTION - std::fill(center + (eighth_length / 2) + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::LEFT)]); // Left - std::fill(center - (eighth_length / 2) - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::RIGHT)]); // Right + std::fill(center + (eighth_length / 2) + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::LEFT)].value); // Left + std::fill(center - (eighth_length / 2) - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::RIGHT)].value); // Right #else - std::fill(center + (eighth_length / 2) + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::RIGHT)]); // Right - std::fill(center - (eighth_length / 2) - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::LEFT)]); // Left + std::fill(center + (eighth_length / 2) + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::RIGHT)].value); // Right + std::fill(center - (eighth_length / 2) - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::LEFT)].value); // Left #endif #ifdef LEDSTRIP_WRONG_DIRECTION - std::fill(center + (eighth_length / 2) + eighth_length + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::FRONT_LEFT)]); // Front Left - std::fill(center - (eighth_length / 2) - eighth_length - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length - eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::FRONT_RIGHT)]); // Front Right + std::fill(center + (eighth_length / 2) + eighth_length + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::FRONT_LEFT)].value); // Front Left + std::fill(center - (eighth_length / 2) - eighth_length - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length - eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::FRONT_RIGHT)].value); // Front Right #else - std::fill(center + (eighth_length / 2) + eighth_length + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length + eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::FRONT_RIGHT)]); // Front Right - std::fill(center - (eighth_length / 2) - eighth_length - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length - eighth_length, ledstrip_custom_colors[int(Bobbycar_Side::FRONT_LEFT)]); // Front Left + std::fill(center + (eighth_length / 2) + eighth_length + eighth_length, center + (eighth_length / 2) + eighth_length + eighth_length + eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::FRONT_RIGHT)].value); // Front Right + std::fill(center - (eighth_length / 2) - eighth_length - eighth_length - eighth_length, center - (eighth_length / 2) - eighth_length - eighth_length, configs.ledstrip.custom_color[int(Bobbycar_Side::FRONT_LEFT)].value); // Front Left #endif } - -#endif diff --git a/main/ledstrip.h b/main/ledstrip.h index c1214ca..06f0037 100644 --- a/main/ledstrip.h +++ b/main/ledstrip.h @@ -23,7 +23,6 @@ DECLARE_BOBBYTYPESAFE_ENUM(OtaAnimationModes, : uint8_t, OtaAnimationModesValues x(CustomColor) DECLARE_BOBBYTYPESAFE_ENUM(LedstripAnimation, : uint8_t, LedstripAnimationValues) -#ifdef FEATURE_LEDSTRIP enum Bobbycar_Side { FRONT_RIGHT, @@ -46,10 +45,7 @@ void showAnimation(); void showBetterRainbow(); void showSpeedSyncAnimation(); void showCustomColor(); -#ifdef FEATURE_OTA void showOtaAnimation(); -#endif void initLedStrip(); void updateLedStrip(); -#endif diff --git a/main/main.cpp b/main/main.cpp index e77dcd1..b394d47 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -107,7 +107,8 @@ extern "C" void app_main() for (auto &schedulerTask : schedulerTasks) { - schedulerTask.loop(); + if (schedulerTask.isInitialized()) + schedulerTask.loop(); } if (!lastStatsUpdate || now - *lastStatsUpdate >= 1000ms/configs.boardcomputerHardware.timersSettings.statsUpdateRate.value) diff --git a/main/newsettings.h b/main/newsettings.h index d89c8eb..7a3c4c7 100644 --- a/main/newsettings.h +++ b/main/newsettings.h @@ -52,6 +52,21 @@ public: staticDns2 {wifi_stack::ip_address_t{}, DoReset, {}, staticDns2Key } {} + WiFiConfig(const char *ssidNvsKey, const char *keyNvsKey, + const char *useStaticIpKey, const char *staticIpKey, const char *staticSubnetKey, const char *staticGatewayKey, + const char *useStaticDnsKey, const char *staticDns0Key, const char *staticDns1Key, const char *staticDns2Key, const char *default_ssid, const char *default_key) : + ssid {default_ssid, DoReset, StringMaxSize<32>, ssidNvsKey }, + key {default_key, DoReset, StringOr>, keyNvsKey }, + useStaticIp {false, DoReset, {}, useStaticIpKey }, + staticIp {wifi_stack::ip_address_t{}, DoReset, {}, staticIpKey }, + staticSubnet {wifi_stack::ip_address_t{}, DoReset, {}, staticSubnetKey }, + staticGateway{wifi_stack::ip_address_t{}, DoReset, {}, staticGatewayKey }, + useStaticDns {false, DoReset, {}, useStaticDnsKey }, + staticDns0 {wifi_stack::ip_address_t{}, DoReset, {}, staticDns0Key }, + staticDns1 {wifi_stack::ip_address_t{}, DoReset, {}, staticDns1Key }, + staticDns2 {wifi_stack::ip_address_t{}, DoReset, {}, staticDns2Key } + {} + ConfigWrapper ssid; ConfigWrapper key; ConfigWrapper useStaticIp; @@ -98,7 +113,7 @@ public: ConfigWrapper hostname {defaultHostname, DoReset, StringMinMaxSize<4, 32>, "hostname" }; ConfigWrapper wifiStaEnabled {true, DoReset, {}, "wifiStaEnabled" }; std::array wifi_configs { - WiFiConfig {"wifi_ssid0", "wifi_key0", "wifi_usestatic0", "wifi_static_ip0", "wifi_stati_sub0", "wifi_stat_gate0", "wifi_usestadns0", "wifi_stat_dnsA0", "wifi_stat_dnsB0", "wifi_stat_dnsC0"}, + WiFiConfig {"wifi_ssid0", "wifi_key0", "wifi_usestatic0", "wifi_static_ip0", "wifi_stati_sub0", "wifi_stat_gate0", "wifi_usestadns0", "wifi_stat_dnsA0", "wifi_stat_dnsB0", "wifi_stat_dnsC0", "bobbycar", "12345678"}, WiFiConfig {"wifi_ssid1", "wifi_key1", "wifi_usestatic1", "wifi_static_ip1", "wifi_stati_sub1", "wifi_stat_gate1", "wifi_usestadns1", "wifi_stat_dnsA1", "wifi_stat_dnsB1", "wifi_stat_dnsC1"}, WiFiConfig {"wifi_ssid2", "wifi_key2", "wifi_usestatic2", "wifi_static_ip2", "wifi_stati_sub2", "wifi_stat_gate2", "wifi_usestadns2", "wifi_stat_dnsA2", "wifi_stat_dnsB2", "wifi_stat_dnsC2"}, WiFiConfig {"wifi_ssid3", "wifi_key3", "wifi_usestatic3", "wifi_static_ip3", "wifi_stati_sub3", "wifi_stat_gate3", "wifi_usestadns3", "wifi_stat_dnsA3", "wifi_stat_dnsB3", "wifi_stat_dnsC3"}, @@ -250,6 +265,17 @@ public: ConfigWrapper otaMode {OtaAnimationModes::GreenProgressBar, DoReset, {}, "ledOtaAnim" }; ConfigWrapper maxMilliamps {3000, DoReset, {}, "ledMaxMilliamps" }; ConfigWrapper enableVisualizeBlink {false, DoReset, {}, "enVisualBlink" }; + std::array, 8> custom_color { + ConfigWrapper {0, DoReset, {}, "ledCustomCol1" }, + ConfigWrapper {0, DoReset, {}, "ledCustomCol2" }, + ConfigWrapper {0, DoReset, {}, "ledCustomCol3" }, + ConfigWrapper {0, DoReset, {}, "ledCustomCol4" }, + ConfigWrapper {0, DoReset, {}, "ledCustomCol5" }, + ConfigWrapper {0, DoReset, {}, "ledCustomCol6" }, + ConfigWrapper {0, DoReset, {}, "ledCustomCol7" }, + ConfigWrapper {0, DoReset, {}, "ledCustomCol8" }, + }; + ConfigWrapper leds_per_meter {144, DoReset, {}, "ledsPerMeter" }; } ledstrip; struct { @@ -294,6 +320,21 @@ public: ConfigWrapper syncBlink {false, DoReset, {}, "espnowSyncBl" }; } espnow; + struct { + ConfigWrapper ledstrip {false, DoReset, {}, "f_ledstrip" }; + ConfigWrapper webserver_disable_lock{false, DoReset, {}, "f_no_web_lock" }; + ConfigWrapper garage {false, DoReset, {}, "f_garage" }; + ConfigWrapper cloud {false, DoReset, {}, "f_cloud" }; + ConfigWrapper udpcloud {false, DoReset, {}, "f_udpcloud" }; + ConfigWrapper dnsannounce {false, DoReset, {}, "f_dnsannounce" }; + ConfigWrapper ntp {false, DoReset, {}, "f_ntp" }; + ConfigWrapper ble {false, DoReset, {}, "f_ble" }; + ConfigWrapper ota {false, DoReset, {}, "f_ota" }; + ConfigWrapper webserver {true, DoReset, {}, "featureWebserv" }; + ConfigWrapper gschissene_diode {false, DoReset, {}, "featurDiodeHin" }; + ConfigWrapper esp_now {false, DoReset, {}, "featureEspNow" }; + } feature; + struct { ConfigWrapper bleEnabled {true, DoReset, {}, "bleEnabled" }; } bleSettings; @@ -542,6 +583,17 @@ public: x(ledstrip.maxMilliamps) \ x(ledstrip.enableVisualizeBlink) \ \ + x(ledstrip.custom_color[0]) \ + x(ledstrip.custom_color[1]) \ + x(ledstrip.custom_color[2]) \ + x(ledstrip.custom_color[3]) \ + x(ledstrip.custom_color[4]) \ + x(ledstrip.custom_color[5]) \ + x(ledstrip.custom_color[6]) \ + x(ledstrip.custom_color[7]) \ + \ + x(ledstrip.leds_per_meter) \ + \ x(battery.cellsSeries) \ x(battery.cellsParallel) \ x(battery.cellType) \ @@ -570,9 +622,36 @@ public: \ x(espnow.syncTime) \ x(espnow.syncTimeWithOthers) \ - x(espnow.syncBlink) + x(espnow.syncBlink) \ + \ + x(feature.ledstrip) \ + x(feature.webserver_disable_lock) \ + x(feature.garage) \ + x(feature.udpcloud) \ + x(feature.cloud) \ + x(feature.dnsannounce) \ + x(feature.ntp) \ + x(feature.ble) \ + x(feature.ota) \ + x(feature.webserver) \ + x(feature.gschissene_diode) \ + x(feature.esp_now) //x(bleSettings.bleEnabled) +#define FEATURES(x) \ + x(feature.ledstrip) \ + x(feature.webserver_disable_lock) \ + x(feature.garage) \ + x(feature.udpcloud) \ + x(feature.cloud) \ + x(feature.dnsannounce) \ + x(feature.ntp) \ + x(feature.ble) \ + x(feature.ota) \ + x(feature.esp_now) \ + x(feature.webserver) + //x(feature.gschisseneDiode) + template void callForEveryConfig(T &&callback) { @@ -591,6 +670,25 @@ public: std::ref(bleSettings.bleEnabled) ); } + + template + void callForEveryFeature(T &&callback) + { +#define HELPER(x) callback(x); + FEATURES(HELPER) +#undef HELPER + callback(feature.gschissene_diode); + } + + auto getAllFeatureParams() + { + return cpputils::make_array( +#define HELPER(x) std::ref(x), + FEATURES(HELPER) +#undef HELPER + std::ref(feature.gschissene_diode) + ); + } }; extern ConfigManager configs; diff --git a/main/ota.cpp b/main/ota.cpp index 06214ae..264aa01 100644 --- a/main/ota.cpp +++ b/main/ota.cpp @@ -6,7 +6,9 @@ // 3rdparty lib includes #include -#ifdef FEATURE_OTA +// local includes +#include "globals.h" + cpputils::DelayedConstruction asyncOta; bool asyncOtaTaskStarted{}; @@ -26,6 +28,9 @@ void handleOta() tl::expected triggerOta(std::string_view url) { + if (!configs.feature.ota.value) + return tl::make_unexpected("OTA is not enabled!"); + ESP_LOGI(TAG, "%.*s", url.size(), url.data()); if (!asyncOta) @@ -49,4 +54,3 @@ tl::expected triggerOta(std::string_view url) return {}; } -#endif diff --git a/main/ota.h b/main/ota.h index 0b501da..6eb41a0 100644 --- a/main/ota.h +++ b/main/ota.h @@ -1,18 +1,12 @@ #pragma once // 3rdparty lib includes -#ifdef FEATURE_OTA #include -#endif #include -// local includes - -#ifdef FEATURE_OTA extern cpputils::DelayedConstruction asyncOta; extern bool asyncOtaTaskStarted; void initOta(); void handleOta(); tl::expected triggerOta(std::string_view url); -#endif diff --git a/main/presets.h b/main/presets.h index ecc7f97..f42fea6 100644 --- a/main/presets.h +++ b/main/presets.h @@ -1,20 +1,7 @@ #pragma once -// esp-idf includes -#ifdef FEATURE_NTP -#include -#include -#endif - -// 3rdparty lib includes -#include - // local includes #include "profilesettings.h" -#include "ledstripdefines.h" -#include "ledstrip.h" - -using namespace std::chrono_literals; namespace presets { constexpr ProfileSettings::Limits defaultLimits { diff --git a/main/profilesettings.h b/main/profilesettings.h index 57d6e26..7b9e62e 100644 --- a/main/profilesettings.h +++ b/main/profilesettings.h @@ -2,21 +2,8 @@ // system includes #include -#include -#include - -// esp-idf includes -#include -#ifdef FEATURE_NTP -#include -#include -#endif - -// 3rdparty lib includes -#include // local includes -#include "bobbycar-common.h" #include "unifiedmodelmode.h" #include "modes/larsmmode.h" diff --git a/main/settingspersister.cpp b/main/settingspersister.cpp index 71efff0..f2ab9f1 100644 --- a/main/settingspersister.cpp +++ b/main/settingspersister.cpp @@ -6,10 +6,8 @@ // esp-idf includes #include #include -#ifdef FEATURE_NTP #include #include -#endif // 3rdparty lib includes #include @@ -209,7 +207,6 @@ template<> struct nvsGetterHelper { static esp_err_t nvs_get *out_value = espchrono::hours32(tempValue); return err; }}; -#ifdef FEATURE_NTP template<> struct nvsGetterHelper { static esp_err_t nvs_get(nvs_handle handle, const char* key, sntp_sync_mode_t* out_value) { uint8_t tempValue; @@ -218,7 +215,6 @@ template<> struct nvsGetterHelper { static esp_err_t nvs_get(n *out_value = sntp_sync_mode_t(tempValue); return err; }}; -#endif template<> struct nvsGetterHelper> { static esp_err_t nvs_get(nvs_handle handle, const char* key, std::array* out_value) { uint32_t tempValue; @@ -322,12 +318,10 @@ template<> struct nvsSetterHelper { static esp_err_t nvs_set { return nvs_set_i32(handle, key, value.count()); }}; -#ifdef FEATURE_NTP template<> struct nvsSetterHelper { static esp_err_t nvs_set(nvs_handle handle, const char* key, sntp_sync_mode_t value) { return nvs_set_u8(handle, key, uint8_t(value)); }}; -#endif template<> struct nvsSetterHelper> { static esp_err_t nvs_set(nvs_handle handle, const char* key, std::array value) { return nvs_set_u32(handle, key, std::bit_cast(value)); diff --git a/main/taskmanager.cpp b/main/taskmanager.cpp index ee1d64c..4063d49 100644 --- a/main/taskmanager.cpp +++ b/main/taskmanager.cpp @@ -9,9 +9,6 @@ // esp-idf includes #include -// 3rdparty lib includes -#include - // local includes #include "wifi_bobbycar.h" #include "dpad.h" @@ -33,9 +30,7 @@ #ifdef FEATURE_MOSFETS #include "mosfets.h" #endif -#ifdef FEATURE_NTP #include "time_bobbycar.h" -#endif #include "potis.h" #ifdef FEATURE_BLUETOOTH #include "bluetooth_bobby.h" @@ -50,32 +45,16 @@ #ifdef FEATURE_SERIAL #include "serial_bobby.h" #endif -#ifdef FEATURE_OTA #include "ota.h" -#endif -#ifdef FEATURE_BLE #include "ble_bobby.h" -#endif -#ifdef FEATURE_WEBSERVER #include "webserver.h" -#endif -#ifdef FEATURE_LEDSTRIP #include "ledstrip.h" -#endif -#ifdef FEATURE_ESPNOW #include "espnowfunctions.h" -#endif -#ifdef FEATURE_CLOUD #include "cloud.h" -#endif -#ifdef FEATURE_UDPCLOUD #include "udpcloud.h" -#endif #include "modes.h" #include "drivingstatistics.h" -#ifdef FEATURE_DNS_NS #include "dnsannounce.h" -#endif #include "screens.h" using namespace std::chrono_literals; @@ -85,81 +64,63 @@ constexpr const char * const TAG = "TASKS"; void not_needed() {} -espcpputils::SchedulerTask schedulerTasksArr[] { - espcpputils::SchedulerTask { "wifi", wifi_begin, wifi_update, 100ms }, +BobbySchedulerTask schedulerTasksArr[] { + BobbySchedulerTask { "wifi", wifi_begin, wifi_update, 100ms }, #ifdef FEATURE_DPAD - espcpputils::SchedulerTask { "dpad", dpad::init, dpad::update, 20ms }, + BobbySchedulerTask { "dpad", dpad::init, dpad::update, 20ms }, #endif #ifdef FEATURE_DPAD_3WIRESW - espcpputils::SchedulerTask { "dpad3wire", dpad3wire::init, dpad3wire::update, 20ms }, + BobbySchedulerTask { "dpad3wire", dpad3wire::init, dpad3wire::update, 20ms }, #endif #ifdef FEATURE_DPAD_5WIRESW - espcpputils::SchedulerTask { "dpad5wire", dpad5wire::init, dpad5wire::update, 20ms }, + BobbySchedulerTask { "dpad5wire", dpad5wire::init, dpad5wire::update, 20ms }, #endif #ifdef FEATURE_DPAD_5WIRESW_2OUT - espcpputils::SchedulerTask { "dpad5wire_2out", dpad5wire_2out::init, dpad5wire_2out::update, 20ms }, + BobbySchedulerTask { "dpad5wire_2out", dpad5wire_2out::init, dpad5wire_2out::update, 20ms }, #endif #ifdef FEATURE_DPAD_6WIRESW - espcpputils::SchedulerTask { "dpad6wire", dpad6wire::init, dpad6wire::update, 20ms }, + BobbySchedulerTask { "dpad6wire", dpad6wire::init, dpad6wire::update, 20ms }, #endif #ifdef FEATURE_ROTARY - espcpputils::SchedulerTask { "rotary", initRotary, updateRotary, 20ms }, + BobbySchedulerTask { "rotary", initRotary, updateRotary, 20ms }, #endif #ifdef FEATURE_MOSFETS - espcpputils::SchedulerTask { "mosfets", init_mosfets, update_mosfets, 100ms }, + BobbySchedulerTask { "mosfets", init_mosfets, update_mosfets, 100ms }, #endif -#ifdef FEATURE_NTP - espcpputils::SchedulerTask { "time", initTime, updateTime, 100ms }, -#endif - espcpputils::SchedulerTask { "potis", initPotis, readPotis, 20ms }, + BobbySchedulerTask { "time", initTime, updateTime, 100ms }, + BobbySchedulerTask { "potis", initPotis, readPotis, 20ms }, #ifdef FEATURE_BLUETOOTH - espcpputils::SchedulerTask { "bluetooth", bluetooth_init, bluetooth_update, 100ms }, + BobbySchedulerTask { "bluetooth", bluetooth_init, bluetooth_update, 100ms }, #ifdef FEATURE_BMS - espcpputils::SchedulerTask { "bms", bms::init, bms::update, 100ms }, + BobbySchedulerTask { "bms", bms::init, bms::update, 100ms }, #endif #endif #ifdef FEATURE_CAN - espcpputils::SchedulerTask { "can", can::initCan, can::updateCan, 10ms }, + BobbySchedulerTask { "can", can::initCan, can::updateCan, 10ms }, #endif - espcpputils::SchedulerTask { "debuginput", initDebugInput, handleDebugInput, 50ms }, + BobbySchedulerTask { "debuginput", initDebugInput, handleDebugInput, 50ms }, #ifdef FEATURE_SERIAL - espcpputils::SchedulerTask { "serial", initSerial, updateSerial, 50ms }, + BobbySchedulerTask { "serial", initSerial, updateSerial, 50ms }, #endif -#ifdef FEATURE_OTA - espcpputils::SchedulerTask { "ota", initOta, handleOta, 50ms }, -#endif -#ifdef FEATURE_BLE - espcpputils::SchedulerTask { "ble", initBle, handleBle, 100ms }, -#endif -#ifdef FEATURE_WEBSERVER - espcpputils::SchedulerTask { "webserver", initWebserver, handleWebserver, 100ms }, -#endif -#ifdef FEATURE_LEDSTRIP - espcpputils::SchedulerTask { "ledstrip", initLedStrip, updateLedStrip, 30ms }, -#endif -#ifdef FEATURE_ESPNOW - espcpputils::SchedulerTask { "espnow", espnow::initESPNow, espnow::handle, 100ms }, -#endif -#ifdef FEATURE_CLOUD - espcpputils::SchedulerTask { "cloud", initCloud, updateCloud, 50ms }, -#endif -#ifdef FEATURE_UDPCLOUD - espcpputils::SchedulerTask { "udpcloud", udpCloudInit, udpCloudUpdate, 50ms }, -#endif - espcpputils::SchedulerTask { "drivingmode", initDrivingMode, updateDrivingMode, 20ms }, - espcpputils::SchedulerTask { "drivingstatistics", initStatistics, calculateStatistics, 100ms }, -#ifdef FEATURE_DNS_NS - espcpputils::SchedulerTask { "dnsannounce", init_dns_announce, handle_dns_announce, 100ms }, -#endif - espcpputils::SchedulerTask { "updateDisp", not_needed, updateDisplay, 20ms }, - espcpputils::SchedulerTask { "redrawDisp", not_needed, redrawDisplay, 20ms }, + BobbySchedulerTask { "ota", initOta, handleOta, 50ms }, + BobbySchedulerTask { "ble", initBle, handleBle, 100ms }, + BobbySchedulerTask { "webserver", initWebserver, handleWebserver, 100ms }, + BobbySchedulerTask { "ledstrip", initLedStrip, updateLedStrip, 30ms }, + BobbySchedulerTask { "espnow", espnow::initESPNow, espnow::handle, 100ms }, + BobbySchedulerTask { "cloud", initCloud, updateCloud, 50ms }, + BobbySchedulerTask { "udpcloud", udpCloudInit, udpCloudUpdate, 50ms }, + BobbySchedulerTask { "drivingmode", initDrivingMode, updateDrivingMode, 20ms }, + BobbySchedulerTask { "drivingstatistics", initStatistics, calculateStatistics, 100ms }, + BobbySchedulerTask { "dnsannounce", init_dns_announce, handle_dns_announce, 100ms }, + BobbySchedulerTask { "updateDisp", not_needed, updateDisplay, 20ms }, + BobbySchedulerTask { "redrawDisp", not_needed, redrawDisplay, 20ms }, }; } // namespace -cpputils::ArrayView schedulerTasks{std::begin(schedulerTasksArr), std::end(schedulerTasksArr)}; +cpputils::ArrayView schedulerTasks{std::begin(schedulerTasksArr), std::end(schedulerTasksArr)}; -const espcpputils::SchedulerTask &drivingModeTask = []() -> const espcpputils::SchedulerTask & { - auto iter = std::find_if(std::begin(schedulerTasksArr), std::end(schedulerTasksArr), [](const espcpputils::SchedulerTask &task){ +const BobbySchedulerTask &drivingModeTask = []() -> const BobbySchedulerTask & { + auto iter = std::find_if(std::begin(schedulerTasksArr), std::end(schedulerTasksArr), [](const BobbySchedulerTask &task){ return std::string_view{task.name()} == "drivingmode"; }); return *iter; diff --git a/main/taskmanager.h b/main/taskmanager.h index b83c937..27a2308 100644 --- a/main/taskmanager.h +++ b/main/taskmanager.h @@ -3,11 +3,11 @@ // 3rdparty lib includes #include -// forward declares -namespace espcpputils { class SchedulerTask; } +// local includes +#include "bobbyschedulertask.h" -extern cpputils::ArrayView schedulerTasks; +extern cpputils::ArrayView schedulerTasks; -extern const espcpputils::SchedulerTask &drivingModeTask; +extern const BobbySchedulerTask &drivingModeTask; void sched_pushStats(bool printTasks); diff --git a/main/time_bobbycar.cpp b/main/time_bobbycar.cpp index a0a4cc9..4abf988 100644 --- a/main/time_bobbycar.cpp +++ b/main/time_bobbycar.cpp @@ -2,10 +2,8 @@ // esp-idf includes #include -#ifdef FEATURE_NTP #include #include -#endif // 3rdparty lib includes #include @@ -30,7 +28,6 @@ namespace { constexpr const char * const TAG = "BOBBYTIME"; } // namespace -#ifdef FEATURE_NTP void time_sync_notification_cb(struct timeval *tv); void initTime() @@ -54,6 +51,9 @@ void initTime() void updateTime() { + if (!configs.feature.ntp.value) + return; + if (bool(sntp_enabled()) != configs.timeServerEnabled.value) { if (configs.timeServerEnabled.value) @@ -107,7 +107,6 @@ void time_sync_notification_cb(struct timeval *tv) else ESP_LOGI("BOBBY", "nullptr"); } -#endif void time_set_now(espchrono::utc_clock::time_point now) { diff --git a/main/time_bobbycar.h b/main/time_bobbycar.h index 5e38aa0..358a873 100644 --- a/main/time_bobbycar.h +++ b/main/time_bobbycar.h @@ -7,9 +7,7 @@ espchrono::time_zone get_default_timezone() noexcept; -#ifdef FEATURE_NTP void initTime(); void updateTime(); -#endif void time_set_now(espchrono::utc_clock::time_point now); diff --git a/main/udpcloud.cpp b/main/udpcloud.cpp index 27bee48..1062b70 100644 --- a/main/udpcloud.cpp +++ b/main/udpcloud.cpp @@ -21,7 +21,6 @@ #include "drivingstatistics.h" #include "newsettings.h" -#ifdef FEATURE_UDPCLOUD using namespace std::chrono_literals; namespace { @@ -40,6 +39,9 @@ void udpCloudInit() void udpCloudUpdate() { + if (!configs.feature.udpcloud.value) + return; + if (configs.udpCloudSettings.udpCloudEnabled.value && configs.udpCloudSettings.udpUid.touched()) sendUdpCloudPacket(); } @@ -372,4 +374,3 @@ void sendUdpCloudPacket() visualSendUdpPacket = !visualSendUdpPacket; } } -#endif diff --git a/main/udpcloud.h b/main/udpcloud.h index 15ec9ff..71976ee 100644 --- a/main/udpcloud.h +++ b/main/udpcloud.h @@ -3,7 +3,6 @@ // system includes #include -#ifdef FEATURE_UDPCLOUD // Little "flash" on statusdisplay when udp stuff is happening extern bool visualSendUdpPacket; @@ -14,4 +13,3 @@ void spamUdpBroadcast(); std::string buildUdpCloudJson(); std::string buildUdpCloudString(); void sendUdpCloudPacket(); -#endif diff --git a/main/utils.h b/main/utils.h index bc22fd0..6003dde 100644 --- a/main/utils.h +++ b/main/utils.h @@ -61,3 +61,19 @@ float wattToMotorCurrent(float watt); uint8_t time_to_percent(espchrono::milliseconds32 repeat, espchrono::milliseconds32 riseTime, espchrono::milliseconds32 fullTime, size_t numLeds, bool invert); std::string local_clock_string(); int16_t map_analog_stick(uint16_t middle, uint16_t start, uint16_t end, uint16_t raw); + +inline uint32_t CRGB_TO_UINT32(CRGB crgb) +{ + return crgb.raw[0]<<16 | crgb.raw[1]<<8 | crgb.raw[2]; +} + +inline CRGB UINT32_TO_CRGB(uint32_t color) +{ + CRGB crgb; + + crgb.raw[0]=color>>16 & 0xFF; + crgb.raw[1]=color>>8 & 0xFF; + crgb.raw[2]=color & 0xFF; + + return crgb; +} diff --git a/main/webserver.cpp b/main/webserver.cpp index 9812683..59db95c 100644 --- a/main/webserver.cpp +++ b/main/webserver.cpp @@ -20,20 +20,15 @@ // local includes #include "webserver_lock.h" #include "webserver_displaycontrol.h" -#ifdef FEATURE_OTA #include "webserver_ota.h" -#endif #include "webserver_settings.h" #include "webserver_newsettings.h" -#ifdef OLD_NVS #include "webserver_dumpnvs.h" -#endif #include "globals.h" #include "newsettings.h" using namespace std::chrono_literals; -#ifdef FEATURE_WEBSERVER namespace { constexpr const char * const TAG = "BOBBYWEB"; @@ -45,16 +40,42 @@ std::vector> menuBuf{}; esp_err_t webserver_reboot_handler(httpd_req_t *req); bool menuDisplayChanged(); esp_err_t webserver_status_handler(httpd_req_t *req); -} // namespace bobbywebserver + +esp_err_t webserver_middleware_handler(httpd_req_t *req) { + const auto handler = reinterpret_cast(req->user_ctx); + + if (configs.feature.webserver_disable_lock.value) + { + return handler(req); + } + + if (!webserver_lock.constructed()) + { + webserver_lock.construct(); + webserver_lock->take(portMAX_DELAY); + } + + espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; + if (!helper.locked()) + { + constexpr const std::string_view msg = "could not lock webserver_lock"; + ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); + CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); + } + + return handler(req); +} +} // namespace httpd_handle_t httpdHandle; void initWebserver() { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - webserver_lock.construct(); - webserver_lock->take(portMAX_DELAY); -#endif + if(!configs.feature.webserver_disable_lock.value) + { + webserver_lock.construct(); + webserver_lock->take(portMAX_DELAY); + } { httpd_config_t httpConfig HTTPD_DEFAULT_CONFIG(); @@ -69,26 +90,22 @@ void initWebserver() } for (const httpd_uri_t &uri : { - httpd_uri_t { .uri = "/", .method = HTTP_GET, .handler = webserver_root_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/triggerRawButton", .method = HTTP_GET, .handler = webserver_triggerRawButton_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/triggerButton", .method = HTTP_GET, .handler = webserver_triggerButton_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/triggerItem", .method = HTTP_GET, .handler = webserver_triggerItem_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/setValue", .method = HTTP_GET, .handler = webserver_setValue_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/reboot", .method = HTTP_GET, .handler = webserver_reboot_handler, .user_ctx = NULL }, -#ifdef FEATURE_OTA - httpd_uri_t { .uri = "/ota", .method = HTTP_GET, .handler = webserver_ota_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/otaPercent", .method = HTTP_GET, .handler = webserver_ota_percentage_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/triggerOta", .method = HTTP_GET, .handler = webserver_trigger_ota_handler, .user_ctx = NULL }, -#endif - httpd_uri_t { .uri = "/settings", .method = HTTP_GET, .handler = webserver_settings_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/saveSettings", .method = HTTP_GET, .handler = webserver_saveSettings_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/newSettings", .method = HTTP_GET, .handler = webserver_newSettings_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/saveNewSettings", .method = HTTP_GET, .handler = webserver_saveNewSettings_handler, .user_ctx = NULL }, - httpd_uri_t { .uri = "/resetNewSettings", .method = HTTP_GET, .handler = webserver_resetNewSettings_handler, .user_ctx = NULL }, -#ifdef OLD_NVS - httpd_uri_t { .uri = "/dumpnvs", .method = HTTP_GET, .handler = webserver_dump_nvs_handler, .user_ctx = NULL }, -#endif - httpd_uri_t { .uri = "/check", .method = HTTP_GET, .handler = webserver_status_handler, .user_ctx = NULL }, + httpd_uri_t { .uri = "/", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_root_handler, }, + httpd_uri_t { .uri = "/triggerRawButton", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_triggerRawButton_handler, }, + httpd_uri_t { .uri = "/triggerButton", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_triggerButton_handler, }, + httpd_uri_t { .uri = "/triggerItem", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_triggerItem_handler, }, + httpd_uri_t { .uri = "/setValue", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_setValue_handler, }, + httpd_uri_t { .uri = "/reboot", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_reboot_handler, }, + httpd_uri_t { .uri = "/ota", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_ota_handler, }, + httpd_uri_t { .uri = "/otaPercent", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_ota_percentage_handler, }, + httpd_uri_t { .uri = "/triggerOta", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_trigger_ota_handler, }, + httpd_uri_t { .uri = "/settings", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_settings_handler, }, + httpd_uri_t { .uri = "/saveSettings", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_saveSettings_handler, }, + httpd_uri_t { .uri = "/newSettings", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_newSettings_handler, }, + httpd_uri_t { .uri = "/saveNewSettings", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_saveNewSettings_handler, }, + httpd_uri_t { .uri = "/resetNewSettings", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_resetNewSettings_handler, }, + httpd_uri_t { .uri = "/dumpnvs", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_dump_nvs_handler, }, + httpd_uri_t { .uri = "/check", .method = HTTP_GET, .handler = webserver_middleware_handler, .user_ctx = (void*)&webserver_status_handler, }, }) { const auto result = httpd_register_uri_handler(httpdHandle, &uri); @@ -100,11 +117,12 @@ void initWebserver() void handleWebserver() { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - webserver_lock->give(); - vTaskDelay(1); - webserver_lock->take(portMAX_DELAY); -#endif + if (!configs.feature.webserver_disable_lock.value) + { + webserver_lock->give(); + vTaskDelay(1); + webserver_lock->take(portMAX_DELAY); + } } namespace { @@ -165,16 +183,8 @@ bool menuDisplayChanged() esp_err_t webserver_status_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud"); + std::string wants_json_query; if (auto result = esphttpdutils::webserver_get_query(req)) wants_json_query = *result; @@ -207,4 +217,3 @@ esp_err_t webserver_status_handler(httpd_req_t *req) } } // namespace -#endif diff --git a/main/webserver.h b/main/webserver.h index 6312b93..ae61cd2 100644 --- a/main/webserver.h +++ b/main/webserver.h @@ -1,14 +1,10 @@ #pragma once // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif -#ifdef FEATURE_WEBSERVER extern httpd_handle_t httpdHandle; void initWebserver(); void handleWebserver(); bool MenuDisplayChanged(); -#endif diff --git a/main/webserver_displaycontrol.cpp b/main/webserver_displaycontrol.cpp index 7e9ef9d..bd92d52 100644 --- a/main/webserver_displaycontrol.cpp +++ b/main/webserver_displaycontrol.cpp @@ -1,9 +1,7 @@ #include "webserver_displaycontrol.h" // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif #include // 3rdparty lib includes @@ -26,7 +24,6 @@ #include "webserver_lock.h" #include "newsettings.h" -#ifdef FEATURE_WEBSERVER using esphttpdutils::HtmlTag; using namespace std::chrono_literals; @@ -36,15 +33,6 @@ constexpr const char * const TAG = "BOBBYWEB"; esp_err_t webserver_root_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif std::string body; @@ -180,10 +168,7 @@ esp_err_t webserver_root_handler(httpd_req_t *req) { HtmlTag pTag{"p", body}; body += "Display control - " -#ifdef FEATURE_OTA "Update - " -#endif - "Settings - " "New Settings - " "Dump NVS"; @@ -288,15 +273,6 @@ esp_err_t webserver_root_handler(httpd_req_t *req) esp_err_t webserver_triggerRawButton_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif std::string query; if (auto result = esphttpdutils::webserver_get_query(req)) @@ -362,15 +338,6 @@ esp_err_t webserver_triggerRawButton_handler(httpd_req_t *req) esp_err_t webserver_triggerButton_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif std::string query; if (auto result = esphttpdutils::webserver_get_query(req)) @@ -436,15 +403,7 @@ esp_err_t webserver_triggerButton_handler(httpd_req_t *req) esp_err_t webserver_triggerItem_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif + CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud"); std::string query; @@ -525,15 +484,6 @@ esp_err_t webserver_triggerItem_handler(httpd_req_t *req) esp_err_t webserver_setValue_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud"); @@ -610,4 +560,3 @@ esp_err_t webserver_setValue_handler(httpd_req_t *req) CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Location", "/") CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::TemporaryRedirect, "text/html", "Ok, continue at /") } -#endif diff --git a/main/webserver_displaycontrol.h b/main/webserver_displaycontrol.h index 90a6fbf..3ba9dfb 100644 --- a/main/webserver_displaycontrol.h +++ b/main/webserver_displaycontrol.h @@ -1,15 +1,11 @@ #pragma once // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif #include -#ifdef FEATURE_WEBSERVER esp_err_t webserver_root_handler(httpd_req_t *req); esp_err_t webserver_triggerRawButton_handler(httpd_req_t *req); esp_err_t webserver_triggerButton_handler(httpd_req_t *req); esp_err_t webserver_triggerItem_handler(httpd_req_t *req); esp_err_t webserver_setValue_handler(httpd_req_t *req); -#endif diff --git a/main/webserver_dumpnvs.cpp b/main/webserver_dumpnvs.cpp index 07c721b..0eaa6e8 100644 --- a/main/webserver_dumpnvs.cpp +++ b/main/webserver_dumpnvs.cpp @@ -1,9 +1,7 @@ #include "webserver_dumpnvs.h" // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif #include // 3rdparty lib includes @@ -38,9 +36,7 @@ typename std::enable_if< !std::is_same::value && !std::is_same::value && !std::is_same::value -#if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA) && !std::is_same::value -#endif , bool>::type showInputForSetting(std::string_view key, T value, JsonObject &body) { @@ -120,8 +116,6 @@ showInputForSetting(std::string_view key, T value, JsonObject &body) return true; } -#if defined(FEATURE_LEDSTRIP) && defined(FEATURE_OTA) - template typename std::enable_if< std::is_same::value @@ -131,21 +125,19 @@ showInputForSetting(std::string_view key, T value, JsonObject &body) body[key] = int(value); return true; } -#endif esp_err_t webserver_dump_nvs_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif DynamicJsonDocument doc(6144); + + JsonObject settings = doc.createNestedObject("settings"); + + configs.callForEveryConfig([&](auto &config){ + const std::string_view nvsName{config.nvsName()}; + showInputForSetting(nvsName, config.value, settings); + }); + const auto profile = settingsPersister.currentlyOpenProfileIndex(); const auto switchBackProfile = profile ? int(*profile) : 0; @@ -165,10 +157,9 @@ esp_err_t webserver_dump_nvs_handler(httpd_req_t *req) const auto profile_str = cur_profile ? std::to_string(*cur_profile) : "-"; JsonObject profile = profiles.createNestedObject(profile_str); - JsonObject profile_settings = profile.createNestedObject("settings"); profileSettings.executeForEveryProfileSetting([&](const char *key, auto &value){ - showInputForSetting(key, value, profile_settings); + showInputForSetting(key, value, profile); }); } diff --git a/main/webserver_dumpnvs.h b/main/webserver_dumpnvs.h index 9653e26..8ab5084 100644 --- a/main/webserver_dumpnvs.h +++ b/main/webserver_dumpnvs.h @@ -1,12 +1,8 @@ #pragma once // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif #include -#ifdef FEATURE_WEBSERVER esp_err_t webserver_dump_nvs_handler(httpd_req_t *req); -#endif diff --git a/main/webserver_lock.cpp b/main/webserver_lock.cpp index c2215f9..ae0dbe1 100644 --- a/main/webserver_lock.cpp +++ b/main/webserver_lock.cpp @@ -1,5 +1,3 @@ #include "webserver_lock.h" -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET cpputils::DelayedConstruction webserver_lock; -#endif diff --git a/main/webserver_lock.h b/main/webserver_lock.h index e6f2429..ddb94b5 100644 --- a/main/webserver_lock.h +++ b/main/webserver_lock.h @@ -4,6 +4,4 @@ #include #include -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET extern cpputils::DelayedConstruction webserver_lock; -#endif diff --git a/main/webserver_newsettings.cpp b/main/webserver_newsettings.cpp index 8b65352..f88bc23 100644 --- a/main/webserver_newsettings.cpp +++ b/main/webserver_newsettings.cpp @@ -4,9 +4,7 @@ #include // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif #include // 3rdparty lib includes @@ -24,7 +22,6 @@ #include "newsettings.h" #include "webserver_lock.h" -#ifdef FEATURE_WEBSERVER using namespace std::chrono_literals; using esphttpdutils::HtmlTag; @@ -262,16 +259,6 @@ showInputForSetting(std::string_view key, T value, std::string &body) esp_err_t webserver_newSettings_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - ESP_LOGI(TAG, "trying to lock..."); - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif std::string body; @@ -316,9 +303,7 @@ esp_err_t webserver_newSettings_handler(httpd_req_t *req) { HtmlTag pTag{"p", body}; body += "Display control - " -#ifdef FEATURE_OTA "Update - " -#endif "Settings - " "New Settings - " "Dump NVS"; @@ -507,15 +492,6 @@ saveSetting(ConfigWrapper &config, std::string_view newValue) esp_err_t webserver_saveNewSettings_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif std::string query; if (auto result = esphttpdutils::webserver_get_query(req)) @@ -576,15 +552,6 @@ esp_err_t webserver_saveNewSettings_handler(httpd_req_t *req) esp_err_t webserver_resetNewSettings_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif std::string query; if (auto result = esphttpdutils::webserver_get_query(req)) @@ -644,4 +611,3 @@ esp_err_t webserver_resetNewSettings_handler(httpd_req_t *req) "text/plain", body) } -#endif diff --git a/main/webserver_newsettings.h b/main/webserver_newsettings.h index cbdaa55..d95eb54 100644 --- a/main/webserver_newsettings.h +++ b/main/webserver_newsettings.h @@ -1,13 +1,9 @@ #pragma once // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif #include -#ifdef FEATURE_WEBSERVER esp_err_t webserver_newSettings_handler(httpd_req_t *req); esp_err_t webserver_saveNewSettings_handler(httpd_req_t *req); esp_err_t webserver_resetNewSettings_handler(httpd_req_t *req); -#endif diff --git a/main/webserver_ota.cpp b/main/webserver_ota.cpp index f2546ce..fa3038a 100644 --- a/main/webserver_ota.cpp +++ b/main/webserver_ota.cpp @@ -1,9 +1,7 @@ #include "webserver_ota.h" // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif #include #include @@ -17,14 +15,11 @@ #include // local includes -#ifdef FEATURE_OTA #include "ota.h" -#endif #include "webserver_lock.h" #include "globals.h" #include "newsettings.h" -#if defined(FEATURE_WEBSERVER) && defined(FEATURE_OTA) using namespace std::chrono_literals; using esphttpdutils::HtmlTag; @@ -34,16 +29,9 @@ constexpr const char * const TAG = "BOBBYWEB"; esp_err_t webserver_ota_percentage_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif + CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud"); + std::string body; std::string wants_json_query; @@ -93,16 +81,9 @@ esp_err_t webserver_ota_percentage_handler(httpd_req_t *req) esp_err_t webserver_ota_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif + CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud"); + std::string body; std::string wants_json_query; @@ -361,16 +342,9 @@ esp_err_t webserver_ota_handler(httpd_req_t *req) esp_err_t webserver_trigger_ota_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif + CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud"); + std::string query; if (auto result = esphttpdutils::webserver_get_query(req)) query = *result; @@ -416,4 +390,3 @@ esp_err_t webserver_trigger_ota_handler(httpd_req_t *req) CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Location", "/ota") CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::TemporaryRedirect, "text/html", "Ok, continue at /") } -#endif diff --git a/main/webserver_ota.h b/main/webserver_ota.h index c76ed46..b6711e4 100644 --- a/main/webserver_ota.h +++ b/main/webserver_ota.h @@ -1,13 +1,9 @@ #pragma once // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif #include -#if defined(FEATURE_WEBSERVER) && defined(FEATURE_OTA) esp_err_t webserver_ota_handler(httpd_req_t *req); esp_err_t webserver_ota_percentage_handler(httpd_req_t *req); esp_err_t webserver_trigger_ota_handler(httpd_req_t *req); -#endif diff --git a/main/webserver_settings.cpp b/main/webserver_settings.cpp index 927b7a6..a805a47 100644 --- a/main/webserver_settings.cpp +++ b/main/webserver_settings.cpp @@ -4,9 +4,7 @@ #include // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif #include // 3rdparty lib includes @@ -22,7 +20,6 @@ #include "globals.h" #include "webserver_lock.h" -#ifdef FEATURE_WEBSERVER using namespace std::chrono_literals; using esphttpdutils::HtmlTag; @@ -89,15 +86,6 @@ showInputForSetting(std::string_view key, T value, std::string &body) esp_err_t webserver_settings_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif std::string body; @@ -142,9 +130,7 @@ esp_err_t webserver_settings_handler(httpd_req_t *req) { HtmlTag pTag{"p", body}; body += "Display control - " -#ifdef FEATURE_OTA "Update - " -#endif "Settings - " "New Settings - " "Dump NVS"; @@ -257,15 +243,6 @@ saveSetting(T &value, std::string_view newValue, std::string &body) esp_err_t webserver_saveSettings_handler(httpd_req_t *req) { -#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET - espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil(5s).count()}; - if (!helper.locked()) - { - constexpr const std::string_view msg = "could not lock webserver_lock"; - ESP_LOGE(TAG, "%.*s", msg.size(), msg.data()); - CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg); - } -#endif std::string query; if (auto result = esphttpdutils::webserver_get_query(req)) @@ -326,4 +303,3 @@ esp_err_t webserver_saveSettings_handler(httpd_req_t *req) "text/plain", body) } -#endif diff --git a/main/webserver_settings.h b/main/webserver_settings.h index db6c309..b55cb3f 100644 --- a/main/webserver_settings.h +++ b/main/webserver_settings.h @@ -1,12 +1,8 @@ #pragma once // esp-idf includes -#ifdef FEATURE_WEBSERVER #include -#endif #include -#ifdef FEATURE_WEBSERVER esp_err_t webserver_settings_handler(httpd_req_t *req); esp_err_t webserver_saveSettings_handler(httpd_req_t *req); -#endif