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.

97 lines
4.2 KiB

  1. /* Copyright 2020 Kyrre Havik Eriksen
  2. *
  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. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "xenon.h"
  17. #ifdef OLED_ENABLE
  18. oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
  19. if (!is_keyboard_master()) {
  20. return OLED_ROTATION_180; // flips the display 180 degrees if offhand
  21. }
  22. return OLED_ROTATION_270;
  23. }
  24. static void render_named_logo(void) {
  25. static const char PROGMEM raw_logo[] = {
  26. 12, 60,252,252,252,236,236,140, 12, 28,248,192, 0,192,248,252,252,252,108, 12, 12,140,236, 60, 12, 0, 0, 0,248,252,252,252,236,204,204,204,204,204,204,204,204,204,204,204,204,140, 12,252,248, 0, 0, 0,252,252,252,252,236,236,236,204, 12, 60,240,192, 0, 0, 0,252,252,252,236,236, 12, 12, 12,252,248, 0, 0,192,224, 96, 48, 24, 24,140,140,132,196,196,196,196,132,140,140, 12, 24, 48, 48, 96,192,128, 0, 0,252,252,252,236,236,236,236,140, 28,120,224,128, 0, 0,252,252,252,252,236,236, 12, 12, 12,252,
  27. 0, 0, 0, 3, 15,255,255,255,254,248,192,195,223,255,255, 63, 15, 1,224,248, 30, 7, 1, 0, 0, 0, 0, 0,255,255,255,255,255,255, 0, 0, 1, 63, 63, 51, 51, 51, 51, 51, 51, 51,243, 3, 1, 0, 0, 0,255,255,255,255,255, 1, 15,127,255,252,240,195, 15, 60,240,255,255,255,255,255, 0, 0, 0,255,255,254,255,255,255,127, 14, 2,195,247, 63, 31, 15, 15, 15, 15, 31, 63,255,255,254,252,248,224, 1, 3, 30,252,255,255,255,255,255, 3, 31,255,254,248,225,135, 30,120,255,255,255,255,255,255, 0, 0, 0,255,
  28. 0, 0,128,240,252,255,255,255, 63, 7, 1,227,127,255,255,255,248,224, 1, 7, 62,240,192, 0, 0, 0, 0, 0,255,255,255,255,255,255, 1, 3, 7,255,255,207,207,207,207,207,206,204,207,192,128, 0, 0, 0,255,255,255,255,255, 0, 0, 0,255,255, 15,127,255,252,240,227,143,127,255,255, 0, 0, 0,255,255, 63,255,255,255,254,240,192,131,135, 12, 24, 48, 48, 48, 48, 24, 28, 15,159,255, 63, 31, 7,128,192,120, 31,255,255,255,255,255, 0, 0, 0,255,255, 31,127,255,252,241,199, 31,127,255,255, 0, 0, 0,255,
  29. 48, 62, 63, 63, 63, 63, 63, 56, 48, 60, 31, 3, 0, 3, 31, 63, 63, 63, 63, 60, 60, 56, 59, 63, 56, 0, 0, 0, 31, 63, 63, 63, 63, 63, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 56, 63, 31, 0, 0, 0, 63, 63, 63, 63, 63, 60, 56, 48, 63, 63, 0, 0, 0, 3, 31, 63, 63, 62, 61, 63, 60, 56, 48, 63, 31, 0, 0, 1, 7, 7, 15, 31, 31, 63, 63, 63, 62, 62, 62, 62, 63, 63, 63, 31, 31, 15, 14, 6, 3, 1, 0, 0, 63, 63, 63, 63, 63, 60, 56, 56, 63, 31, 0, 0, 1, 7, 31, 63, 63, 60, 63, 63, 60, 56, 48, 63
  30. };
  31. oled_write_raw_P(raw_logo, sizeof(raw_logo));
  32. }
  33. static void render_status(void) {
  34. oled_write_P(PSTR("\n\n\n-----\nXENON\n-----\n\n"), false);
  35. // Host Keyboard Layer Status
  36. switch (get_highest_layer(layer_state)) {
  37. case 0:
  38. oled_write_P(PSTR("Base \n"), false);
  39. break;
  40. case 1:
  41. oled_write_P(PSTR("Lower\n"), false);
  42. break;
  43. case 2:
  44. oled_write_P(PSTR("Raise\n"), false);
  45. break;
  46. default:
  47. oled_write_P(PSTR("Undef\n"), false);
  48. }
  49. oled_write_P(PSTR("Layer\n"), false);
  50. }
  51. bool oled_task_kb(void) {
  52. if (!oled_task_user()) {
  53. return false;
  54. }
  55. if (is_keyboard_master()) {
  56. render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
  57. } else {
  58. render_named_logo();
  59. }
  60. return true;
  61. }
  62. #endif
  63. #ifdef ENCODER_ENABLE
  64. bool encoder_update_kb(uint8_t index, bool clockwise) {
  65. if (!encoder_update_user(index, clockwise)) {
  66. return false;
  67. }
  68. if (index == 0) {
  69. // Volume control
  70. if (clockwise) {
  71. tap_code(KC_VOLD);
  72. } else {
  73. tap_code(KC_VOLU);
  74. }
  75. }
  76. else if (index == 1) {
  77. // Page up/Page down
  78. if (clockwise) {
  79. tap_code(KC_PGDN);
  80. } else {
  81. tap_code(KC_PGUP);
  82. }
  83. }
  84. return true;
  85. }
  86. #endif