APM:Libraries
DiscreteRGBLed.cpp
Go to the documentation of this file.
1 /*
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License as published by
4  the Free Software Foundation, either version 3 of the License, or
5  (at your option) any later version.
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10  You should have received a copy of the GNU General Public License
11  along with this program. If not, see <http://www.gnu.org/licenses/>.
12 */
13 
14 #include "DiscreteRGBLed.h"
15 
16 extern const AP_HAL::HAL& hal;
17 
18 DiscreteRGBLed::DiscreteRGBLed(uint16_t red, uint16_t green, uint16_t blue, bool normal_polarity)
19  : RGBLed(normal_polarity ? 0 : 1,
20  normal_polarity ? 1 : 0,
21  normal_polarity ? 1 : 0,
22  normal_polarity ? 1 : 0),
23  red_pin_number(red),
24  green_pin_number(green),
25  blue_pin_number(blue)
26 {
27 
28 }
29 
31 {
35 
39 
40  red_pin->write(0);
41  green_pin->write(0);
42  blue_pin->write(0);
43 
44  return true;
45 }
46 
47 // set_rgb - set color as a combination of red, green and blue values
48 bool DiscreteRGBLed::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
49 {
50  red_pin->write(!!red);
51  green_pin->write(!!green);
52  blue_pin->write(!!blue);
53 
54  return true;
55 }
Definition: RGBLed.h:25
bool hw_init(void) override
uint16_t green_pin_number
bool hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue) override
AP_HAL::DigitalSource * red_pin
AP_HAL::DigitalSource * green_pin
uint16_t red_pin_number
virtual void mode(uint8_t output)=0
AP_HAL::DigitalSource * blue_pin
virtual AP_HAL::DigitalSource * channel(uint16_t n)=0
const AP_HAL::HAL & hal
-*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
Definition: AC_PID_test.cpp:14
#define HAL_GPIO_OUTPUT
Definition: GPIO.h:8
AP_HAL::GPIO * gpio
Definition: HAL.h:111
DiscreteRGBLed(uint16_t red, uint16_t green, uint16_t blue, bool polarity)
uint16_t blue_pin_number
virtual void write(uint8_t value)=0