Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
light_scheduler.c File Reference

basic LED scheduler based on WS2812 RGB led driver More...

#include "modules/light/light_scheduler.h"
#include "modules/light/light_ws2812_arch.h"
#include "generated/airframe.h"
+ Include dependency graph for light_scheduler.c:

Go to the source code of this file.

Macros

#define LIGHT_SCHEDULER_MODE   LIGHT_SCHEDULER_MODE_RAINBOW
 Optional header needed by the alert condition.
 
#define LIGHT_SCHEDULER_RED   255
 
#define LIGHT_SCHEDULER_GREEN   255
 
#define LIGHT_SCHEDULER_BLUE   255
 
#define LIGHT_SCHEDULER_BRIGHTNESS   255
 
#define LIGHT_SCHEDULER_COLOR   LIGHT_SCHEDULER_COLOR_CUSTOM
 Startup color preset, overrides LIGHT_SCHEDULER_RED/GREEN/BLUE when not custom.
 
#define LIGHT_SCHEDULER_ALERT_COLOR   LIGHT_SCHEDULER_COLOR_RED
 Alert color, shown in every mode while LIGHT_SCHEDULER_ALERT is true.
 
#define LIGHT_SCHEDULER_ALERT_SPARKLE   FALSE
 Show the sparkle effect instead of the alert color while LIGHT_SCHEDULER_ALERT is true.
 

Functions

static void light_scheduler_set (uint32_t n, uint8_t r, uint8_t g, uint8_t b)
 set one led, scaled by the brightness setting
 
static uint32_t sparkle_rand (void)
 xorshift32 pseudo random numbers for the sparkle effect
 
static void light_scheduler_sparkle (void)
 Sparkle: every led takes a random bright color, with white twinkles and short dark blinks.
 
void light_scheduler_set_color (uint8_t color)
 Settings handler: apply a color preset to red/green/blue (or select a flag) and switch to color mode.
 
void light_scheduler_init (void)
 
void light_scheduler_periodic (void)
 

Variables

uint8_t light_scheduler_mode = LIGHT_SCHEDULER_MODE
 one of LIGHT_SCHEDULER_MODE_*
 
uint8_t light_scheduler_red = LIGHT_SCHEDULER_RED
 red value in color mode
 
uint8_t light_scheduler_green = LIGHT_SCHEDULER_GREEN
 green value in color mode
 
uint8_t light_scheduler_blue = LIGHT_SCHEDULER_BLUE
 blue value in color mode
 
uint8_t light_scheduler_brightness = LIGHT_SCHEDULER_BRIGHTNESS
 brightness scaling (255 = full)
 
uint8_t light_scheduler_color = LIGHT_SCHEDULER_COLOR
 selected preset (light_scheduler_color_t)
 
static const uint8_t light_scheduler_presets [LIGHT_SCHEDULER_COLOR_FLAG_FIRST][3]
 RGB values of the single color presets.
 
static const uint8_t light_scheduler_flags [LIGHT_SCHEDULER_COLOR_NB - LIGHT_SCHEDULER_COLOR_FLAG_FIRST][3]
 Flags: three color presets, from the first to the last led of a strip.
 
static uint32_t s = 0
 
static uint32_t sparkle_seed = 0x2545F491
 

Detailed Description

basic LED scheduler based on WS2812 RGB led driver

Author
Xavier Paris @maintainer Gautier Hattenberger gauti.nosp@m.er.h.nosp@m.atten.nosp@m.berg.nosp@m.er@en.nosp@m.ac.f.nosp@m.r

Definition in file light_scheduler.c.

Macro Definition Documentation

◆ LIGHT_SCHEDULER_ALERT_COLOR

#define LIGHT_SCHEDULER_ALERT_COLOR   LIGHT_SCHEDULER_COLOR_RED

Alert color, shown in every mode while LIGHT_SCHEDULER_ALERT is true.

Definition at line 66 of file light_scheduler.c.

◆ LIGHT_SCHEDULER_ALERT_SPARKLE

