From dd081ab23bdc419a9049c2856dad05f9d61d266a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 28 Sep 2013 19:24:45 +1000 Subject: [PATCH] AP_Notify: enable toshibaled on all I2C capable platforms --- libraries/AP_Notify/AP_Notify.cpp | 7 +- libraries/AP_Notify/AP_Notify.h | 6 +- .../AP_Notify_test/AP_Notify_test.pde | 81 ++++++++++--------- .../ToshibaLED_test/ToshibaLED_test.pde | 21 +++-- 4 files changed, 61 insertions(+), 54 deletions(-) diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index 5c26e7dc78..c019bba0a7 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -23,22 +23,17 @@ struct AP_Notify::notify_type AP_Notify::flags; void AP_Notify::init(void) { boardled.init(); -#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2 || CONFIG_HAL_BOARD == HAL_BOARD_PX4 - toshibaled.init(); -#endif #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 tonealarm.init(); #endif + toshibaled.init(); } // main update function, called at 50Hz void AP_Notify::update(void) { boardled.update(); - -#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2 || CONFIG_HAL_BOARD == HAL_BOARD_PX4 toshibaled.update(); -#endif #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 tonealarm.update(); diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h index d195b1a04c..b3ca1af17b 100644 --- a/libraries/AP_Notify/AP_Notify.h +++ b/libraries/AP_Notify/AP_Notify.h @@ -55,11 +55,11 @@ public: private: // individual drivers AP_BoardLED boardled; -#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2 - ToshibaLED_I2C toshibaled; -#elif CONFIG_HAL_BOARD == HAL_BOARD_PX4 +#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 ToshibaLED_PX4 toshibaled; ToneAlarm_PX4 tonealarm; +#else + ToshibaLED_I2C toshibaled; #endif }; diff --git a/libraries/AP_Notify/examples/AP_Notify_test/AP_Notify_test.pde b/libraries/AP_Notify/examples/AP_Notify_test/AP_Notify_test.pde index 0248b98c96..0ccd5ee536 100644 --- a/libraries/AP_Notify/examples/AP_Notify_test/AP_Notify_test.pde +++ b/libraries/AP_Notify/examples/AP_Notify_test/AP_Notify_test.pde @@ -1,39 +1,42 @@ -/* - * Example of AC_Notify library . - * DIYDrones.com - */ - -#include -#include -#include // ArduPilot Mega Vector/Matrix math Library -#include -#include -#include -#include // Notify library -#include // Board LED library - -const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER; - -// create board led object -AP_BoardLED board_led; - -void setup() -{ - hal.console->println("AP_Notify library test"); - - // initialise the board leds - board_led.init(); - - // turn on initialising notification - AP_Notify::flags.initialising = true; - AP_Notify::flags.gps_status = 1; - AP_Notify::flags.armed = 1; - AP_Notify::flags.pre_arm_check = 1; -} - -void loop() -{ - hal.scheduler->delay(1000); -} - -AP_HAL_MAIN(); +/* + * Example of AC_Notify library . + * DIYDrones.com + */ + +#include +#include +#include // ArduPilot Mega Vector/Matrix math Library +#include +#include +#include +#include +#include +#include +#include // Notify library +#include // Board LED library + +const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER; + +// create board led object +AP_BoardLED board_led; + +void setup() +{ + hal.console->println("AP_Notify library test"); + + // initialise the board leds + board_led.init(); + + // turn on initialising notification + AP_Notify::flags.initialising = true; + AP_Notify::flags.gps_status = 1; + AP_Notify::flags.armed = 1; + AP_Notify::flags.pre_arm_check = 1; +} + +void loop() +{ + hal.scheduler->delay(1000); +} + +AP_HAL_MAIN(); diff --git a/libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.pde b/libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.pde index 55e217ca2c..d327adfdf9 100644 --- a/libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.pde +++ b/libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.pde @@ -4,21 +4,30 @@ #include #include // ArduPilot Mega Vector/Matrix math Library #include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include #include // Notify library #include const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER; -#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2 -ToshibaLED_I2C toshiba_led; -#elif CONFIG_HAL_BOARD == HAL_BOARD_PX4 -ToshibaLED_PX4 toshiba_led; +#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 +static ToshibaLED_PX4 toshiba_led; +#else +static ToshibaLED_I2C toshiba_led; #endif -uint8_t led_state; -uint8_t red, green, blue; +static uint8_t led_state; +static uint8_t red, green, blue; void setup(void) {