2
0

visualizer.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #define RED 0
  16. #define ORANGE 21
  17. #define YELLOW 42
  18. #define SPRING_GREEN 64
  19. #define GREEN 85
  20. #define TURQUOISE 107
  21. #define CYAN 127
  22. #define OCEAN 149
  23. #define BLUE 170
  24. #define VIOLET 192
  25. #define MAGENTA 212
  26. #define RASPBERRY 234
  27. // This function should be implemented by the keymap visualizer
  28. // Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing
  29. // that the simple_visualizer assumes that you are updating
  30. // Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is
  31. // stopped. This can be done by either double buffering it or by using constant strings
  32. static void get_visualizer_layer_and_color(visualizer_state_t* state) {
  33. uint8_t saturation = 255;
  34. /* if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) {
  35. saturation = 255;
  36. } */
  37. if (state->status.layer & 0x100) {
  38. state->target_lcd_color = LCD_COLOR(MAGENTA, saturation, 0xFF);
  39. state->layer_text = "Shortcuts Layer";
  40. }
  41. else if (state->status.layer & 0x80) {
  42. state->target_lcd_color = LCD_COLOR(VIOLET, saturation, 0xFF);
  43. state->layer_text = "Plover";
  44. }
  45. else if (state->status.layer & 0x40) {
  46. state->target_lcd_color = LCD_COLOR(RASPBERRY, saturation, 0xFF);
  47. state->layer_text = "Mirrored Symbols";
  48. }
  49. else if (state->status.layer & 0x20) {
  50. state->target_lcd_color = LCD_COLOR(RED, saturation, 0xFF);
  51. state->layer_text = "Symbols";
  52. }
  53. else if (state->status.layer & 0x8) {
  54. state->target_lcd_color = LCD_COLOR(OCEAN, saturation, 0xFF);
  55. state->layer_text = "Mirrored Dvorak";
  56. }
  57. else if (state->status.layer & 0x4) {
  58. state->target_lcd_color = LCD_COLOR(BLUE, saturation, 0xFF);
  59. state->layer_text = "Dvorak";
  60. }
  61. else if (state->status.layer & 0x2) {
  62. state->target_lcd_color = LCD_COLOR(ORANGE, saturation, 0xFF);
  63. state->layer_text = "Mirrored Qwerty";
  64. }
  65. else {
  66. state->target_lcd_color = LCD_COLOR(YELLOW, saturation, 0xFF);
  67. state->layer_text = "Qwerty";
  68. }
  69. }