Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_module_power.c
1 #include <bc_module_power.h>
2 #include <bc_scheduler.h>
3 #include <bc_gpio.h>
4 #include <bc_ws2812b.h>
5 
6 #define BC_MODULE_POWER_PIN_RELAY BC_GPIO_P0
7 
8 static uint32_t _bc_module_power_led_strip_dma_buffer_rgbw_144[144 * 4 * 2];
9 static uint32_t _bc_module_power_led_strip_dma_buffer_rgb_150[150 * 3 * 2];
10 
11 const bc_led_strip_buffer_t bc_module_power_led_strip_buffer_rgbw_144 =
12 {
13  .type = BC_LED_STRIP_TYPE_RGBW,
14  .count = 144,
15  .buffer = _bc_module_power_led_strip_dma_buffer_rgbw_144
16 };
17 
18 const bc_led_strip_buffer_t bc_module_power_led_strip_buffer_rgb_150 =
19 {
20  .type = BC_LED_STRIP_TYPE_RGB,
21  .count = 150,
22  .buffer = _bc_module_power_led_strip_dma_buffer_rgb_150
23 };
24 
25 #if LED_STRIP_SWAP_RG == 0
26 
27 const bc_led_strip_driver_t bc_module_power_led_strip_driver =
28 {
29  .init = bc_ws2812b_init,
30  .write = bc_ws2812b_write,
31  .set_pixel = bc_ws2812b_set_pixel_from_uint32,
32  .set_pixel_rgbw = bc_ws2812b_set_pixel_from_rgb,
33  .is_ready = bc_ws2812b_is_ready
34 };
35 
36 #else
37 
38 const bc_led_strip_driver_t bc_module_power_led_strip_driver =
39 {
40  .init = bc_ws2812b_init,
41  .write = bc_ws2812b_write,
42  .set_pixel = bc_ws2812b_set_pixel_from_uint32_swap_rg,
43  .set_pixel_rgbw = bc_ws2812b_set_pixel_from_rgb_swap_rg,
44  .is_ready = bc_ws2812b_is_ready
45 };
46 
47 #endif
48 
49 static struct
50 {
51  struct
52  {
53  bool on;
54 
55  } relay;
56 
57 } _bc_module_power;
58 
60 {
61  memset(&_bc_module_power, 0, sizeof(_bc_module_power));
62 
63  bc_gpio_init(BC_MODULE_POWER_PIN_RELAY);
64  bc_gpio_set_mode(BC_MODULE_POWER_PIN_RELAY, BC_GPIO_MODE_OUTPUT);
65 }
66 
68 {
69  _bc_module_power.relay.on = state;
70 
71  bc_gpio_set_output(BC_MODULE_POWER_PIN_RELAY, _bc_module_power.relay.on ? 1 : 0);
72 }
73 
75 {
76  return _bc_module_power.relay.on;
77 }
78 
80 {
81  return &bc_module_power_led_strip_driver;
82 }
void bc_module_power_init(void)
Initialize power module.
void bc_gpio_set_output(bc_gpio_channel_t channel, int state)
Set output state for GPIO channel.
Definition: bc_gpio.c:442
const bc_led_strip_driver_t * bc_module_power_get_led_strip_driver(void)
Set relay state.
void bc_gpio_set_mode(bc_gpio_channel_t channel, bc_gpio_mode_t mode)
Set mode of operation for GPIO channel.
Definition: bc_gpio.c:340
bool bc_module_power_relay_get_state(void)
Set relay state.
void bc_module_power_relay_set_state(bool state)
Set relay state.
void bc_gpio_init(bc_gpio_channel_t channel)
Initialize GPIO channel.
Definition: bc_gpio.c:301
GPIO channel operates as output.
Definition: bc_gpio.h:102