logo

qmk_firmware

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

microdox.c (2947B)


  1. /*
  2. Copyright 2022 Cole Smith <cole@boadsource.xyz>
  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. #ifdef OLED_ENABLE
  15. #include "oled_driver.h"
  16. #include "bitwise.h"
  17. #include "action_layer.h"
  18. oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
  19. if (is_keyboard_master())
  20. return OLED_ROTATION_180;
  21. return rotation;
  22. }
  23. static void render_logo(void) {
  24. static const char PROGMEM qmk_logo[] = {
  25. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
  26. 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
  27. 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00
  28. };
  29. oled_write_P(qmk_logo, false);
  30. }
  31. static void render_status(void) {
  32. switch (get_highest_layer(layer_state)) {
  33. case 0:
  34. oled_write_P(PSTR("B R L A O\n"), false);
  35. oled_write_P(PSTR("^\n"), false);
  36. oled_write_P(PSTR("Layer: Base\n"), false);
  37. break;
  38. case 1:
  39. oled_write_P(PSTR("B R L A O\n"), false);
  40. oled_write_P(PSTR(" ^\n"), false);
  41. oled_write_P(PSTR("Layer: Raise\n"), false);
  42. break;
  43. case 2:
  44. oled_write_P(PSTR("B R L A O\n"), false);
  45. oled_write_P(PSTR(" ^\n"), false);
  46. oled_write_P(PSTR("Layer: Lower\n"), false);
  47. break;
  48. case 3:
  49. oled_write_P(PSTR("B R L A O\n"), false);
  50. oled_write_P(PSTR(" ^\n"), false);
  51. oled_write_P(PSTR("Layer: Adjust\n"), false);
  52. break;
  53. default:
  54. oled_write_P(PSTR("B R L A O"), false);
  55. oled_write_P(PSTR(" ^\n"), false);
  56. oled_write_P(PSTR("Layer: Other\n"), false);
  57. }
  58. }
  59. bool oled_task_kb(void) {
  60. if (!oled_task_user()) { return false; }
  61. if (is_keyboard_master()) {
  62. render_status();
  63. } else {
  64. render_logo();
  65. oled_scroll_left();
  66. }
  67. return false;
  68. }
  69. #endif
  70. #ifdef ENCODER_ENABLE
  71. #include "encoder.h"
  72. bool encoder_update_kb(uint8_t index, bool clockwise) {
  73. if (!encoder_update_user(index, clockwise)) { return false; }
  74. if (index == 0) {
  75. if (clockwise) {
  76. tap_code_delay(KC_VOLU, 10);
  77. } else {
  78. tap_code_delay(KC_VOLD, 10);
  79. }
  80. } else {
  81. if (clockwise) {
  82. tap_code(KC_MNXT);
  83. } else {
  84. tap_code(KC_MPRV);
  85. }
  86. }
  87. return true;
  88. }
  89. #endif