Browse Source

AP_Notify: enable toshibaled on all I2C capable platforms

master
Andrew Tridgell 12 years ago
parent
commit
dd081ab23b
  1. 7
      libraries/AP_Notify/AP_Notify.cpp
  2. 6
      libraries/AP_Notify/AP_Notify.h
  3. 81
      libraries/AP_Notify/examples/AP_Notify_test/AP_Notify_test.pde
  4. 21
      libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.pde

7
libraries/AP_Notify/AP_Notify.cpp

@ -23,22 +23,17 @@ struct AP_Notify::notify_type AP_Notify::flags;
void AP_Notify::init(void) void AP_Notify::init(void)
{ {
boardled.init(); 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 #if CONFIG_HAL_BOARD == HAL_BOARD_PX4
tonealarm.init(); tonealarm.init();
#endif #endif
toshibaled.init();
} }
// main update function, called at 50Hz // main update function, called at 50Hz
void AP_Notify::update(void) void AP_Notify::update(void)
{ {
boardled.update(); boardled.update();
#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2 || CONFIG_HAL_BOARD == HAL_BOARD_PX4
toshibaled.update(); toshibaled.update();
#endif
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 #if CONFIG_HAL_BOARD == HAL_BOARD_PX4
tonealarm.update(); tonealarm.update();

6
libraries/AP_Notify/AP_Notify.h

@ -55,11 +55,11 @@ public:
private: private:
// individual drivers // individual drivers
AP_BoardLED boardled; AP_BoardLED boardled;
#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2 #if CONFIG_HAL_BOARD == HAL_BOARD_PX4
ToshibaLED_I2C toshibaled;
#elif CONFIG_HAL_BOARD == HAL_BOARD_PX4
ToshibaLED_PX4 toshibaled; ToshibaLED_PX4 toshibaled;
ToneAlarm_PX4 tonealarm; ToneAlarm_PX4 tonealarm;
#else
ToshibaLED_I2C toshibaled;
#endif #endif
}; };

81
libraries/AP_Notify/examples/AP_Notify_test/AP_Notify_test.pde

@ -1,39 +1,42 @@
/* /*
* Example of AC_Notify library . * Example of AC_Notify library .
* DIYDrones.com * DIYDrones.com
*/ */
#include <AP_Common.h> #include <AP_Common.h>
#include <AP_Progmem.h> #include <AP_Progmem.h>
#include <AP_Math.h> // ArduPilot Mega Vector/Matrix math Library #include <AP_Math.h> // ArduPilot Mega Vector/Matrix math Library
#include <AP_Param.h> #include <AP_Param.h>
#include <AP_HAL.h> #include <AP_HAL.h>
#include <AP_HAL_AVR.h> #include <AP_HAL_AVR.h>
#include <AP_Notify.h> // Notify library #include <AP_HAL_Linux.h>
#include <AP_BoardLED.h> // Board LED library #include <AP_HAL_PX4.h>
#include <AP_HAL_Empty.h>
const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER; #include <AP_Notify.h> // Notify library
#include <AP_BoardLED.h> // Board LED library
// create board led object
AP_BoardLED board_led; const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER;
void setup() // create board led object
{ AP_BoardLED board_led;
hal.console->println("AP_Notify library test");
void setup()
// initialise the board leds {
board_led.init(); hal.console->println("AP_Notify library test");
// turn on initialising notification // initialise the board leds
AP_Notify::flags.initialising = true; board_led.init();
AP_Notify::flags.gps_status = 1;
AP_Notify::flags.armed = 1; // turn on initialising notification
AP_Notify::flags.pre_arm_check = 1; AP_Notify::flags.initialising = true;
} AP_Notify::flags.gps_status = 1;
AP_Notify::flags.armed = 1;
void loop() AP_Notify::flags.pre_arm_check = 1;
{ }
hal.scheduler->delay(1000);
} void loop()
{
AP_HAL_MAIN(); hal.scheduler->delay(1000);
}
AP_HAL_MAIN();

21
libraries/AP_Notify/examples/ToshibaLED_test/ToshibaLED_test.pde

@ -4,21 +4,30 @@
#include <AP_Progmem.h> #include <AP_Progmem.h>
#include <AP_Math.h> // ArduPilot Mega Vector/Matrix math Library #include <AP_Math.h> // ArduPilot Mega Vector/Matrix math Library
#include <AP_Param.h> #include <AP_Param.h>
#include <Filter.h>
#include <AP_ADC.h>
#include <GCS_MAVLink.h>
#include <AP_Declination.h>
#include <AP_HAL.h> #include <AP_HAL.h>
#include <AP_HAL_AVR.h> #include <AP_HAL_AVR.h>
#include <AP_HAL_AVR_SITL.h>
#include <AP_HAL_Linux.h>
#include <AP_HAL_PX4.h>
#include <AP_HAL_Empty.h>
#include <AP_HAL_FLYMAPLE.h>
#include <AP_Notify.h> // Notify library #include <AP_Notify.h> // Notify library
#include <ToshibaLED.h> #include <ToshibaLED.h>
const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER; const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER;
#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2 #if CONFIG_HAL_BOARD == HAL_BOARD_PX4
ToshibaLED_I2C toshiba_led; static ToshibaLED_PX4 toshiba_led;
#elif CONFIG_HAL_BOARD == HAL_BOARD_PX4 #else
ToshibaLED_PX4 toshiba_led; static ToshibaLED_I2C toshiba_led;
#endif #endif
uint8_t led_state; static uint8_t led_state;
uint8_t red, green, blue; static uint8_t red, green, blue;
void setup(void) void setup(void)
{ {

Loading…
Cancel
Save