#define LIGHT_SCHEDULER_ALERT_SPARKLE   FALSE

Show the sparkle effect instead of the alert color while LIGHT_SCHEDULER_ALERT is true.

Definition at line 71 of file light_scheduler.c.

◆ LIGHT_SCHEDULER_BLUE

#define LIGHT_SCHEDULER_BLUE   255

Definition at line 52 of file light_scheduler.c.

◆ LIGHT_SCHEDULER_BRIGHTNESS

#define LIGHT_SCHEDULER_BRIGHTNESS   255

Definition at line 56 of file light_scheduler.c.

◆ LIGHT_SCHEDULER_COLOR

#define LIGHT_SCHEDULER_COLOR   LIGHT_SCHEDULER_COLOR_CUSTOM

Startup color preset, overrides LIGHT_SCHEDULER_RED/GREEN/BLUE when not custom.

Definition at line 61 of file light_scheduler.c.

◆ LIGHT_SCHEDULER_GREEN

#define LIGHT_SCHEDULER_GREEN   255

Definition at line 48 of file light_scheduler.c.

◆ LIGHT_SCHEDULER_MODE

#define LIGHT_SCHEDULER_MODE   LIGHT_SCHEDULER_MODE_RAINBOW

Optional header needed by the alert condition.

Definition at line 40 of file light_scheduler.c.

◆ LIGHT_SCHEDULER_RED

#define LIGHT_SCHEDULER_RED   255

Definition at line 44 of file light_scheduler.c.

Function Documentation

◆ light_scheduler_init()

void light_scheduler_init ( void  )

Definition at line 156 of file light_scheduler.c.

References light_scheduler_color, LIGHT_SCHEDULER_COLOR_CUSTOM, light_scheduler_mode, light_scheduler_set_color(), light_ws2812_arch_init(), and mode.

+ Here is the call graph for this function:

◆ light_scheduler_periodic()

◆ light_scheduler_set()

static void light_scheduler_set ( uint32_t  n,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)
static

set one led, scaled by the brightness setting

Definition at line 109 of file light_scheduler.c.

References b, g, light_scheduler_brightness, and light_ws2812_arch_set().

Referenced by light_scheduler_periodic(), and light_scheduler_sparkle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ light_scheduler_set_color()

void light_scheduler_set_color ( uint8_t  color)

Settings handler: apply a color preset to red/green/blue (or select a flag) and switch to color mode.

Definition at line 143 of file light_scheduler.c.

References foo, light_scheduler_blue, light_scheduler_color, LIGHT_SCHEDULER_COLOR_CUSTOM, LIGHT_SCHEDULER_COLOR_FLAG_FIRST, LIGHT_SCHEDULER_COLOR_NB, light_scheduler_green, light_scheduler_mode, LIGHT_SCHEDULER_MODE_COLOR, light_scheduler_presets, and light_scheduler_red.

Referenced by light_scheduler_init().

+ Here is the caller graph for this function:

◆ light_scheduler_sparkle()

static void light_scheduler_sparkle ( void  )
static

Sparkle: every led takes a random bright color, with white twinkles and short dark blinks.

Definition at line 125 of file light_scheduler.c.

References LIGHT_SCHEDULER_COLOR_BLUE, LIGHT_SCHEDULER_COLOR_CYAN, LIGHT_SCHEDULER_COLOR_GREEN, LIGHT_SCHEDULER_COLOR_MAGENTA, LIGHT_SCHEDULER_COLOR_ORANGE, LIGHT_SCHEDULER_COLOR_RED, LIGHT_SCHEDULER_COLOR_WHITE, LIGHT_SCHEDULER_COLOR_YELLOW, light_scheduler_presets, light_scheduler_set(), light_ws2812_arch_set(), sparkle_rand(), and WS2812_NB_LEDS.

Referenced by light_scheduler_periodic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sparkle_rand()

static uint32_t sparkle_rand ( void  )
static

