Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_led_strip.h
1 #ifndef _BC_LED_STRIP_H
2 #define _BC_LED_STRIP_H
3 
4 #include <bc_scheduler.h>
5 
6 typedef enum
7 {
8  BC_LED_STRIP_TYPE_RGBW = 4,
9  BC_LED_STRIP_TYPE_RGB = 3
10 
11 } bc_led_strip_type_t;
12 
13 typedef struct
14 {
15  bc_led_strip_type_t type;
16  int count;
17  uint32_t *buffer;
18 
20 
21 typedef struct
22 {
23  bool (*init)(const bc_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  BC_LED_STRIP_EVENT_EFFECT_DONE = 0,
34 
35 } bc_led_strip_event_t;
36 
37 typedef struct bc_led_strip_t bc_led_strip_t;
38 
40 {
41  const bc_led_strip_driver_t *_driver;
42  const bc_led_strip_buffer_t *_buffer;
43 
44  struct
45  {
46  int led;
47  int round;
48  bc_tick_t wait;
49  uint32_t color;
50  bc_scheduler_task_id_t task_id;
51 
52  } _effect;
53  uint8_t _brightness;
54  void (*_event_handler)(bc_led_strip_t *, bc_led_strip_event_t, void *);
55  void *_event_param;
56 
57 };
58 
59 void bc_led_strip_init(bc_led_strip_t *self, const bc_led_strip_driver_t *driver, const bc_led_strip_buffer_t *buffer);
60 
61 void bc_led_strip_set_event_handler(bc_led_strip_t *self, void (*event_handler)(bc_led_strip_t *, bc_led_strip_event_t, void *), void *event_param);
62 
63 int bc_led_strip_get_pixel_count(bc_led_strip_t *self);
64 
65 bc_led_strip_type_t bc_led_strip_get_strip_type(bc_led_strip_t *self);
66 
67 void bc_led_strip_set_pixel(bc_led_strip_t *self, int position, uint32_t color);
68 
69 void bc_led_strip_set_pixel_rgbw(bc_led_strip_t *self, int position, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
70 
71 bool bc_led_strip_set_rgbw_framebuffer(bc_led_strip_t *self, uint8_t *framebuffer, size_t length);
72 
73 void bc_led_strip_fill(bc_led_strip_t *self, uint32_t color);
74 
75 bool bc_led_strip_write(bc_led_strip_t *self);
76 
77 bool bc_led_strip_is_ready(bc_led_strip_t *self);
78 
79 void bc_led_strip_set_brightness(bc_led_strip_t *self, uint8_t brightness);
80 
81 void bc_led_strip_effect_stop(bc_led_strip_t *self);
82 
83 void bc_led_strip_effect_test(bc_led_strip_t *self);
84 
85 void bc_led_strip_effect_rainbow(bc_led_strip_t *self, bc_tick_t wait);
86 
87 // Slightly different, this makes the rainbow equally distributed throughout
88 void bc_led_strip_effect_rainbow_cycle(bc_led_strip_t *self, bc_tick_t wait);
89 
90 // Fill the dots one after the other with a color
91 void bc_led_strip_effect_color_wipe(bc_led_strip_t *self, uint32_t color, bc_tick_t wait);
92 
93 //Theatre-style crawling lights.
94 void bc_led_strip_effect_theater_chase(bc_led_strip_t *self, uint32_t color, bc_tick_t wait);
95 
96 void bc_led_strip_effect_theater_chase_rainbow(bc_led_strip_t *self, bc_tick_t wait);
97 
98 void bc_led_strip_effect_stroboscope(bc_led_strip_t *self, uint32_t color, bc_tick_t wait);
99 
100 void bc_led_strip_effect_icicle(bc_led_strip_t *self, uint32_t color, bc_tick_t wait);
101 
102 void bc_led_strip_effect_pulse_color(bc_led_strip_t *self, uint32_t color, bc_tick_t wait);
103 
104 void bc_led_strip_thermometer(bc_led_strip_t *self, float temperature, float min, float max, uint8_t white_dots, float set_point, uint32_t color);
105 
106 #endif // _BC_LED_STRIP_H
uint64_t bc_tick_t
Timestamp data type.
Definition: bc_tick.h:16
size_t bc_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: bc_scheduler.h:18