|
| 1 | + |
| 2 | +#ifndef _ESP32_LED_BUS_H_ |
| 3 | + #define _ESP32_LED_BUS_H_ |
| 4 | + |
| 5 | + //local_includes |
| 6 | + #include "lcd_types.h" |
| 7 | + #include "../../../micropy_updates/common/mp_spi_common.h" |
| 8 | + |
| 9 | + #include "driver/rmt.h" |
| 10 | + |
| 11 | + // micropython includes |
| 12 | + #include "mphalport.h" |
| 13 | + #include "py/obj.h" |
| 14 | + #include "py/objarray.h" |
| 15 | + |
| 16 | + typedef enum mp_lcd_led_ic_type { |
| 17 | + APA104, |
| 18 | + APA105, |
| 19 | + APA109, |
| 20 | + WS2811, |
| 21 | + WS2812, |
| 22 | + WS2812B, |
| 23 | + WS2813, |
| 24 | + WS2814, |
| 25 | + WS2815, |
| 26 | + WS2815B, |
| 27 | + WS2816A, |
| 28 | + WS2816B, |
| 29 | + WS2816C, |
| 30 | + WS2818, |
| 31 | + WS2818A, |
| 32 | + WS2818B, |
| 33 | + WS2851, |
| 34 | + SK6805, |
| 35 | + SK6812, |
| 36 | + SK6813, |
| 37 | + SK6818, |
| 38 | + SK6822, |
| 39 | + CUSTOM = 0xFF |
| 40 | + } mp_lcd_led_ic_type; |
| 41 | + |
| 42 | + typedef enum mp_lcd_led_pixel_order { |
| 43 | + RGB, |
| 44 | + RBG, |
| 45 | + GRB, |
| 46 | + GBR, |
| 47 | + BRG, |
| 48 | + BGR, |
| 49 | + } mp_lcd_led_pixel_order; |
| 50 | + |
| 51 | + typedef struct _mp_lcd_led_bit_timing { |
| 52 | + uint16_t high; |
| 53 | + uint16_t low; |
| 54 | + } mp_lcd_led_bit_timing; |
| 55 | + |
| 56 | + typedef struct { |
| 57 | + rmt_encoder_t base; |
| 58 | + rmt_encoder_t *bytes_encoder; |
| 59 | + rmt_encoder_t *copy_encoder; |
| 60 | + int state; |
| 61 | + rmt_symbol_word_t reset_code; |
| 62 | + } mp_lcd_led_strip_encoder_t; |
| 63 | + |
| 64 | + typedef struct _mp_lcd_led_color_temp { |
| 65 | + uint8_t r; |
| 66 | + uint8_t g; |
| 67 | + uint8_t b; |
| 68 | + bool blue_correct; |
| 69 | + } mp_lcd_led_color_temp; |
| 70 | + |
| 71 | + typedef struct _mp_lcd_led_bus_obj_t { |
| 72 | + mp_obj_base_t base; |
| 73 | + |
| 74 | + mp_obj_t callback; |
| 75 | + |
| 76 | + void *buf1; |
| 77 | + void *buf2; |
| 78 | + uint32_t buffer_flags; |
| 79 | + |
| 80 | + bool trans_done; |
| 81 | + bool rgb565_byte_swap; |
| 82 | + |
| 83 | + lcd_panel_io_t panel_io_handle; |
| 84 | + |
| 85 | + uint32_t buffer_size; |
| 86 | + |
| 87 | + mp_obj_array_t *view1; |
| 88 | + mp_obj_array_t *view2; |
| 89 | + |
| 90 | + // common config |
| 91 | + mp_lcd_led_pixel_order pixel_order; |
| 92 | + uint8_t rgb_order[3]; |
| 93 | + uint16_t pixel_count; |
| 94 | + uint8_t leds_per_pixel; |
| 95 | + mp_lcd_led_color_temp color_temp; |
| 96 | + |
| 97 | + // RMT specific config |
| 98 | + esp_gpio_t data_pin; |
| 99 | + mp_lcd_led_bit_timing bit0; |
| 100 | + mp_lcd_led_bit_timing bit1; |
| 101 | + uint16_t res; |
| 102 | + rmt_channel_handle_t rmt_chan; |
| 103 | + mp_lcd_led_strip_encoder_t *strip_encoder |
| 104 | + |
| 105 | + // SPI specific config |
| 106 | + esp_lcd_panel_io_spi_config_t *panel_io_config; |
| 107 | + esp_lcd_spi_bus_handle_t *bus_handle; |
| 108 | + machine_hw_spi_device_obj_t *spi_device; |
| 109 | + } mp_lcd_led_bus_obj_t; |
| 110 | + |
| 111 | + |
| 112 | + extern const mp_obj_type_t mp_lcd_led_bus_type; |
| 113 | + |
| 114 | +#endif /* _ESP32_LED_BUS_H_ */ |
| 115 | + |
0 commit comments