visualizer.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. Copyright 2017 Fred Sundvik
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "simple_visualizer.h"
  15. // This function should be implemented by the keymap visualizer
  16. // Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing
  17. // that the simple_visualizer assumes that you are updating
  18. // Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is
  19. // stopped. This can be done by either double buffering it or by using constant strings
  20. static void get_visualizer_layer_and_color(visualizer_state_t* state) {
  21. uint8_t saturation = 60;
  22. if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) {
  23. saturation = 255;
  24. }
  25. if (state->status.layer & 0x4) {
  26. state->target_lcd_color = LCD_COLOR(0, saturation, 0xFF);
  27. state->layer_text = "Media & Mouse";
  28. }
  29. else if (state->status.layer & 0x2) {
  30. state->target_lcd_color = LCD_COLOR(168, saturation, 0xFF);
  31. state->layer_text = "Symbol";
  32. }
  33. else {
  34. state->target_lcd_color = LCD_COLOR(84, saturation, 0xFF);
  35. state->layer_text = "Default";
  36. }
  37. }