mirror of https://github.com/ArduPilot/ardupilot
AP_Notify: use RGB driver for board led in VRBRAIN boards.
This commit is contained in:
parent
3e97592e5c
commit
26432d6064
|
@ -32,7 +32,11 @@ struct AP_Notify::notify_events_type AP_Notify::events;
|
|||
NotifyDevice *AP_Notify::_devices[CONFIG_NOTIFY_DEVICES_COUNT] = {&boardled, &externalled, &buzzer};
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
||||
Buzzer buzzer;
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_VRBRAIN_V45
|
||||
AP_BoardLED boardled;
|
||||
#else
|
||||
VRBoard_LED boardled;
|
||||
#endif
|
||||
ToshibaLED_I2C toshibaled;
|
||||
ExternalLED externalled;
|
||||
NotifyDevice *AP_Notify::_devices[CONFIG_NOTIFY_DEVICES_COUNT] = {&boardled, &toshibaled, &externalled, &buzzer};
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <NavioLED_I2C.h>
|
||||
#include <ExternalLED.h>
|
||||
#include <Buzzer.h>
|
||||
#include <VRBoard_LED.h>
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
||||
#define CONFIG_NOTIFY_DEVICES_COUNT 3
|
||||
|
|
|
@ -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 "VRBoard_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;
|
||||
|
||||
VRBoard_LED::VRBoard_LED():
|
||||
RGBLed(VRBRAIN_LED_OFF, VRBRAIN_LED_BRIGHT, VRBRAIN_LED_MEDIUM, VRBRAIN_LED_DIM)
|
||||
{
|
||||
|
||||
}
|
||||
bool VRBoard_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 VRBoard_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;
|
||||
}
|
|
@ -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 VRBoard_LED: public RGBLed {
|
||||
public:
|
||||
VRBoard_LED();
|
||||
|
||||
bool hw_init(void);
|
||||
bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue