AP_Notify: added missing VRBRAIN led files

This commit is contained in:
Emile Castelnuovo 2015-01-22 19:09:12 +01:00 committed by Andrew Tridgell
parent b62ad2db71
commit c044901f9f
2 changed files with 102 additions and 0 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "VRBRAIN_LED.h"
#include <AP_HAL.h>
#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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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