diff --git a/libraries/AP_Notify/VRBRAIN_LED.cpp b/libraries/AP_Notify/VRBRAIN_LED.cpp new file mode 100644 index 0000000000..d11a5d69ea --- /dev/null +++ b/libraries/AP_Notify/VRBRAIN_LED.cpp @@ -0,0 +1,66 @@ +/* + ToshibaLED driver +*/ + +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include "VRBRAIN_LED.h" +#include + +#define VRBRAIN_LED_BRIGHT 1 // full brightness +#define VRBRAIN_LED_MEDIUM 1 // medium brightness +#define VRBRAIN_LED_DIM 1 // dim +#define VRBRAIN_LED_OFF 0 // off + +extern const AP_HAL::HAL& hal; + +VRBRAIN_LED::VRBRAIN_LED(): + RGBLed(VRBRAIN_LED_OFF, VRBRAIN_LED_BRIGHT, VRBRAIN_LED_MEDIUM, VRBRAIN_LED_DIM) +{ + +} +bool VRBRAIN_LED::hw_init(void){ + // setup the main LEDs as outputs + hal.gpio->pinMode(HAL_GPIO_A_LED_PIN, HAL_GPIO_OUTPUT); + hal.gpio->pinMode(HAL_GPIO_B_LED_PIN, HAL_GPIO_OUTPUT); + hal.gpio->pinMode(HAL_GPIO_C_LED_PIN, HAL_GPIO_OUTPUT); + + // turn all lights off + hal.gpio->write(HAL_GPIO_A_LED_PIN, HAL_GPIO_LED_OFF); + hal.gpio->write(HAL_GPIO_B_LED_PIN, HAL_GPIO_LED_OFF); + hal.gpio->write(HAL_GPIO_C_LED_PIN, HAL_GPIO_LED_OFF); + return true; +} +bool VRBRAIN_LED::hw_set_rgb(uint8_t r, uint8_t g, uint8_t b){ + + if(r > 0){ + hal.gpio->write(HAL_GPIO_C_LED_PIN, HAL_GPIO_LED_ON); + } else { + hal.gpio->write(HAL_GPIO_C_LED_PIN, HAL_GPIO_LED_OFF); + } + if (g > 0) { + hal.gpio->write(HAL_GPIO_A_LED_PIN, HAL_GPIO_LED_ON); + } else { + hal.gpio->write(HAL_GPIO_A_LED_PIN, HAL_GPIO_LED_OFF); + } + if (b > 0) { + hal.gpio->write(HAL_GPIO_B_LED_PIN, HAL_GPIO_LED_ON); + } else { + hal.gpio->write(HAL_GPIO_B_LED_PIN, HAL_GPIO_LED_OFF); + } + + return true; +} diff --git a/libraries/AP_Notify/VRBRAIN_LED.h b/libraries/AP_Notify/VRBRAIN_LED.h new file mode 100644 index 0000000000..9ca0691bd6 --- /dev/null +++ b/libraries/AP_Notify/VRBRAIN_LED.h @@ -0,0 +1,36 @@ +/* + * AP_Notify Library. + * based upon a prototype library by David "Buzz" Bussenschutt. + */ + +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#ifndef __VRBRAIN_LED_H__ +#define __VRBRAIN_LED_H__ + +#include "RGBLed.h" +#include "AP_BoardLED.h" + + +class VRBRAIN_LED: public RGBLed { +public: + VRBRAIN_LED(); + + bool hw_init(void); + bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b); +}; + +#endif