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.

266 lines
9.4 KiB

Makefile redo & other features (#395) * .build containment implemented * no destructive variable setting - builds in either folder * make from 3 places * cleans before each build * make from root with keyboard=keyboard, keymap=keymap * make from keyboard/keyboard with keymap=keymap * make from keymaps/keymap * only implemented on planck * adds color diag to avr-gcc * makefiles for all plancks, clean-up * quick build-all makefile for plancks * reformatting of make output (colors) * color toggle, tmk path corrections * correct if statement for color * move config.h to main makefile, updates preonic, atomic * format update, all keyboards targets * makefile optional for build all target, alps and arrow_pad updated * alps updated * make planck default, trying out travis recipe for all-keyboards * all-keymaps target, different travis recipe * updates alps64 * updates keyboards to new format * updates clue* projects * all projects updated, specialise EZ .hex, let .hex through * updates travis * automatically find root, keyboard, keymap * silent echo, cleaned-up mass make output * updates all keyboards' .hex files except EZ * Rename Bantam44.c to bantam44.c * Rename Bantam44.h to bantam44.h * nananana * adds six key keyboard * does same to ez as rest * updates send_string example * brings ergodox_ez up to date * updates template/new project script * adds sixkeyboard * adds readme for sixkeyboard * adds sixkeyboard to travis * filenames, gitignore mess * define clock prescaler stuff manually * make quick, size test example * documentation and dfu-no-build
8 years ago
Makefile redo & other features (#395) * .build containment implemented * no destructive variable setting - builds in either folder * make from 3 places * cleans before each build * make from root with keyboard=keyboard, keymap=keymap * make from keyboard/keyboard with keymap=keymap * make from keymaps/keymap * only implemented on planck * adds color diag to avr-gcc * makefiles for all plancks, clean-up * quick build-all makefile for plancks * reformatting of make output (colors) * color toggle, tmk path corrections * correct if statement for color * move config.h to main makefile, updates preonic, atomic * format update, all keyboards targets * makefile optional for build all target, alps and arrow_pad updated * alps updated * make planck default, trying out travis recipe for all-keyboards * all-keymaps target, different travis recipe * updates alps64 * updates keyboards to new format * updates clue* projects * all projects updated, specialise EZ .hex, let .hex through * updates travis * automatically find root, keyboard, keymap * silent echo, cleaned-up mass make output * updates all keyboards' .hex files except EZ * Rename Bantam44.c to bantam44.c * Rename Bantam44.h to bantam44.h * nananana * adds six key keyboard * does same to ez as rest * updates send_string example * brings ergodox_ez up to date * updates template/new project script * adds sixkeyboard * adds readme for sixkeyboard * adds sixkeyboard to travis * filenames, gitignore mess * define clock prescaler stuff manually * make quick, size test example * documentation and dfu-no-build
8 years ago
Makefile redo & other features (#395) * .build containment implemented * no destructive variable setting - builds in either folder * make from 3 places * cleans before each build * make from root with keyboard=keyboard, keymap=keymap * make from keyboard/keyboard with keymap=keymap * make from keymaps/keymap * only implemented on planck * adds color diag to avr-gcc * makefiles for all plancks, clean-up * quick build-all makefile for plancks * reformatting of make output (colors) * color toggle, tmk path corrections * correct if statement for color * move config.h to main makefile, updates preonic, atomic * format update, all keyboards targets * makefile optional for build all target, alps and arrow_pad updated * alps updated * make planck default, trying out travis recipe for all-keyboards * all-keymaps target, different travis recipe * updates alps64 * updates keyboards to new format * updates clue* projects * all projects updated, specialise EZ .hex, let .hex through * updates travis * automatically find root, keyboard, keymap * silent echo, cleaned-up mass make output * updates all keyboards' .hex files except EZ * Rename Bantam44.c to bantam44.c * Rename Bantam44.h to bantam44.h * nananana * adds six key keyboard * does same to ez as rest * updates send_string example * brings ergodox_ez up to date * updates template/new project script * adds sixkeyboard * adds readme for sixkeyboard * adds sixkeyboard to travis * filenames, gitignore mess * define clock prescaler stuff manually * make quick, size test example * documentation and dfu-no-build
8 years ago
  1. // This is the canonical layout file for the Quantum project. If you want to add another keyboard,
  2. // this is the style you want to emulate.
  3. #include "planck.h"
  4. #include "action_layer.h"
  5. #ifdef AUDIO_ENABLE
  6. #include "audio.h"
  7. #endif
  8. #include "eeconfig.h"
  9. extern keymap_config_t keymap_config;
  10. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  11. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  12. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  13. // entirely and just use numbers.
  14. #define _QWERTY 0
  15. #define _COLEMAK 1
  16. #define _DVORAK 2
  17. #define _LOWER 3
  18. #define _RAISE 4
  19. #define _FCT 5
  20. #define _SETUP 6
  21. #define _MAC 7
  22. #define _WIN 8
  23. #define _LIN 9
  24. #define _MICMUTE 16
  25. #define _OS 17
  26. // Macro name shortcuts
  27. #define QWERTY M(_QWERTY)
  28. #define COLEMAK M(_COLEMAK)
  29. #define DVORAK M(_DVORAK)
  30. #define LOWER M(_LOWER)
  31. #define RAISE M(_RAISE)
  32. #define FCT M(_FCT)
  33. #define OS M(_OS)
  34. #define MAC M(_MAC)
  35. #define WIN M(_WIN)
  36. #define LIN M(_LIN)
  37. #define MICMUTE M(_MICMUTE)
  38. #define MACPRNT LGUI(LSFT(KC_3))
  39. #define MACPRNT2 LGUI(LSFT(KC_4))
  40. #define WINPRNT KC_PSCR
  41. #define WINPRNT2 LGUI(KC_PSCR)
  42. #define CYCLWIN LGUI(KC_GRV)
  43. #define MACSLEEP LSFT(LCTL(KC_POWER))
  44. #define WINSLEEP KC_SLEP
  45. // Fillers to make layering more clear
  46. #define _______ KC_TRNS
  47. #define XXXXXXX KC_NO
  48. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  49. [_QWERTY] = {
  50. {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
  51. {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
  52. {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
  53. {OS, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
  54. },
  55. [_COLEMAK] = {
  56. {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
  57. {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
  58. {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT },
  59. {OS, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
  60. },
  61. [_DVORAK] = {
  62. {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC},
  63. {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH},
  64. {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT },
  65. {OS, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT}
  66. },
  67. [_LOWER] = {
  68. {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC},
  69. {_______, _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE},
  70. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  71. {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
  72. },
  73. [_RAISE] = {
  74. {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC},
  75. {_______, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS},
  76. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  77. {_RAISE, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
  78. },
  79. [_SETUP] = { /* Setup */
  80. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  81. {_______, _______, _______, WIN, MAC, _______, _______, QWERTY, COLEMAK, DVORAK, _______, _______},
  82. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  83. {_______, _______, _______, _______, _______, RESET, RESET, _______, _______, _______, _______, _______}
  84. },
  85. [_MAC] = { /* Mac */
  86. {CYCLWIN,MACSLEEP, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F4, KC_DELT},
  87. {_______, MICMUTE, KC_MUTE, KC_VOLD, KC_VOLU, MACPRNT,MACPRNT2, KC_F5, KC_F6, KC_F7, KC_F8, XXXXXXX},
  88. {_______, BL_STEP, KC_MPRV, KC_MPLY, KC_MNXT, XXXXXXX, XXXXXXX, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX},
  89. {_______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_HOME, KC_PGDOWN,KC_PGUP,KC_END }
  90. },
  91. [_WIN] = { /* Windows */
  92. {CYCLWIN,WINSLEEP, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F4, KC_DELT},
  93. {_______, MICMUTE, KC_MUTE, KC_VOLD, KC_VOLU, WINPRNT,WINPRNT2, KC_F5, KC_F6, KC_F7, KC_F8, XXXXXXX},
  94. {_______, BL_STEP, KC_MPRV, KC_MPLY, KC_MNXT, XXXXXXX, XXXXXXX, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX},
  95. {_______, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_HOME, KC_PGDOWN,KC_PGUP,KC_END }
  96. },
  97. [_LIN] = { /* Linux */
  98. {KC_L, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  99. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  100. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______},
  101. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
  102. }
  103. };
  104. int currentOs = _MAC;
  105. const uint16_t PROGMEM fn_actions[] = {
  106. };
  107. #ifdef AUDIO_ENABLE
  108. float tone_startup[][2] = {
  109. {440.0*pow(2.0,(31)/12.0), 12},
  110. {440.0*pow(2.0,(28)/12.0), 8},
  111. {440.0*pow(2.0,(19)/12.0), 8},
  112. {440.0*pow(2.0,(24)/12.0), 8},
  113. {440.0*pow(2.0,(28)/12.0), 20}
  114. };
  115. float tone_qwerty[][2] = SONG(QWERTY_SOUND);
  116. float tone_dvorak[][2] = SONG(DVORAK_SOUND);
  117. float tone_colemak[][2] = SONG(COLEMAK_SOUND);
  118. float tone_plover[][2] = SONG(PLOVER_SOUND);
  119. float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
  120. float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
  121. float goodbye[][2] = SONG(GOODBYE_SOUND);
  122. #endif
  123. void persistent_default_layer_set(uint16_t default_layer) {
  124. eeconfig_update_default_layer(default_layer);
  125. default_layer_set(default_layer);
  126. }
  127. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  128. {
  129. switch(id) {
  130. case _QWERTY:
  131. if (record->event.pressed) {
  132. #ifdef AUDIO_ENABLE
  133. PLAY_SONG(tone_qwerty);
  134. #endif
  135. persistent_default_layer_set(1UL<<_QWERTY);
  136. }
  137. break;
  138. case _COLEMAK:
  139. if (record->event.pressed) {
  140. #ifdef AUDIO_ENABLE
  141. PLAY_SONG(tone_colemak);
  142. #endif
  143. persistent_default_layer_set(1UL<<_COLEMAK);
  144. }
  145. break;
  146. case _DVORAK:
  147. if (record->event.pressed) {
  148. #ifdef AUDIO_ENABLE
  149. PLAY_SONG(tone_dvorak);
  150. #endif
  151. persistent_default_layer_set(1UL<<_DVORAK);
  152. }
  153. break;
  154. case _LOWER:
  155. if (record->event.pressed) {
  156. layer_on(_LOWER);
  157. update_tri_layer(_LOWER, _RAISE, _SETUP);
  158. } else {
  159. layer_off(_LOWER);
  160. update_tri_layer(_LOWER, _RAISE, _SETUP);
  161. }
  162. break;
  163. case _RAISE:
  164. if (record->event.pressed) {
  165. layer_on(_RAISE);
  166. update_tri_layer(_LOWER, _RAISE, _SETUP);
  167. } else {
  168. layer_off(_RAISE);
  169. update_tri_layer(_LOWER, _RAISE, _SETUP);
  170. }
  171. break;
  172. case _FCT:
  173. if (record->event.pressed) {
  174. layer_on(_FCT);
  175. } else {
  176. layer_off(_FCT);
  177. }
  178. break;
  179. case _MICMUTE:
  180. if (record->event.pressed) {
  181. register_code(KC_RSFT);
  182. register_code(KC_RCTL);
  183. register_code(KC_RALT);
  184. register_code(KC_RGUI);
  185. } else {
  186. unregister_code(KC_RSFT);
  187. unregister_code(KC_RCTL);
  188. unregister_code(KC_RALT);
  189. unregister_code(KC_RGUI);
  190. }
  191. break;
  192. case _OS:
  193. if (record->event.pressed) {
  194. layer_on(currentOs);
  195. } else {
  196. layer_off(_MAC);
  197. layer_off(_WIN);
  198. layer_off(_LIN);
  199. }
  200. break;
  201. case _MAC:
  202. case _WIN:
  203. case _LIN:
  204. if (record->event.pressed) {
  205. layer_off(currentOs);
  206. currentOs = id;
  207. }
  208. break;
  209. }
  210. return MACRO_NONE;
  211. };
  212. void matrix_init_user(void) {
  213. #ifdef AUDIO_ENABLE
  214. _delay_ms(20); // stops the tick
  215. PLAY_SONG(tone_startup);
  216. #endif
  217. }
  218. #ifdef AUDIO_ENABLE
  219. void play_goodbye_tone()
  220. {
  221. PLAY_SONG(goodbye);
  222. _delay_ms(150);
  223. }
  224. uint8_t starting_note = 0x0C;
  225. int offset = 0;
  226. bool process_action_user(keyrecord_t *record) {
  227. if (IS_LAYER_ON(_MUSIC)) {
  228. if (record->event.pressed) {
  229. play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF);
  230. } else {
  231. stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)));
  232. }
  233. return false;
  234. }
  235. return true;
  236. }
  237. #endif