From 8041a7f18333b0b12a3caecc540a336d694b7f72 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Thu, 26 Jan 2017 21:13:01 +0900 Subject: [PATCH] AP_Notify: add PixRacerLED --- libraries/AP_Notify/PixRacerLED.cpp | 39 +++++++++++++++++++++++++++++ libraries/AP_Notify/PixRacerLED.h | 30 ++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 libraries/AP_Notify/PixRacerLED.cpp create mode 100644 libraries/AP_Notify/PixRacerLED.h diff --git a/libraries/AP_Notify/PixRacerLED.cpp b/libraries/AP_Notify/PixRacerLED.cpp new file mode 100644 index 0000000000..aacfb7430a --- /dev/null +++ b/libraries/AP_Notify/PixRacerLED.cpp @@ -0,0 +1,39 @@ +/* + 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 "PixRacerLED.h" + +extern const AP_HAL::HAL& hal; + +PixRacerLED::PixRacerLED() : + RGBLed(0, 1, 1, 1) +{ +} + +bool PixRacerLED::hw_init(void) +{ + hal.gpio->write(HAL_GPIO_A_LED_PIN, 0); + hal.gpio->write(HAL_GPIO_B_LED_PIN, 0); + hal.gpio->write(HAL_GPIO_C_LED_PIN, 0); + return true; +} + +bool PixRacerLED::hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) +{ + hal.gpio->write(HAL_GPIO_A_LED_PIN, (r > 0)); + hal.gpio->write(HAL_GPIO_B_LED_PIN, (g > 0)); + hal.gpio->write(HAL_GPIO_C_LED_PIN, (b > 0)); + return true; +} diff --git a/libraries/AP_Notify/PixRacerLED.h b/libraries/AP_Notify/PixRacerLED.h new file mode 100644 index 0000000000..e4840751e3 --- /dev/null +++ b/libraries/AP_Notify/PixRacerLED.h @@ -0,0 +1,30 @@ +/* + 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 . + */ +#pragma once + +#include +#include + +#include "RGBLed.h" + +class PixRacerLED: public RGBLed +{ +public: + PixRacerLED(); + +protected: + bool hw_init(void) override; + bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override; +};