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.

422 lines
21 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
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
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. #ifdef USE_I2C
  3. #include "i2c.h"
  4. #endif
  5. #ifdef SSD1306OLED
  6. #include "ssd1306.h"
  7. #endif
  8. extern keymap_config_t keymap_config;
  9. //Following line allows macro to read current RGB settings
  10. extern rgblight_config_t rgblight_config;
  11. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  12. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  13. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  14. // entirely and just use numbers.
  15. #define _QWERTY 0
  16. #define _COLEMAK 1
  17. #define _DVORAK 2
  18. #define _LOWER 3
  19. #define _RAISE 4
  20. #define _MOUSECURSOR 8
  21. #define _ADJUST 16
  22. enum preonic_keycodes {
  23. QWERTY = SAFE_RANGE,
  24. COLEMAK,
  25. DVORAK,
  26. LOWER,
  27. RAISE,
  28. BACKLIT,
  29. RGBLED_TOGGLE,
  30. RGBLED_STEP_MODE,
  31. RGBLED_INCREASE_HUE,
  32. RGBLED_DECREASE_HUE,
  33. RGBLED_INCREASE_SAT,
  34. RGBLED_DECREASE_SAT,
  35. RGBLED_INCREASE_VAL,
  36. RGBLED_DECREASE_VAL,
  37. DEMOMACRO
  38. };
  39. // Custom macros
  40. #define CTL_ESC CTL_T(KC_ESC) // Tap for Esc, hold for Ctrl
  41. #define CTL_TTAB CTL_T(KC_TAB) // Tap for Esc, hold for Ctrl
  42. #define CTL_ENT CTL_T(KC_ENT) // Tap for Enter, hold for Ctrl
  43. #define SFT_ENT SFT_T(KC_ENT) // Tap for Enter, hold for Shift
  44. // Requires KC_TRNS/_______ for the trigger key in the destination layer
  45. #define LT_MC(kc) LT(_MOUSECURSOR, kc) // L-ayer T-ap M-ouse C-ursor
  46. #define LT_RAI(kc) LT(_RAISE, kc) // L-ayer T-ap to Raise
  47. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  48. /* Qwerty
  49. * ,------+------+------+------+------+------------------------------------------------.
  50. * | Esc | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | DEL |
  51. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  52. * | Tab | Q | W | E | R | T | 7 | 8 | 9 | Y | U | I | O | P | Bksp |
  53. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  54. * | CAPS | A | S | D | F | G | 4 | 5 | 6 | H | J | K | L | ;/Nav| ' |
  55. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  56. * | Shift| Z | X | C | V | B | 1 | 2 | 3 | N | M | , | . | / |Ctl/Et|
  57. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  58. * | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right |
  59. * `--------------------------------------------------------------------------------------------------------'
  60. */
  61. [_QWERTY] = LAYOUT(
  62. KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\
  63. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_P7, KC_P8, KC_P9, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
  64. KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_P4, KC_P5, KC_P6, KC_H, KC_J, KC_K, KC_L,LT_MC(KC_SCLN), KC_QUOT, \
  65. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_P1, KC_P2, KC_P3, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, CTL_ENT, \
  66. KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT,KC_DOWN, KC_UP, KC_RGHT \
  67. ),
  68. /* Colemak
  69. * ,------+------+------+------+------+------------------------------------------------.
  70. * | Esc | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | 0 | - |
  71. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  72. * | Tab | Q | W | F | P | G | 7 | 8 | 9 | J | L | U | Y | ; | Bksp |
  73. * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
  74. * | CAPS | A | R | S | T | D | 4 | 5 | 6 | H | N | E | I | O | ' |
  75. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  76. * | Shift| Z | X | C | V | B | 1 | 2 | 3 | K | M | , | . | / |Ctl/Et|
  77. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  78. * | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right |
  79. * `--------------------------------------------------------------------------------------------------------'
  80. */
  81. [_COLEMAK] = LAYOUT(
  82. KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\
  83. KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_P7, KC_P8, KC_P9, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
  84. KC_LCTRL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_P4, KC_P5, KC_P6, KC_H, KC_N, KC_E, KC_I, LT_MC(KC_O), KC_QUOT, \
  85. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_P1, KC_P2, KC_P3, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, CTL_ENT, \
  86. KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  87. ),
  88. /* Dvorak
  89. * ,------+------+------+------+------+------------------------------------------------.
  90. * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
  91. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  92. * | Tab | " | , | . | P | Y | 7 | 8 | 9 | F | G | C | R | L | Bksp |
  93. * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
  94. * | Esc | A | O | E | U | I | 4 | 5 | 6 | D | H | T | N | S | / |
  95. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  96. * | Shift| ; | Q | J | K | X | 1 | 2 | 3 | B | M | W | V | Z |Ctl/Et|
  97. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  98. * | ` | Ctrl | Alt | GUI |Lower |Space | 0 | . | = |Space |Raise | Left | Down | Up |Right |
  99. * `--------------------------------------------------------------------------------------------------------'
  100. */
  101. [_DVORAK] = LAYOUT(
  102. KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_DEL,\
  103. KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_P7, KC_P8, KC_P9, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
  104. KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_P4, KC_P5, KC_P6, KC_D, KC_H, KC_T, KC_N, LT_MC(KC_S), KC_SLSH, \
  105. KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_P1, KC_P2, KC_P3, KC_B, KC_M, KC_W, KC_V, KC_Z, CTL_ENT, \
  106. KC_GRV, KC_LCTRL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_P0, KC_DOT, KC_EQL, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  107. ),
  108. /* Lower
  109. * ,------+------+------+------+------+------------------------------------------------.
  110. * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
  111. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  112. * | ~ | ! | @ | # | $ | % | | | | ^ | & | * | ( | ) | Del |
  113. * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
  114. * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | _ | + | { | } | | |
  115. * |------+------+------+------+------+------|------+------+------+------+------+------+------+------+------|
  116. * | | F7 | F8 | F9 | F10 | F11 | | | | F12 |ISO ~ |ISO | | | | |
  117. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  118. * | | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  119. * `--------------------------------------------------------------------------------------------------------'
  120. */
  121. [_LOWER] = LAYOUT(
  122. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
  123. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, _______, _______, _______, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
  124. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, _______, KC_F6, KC_UNDS, KC_PLUS, KC_LBRC, KC_RBRC, KC_PIPE, \
  125. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, KC_F12,S(KC_NUHS),S(KC_NUBS),_______,_______, _______, \
  126. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  127. ),
  128. /* Raise
  129. * ,------+------+------+------+------+------------------------------------------------.
  130. * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
  131. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  132. * | ` | 1 | 2 | 3 | 4 | 5 | | | | 6 | 7 | 8 | 9 | 0 | Del |
  133. * |------+------+------+------+------+-------------+------+------+------+------+------+------+------+------|
  134. * | Del | F1 | F2 | F3 | F4 | F5 | | | | F6 | - | = | [ | ] | \ |
  135. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  136. * | | F7 | F8 | F9 | F10 | F11 | | | | F12 |ISO # |ISO / | | | |
  137. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  138. * | | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  139. * `--------------------------------------------------------------------------------------------------------'
  140. */
  141. [_RAISE] = LAYOUT(
  142. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
  143. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, _______, _______, _______, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  144. KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______, _______, _______, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
  145. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, _______, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
  146. _______, _______, _______, _______, _______, KC_SPC, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  147. ),
  148. /* Mouse Layer (semi-col)
  149. * ,------+------+------+------+------+------------------------------------------------.
  150. * | ACCL0| ACCL1| ACCL2| | | | | | | | | |
  151. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  152. * | | | | | | | | | Home | Wh_Up| WHL_L| M_Up | WHL_R| Macro| |
  153. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  154. * | | | | | | | | | End | Wh_Dn| M_Lft| M_Dn | M_Rt | | |
  155. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  156. * | | | | | | | | | | BTN2 | BTN3 | BTN4 | BTN5 | | |
  157. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  158. * | | | | | | BTN1 | | | | BTN1 | | | | | |
  159. * `--------------------------------------------------------------------------------------------------------'
  160. */
  161. [_MOUSECURSOR] = LAYOUT(
  162. KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  163. _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGUP, KC_WH_L, KC_MS_U, KC_WH_R,DEMOMACRO,_______, \
  164. _______, _______, _______, _______, _______, _______, _______, _______, KC_END , KC_PGDN, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, \
  165. _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_BTN2, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, \
  166. _______, _______, _______, _______, _______, KC_BTN1, _______, _______, _______, KC_BTN1, _______, _______, _______, _______, _______ \
  167. ),
  168. /* Adjust (Lower + Raise)
  169. * ,------+------+------+------+------+------------------------------------------------.
  170. * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - |
  171. * |------+------+------+------+------+------+------+------+------+------+------+------+--------------------.
  172. * | Reset|RGB TG|RGB ST|RGBH -|RGBH +|RGBS -|RGBS +|RGBV -|RGBV +| | | | | | Del |
  173. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  174. * | | | |Aud on|Audoff|AGnorm| | | |AGswap|Qwerty|Colemk| | | |
  175. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  176. * | |Voice-|Voice+|Mus on|Musoff| | | | | | | | BL + |BL ST |BL TG |
  177. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  178. * | | | | | | | | | | | | | | | |
  179. * `--------------------------------------------------------------------------------------------------------'
  180. */
  181. [_ADJUST] = LAYOUT(
  182. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
  183. RESET, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______, _______, KC_DEL, \
  184. _______, _______, _______, AU_ON, AU_OFF, AG_NORM, _______, _______, _______, AG_SWAP, QWERTY, COLEMAK, _______, _______, _______, \
  185. _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, BL_DEC, BL_INC, BL_STEP, BL_TOGG, \
  186. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______\
  187. )
  188. };
  189. // define variables for reactive RGB
  190. bool RGB_INIT = false;
  191. bool TOG_STATUS = false;
  192. int RGB_current_mode;
  193. void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  194. if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
  195. rgblight_mode(RGB_current_mode);
  196. layer_on(layer3);
  197. } else {
  198. layer_off(layer3);
  199. }
  200. }
  201. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  202. switch (keycode) {
  203. case QWERTY:
  204. if (record->event.pressed) {
  205. set_single_persistent_default_layer(_QWERTY);
  206. }
  207. return false;
  208. break;
  209. case COLEMAK:
  210. if (record->event.pressed) {
  211. set_single_persistent_default_layer(_COLEMAK);
  212. }
  213. return false;
  214. break;
  215. case LOWER:
  216. if (record->event.pressed) {
  217. //not sure how to have keyboard check mode and set it to a variable, so my work around
  218. //uses another variable that would be set to true after the first time a reactive key is pressed.
  219. if (RGB_INIT) {} else {
  220. RGB_current_mode = rgblight_config.mode;
  221. RGB_INIT = true;
  222. }
  223. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  224. } else {
  225. TOG_STATUS = !TOG_STATUS;
  226. rgblight_mode(16);
  227. }
  228. layer_on(_LOWER);
  229. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  230. } else {
  231. rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  232. TOG_STATUS = false;
  233. layer_off(_LOWER);
  234. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  235. }
  236. return false;
  237. break;
  238. case RAISE:
  239. if (record->event.pressed) {
  240. //not sure how to have keyboard check mode and set it to a variable, so my work around
  241. //uses another variable that would be set to true after the first time a reactive key is pressed.
  242. if (RGB_INIT) {} else {
  243. RGB_current_mode = rgblight_config.mode;
  244. RGB_INIT = true;
  245. }
  246. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  247. } else {
  248. TOG_STATUS = !TOG_STATUS;
  249. rgblight_mode(15);
  250. }
  251. layer_on(_RAISE);
  252. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  253. } else {
  254. rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  255. layer_off(_RAISE);
  256. TOG_STATUS = false;
  257. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  258. }
  259. return false;
  260. break;
  261. case BACKLIT:
  262. if (record->event.pressed) {
  263. register_code(KC_RSFT);
  264. #ifdef BACKLIGHT_ENABLE
  265. backlight_step();
  266. #endif
  267. } else {
  268. unregister_code(KC_RSFT);
  269. }
  270. return false;
  271. break;
  272. case RGB_MOD:
  273. //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
  274. if (record->event.pressed) {
  275. rgblight_mode(RGB_current_mode);
  276. rgblight_step();
  277. RGB_current_mode = rgblight_config.mode;
  278. }
  279. return false;
  280. break;
  281. case DEMOMACRO:
  282. if (record->event.pressed) {
  283. SEND_STRING("hello world");
  284. }
  285. return false;
  286. break;
  287. }
  288. return true;
  289. }
  290. //Functions for ver2
  291. #ifdef KEYBOARD_hadron_ver2
  292. #include "LUFA/Drivers/Peripheral/TWI.h"
  293. void matrix_init_user(void) {
  294. #ifdef USE_I2C
  295. i2c_master_init();
  296. #ifdef SSD1306OLED
  297. // calls code for the SSD1306 OLED
  298. _delay_ms(400);
  299. TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
  300. iota_gfx_init(); // turns on the display
  301. #endif
  302. #endif
  303. #ifdef AUDIO_ENABLE
  304. startup_user();
  305. #endif
  306. }
  307. void matrix_scan_user(void) {
  308. #ifdef SSD1306OLED
  309. iota_gfx_task(); // this is what updates the display continuously
  310. #endif
  311. }
  312. void matrix_update(struct CharacterMatrix *dest,
  313. const struct CharacterMatrix *source) {
  314. if (memcmp(dest->display, source->display, sizeof(dest->display))) {
  315. memcpy(dest->display, source->display, sizeof(dest->display));
  316. dest->dirty = true;
  317. }
  318. }
  319. //assign the right code to your layers for OLED display
  320. #define L_BASE 0
  321. #define L_LOWER 8
  322. #define L_RAISE 16
  323. #define L_FNLAYER 64
  324. #define L_NUMLAY 128
  325. #define L_NLOWER 136
  326. #define L_NFNLAYER 192
  327. #define L_MOUSECURSOR 256
  328. #define L_ADJUST 65560
  329. void iota_gfx_task_user(void) {
  330. #if DEBUG_TO_SCREEN
  331. if (debug_enable) {
  332. return;
  333. }
  334. #endif
  335. struct CharacterMatrix matrix;
  336. matrix_clear(&matrix);
  337. matrix_write_P(&matrix, PSTR("USB: "));
  338. #ifdef PROTOCOL_LUFA
  339. switch (USB_DeviceState) {
  340. case DEVICE_STATE_Unattached:
  341. matrix_write_P(&matrix, PSTR("Unattached"));
  342. break;
  343. case DEVICE_STATE_Suspended:
  344. matrix_write_P(&matrix, PSTR("Suspended"));
  345. break;
  346. case DEVICE_STATE_Configured:
  347. matrix_write_P(&matrix, PSTR("Connected"));
  348. break;
  349. case DEVICE_STATE_Powered:
  350. matrix_write_P(&matrix, PSTR("Powered"));
  351. break;
  352. case DEVICE_STATE_Default:
  353. matrix_write_P(&matrix, PSTR("Default"));
  354. break;
  355. case DEVICE_STATE_Addressed:
  356. matrix_write_P(&matrix, PSTR("Addressed"));
  357. break;
  358. default:
  359. matrix_write_P(&matrix, PSTR("Invalid"));
  360. }
  361. #endif
  362. // 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
  363. char buf[40];
  364. snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
  365. matrix_write_P(&matrix, PSTR("\n\nLayer: "));
  366. switch (layer_state) {
  367. case L_BASE:
  368. matrix_write_P(&matrix, PSTR("Default"));
  369. break;
  370. case L_RAISE:
  371. matrix_write_P(&matrix, PSTR("Raise"));
  372. break;
  373. case L_LOWER:
  374. matrix_write_P(&matrix, PSTR("Lower"));
  375. break;
  376. case L_ADJUST:
  377. matrix_write_P(&matrix, PSTR("ADJUST"));
  378. break;
  379. default:
  380. matrix_write(&matrix, buf);
  381. }
  382. // Host Keyboard LED Status
  383. char led[40];
  384. snprintf(led, sizeof(led), "\n%s %s %s",
  385. (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
  386. (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
  387. (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
  388. matrix_write(&matrix, led);
  389. matrix_update(&display, &matrix);
  390. }
  391. #endif