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.

481 lines
22 KiB

adding Hadron v3 keyboard, QWIIC devices support, haptic feedback support (#4462) * add initial support for hadron ver3 * add initial support for hadron ver3 * pull qwiic support for micro_led to be modified for use in hadron's 64x24 ssd1306 oled display * initial work on OLED using qwiic driver * early work to get 128x32 oled working by redefining qwiic micro oled parameters. Currently working, but would affect qwiic's micro oled functionality * moved oled defines to config.h and added ifndef to micro_oled driver * WORKING :D - note, still work in progress to get the start location correct on the 128x32 display. * added equation to automatically calculate display offset based on screen width * adding time-out timer to oled display * changed read lock staus via read_led_state * lock indications fixes * Added scroll lock indication to oled * add support for DRV2605 haptic driver * Improve readabiity of DRV2605 driver. -added typedef for waveform library -added unions for registers * Update keyboards/hadron/ver2/keymaps/default/config.h Co-Authored-By: ishtob <ishtob@gmail.com> * Update keyboards/hadron/ver2/keymaps/default/config.h Co-Authored-By: ishtob <ishtob@gmail.com> * Update keyboards/hadron/ver2/keymaps/default/config.h Co-Authored-By: ishtob <ishtob@gmail.com> * Update keyboards/hadron/ver2/keymaps/default/config.h Co-Authored-By: ishtob <ishtob@gmail.com> * Fixes for PR * PR fixes * fix old persistent layer function to use new set_single_persistent_default_layer * fix issues with changing makefile defines that broken per-key haptic pulse * Comment fixes * Add definable parameter and auto-calibration based on motor choice
5 years ago
  1. #include QMK_KEYBOARD_H
  2. #include "LUFA/Drivers/Peripheral/TWI.h"
  3. #ifdef AUDIO_ENABLE
  4. #include "audio.h"
  5. #endif
  6. #ifdef USE_I2C
  7. #include "i2c.h"
  8. #endif
  9. #ifdef SSD1306OLED
  10. #include "ssd1306.h"
  11. #endif
  12. extern keymap_config_t keymap_config;
  13. //Following line allows macro to read current RGB settings
  14. extern rgblight_config_t rgblight_config;
  15. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  16. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  17. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  18. // entirely and just use numbers.
  19. #define _QWERTY 0
  20. #define _LOWER 3
  21. #define _RAISE 4
  22. #define _FNLAYER 6
  23. #define _NUMLAY 7
  24. #define _MOUSECURSOR 8
  25. #define _ADJUST 16
  26. enum preonic_keycodes {
  27. QWERTY = SAFE_RANGE,
  28. COLEMAK,
  29. DVORAK,
  30. LOWER,
  31. RAISE,
  32. BACKLIT,
  33. RGBLED_TOGGLE,
  34. RGBLED_STEP_MODE,
  35. RGBLED_INCREASE_HUE,
  36. RGBLED_DECREASE_HUE,
  37. RGBLED_INCREASE_SAT,
  38. RGBLED_DECREASE_SAT,
  39. RGBLED_INCREASE_VAL,
  40. RGBLED_DECREASE_VAL,
  41. };
  42. enum macro_keycodes {
  43. KC_DEMOMACRO,
  44. };
  45. // Custom macros
  46. #define CTL_ESC CTL_T(KC_ESC) // Tap for Esc, hold for Ctrl
  47. #define CTL_TTAB CTL_T(KC_TAB) // Tap for Esc, hold for Ctrl
  48. #define CTL_ENT CTL_T(KC_ENT) // Tap for Enter, hold for Ctrl
  49. #define SFT_ENT SFT_T(KC_ENT) // Tap for Enter, hold for Shift
  50. // Requires KC_TRNS/_______ for the trigger key in the destination layer
  51. #define LT_FN(kc) LT(_FNLAYER, kc) // L-ayer T-ap Function Layer
  52. #define LT_MC(kc) LT(_MOUSECURSOR, kc) // L-ayer T-ap M-ouse C-ursor
  53. #define LT_RAI(kc) LT(_RAISE, kc) // L-ayer T-ap to Raise
  54. #define TG_NUMLAY TG(_NUMLAY) //Toggle for layer _NUMLAY
  55. #define DEMOMACRO M(KC_DEMOMACRO) // My login macros
  56. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  57. /* Qwerty
  58. * ,------+------+------+------+------+------------------------------------------------.
  59. * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
  60. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  61. * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | 7 | 8 | 9 |
  62. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  63. * | CAPS | A | S | D | F | G | H | J | K | L | ; |Enter | 4 | 5 | 6 |
  64. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  65. * | Shift| Z | X | C | V | B | N | M | , | . | / | = | 1 | 2 | 3 |
  66. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  67. * | ~ | Ctrl | Alt | GUI |Lower |Space |Space |Raise | RAlt | Ins | Del |NumLay| 0 | . | ENT |
  68. * `--------------------------------------------------------------------------------------------------------'
  69. */
  70. [_QWERTY] = LAYOUT(
  71. KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,\
  72. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, KC_P7, KC_P8, KC_P9, \
  73. KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, LT_MC(KC_SCLN), CTL_ENT, KC_P4, KC_P5, KC_P6, \
  74. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_EQL, KC_P1, KC_P2, KC_P3, \
  75. KC_GRV, KC_RCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_RALT, KC_INS, KC_DEL, TG_NUMLAY, KC_P0, KC_PDOT, KC_PENT \
  76. ),
  77. /* Lower
  78. * ,-----------------------------------------------------------------------------------.
  79. * | | | | | | | | | | | | |
  80. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  81. * | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | ~ | \ | | | |
  82. * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
  83. * | CAPS | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | | | |
  84. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  85. * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | [ | ] | | | | |
  86. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  87. * | | | | | | | | | Next | Vol- | Vol+ | Play | | | |
  88. * `--------------------------------------------------------------------------------------------------------'
  89. */
  90. [_LOWER] = LAYOUT(
  91. KC_ESC, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
  92. KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_GRV, KC_BSLS, _______, _______, _______, \
  93. KC_CAPS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_EQL, KC_LBRC, KC_RBRC, KC_PIPE, _______, _______, _______, \
  94. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS), S(KC_NUBS), KC_LCBR, KC_RCBR, _______, _______, _______, _______, \
  95. _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, _______, _______\
  96. ),
  97. /* Raise
  98. * ,-----------------------------------------------------------------------------------.
  99. * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
  100. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  101. * | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | ~ | \ | | | |
  102. * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
  103. * | | A | Up | D | PrSc | | 4 | 5 | 6 | * | : | ' | | | |
  104. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  105. * | | Lt | Dn | Rt | Mute | | 1 | 2 | 3 | Up | / | | | | |
  106. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  107. * | | | | | |Space | 0 | | Left | Down | Right| | | | |
  108. * `--------------------------------------------------------------------------------------------------------'
  109. */
  110. [_RAISE] = LAYOUT(
  111. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
  112. KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_PLUS, KC_BSLS, _______, _______, _______, \
  113. _______, KC_A, KC_UP, KC_D, KC_PSCR, _______, KC_4, KC_5, KC_6, KC_PAST, KC_COLN, KC_QUOT, _______, _______, _______, \
  114. _______, KC_LEFT, KC_DOWN, KC_RIGHT, KC__MUTE, _______, KC_1, KC_2, KC_3, KC_UP, KC_SLSH, _______, _______, _______, _______, \
  115. _______, _______, _______, _______, _______, KC_SPC, KC_0, _______, KC_LEFT, KC_DOWN, KC_RIGHT, _______, _______, _______, _______ \
  116. ),
  117. /* FN layer on Esc key
  118. * ,-----------------------------------------------------------------------------------.
  119. * | | | | | | | | | | | | |
  120. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  121. * | | ! | @ | # | $ | % | ^ | & | * | ( | ) | + | | | |
  122. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  123. * | | F1 | F2 | F3 | F4 | F5 | F6 | _ | = | [ | ] | ' | | | |
  124. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  125. * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | { | } | | | | |
  126. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  127. * | | | | | | | | | Next | Vol- | Vol+ | Play | | | |
  128. * `--------------------------------------------------------------------------------------------------------'
  129. */
  130. [_FNLAYER] = LAYOUT(
  131. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,\
  132. _______, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PLUS, _______, _______, _______, \
  133. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_EQL, KC_LBRC, KC_RBRC, KC_QUOT, _______, _______, _______, \
  134. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS), S(KC_NUBS), KC_LCBR, KC_RCBR, _______, _______, _______, _______, \
  135. _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, _______, _______, _______ \
  136. ),
  137. /* Num Layer
  138. * ,-----------------------------------------------------------------------------------.
  139. * | | | | | | | | | | | | |
  140. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  141. * | | | | | | | | | | | | | F7 | F8 | F9 |
  142. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  143. * | | | | | | | | | | | | | F4 | F5 | F6 |
  144. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  145. * | | | | | | | | | | | | | | Up | |
  146. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  147. * | | | | | | | | | | | | Exit | Left | Down | Rght |
  148. * `--------------------------------------------------------------------------------------------------------'
  149. */
  150. [_NUMLAY] = LAYOUT(
  151. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,\
  152. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_HOME, KC_PGUP, \
  153. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, KC_END, KC_PGDN, \
  154. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PMNS, KC_UP, KC_PPLS, \
  155. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RIGHT \
  156. ),
  157. /* Mouse Layer (semi-col)
  158. * ,-----------------------------------------------------------------------------------.
  159. * | |ACCL0| ACCL1| ACCL2 | | | | | | | | |
  160. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  161. * | | | | | | Home | Wh_Up| WHL_L| M_Up | WHL_R| | | | | |
  162. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  163. * | | | | | | End | Wh_Dn| M_Lft| M_Dn | M_Rt | | | | | |
  164. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  165. * | | | | | | | BTN2 | BTN3 | BTN4 | BTN5 | | | | | |
  166. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  167. * | | | | | | BTN1 | | | | BTN1 | | | | | |
  168. * `--------------------------------------------------------------------------------------------------------'
  169. */
  170. [_MOUSECURSOR] = LAYOUT(
  171. _______, KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, _______, _______, _______, _______, _______,\
  172. _______, _______, _______, _______, _______, KC_HOME, KC_PGUP, KC_WH_L, KC_MS_U, KC_WH_R, DEMOMACRO, _______, _______, _______, _______, \
  173. _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_END , KC_PGDN, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, _______, _______, _______, \
  174. _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, KC_BTN2, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, _______, _______, _______, \
  175. _______, _______, _______, _______, _______, KC_BTN1, KC_BTN1, _______, _______, _______, _______, _______, _______, _______, _______ \
  176. ),
  177. /* Adjust (Lower + Raise)
  178. * ,-----------------------------------------------------------------------------------.
  179. * | Reset| | | | | | | | | VolD | VolU | Mute |
  180. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  181. * | |RGB TG|RGB ST|RGBH -|RGBH +|RGBS -|RGBS +|RGBV -|RGBV +| | | Del | | | |
  182. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  183. * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty| | | | | | | |
  184. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  185. * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | BL + |BL ST |BLSTEP| BL TG| | | |
  186. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  187. * | | | | | | | | | | | | | | | |
  188. * `--------------------------------------------------------------------------------------------------------'
  189. */
  190. [_ADJUST] = LAYOUT(
  191. RESET, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_VOLD, KC_VOLU, KC_MUTE, \
  192. _______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, KC_DEL, _______, _______, _______, \
  193. _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, _______, _______, _______, _______, _______, _______, _______, \
  194. _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, BL_DEC, BL_INC, BL_STEP, BL_TOGG, _______, _______, _______, \
  195. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
  196. )
  197. };
  198. // define variables for reactive RGB
  199. bool RGB_INIT = false;
  200. bool TOG_STATUS = false;
  201. bool NUMLAY_STATUS = false;
  202. int RGB_current_mode;
  203. void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  204. if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
  205. rgblight_mode(RGB_current_mode);
  206. layer_on(layer3);
  207. } else {
  208. layer_off(layer3);
  209. }
  210. }
  211. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  212. switch (keycode) {
  213. case QWERTY:
  214. if (record->event.pressed) {
  215. set_single_persistent_default_layer(_QWERTY);
  216. }
  217. return false;
  218. break;
  219. case LOWER:
  220. if (record->event.pressed) {
  221. //not sure how to have keyboard check mode and set it to a variable, so my work around
  222. //uses another variable that would be set to true after the first time a reactive key is pressed.
  223. if (RGB_INIT) {} else {
  224. RGB_current_mode = rgblight_config.mode;
  225. RGB_INIT = true;
  226. }
  227. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  228. } else {
  229. TOG_STATUS = !TOG_STATUS;
  230. rgblight_mode(16);
  231. }
  232. layer_on(_LOWER);
  233. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  234. } else {
  235. rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  236. TOG_STATUS = false;
  237. layer_off(_LOWER);
  238. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  239. }
  240. return false;
  241. break;
  242. case RAISE:
  243. if (record->event.pressed) {
  244. //not sure how to have keyboard check mode and set it to a variable, so my work around
  245. //uses another variable that would be set to true after the first time a reactive key is pressed.
  246. if (RGB_INIT) {} else {
  247. RGB_current_mode = rgblight_config.mode;
  248. RGB_INIT = true;
  249. }
  250. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  251. } else {
  252. TOG_STATUS = !TOG_STATUS;
  253. rgblight_mode(15);
  254. }
  255. layer_on(_RAISE);
  256. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  257. } else {
  258. rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  259. layer_off(_RAISE);
  260. TOG_STATUS = false;
  261. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  262. }
  263. return false;
  264. break;
  265. case BACKLIT:
  266. if (record->event.pressed) {
  267. register_code(KC_RSFT);
  268. #ifdef BACKLIGHT_ENABLE
  269. backlight_step();
  270. #endif
  271. } else {
  272. unregister_code(KC_RSFT);
  273. }
  274. return false;
  275. break;
  276. //my attempt for RGB layer lock indication via changing the mode, still have to figure out how to not have other keypress not override this mode
  277. case TG_NUMLAY:
  278. if (record->event.pressed) {
  279. if (RGB_INIT) {} else {
  280. RGB_current_mode = rgblight_config.mode;
  281. RGB_INIT = true;
  282. }
  283. NUMLAY_STATUS = !NUMLAY_STATUS;
  284. if (NUMLAY_STATUS) {
  285. rgblight_mode(4);
  286. layer_on(_NUMLAY);
  287. } else {
  288. rgblight_mode(RGB_current_mode);
  289. layer_off(_NUMLAY); }
  290. }
  291. return false;
  292. break;
  293. case RGB_MOD:
  294. //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
  295. if (record->event.pressed) {
  296. rgblight_mode(RGB_current_mode);
  297. rgblight_step();
  298. RGB_current_mode = rgblight_config.mode;
  299. }
  300. return false;
  301. break;
  302. }
  303. return true;
  304. }
  305. void matrix_init_user(void) {
  306. #ifdef USE_I2C
  307. i2c_master_init();
  308. #ifdef SSD1306OLED
  309. // calls code for the SSD1306 OLED
  310. _delay_ms(400);
  311. TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
  312. iota_gfx_init(); // turns on the display
  313. #endif
  314. #endif
  315. #ifdef AUDIO_ENABLE
  316. startup_user();
  317. #endif
  318. }
  319. void matrix_scan_user(void) {
  320. #ifdef SSD1306OLED
  321. iota_gfx_task(); // this is what updates the display continuously
  322. #endif
  323. }
  324. #ifdef AUDIO_ENABLE
  325. void startup_user()
  326. {
  327. _delay_ms(20); // gets rid of tick
  328. PLAY_SONG(tone_startup);
  329. }
  330. void shutdown_user()
  331. {cc
  332. PLAY_SONG(tone_goodbye);
  333. _delay_ms(150);
  334. stop_all_notes();
  335. }
  336. void music_on_user(void)
  337. {
  338. music_scale_user();
  339. }
  340. void music_scale_user(void)
  341. {
  342. PLAY_SONG(music_scale);
  343. }
  344. #endif
  345. /*
  346. * Macro definition
  347. */
  348. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  349. {
  350. if (!eeconfig_is_enabled()) {
  351. eeconfig_init();
  352. }
  353. switch (id) {
  354. case KC_DEMOMACRO:
  355. if (record->event.pressed){
  356. return MACRO (I(1), T(H),T(E),T(L), T(L), T(O), T(SPACE), T(W), T(O), T(R), T(L), T(D), END);
  357. }
  358. }
  359. return MACRO_NONE;
  360. }
  361. void matrix_update(struct CharacterMatrix *dest,
  362. const struct CharacterMatrix *source) {
  363. if (memcmp(dest->display, source->display, sizeof(dest->display))) {
  364. memcpy(dest->display, source->display, sizeof(dest->display));
  365. dest->dirty = true;
  366. }
  367. }
  368. //assign the right code to your layers for OLED display
  369. #define L_BASE 0
  370. #define L_LOWER 8
  371. #define L_RAISE 16
  372. #define L_FNLAYER 64
  373. #define L_NUMLAY 128
  374. #define L_NLOWER 136
  375. #define L_NFNLAYER 192
  376. #define L_MOUSECURSOR 256
  377. #define L_ADJUST 65560
  378. void iota_gfx_task_user(void) {
  379. #if DEBUG_TO_SCREEN
  380. if (debug_enable) {
  381. return;
  382. }
  383. #endif
  384. struct CharacterMatrix matrix;
  385. matrix_clear(&matrix);
  386. matrix_write_P(&matrix, PSTR("USB: "));
  387. #ifdef PROTOCOL_LUFA
  388. switch (USB_DeviceState) {
  389. case DEVICE_STATE_Unattached:
  390. matrix_write_P(&matrix, PSTR("Unattached"));
  391. break;
  392. case DEVICE_STATE_Suspended:
  393. matrix_write_P(&matrix, PSTR("Suspended"));
  394. break;
  395. case DEVICE_STATE_Configured:
  396. matrix_write_P(&matrix, PSTR("Connected"));
  397. break;
  398. case DEVICE_STATE_Powered:
  399. matrix_write_P(&matrix, PSTR("Powered"));
  400. break;
  401. case DEVICE_STATE_Default:
  402. matrix_write_P(&matrix, PSTR("Default"));
  403. break;
  404. case DEVICE_STATE_Addressed:
  405. matrix_write_P(&matrix, PSTR("Addressed"));
  406. break;
  407. default:
  408. matrix_write_P(&matrix, PSTR("Invalid"));
  409. }
  410. #endif
  411. // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
  412. char buf[40];
  413. snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
  414. matrix_write_P(&matrix, PSTR("\n\nLayer: "));
  415. switch (layer_state) {
  416. case L_BASE:
  417. matrix_write_P(&matrix, PSTR("Default"));
  418. break;
  419. case L_RAISE:
  420. matrix_write_P(&matrix, PSTR("Raise"));
  421. break;
  422. case L_LOWER:
  423. matrix_write_P(&matrix, PSTR("Lower"));
  424. break;
  425. case L_ADJUST:
  426. matrix_write_P(&matrix, PSTR("ADJUST"));
  427. break;
  428. default:
  429. matrix_write(&matrix, buf);
  430. }
  431. // Host Keyboard LED Status
  432. char led[40];
  433. snprintf(led, sizeof(led), "\n%s %s %s",
  434. (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
  435. (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
  436. (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
  437. matrix_write(&matrix, led);
  438. matrix_update(&display, &matrix);
  439. }