You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
691 B

  1. #include "ws2812.h"
  2. #include "i2c_master.h"
  3. #ifndef WS2812_ADDRESS
  4. # define WS2812_ADDRESS 0xb0
  5. #endif
  6. #ifndef WS2812_TIMEOUT
  7. # define WS2812_TIMEOUT 100
  8. #endif
  9. void ws2812_init(void) { i2c_init(); }
  10. // Setleds for standard RGB
  11. void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
  12. static bool s_init = false;
  13. if (!s_init) {
  14. ws2812_init();
  15. s_init = true;
  16. }
  17. i2c_transmit(WS2812_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_TIMEOUT);
  18. }
  19. // Setleds for SK6812RGBW
  20. void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
  21. // not supported - for now error out if its enabled
  22. #ifdef RGBW
  23. # error "RGBW not supported"
  24. #endif
  25. }