diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/byte_math.h | 15 | ||||
-rw-r--r-- | include/sysled.h | 19 | ||||
-rw-r--r-- | include/ws2812b.h | 4 |
3 files changed, 36 insertions, 2 deletions
diff --git a/include/byte_math.h b/include/byte_math.h new file mode 100644 index 0000000..79f93b8 --- /dev/null +++ b/include/byte_math.h @@ -0,0 +1,15 @@ +#pragma once + +#include <stdint.h> + +/* Library for doing fast math functions using just uint8_t. */ + +extern uint8_t sintable[256]; + +/* Returns ((sin(n) + 1) / 2) * 255 */ +static inline uint8_t byte_sin(uint8_t n) +{ + return sintable[n]; +} + +uint8_t calc_w(uint8_t n); diff --git a/include/sysled.h b/include/sysled.h new file mode 100644 index 0000000..b9556f1 --- /dev/null +++ b/include/sysled.h @@ -0,0 +1,19 @@ +#pragma once + +/* Easily turn on and off the system-led. */ + +#include "ch573/gpio.h" + +static inline void enable_sysled() +{ + CH573_GPIO__GPIO_PORT_T_INTF.dir.set(ch573_gpio__gpio_port_a, DIR_OUT, 8); + CH573_GPIO__GPIO_PORT_T_INTF.pd_drv.set(ch573_gpio__gpio_port_a, 0, 8); +} + +// If "on" then turn on the sysled (which counter-intuitively means turning off +// the GPIO). +static inline void set_sysled(int on) +{ +// CH573_GPIO__GPIO_PORT_T_INTF.out.set( +// ch573_gpio__gpio_port_a, on ? OFF : ON, 8); +} diff --git a/include/ws2812b.h b/include/ws2812b.h index cb10979..e814b65 100644 --- a/include/ws2812b.h +++ b/include/ws2812b.h @@ -4,11 +4,11 @@ #include <stdlib.h> #define WIRE_BYTES_PER_COLOR 9 -#define PADDING_BYTES 0 +#define PADDING_BYTES 1 #define TOTAL_BYTES_PER_LED (PADDING_BYTES + WIRE_BYTES_PER_COLOR) enum ws2812b_byte_order { - BYTE_ORDER_BGR = 0, + BYTE_ORDER_RGB = 0, BYTE_ORDER_GBR = 1, }; |