APM:Libraries
PixRacerLED.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 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #include "PixRacerLED.h"
17 
18 #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 && CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V4 \
19  || CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
20 
21 extern const AP_HAL::HAL& hal;
22 
25 {
26 }
27 
29 {
33  return true;
34 }
35 
36 bool PixRacerLED::hw_set_rgb(uint8_t r, uint8_t g, uint8_t b)
37 {
39  hal.gpio->write(HAL_GPIO_B_LED_PIN, (g > 0)?HAL_GPIO_LED_ON:HAL_GPIO_LED_OFF);
40  hal.gpio->write(HAL_GPIO_C_LED_PIN, (b > 0)?HAL_GPIO_LED_ON:HAL_GPIO_LED_OFF);
41  return true;
42 }
43 
44 #else
45 bool PixRacerLED::hw_init(void) { return true; }
46 bool PixRacerLED::hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) { return true; }
47 #endif
uint8_t b
Definition: RGBLed.h:67
Definition: RGBLed.h:25
bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override
Definition: PixRacerLED.cpp:36
uint8_t g
Definition: RGBLed.h:67
#define HAL_GPIO_A_LED_PIN
Definition: chibios.h:9
bool hw_init(void) override
Definition: PixRacerLED.cpp:28
#define HAL_GPIO_C_LED_PIN
Definition: chibios.h:15
virtual void write(uint8_t pin, uint8_t value)=0
uint8_t r
Definition: RGBLed.h:67
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_LED_OFF
Definition: chibios.h:21
AP_HAL::GPIO * gpio
Definition: HAL.h:111
#define HAL_GPIO_LED_ON
Definition: chibios.h:18
#define HAL_GPIO_B_LED_PIN
Definition: chibios.h:12