2019-10-30 07:11:39 -03:00
|
|
|
/*
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
AP_SerialLED for controlling serial connected LEDs using WS2812B protocol
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
|
2020-02-11 23:05:30 -04:00
|
|
|
// limit number of LEDs, mostly to keep DMA memory consumption within
|
|
|
|
// reasonable bounds
|
2020-02-22 19:53:31 -04:00
|
|
|
#define AP_SERIALLED_MAX_LEDS 128
|
2020-02-11 23:05:30 -04:00
|
|
|
|
2019-10-30 07:11:39 -03:00
|
|
|
class AP_SerialLED {
|
|
|
|
public:
|
|
|
|
AP_SerialLED();
|
|
|
|
|
|
|
|
// set number of LEDs per pin
|
2020-02-22 19:53:31 -04:00
|
|
|
bool set_num_neopixel(uint8_t chan, uint8_t num_leds);
|
|
|
|
bool set_num_profiled(uint8_t chan, uint8_t num_leds);
|
2019-10-30 07:11:39 -03:00
|
|
|
|
|
|
|
// set RGB value on mask of LEDs. chan is PWM output, 1..16
|
2020-02-09 06:36:16 -04:00
|
|
|
void set_RGB_mask(uint8_t chan, uint32_t ledmask, uint8_t red, uint8_t green, uint8_t blue);
|
2019-10-30 07:11:39 -03:00
|
|
|
|
2020-02-09 06:36:16 -04:00
|
|
|
// set RGB value on LED. LED -1 is all LEDs. LED 0 is first LED. chan is PWM output, 1..16
|
|
|
|
void set_RGB(uint8_t chan, int8_t led, uint8_t red, uint8_t green, uint8_t blue);
|
|
|
|
|
2019-10-30 07:11:39 -03:00
|
|
|
// trigger sending of LED changes to LEDs
|
2020-02-22 19:53:31 -04:00
|
|
|
void send(uint8_t chan);
|
2019-10-30 07:11:39 -03:00
|
|
|
|
|
|
|
// singleton support
|
|
|
|
static AP_SerialLED *get_singleton(void) {
|
|
|
|
return &singleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static AP_SerialLED singleton;
|
|
|
|
};
|