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.

145 lines
5.2 KiB

  1. /* Copyright 2019 Thomas Baart
  2. * Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include QMK_KEYBOARD_H
  18. #ifdef HAPTIC_ENABLE
  19. # include "haptic.h"
  20. extern haptic_config_t haptic_config;
  21. #endif
  22. // clang-format off
  23. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  24. [0] = LAYOUT_ortho_4x3( /* Base */
  25. KC_MUTE, TG(1), TG(2),
  26. KC_P7, KC_P8, KC_P9,
  27. KC_P4, KC_P5, KC_P6,
  28. KC_P1, KC_P2, KC_P3
  29. ),
  30. [1] = LAYOUT_ortho_4x3( /* Layer 1 */
  31. QK_BOOT, _______, XXXXXXX,
  32. AU_ON, AU_OFF, XXXXXXX,
  33. CK_TOGG, XXXXXXX, CK_UP,
  34. CK_RST, XXXXXXX, CK_DOWN
  35. ),
  36. [2] = LAYOUT_ortho_4x3( /* Layer 2*/
  37. RGB_TOG, RGB_MOD, _______,
  38. RGB_HUI, RGB_SAI, RGB_VAI,
  39. RGB_HUD, RGB_SAD, RGB_VAD,
  40. HF_TOGG, HF_FDBK, HF_CONT
  41. )
  42. };
  43. #ifdef ENCODER_MAP_ENABLE
  44. const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
  45. [0] = { { KC_DOWN, KC_UP } },
  46. [1] = { { KC_VOLD, KC_VOLU } },
  47. [2] = { { RGB_MOD, RGB_RMOD} },
  48. };
  49. #endif
  50. // clang-format on
  51. static bool is_asleep = false;
  52. static uint32_t oled_timer;
  53. void render_oled_logo(void) {
  54. // clang-format off
  55. static const char PROGMEM qmk_logo[] = {
  56. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  57. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  58. 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
  59. // clang-format on
  60. oled_write_ln_P(qmk_logo, false);
  61. }
  62. void render_user_status(void) {
  63. static const char PROGMEM audio_status[2][3] = {{0xE0, 0xE1, 0}, {0xE2, 0xE3, 0}};
  64. oled_write_P(audio_status[is_audio_on()], false);
  65. static const char PROGMEM audio_clicky_status[2][3] = {{0xF4, 0xF5, 0}, {0xF6, 0xF7, 0}};
  66. oled_write_P(audio_clicky_status[is_clicky_on() && is_audio_on()], false);
  67. static const char PROGMEM rgb_layer_status[2][3] = {{0xEE, 0xEF, 0}, {0xF0, 0xF1, 0}};
  68. oled_write_P(rgb_layer_status[rgblight_is_enabled()], false);
  69. static const char PROGMEM nukem_good[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
  70. oled_write_P(nukem_good[0], haptic_config.enable);
  71. }
  72. void keyboard_post_init_user(void) { oled_scroll_set_speed(0); }
  73. bool oled_task_user(void) {
  74. if (is_asleep) {
  75. oled_off();
  76. return false;;
  77. }
  78. if (timer_elapsed32(oled_timer) < 30000) {
  79. oled_on();
  80. oled_scroll_off();
  81. oled_write_P(PSTR("SplitKB's Zima"), false);
  82. char layer[2] = {0};
  83. uint8_t n = get_highest_layer(layer_state);
  84. layer[1] = '\0';
  85. layer[0] = '0' + n % 10;
  86. oled_write_P(PSTR(" L:"), false);
  87. oled_write_ln(layer, false);
  88. oled_write_ln_P(PSTR("--------------"), false);
  89. if (rgblight_is_enabled()) {
  90. oled_write_P(PSTR("HSV: "), false);
  91. char hsv_char[4];
  92. n = rgblight_get_hue();
  93. hsv_char[3] = '\0';
  94. hsv_char[2] = '0' + n % 10;
  95. hsv_char[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  96. hsv_char[0] = n / 10 ? '0' + n / 10 : ' ';
  97. oled_write(hsv_char, false);
  98. oled_write_P(PSTR(", "), false);
  99. n = rgblight_get_sat();
  100. hsv_char[3] = '\0';
  101. hsv_char[2] = '0' + n % 10;
  102. hsv_char[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  103. hsv_char[0] = n / 10 ? '0' + n / 10 : ' ';
  104. oled_write(hsv_char, false);
  105. oled_write_P(PSTR(", "), false);
  106. n = rgblight_get_val();
  107. hsv_char[3] = '\0';
  108. hsv_char[2] = '0' + n % 10;
  109. hsv_char[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  110. hsv_char[0] = n / 10 ? '0' + n / 10 : ' ';
  111. oled_write_ln(hsv_char, false);
  112. } else {
  113. oled_write_ln_P(PSTR("RGB LIGHT DISABLED"), false);
  114. }
  115. render_user_status();
  116. } else {
  117. if (timer_elapsed32(oled_timer) < 120000) {
  118. oled_on();
  119. render_oled_logo();
  120. oled_scroll_right();
  121. } else {
  122. oled_off();
  123. }
  124. }
  125. return false;
  126. }
  127. void suspend_power_down_user(void) { is_asleep = true; }
  128. void suspend_wakeup_init_user(void) { is_asleep = false; }
  129. bool process_record_user(uint16_t keycode, keyrecord_t* record) {
  130. oled_timer = timer_read32();
  131. return true;
  132. }