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.

29 lines
553 B

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