xorshift32 pseudo random numbers for the sparkle effect

Definition at line 116 of file light_scheduler.c.

References sparkle_seed.

Referenced by light_scheduler_sparkle().

+ Here is the caller graph for this function:

Variable Documentation

◆ light_scheduler_blue

uint8_t light_scheduler_blue = LIGHT_SCHEDULER_BLUE

blue value in color mode

Definition at line 77 of file light_scheduler.c.

Referenced by light_scheduler_periodic(), and light_scheduler_set_color().

◆ light_scheduler_brightness

uint8_t light_scheduler_brightness = LIGHT_SCHEDULER_BRIGHTNESS

brightness scaling (255 = full)

Definition at line 78 of file light_scheduler.c.

Referenced by light_scheduler_set().

◆ light_scheduler_color

uint8_t light_scheduler_color = LIGHT_SCHEDULER_COLOR

selected preset (light_scheduler_color_t)

Definition at line 79 of file light_scheduler.c.

Referenced by light_scheduler_init(), light_scheduler_periodic(), and light_scheduler_set_color().

◆ light_scheduler_flags

Initial value:

Flags: three color presets, from the first to the last led of a strip.

Definition at line 96 of file light_scheduler.c.

Referenced by light_scheduler_periodic().

◆ light_scheduler_green

uint8_t light_scheduler_green = LIGHT_SCHEDULER_GREEN

green value in color mode

Definition at line 76 of file light_scheduler.c.

Referenced by light_scheduler_periodic(), and light_scheduler_set_color().

◆ light_scheduler_mode

uint8_t light_scheduler_mode = LIGHT_SCHEDULER_MODE

one of LIGHT_SCHEDULER_MODE_*

Definition at line 74 of file light_scheduler.c.

Referenced by light_scheduler_init(), light_scheduler_periodic(), and light_scheduler_set_color().

◆ light_scheduler_presets

const uint8_t light_scheduler_presets[LIGHT_SCHEDULER_COLOR_FLAG_FIRST][3]
static
Initial value:
= {
[LIGHT_SCHEDULER_COLOR_CUSTOM] = {255, 255, 255},
[LIGHT_SCHEDULER_COLOR_RED] = {255, 0, 0},
[LIGHT_SCHEDULER_COLOR_GREEN] = { 0, 255, 0},
[LIGHT_SCHEDULER_COLOR_BLUE] = { 0, 0, 255},
[LIGHT_SCHEDULER_COLOR_WHITE] = {255, 255, 255},
[LIGHT_SCHEDULER_COLOR_YELLOW] = {255, 180, 0},
[LIGHT_SCHEDULER_COLOR_ORANGE] = {255, 60, 0},
[LIGHT_SCHEDULER_COLOR_CYAN] = { 0, 255, 255},
[LIGHT_SCHEDULER_COLOR_MAGENTA] = {255, 0, 255},
[LIGHT_SCHEDULER_COLOR_PURPLE] = {128, 0, 255},
}
@ LIGHT_SCHEDULER_COLOR_ORANGE
@ LIGHT_SCHEDULER_COLOR_PURPLE
@ LIGHT_SCHEDULER_COLOR_YELLOW
@ LIGHT_SCHEDULER_COLOR_CUSTOM
@ LIGHT_SCHEDULER_COLOR_CYAN
@ LIGHT_SCHEDULER_COLOR_MAGENTA

RGB values of the single color presets.

Definition at line 82 of file light_scheduler.c.

Referenced by light_scheduler_periodic(), light_scheduler_set_color(), and light_scheduler_sparkle().

◆ light_scheduler_red

uint8_t light_scheduler_red = LIGHT_SCHEDULER_RED

red value in color mode

Definition at line 75 of file light_scheduler.c.

Referenced by light_scheduler_periodic(), and light_scheduler_set_color().

◆ s

◆ sparkle_seed

uint32_t sparkle_seed = 0x2545F491
static

Definition at line 106 of file light_scheduler.c.

Referenced by sparkle_rand().