rgblite.h 585 B

123456789101112131415161718192021222324252627
  1. // Copyright 2022 Makoto Kurauchi (@MakotoKurauchi)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include "ws2812.h"
  5. #include "color.h"
  6. static inline void rgblite_init(void) {
  7. ws2812_init();
  8. }
  9. static inline void rgblite_setrgb(RGB rgb) {
  10. rgb_led_t leds[RGBLIGHT_LED_COUNT] = {{.r = rgb.r, .g = rgb.g, .b = rgb.b}};
  11. ws2812_setleds(leds, RGBLIGHT_LED_COUNT);
  12. }
  13. static void rgblite_increase_hue(void) {
  14. static uint8_t state = 0;
  15. HSV hsv = { 255, 255, 255 };
  16. hsv.h = state;
  17. state = (state + 8) % 256;
  18. rgblite_setrgb(hsv_to_rgb(hsv));
  19. }