visualizer.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #include "util.h"
  16. // Copied from keymap.c
  17. enum ergodox_layers {
  18. _QWERTY,
  19. _COLEMAK,
  20. _QWOC,
  21. _LOWER,
  22. _RAISE,
  23. _PLOVER,
  24. // Intermediate layers for SuperDuper (Combo keys does not work on Infinity yet)
  25. _SUPER,
  26. _DUPER,
  27. _SUPERDUPER,
  28. _MOUSE,
  29. _ADJUST,
  30. _MDIA,
  31. _SYMB,
  32. };
  33. // This function should be implemented by the keymap visualizer
  34. // Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing
  35. // that the simple_visualizer assumes that you are updating
  36. // Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is
  37. // stopped. This can be done by either double buffering it or by using constant strings
  38. static void get_visualizer_layer_and_color(visualizer_state_t* state) {
  39. uint8_t saturation = 255;
  40. uint8_t layer = biton32(state->status.layer);
  41. state->target_lcd_color = LCD_COLOR(layer << 2, saturation, 0xFF);
  42. switch(layer) {
  43. case _QWERTY:
  44. state->layer_text = "QWERTY";
  45. break;
  46. case _COLEMAK:
  47. state->layer_text = "COLEMAK";
  48. break;
  49. case _QWOC:
  50. state->layer_text = "QWERTY on COLEMAK";
  51. break;
  52. case _LOWER:
  53. state->layer_text = "LOWER";
  54. break;
  55. case _RAISE:
  56. state->layer_text = "RAISE";
  57. break;
  58. case _PLOVER:
  59. state->layer_text = "PLOVER";
  60. break;
  61. case _SUPERDUPER:
  62. state->layer_text = "SUPERDUPER";
  63. break;
  64. case _SUPER:
  65. state->layer_text = "SUPER";
  66. break;
  67. case _DUPER:
  68. state->layer_text = "DUPER";
  69. break;
  70. case _MOUSE:
  71. state->layer_text = "MOUSE";
  72. break;
  73. case _ADJUST:
  74. state->layer_text = "ADJUST";
  75. break;
  76. case _MDIA:
  77. state->layer_text = "MDIA";
  78. break;
  79. case _SYMB:
  80. state->layer_text = "SYMB";
  81. break;
  82. default:
  83. state->layer_text = "NONE";
  84. break;
  85. }
  86. }