2015-08-11 03:28:44 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2016-01-29 00:38:21 -04:00
|
|
|
#include <AP_Notify/AP_Notify.h>
|
2017-01-26 23:57:20 -04:00
|
|
|
#include <AP_Notify/ToshibaLED_I2C.h>
|
2013-08-09 00:17:29 -03:00
|
|
|
|
2017-04-13 08:32:23 -03:00
|
|
|
void setup();
|
|
|
|
void loop();
|
|
|
|
void full_spectrum();
|
|
|
|
void blink();
|
|
|
|
|
2015-10-16 17:22:11 -03:00
|
|
|
const AP_HAL::HAL& hal = AP_HAL::get_HAL();
|
2013-08-09 00:17:29 -03:00
|
|
|
|
2017-09-06 07:12:36 -03:00
|
|
|
static ToshibaLED_I2C toshiba_led(1);
|
2013-08-29 02:06:05 -03:00
|
|
|
|
2013-08-09 00:17:29 -03:00
|
|
|
void setup(void)
|
|
|
|
{
|
|
|
|
// display welcome message
|
2017-01-21 00:58:05 -04:00
|
|
|
hal.console->printf("Toshiba LED test ver 0.1\n");
|
2013-08-09 00:17:29 -03:00
|
|
|
|
|
|
|
// initialise LED
|
|
|
|
toshiba_led.init();
|
|
|
|
|
|
|
|
// check if healthy
|
|
|
|
if (!toshiba_led.healthy()) {
|
2017-01-21 00:58:05 -04:00
|
|
|
hal.console->printf("Failed to initialise Toshiba LED\n");
|
2013-08-09 00:17:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// turn on initialising notification
|
2013-08-13 23:50:52 -03:00
|
|
|
AP_Notify::flags.initialising = false;
|
|
|
|
AP_Notify::flags.save_trim = true;
|
|
|
|
AP_Notify::flags.gps_status = 1;
|
|
|
|
AP_Notify::flags.armed = 1;
|
|
|
|
AP_Notify::flags.pre_arm_check = 1;
|
2013-08-09 00:17:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop(void)
|
|
|
|
{
|
|
|
|
// blink test
|
2017-01-21 00:58:05 -04:00
|
|
|
//hal.console->printf("Blink test\n");
|
2013-08-09 00:17:29 -03:00
|
|
|
//blink();
|
|
|
|
/*
|
|
|
|
// full spectrum test
|
2017-01-21 00:58:05 -04:00
|
|
|
hal.console->printf("Spectrum test\n");
|
2013-08-09 00:17:29 -03:00
|
|
|
full_spectrum();
|
|
|
|
*/
|
|
|
|
|
|
|
|
// update the toshiba led
|
|
|
|
toshiba_led.update();
|
|
|
|
|
2013-08-29 02:06:05 -03:00
|
|
|
// wait 1/50th of a second
|
|
|
|
hal.scheduler->delay(20);
|
2013-08-09 00:17:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// full_spectrum - runs through the full spectrum of colours the led can display
|
|
|
|
void full_spectrum()
|
|
|
|
{
|
|
|
|
// go through the full range of colours but only up to the dim light level
|
2017-04-13 08:32:23 -03:00
|
|
|
for (uint8_t red = 0; red <= 0x05; red++) {
|
|
|
|
for (uint8_t green = 0; green <= 0x05; green++) {
|
|
|
|
for (uint8_t blue = 0; blue <= 0x05; blue++) {
|
|
|
|
toshiba_led.set_rgb(red, green, blue);
|
2013-08-09 00:17:29 -03:00
|
|
|
hal.scheduler->delay(5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-27 02:27:56 -04:00
|
|
|
#define LED_DIM 0x11
|
|
|
|
|
2013-08-09 00:17:29 -03:00
|
|
|
// blink - blink the led at 10hz for 10 seconds
|
|
|
|
void blink()
|
|
|
|
{
|
|
|
|
// set colour to red
|
2017-04-13 08:32:23 -03:00
|
|
|
toshiba_led.set_rgb(LED_DIM, 0, 0);
|
2013-08-09 00:17:29 -03:00
|
|
|
|
|
|
|
// full spectrum test
|
|
|
|
for (uint8_t c=0; c<=2; c++ ) {
|
2017-04-13 08:32:23 -03:00
|
|
|
if (c == 0) {
|
|
|
|
toshiba_led.set_rgb(LED_DIM, 0, 0); // red
|
2013-08-09 00:17:29 -03:00
|
|
|
}else if (c==1) {
|
2017-04-13 08:32:23 -03:00
|
|
|
toshiba_led.set_rgb(0, LED_DIM, 0); // green
|
2013-08-09 00:17:29 -03:00
|
|
|
}else{
|
2017-04-13 08:32:23 -03:00
|
|
|
toshiba_led.set_rgb(0, 0, LED_DIM); // blue
|
2013-08-09 00:17:29 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AP_HAL_MAIN();
|