Firmware SDK
twr_led_strip.h
1 #ifndef _TWR_LED_STRIP_H
2 #define _TWR_LED_STRIP_H
3 
4 #include <twr_scheduler.h>
5 
6 typedef enum
7 {
8  TWR_LED_STRIP_TYPE_RGBW = 4,
9  TWR_LED_STRIP_TYPE_RGB = 3
10 
11 } twr_led_strip_type_t;
12 
13 typedef struct
14 {
15  twr_led_strip_type_t type;
16  int count;
17  uint32_t *buffer;
18 
20 
21 typedef struct
22 {
23  bool (*init)(const twr_led_strip_buffer_t *buffer);
24  void (*set_pixel)(int position, uint32_t color);
25  void (*set_pixel_rgbw)(int position, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
26  bool (*write)(void);
27  bool (*is_ready)(void);
28 
30 
31 typedef enum
32 {
33  TWR_LED_STRIP_EVENT_EFFECT_DONE = 0,
34 
35 } twr_led_strip_event_t;
36 
37 typedef struct twr_led_strip_t twr_led_strip_t;
38 
40 {
41  const twr_led_strip_driver_t *_driver;
42  const twr_led_strip_buffer_t *_buffer;
43 
44  struct
45  {
46  int led;
47  int round;
48  twr_tick_t wait;
49  uint32_t color;
51 
52  } _effect;
53  uint8_t _brightness;
54  void (*_event_handler)(twr_led_strip_t *, twr_led_strip_event_t, void *);
55  void *_event_param;
56 
57 };
58 
59 void twr_led_strip_init(twr_led_strip_t *self, const twr_led_strip_driver_t *driver, const twr_led_strip_buffer_t *buffer);
60 
61 void twr_led_strip_set_event_handler(twr_led_strip_t *self, void (*event_handler)(twr_led_strip_t *, twr_led_strip_event_t, void *), void *event_param);
62 
63 int twr_led_strip_get_pixel_count(twr_led_strip_t *self);
64 
65 twr_led_strip_type_t twr_led_strip_get_strip_type(twr_led_strip_t *self);
66 
67 void twr_led_strip_set_pixel(twr_led_strip_t *self, int position, uint32_t color);
68 
69 void twr_led_strip_set_pixel_rgbw(twr_led_strip_t *self, int position, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
70 
71 bool twr_led_strip_set_rgbw_framebuffer(twr_led_strip_t *self, uint8_t *framebuffer, size_t length);
72 
73 void twr_led_strip_fill(twr_led_strip_t *self, uint32_t color);
74 
75 bool twr_led_strip_write(twr_led_strip_t *self);
76 
77 bool twr_led_strip_is_ready(twr_led_strip_t *self);
78 
79 void twr_led_strip_set_brightness(twr_led_strip_t *self, uint8_t brightness);
80 
81 void twr_led_strip_effect_stop(twr_led_strip_t *self);
82 
83 void twr_led_strip_effect_test(twr_led_strip_t *self);
84 
85 void twr_led_strip_effect_rainbow(twr_led_strip_t *self, twr_tick_t wait);
86 
87 // Slightly different, this makes the rainbow equally distributed throughout
88 void twr_led_strip_effect_rainbow_cycle(twr_led_strip_t *self, twr_tick_t wait);
89 
90 // Fill the dots one after the other with a color
91 void twr_led_strip_effect_color_wipe(twr_led_strip_t *self, uint32_t color, twr_tick_t wait);
92 
93 //Theatre-style crawling lights.
94 void twr_led_strip_effect_theater_chase(twr_led_strip_t *self, uint32_t color, twr_tick_t wait);
95 
96 void twr_led_strip_effect_theater_chase_rainbow(twr_led_strip_t *self, twr_tick_t wait);
97 
98 void twr_led_strip_effect_stroboscope(twr_led_strip_t *self, uint32_t color, twr_tick_t wait);
99 
100 void twr_led_strip_effect_icicle(twr_led_strip_t *self, uint32_t color, twr_tick_t wait);
101 
102 void twr_led_strip_effect_pulse_color(twr_led_strip_t *self, uint32_t color, twr_tick_t wait);
103 
104 void twr_led_strip_thermometer(twr_led_strip_t *self, float temperature, float min, float max, uint8_t white_dots, float set_point, uint32_t color);
105 
106 #endif // _TWR_LED_STRIP_H
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: twr_scheduler.h:22
uint64_t twr_tick_t
Timestamp data type.
Definition: twr_tick.h:16