From d177829fb6d2934b1f4a497a1bd65ef46f2ba924 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 22 Mar 2024 14:03:51 +1100 Subject: [PATCH 1/3] AP_HAL_ChibiOS: remove VRBrain board sub-types these were only used to turn choose between AP_Notify LED backends, which can be done much more neatly with specific features defines. --- libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v51/hwdef.dat | 4 ++-- libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v52/hwdef.dat | 4 ++-- libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v54/hwdef.dat | 4 ++-- libraries/AP_HAL_ChibiOS/hwdef/VRCore-v10/hwdef.dat | 4 ++-- libraries/AP_HAL_ChibiOS/hwdef/VRUBrain-v51/hwdef.dat | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v51/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v51/hwdef.dat index a4e96f0fdd157..b33d7ea373351 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v51/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v51/hwdef.dat @@ -1,8 +1,6 @@ # hw definition file for processing by chibios_hwdef.py # for VRBRAINv51 hardware -define CONFIG_HAL_BOARD_SUBTYPE HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V51 - # MCU class and specific type MCU STM32F4xx STM32F407xx @@ -139,6 +137,8 @@ define HAL_OS_FATFS_IO 1 define HAL_GPIO_LED_ON 0 define HAL_GPIO_LED_OFF 1 +define AP_NOTIFY_VRBOARD_LED_ENABLED 1 +define AP_NOTIFY_EXTERNALLED_ENABLED 1 define HAL_GPIO_A_LED_PIN 25 define HAL_GPIO_B_LED_PIN 26 define HAL_GPIO_C_LED_PIN 27 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v52/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v52/hwdef.dat index 83c80fe017bf7..e55dc9dd8debe 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v52/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v52/hwdef.dat @@ -1,8 +1,6 @@ # hw definition file for processing by chibios_hwdef.py # for VRBRAINv52 hardware -define CONFIG_HAL_BOARD_SUBTYPE HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V52 - # MCU class and specific type MCU STM32F4xx STM32F407xx @@ -139,6 +137,8 @@ define HAL_OS_FATFS_IO 1 define HAL_GPIO_LED_ON 0 define HAL_GPIO_LED_OFF 1 +define AP_NOTIFY_VRBOARD_LED_ENABLED 1 +define AP_NOTIFY_EXTERNALLED_ENABLED 1 define HAL_GPIO_A_LED_PIN 25 define HAL_GPIO_B_LED_PIN 26 define HAL_GPIO_C_LED_PIN 27 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v54/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v54/hwdef.dat index ebdf9b10bf518..4d4d1522aa923 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v54/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/VRBrain-v54/hwdef.dat @@ -1,8 +1,6 @@ # hw definition file for processing by chibios_hwdef.py # for VRBRAINv54 hardware -define CONFIG_HAL_BOARD_SUBTYPE HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V54 - # MCU class and specific type MCU STM32F4xx STM32F427xx @@ -140,6 +138,8 @@ define HAL_OS_FATFS_IO 1 define HAL_GPIO_LED_ON 0 define HAL_GPIO_LED_OFF 1 +define AP_NOTIFY_VRBOARD_LED_ENABLED 1 +define AP_NOTIFY_EXTERNALLED_ENABLED 1 define HAL_GPIO_A_LED_PIN 25 define HAL_GPIO_B_LED_PIN 26 define HAL_GPIO_C_LED_PIN 27 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/VRCore-v10/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/VRCore-v10/hwdef.dat index 4336c7dcfa07b..6a49bc977b629 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/VRCore-v10/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/VRCore-v10/hwdef.dat @@ -1,8 +1,6 @@ # hw definition file for processing by chibios_hwdef.py # for VRCOREv10 hardware -define CONFIG_HAL_BOARD_SUBTYPE HAL_BOARD_SUBTYPE_CHIBIOS_VRCORE_V10 - # MCU class and specific type MCU STM32F4xx STM32F407xx @@ -139,6 +137,8 @@ define HAL_OS_FATFS_IO 1 define HAL_GPIO_LED_ON 0 define HAL_GPIO_LED_OFF 1 +define AP_NOTIFY_VRBOARD_LED_ENABLED 1 +define AP_NOTIFY_EXTERNALLED_ENABLED 1 define HAL_GPIO_A_LED_PIN 25 define HAL_GPIO_B_LED_PIN 26 define HAL_GPIO_C_LED_PIN 27 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/VRUBrain-v51/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/VRUBrain-v51/hwdef.dat index 6cb3544f3cced..748c06fcb3b24 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/VRUBrain-v51/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/VRUBrain-v51/hwdef.dat @@ -1,8 +1,6 @@ # hw definition file for processing by chibios_hwdef.py # for VRUBRAINv51 hardware -define CONFIG_HAL_BOARD_SUBTYPE HAL_BOARD_SUBTYPE_CHIBIOS_VRUBRAIN_V51 - # MCU class and specific type MCU STM32F4xx STM32F407xx @@ -142,6 +140,8 @@ define HAL_OS_FATFS_IO 1 define HAL_GPIO_LED_ON 0 define HAL_GPIO_LED_OFF 1 +define AP_NOTIFY_VRBOARD_LED_ENABLED 1 +define AP_NOTIFY_EXTERNALLED_ENABLED 1 define HAL_GPIO_A_LED_PIN 25 define HAL_GPIO_B_LED_PIN 26 define HAL_GPIO_C_LED_PIN 27 From 872eac935dfa2afb1a136ad8816e54f7511133ec Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 22 Mar 2024 14:03:51 +1100 Subject: [PATCH 2/3] AP_HAL: remove VRBrain board sub-types these were only used to turn choose between AP_Notify LED backends, which can be done much more neatly with specific features defines. --- libraries/AP_HAL/AP_HAL_Boards.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/AP_HAL/AP_HAL_Boards.h b/libraries/AP_HAL/AP_HAL_Boards.h index 4eeb7398850b9..b2d9e0c56ea26 100644 --- a/libraries/AP_HAL/AP_HAL_Boards.h +++ b/libraries/AP_HAL/AP_HAL_Boards.h @@ -55,11 +55,11 @@ #define HAL_BOARD_SUBTYPE_CHIBIOS_FMUV4 5002 #define HAL_BOARD_SUBTYPE_CHIBIOS_GENERIC 5009 #define HAL_BOARD_SUBTYPE_CHIBIOS_FMUV5 5013 -#define HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V51 5016 -#define HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V52 5017 -#define HAL_BOARD_SUBTYPE_CHIBIOS_VRUBRAIN_V51 5018 -#define HAL_BOARD_SUBTYPE_CHIBIOS_VRCORE_V10 5019 -#define HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V54 5020 +// #define HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V51 5016 +// #define HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V52 5017 +// #define HAL_BOARD_SUBTYPE_CHIBIOS_VRUBRAIN_V51 5018 +// #define HAL_BOARD_SUBTYPE_CHIBIOS_VRCORE_V10 5019 +// #define HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V54 5020 #define HAL_BOARD_SUBTYPE_ESP32_DIY 6001 #define HAL_BOARD_SUBTYPE_ESP32_ICARUS 6002 From 9b6e5c7ba3303e300b53a55724c209c8f7dd3cb2 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 22 Mar 2024 14:06:31 +1100 Subject: [PATCH 3/3] AP_Notify: remove VRBrain board sub-types these were only used to turn choose between AP_Notify LED backends, which can be done much more neatly with specific features defines. --- libraries/AP_Notify/AP_Notify.cpp | 6 +++--- libraries/AP_Notify/AP_Notify_config.h | 8 ++++++++ libraries/AP_Notify/ExternalLED.cpp | 6 ++++++ libraries/AP_Notify/ExternalLED.h | 6 ++++++ libraries/AP_Notify/VRBoard_LED.cpp | 9 +++++---- libraries/AP_Notify/VRBoard_LED.h | 6 ++++++ 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index 1a1b6d2158276..3d7503f1ed0ec 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -303,14 +303,14 @@ void AP_Notify::add_backends(void) #endif #endif // CONFIG_HAL_BOARD == HAL_BOARD_LINUX -#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V51 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V52 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRUBRAIN_V51 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRCORE_V10 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V54 +#if AP_NOTIFY_EXTERNALLED_ENABLED ADD_BACKEND(new ExternalLED()); // despite the name this is a built in set of onboard LED's -#endif // CONFIG_HAL_BOARD_SUBTYPE == various CHIBIOS-VRBRAINs +#endif #if defined(HAL_HAVE_PIXRACER_LED) ADD_BACKEND(new PixRacerLED()); #elif (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && defined(HAL_GPIO_C_LED_PIN)) - #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V51 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V52 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRUBRAIN_V51 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRCORE_V10 || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_VRBRAIN_V54 + #if AP_NOTIFY_VRBOARD_LED_ENABLED ADD_BACKEND(new VRBoard_LED()); #else ADD_BACKEND(new AP_BoardLED()); diff --git a/libraries/AP_Notify/AP_Notify_config.h b/libraries/AP_Notify/AP_Notify_config.h index 7adcab2b6204a..fb702a8d1e3f7 100644 --- a/libraries/AP_Notify/AP_Notify_config.h +++ b/libraries/AP_Notify/AP_Notify_config.h @@ -25,6 +25,14 @@ #define AP_NOTIFY_DSHOT_LED_ENABLED HAL_SUPPORT_RCOUT_SERIAL #endif +#ifndef AP_NOTIFY_VRBOARD_LED_ENABLED +#define AP_NOTIFY_VRBOARD_LED_ENABLED 0 +#endif + +#ifndef AP_NOTIFY_EXTERNALLED_ENABLED +#define AP_NOTIFY_EXTERNALLED_ENABLED 0 +#endif + #ifndef AP_NOTIFY_LP5562_ENABLED #define AP_NOTIFY_LP5562_ENABLED 1 #endif diff --git a/libraries/AP_Notify/ExternalLED.cpp b/libraries/AP_Notify/ExternalLED.cpp index 6085c054acb58..beec54e3f6b84 100644 --- a/libraries/AP_Notify/ExternalLED.cpp +++ b/libraries/AP_Notify/ExternalLED.cpp @@ -12,6 +12,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "AP_Notify_config.h" + +#if AP_NOTIFY_EXTERNALLED_ENABLED + #include "ExternalLED.h" #include "AP_Notify.h" @@ -242,3 +246,5 @@ void ExternalLED::motor_led2(bool on_off) bool ExternalLED::init(void) {return true;} void ExternalLED::update(void) {return;} #endif + +#endif // AP_NOTIFY_EXTERNALLED_ENABLED diff --git a/libraries/AP_Notify/ExternalLED.h b/libraries/AP_Notify/ExternalLED.h index 404d300636f46..291ab98fa64f1 100644 --- a/libraries/AP_Notify/ExternalLED.h +++ b/libraries/AP_Notify/ExternalLED.h @@ -15,6 +15,10 @@ #pragma once +#include "AP_Notify_config.h" + +#if AP_NOTIFY_EXTERNALLED_ENABLED + #include "NotifyDevice.h" class ExternalLED: public NotifyDevice @@ -64,3 +68,5 @@ class ExternalLED: public NotifyDevice void motor_led1(bool on_off); void motor_led2(bool on_off); }; + +#endif // AP_NOTIFY_EXTERNALLED_ENABLED diff --git a/libraries/AP_Notify/VRBoard_LED.cpp b/libraries/AP_Notify/VRBoard_LED.cpp index 3edf6f7a7e939..fbdf2b02137c3 100644 --- a/libraries/AP_Notify/VRBoard_LED.cpp +++ b/libraries/AP_Notify/VRBoard_LED.cpp @@ -16,13 +16,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "AP_Notify_config.h" + +#if AP_NOTIFY_VRBOARD_LED_ENABLED + #include "VRBoard_LED.h" #include -#if (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && \ - defined(HAL_GPIO_C_LED_PIN)) - #define VRBRAIN_LED_BRIGHT 1 // full brightness #define VRBRAIN_LED_MEDIUM 1 // medium brightness #define VRBRAIN_LED_DIM 1 // dim @@ -68,4 +69,4 @@ bool VRBoard_LED::hw_set_rgb(uint8_t r, uint8_t g, uint8_t b){ return true; } -#endif +#endif // AP_NOTIFY_VRBOARD_LED_ENABLED diff --git a/libraries/AP_Notify/VRBoard_LED.h b/libraries/AP_Notify/VRBoard_LED.h index eaee4eaa53355..a3e2bd7b64416 100644 --- a/libraries/AP_Notify/VRBoard_LED.h +++ b/libraries/AP_Notify/VRBoard_LED.h @@ -20,6 +20,10 @@ #pragma once +#include "AP_Notify_config.h" + +#if AP_NOTIFY_VRBOARD_LED_ENABLED + #include "RGBLed.h" #include "AP_BoardLED.h" @@ -31,3 +35,5 @@ class VRBoard_LED: public RGBLed { protected: bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override; }; + +#endif // AP_NOTIFY_VRBOARD_LED_ENABLED