logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

zima.c (3872B)


  1. /* Copyright 2019 Thomas Baart
  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 "quantum.h"
  17. #include <stdio.h>
  18. #ifdef HAPTIC_ENABLE
  19. # include "haptic.h"
  20. extern haptic_config_t haptic_config;
  21. #endif
  22. #ifdef OLED_ENABLE
  23. static bool is_asleep = false;
  24. static uint32_t oled_timer;
  25. void suspend_power_down_kb(void) {
  26. is_asleep = true;
  27. suspend_power_down_user();
  28. }
  29. void suspend_wakeup_init_kb(void) {
  30. is_asleep = false;
  31. suspend_wakeup_init_user();
  32. }
  33. oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
  34. return OLED_ROTATION_180;
  35. }
  36. bool oled_task_kb(void) {
  37. if (!oled_task_user()) {
  38. return false;
  39. }
  40. if (is_asleep) {
  41. oled_off();
  42. return false;
  43. }
  44. if (timer_elapsed32(oled_timer) < 30000) {
  45. oled_on();
  46. oled_scroll_off();
  47. oled_write_P(PSTR("SplitKB's Zima"), false);
  48. char layer[2] = {0};
  49. snprintf(layer, sizeof(layer), "%d", get_highest_layer(layer_state));
  50. oled_write_P(PSTR(" L:"), false);
  51. oled_write_ln(layer, false);
  52. oled_write_ln_P(PSTR("--------------"), false);
  53. if (rgblight_is_enabled()) {
  54. oled_write_P(PSTR("HSV: "), false);
  55. char rgbs[14];
  56. snprintf(rgbs, sizeof(rgbs), "%3d, %3d, %3d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val());
  57. oled_write_ln(rgbs, false);
  58. } else {
  59. oled_write_ln_P(PSTR("RGB LIGHT DISABLED"), false);
  60. }
  61. # ifdef AUDIO_ENABLE
  62. oled_write_P(PSTR("Audio:"), false);
  63. is_audio_on() ? oled_write_P(PSTR(" on"), false) : oled_write_P(PSTR("off"), false);
  64. # ifdef AUDIO_CLICKY
  65. oled_write_P(PSTR(" Clicky:"), false);
  66. (is_clicky_on() && is_audio_on()) ? oled_write_P(PSTR(" on"), false) : oled_write_P(PSTR("off"), false);
  67. # endif
  68. # endif
  69. } else {
  70. if (timer_elapsed32(oled_timer) < 120000) {
  71. oled_on();
  72. // clang-format off
  73. static const char PROGMEM qmk_logo[] = {
  74. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  75. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  76. 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
  77. // clang-format on
  78. oled_write_ln_P(qmk_logo, false);
  79. oled_scroll_right();
  80. } else {
  81. oled_off();
  82. }
  83. }
  84. return false;
  85. }
  86. bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
  87. oled_timer = timer_read32();
  88. return process_record_user(keycode, record);
  89. }
  90. #endif
  91. #ifdef ENCODER_ENABLE
  92. bool encoder_update_kb(uint8_t index, bool clockwise) {
  93. # ifdef OLED_ENABLE
  94. oled_timer = timer_read32();
  95. # endif
  96. # if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
  97. if (is_audio_on() && is_clicky_on()) clicky_play();
  98. # endif
  99. # ifdef HAPTIC_ENABLE
  100. if (haptic_config.enable) haptic_play();
  101. # endif
  102. if (!encoder_update_user(index, clockwise)) return false;
  103. if (clockwise) {
  104. tap_code16(KC_VOLU);
  105. } else {
  106. tap_code16(KC_VOLD);
  107. }
  108. return true;
  109. }
  110. #endif