29 static uint32_t
led_pwm_on_p(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t uptime, uint8_t *fraction) {
31 uint32_t curr_step = (uptime / pwm_period) % pwm_sweep_steps;
34 uint32_t pwm_duty = pwm_period * curr_step / pwm_sweep_steps;
37 uint32_t curr_sweep = (uptime / (pwm_period * pwm_sweep_steps));
41 pwm_duty = pwm_period - pwm_duty;
45 *fraction = 255 * pwm_duty / pwm_period;
48 return ((uptime % pwm_period) > pwm_duty) ? 1 : 0;
52 uint32_t pwm_1_period_us,
53 uint32_t pwm_1_sweep_steps,
54 uint32_t pwm_2_period_us,
55 uint32_t pwm_2_sweep_steps)
58 if (pwm_1_period_us > 0) {
68 if (pwm_2_period_us > 0) {
84 uint8_t led1_fraction = 128;
89 bool pwm_1_led_state =
true;
98 uint8_t led2_fraction = 0;
100 bool pwm_2_led_state =
false;
113 if (pwm_1_led_state) {
119 #ifdef PIOS_INCLUDE_WS2811
120 #define WS2811_UPDATE_INTERVAL 15000 // 67Hz!
122 if ((leds->
uptime_us - leds->last_ws2811_us) >= WS2811_UPDATE_INTERVAL) {
126 led2_fraction / 3, 0);
131 #ifdef PIOS_LED_ALARM
133 if (pwm_2_led_state) {
static uint32_t led_pwm_on_p(uint32_t pwm_period, uint32_t pwm_sweep_steps, uint32_t uptime, uint8_t *fraction)
Main PiOS header to include all the compiled in PiOS options.
bool led_pwm_update_leds(struct led_pwm_state *leds)
uint32_t pwm_2_sweep_steps
void PIOS_ANNUNC_Off(uint32_t annunc_id)
void led_pwm_add_ticks(struct led_pwm_state *leds, uint32_t elapsed_us)
void PIOS_WS2811_set_all(ws2811_dev_t dev, uint8_t r, uint8_t g, uint8_t b)
Sets all LEDs to a color value.
void led_pwm_config(struct led_pwm_state *leds, uint32_t pwm_1_period_us, uint32_t pwm_1_sweep_steps, uint32_t pwm_2_period_us, uint32_t pwm_2_sweep_steps)
uint32_t pwm_1_sweep_steps
void PIOS_ANNUNC_On(uint32_t annunc_id)
void PIOS_WS2811_trigger_update(ws2811_dev_t dev)
Trigger an update of the LED strand.
#define PIOS_LED_HEARTBEAT