3 #include "outputselect.h"
7 #define TAPPING_TERM 200
10 #ifdef FAUXCLICKY_ENABLE
11 #include "fauxclicky.h"
14 static void do_code16 (uint16_t code, void (*f) (uint8_t)) {
16 case QK_MODS ... QK_MODS_MAX:
31 if (code < QK_RMODS_MIN) return;
43 static inline void qk_register_weak_mods(uint8_t kc) {
44 add_weak_mods(MOD_BIT(kc));
45 send_keyboard_report();
48 static inline void qk_unregister_weak_mods(uint8_t kc) {
49 del_weak_mods(MOD_BIT(kc));
50 send_keyboard_report();
53 static inline void qk_register_mods(uint8_t kc) {
54 add_weak_mods(MOD_BIT(kc));
55 send_keyboard_report();
58 static inline void qk_unregister_mods(uint8_t kc) {
59 del_weak_mods(MOD_BIT(kc));
60 send_keyboard_report();
63 void register_code16 (uint16_t code) {
64 if (IS_MOD(code) || code == KC_NO) {
65 do_code16 (code, qk_register_mods);
67 do_code16 (code, qk_register_weak_mods);
72 void unregister_code16 (uint16_t code) {
73 unregister_code (code);
74 if (IS_MOD(code) || code == KC_NO) {
75 do_code16 (code, qk_unregister_mods);
77 do_code16 (code, qk_unregister_weak_mods);
81 __attribute__ ((weak))
82 bool process_action_kb(keyrecord_t *record) {
86 __attribute__ ((weak))
87 bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
88 return process_record_user(keycode, record);
91 __attribute__ ((weak))
92 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
96 void reset_keyboard(void) {
103 #ifdef CATERINA_BOOTLOADER
104 *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
109 // Shift / paren setup
112 #define LSPO_KEY KC_9
115 #define RSPC_KEY KC_0
118 static bool shift_interrupted[2] = {0, 0};
119 static uint16_t scs_timer = 0;
121 bool process_record_quantum(keyrecord_t *record) {
123 /* This gets the keycode from the key pressed */
124 keypos_t key = record->event.key;
127 #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
128 /* TODO: Use store_or_get_action() or a similar function. */
129 if (!disable_action_cache) {
132 if (record->event.pressed) {
133 layer = layer_switch_get_layer(key);
134 update_source_layers_cache(key, layer);
136 layer = read_source_layers_cache(key);
138 keycode = keymap_key_to_keycode(layer, key);
141 keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key);
143 // This is how you use actions here
144 // if (keycode == KC_LEAD) {
146 // action.code = ACTION_DEFAULT_LAYER_SET(0);
147 // process_action(record, action);
152 process_record_kb(keycode, record) &&
154 process_midi(keycode, record) &&
157 process_music(keycode, record) &&
159 #ifdef TAP_DANCE_ENABLE
160 process_tap_dance(keycode, record) &&
162 #ifndef DISABLE_LEADER
163 process_leader(keycode, record) &&
165 #ifndef DISABLE_CHORDING
166 process_chording(keycode, record) &&
169 process_combo(keycode, record) &&
171 #ifdef UNICODE_ENABLE
172 process_unicode(keycode, record) &&
175 process_ucis(keycode, record) &&
177 #ifdef PRINTING_ENABLE
178 process_printer(keycode, record) &&
180 #ifdef UNICODEMAP_ENABLE
181 process_unicode_map(keycode, record) &&
187 // Shift / paren setup
191 if (record->event.pressed) {
197 if (record->event.pressed) {
198 print("\nDEBUG: enabled.\n");
203 #ifdef FAUXCLICKY_ENABLE
205 if (record->event.pressed) {
211 if (record->event.pressed) {
217 if (record->event.pressed) {
223 #ifdef RGBLIGHT_ENABLE
225 if (record->event.pressed) {
231 if (record->event.pressed) {
237 if (record->event.pressed) {
238 rgblight_increase_hue();
243 if (record->event.pressed) {
244 rgblight_decrease_hue();
249 if (record->event.pressed) {
250 rgblight_increase_sat();
255 if (record->event.pressed) {
256 rgblight_decrease_sat();
261 if (record->event.pressed) {
262 rgblight_increase_val();
267 if (record->event.pressed) {
268 rgblight_decrease_val();
275 if (record->event.pressed) {
276 set_output(OUTPUT_AUTO);
281 if (record->event.pressed) {
282 set_output(OUTPUT_USB);
286 #ifdef BLUETOOTH_ENABLE
288 if (record->event.pressed) {
289 set_output(OUTPUT_BLUETOOTH);
294 #ifdef ADAFRUIT_BLE_ENABLE
296 if (record->event.pressed) {
297 set_output(OUTPUT_ADAFRUIT_BLE);
303 case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO:
304 if (record->event.pressed) {
305 // MAGIC actions (BOOTMAGIC without the boot)
306 if (!eeconfig_is_enabled()) {
310 keymap_config.raw = eeconfig_read_keymap();
313 case MAGIC_SWAP_CONTROL_CAPSLOCK:
314 keymap_config.swap_control_capslock = true;
316 case MAGIC_CAPSLOCK_TO_CONTROL:
317 keymap_config.capslock_to_control = true;
319 case MAGIC_SWAP_LALT_LGUI:
320 keymap_config.swap_lalt_lgui = true;
322 case MAGIC_SWAP_RALT_RGUI:
323 keymap_config.swap_ralt_rgui = true;
326 keymap_config.no_gui = true;
328 case MAGIC_SWAP_GRAVE_ESC:
329 keymap_config.swap_grave_esc = true;
331 case MAGIC_SWAP_BACKSLASH_BACKSPACE:
332 keymap_config.swap_backslash_backspace = true;
334 case MAGIC_HOST_NKRO:
335 keymap_config.nkro = true;
337 case MAGIC_SWAP_ALT_GUI:
338 keymap_config.swap_lalt_lgui = true;
339 keymap_config.swap_ralt_rgui = true;
341 case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
342 keymap_config.swap_control_capslock = false;
344 case MAGIC_UNCAPSLOCK_TO_CONTROL:
345 keymap_config.capslock_to_control = false;
347 case MAGIC_UNSWAP_LALT_LGUI:
348 keymap_config.swap_lalt_lgui = false;
350 case MAGIC_UNSWAP_RALT_RGUI:
351 keymap_config.swap_ralt_rgui = false;
354 keymap_config.no_gui = false;
356 case MAGIC_UNSWAP_GRAVE_ESC:
357 keymap_config.swap_grave_esc = false;
359 case MAGIC_UNSWAP_BACKSLASH_BACKSPACE:
360 keymap_config.swap_backslash_backspace = false;
362 case MAGIC_UNHOST_NKRO:
363 keymap_config.nkro = false;
365 case MAGIC_UNSWAP_ALT_GUI:
366 keymap_config.swap_lalt_lgui = false;
367 keymap_config.swap_ralt_rgui = false;
369 case MAGIC_TOGGLE_NKRO:
370 keymap_config.nkro = !keymap_config.nkro;
375 eeconfig_update_keymap(keymap_config.raw);
376 clear_keyboard(); // clear to prevent stuck keys
382 if (record->event.pressed) {
383 shift_interrupted[0] = false;
384 scs_timer = timer_read ();
385 register_mods(MOD_BIT(KC_LSFT));
388 #ifdef DISABLE_SPACE_CADET_ROLLOVER
389 if (get_mods() & MOD_BIT(KC_RSFT)) {
390 shift_interrupted[0] = true;
391 shift_interrupted[1] = true;
394 if (!shift_interrupted[0] && timer_elapsed(scs_timer) < TAPPING_TERM) {
395 register_code(LSPO_KEY);
396 unregister_code(LSPO_KEY);
398 unregister_mods(MOD_BIT(KC_LSFT));
405 if (record->event.pressed) {
406 shift_interrupted[1] = false;
407 scs_timer = timer_read ();
408 register_mods(MOD_BIT(KC_RSFT));
411 #ifdef DISABLE_SPACE_CADET_ROLLOVER
412 if (get_mods() & MOD_BIT(KC_LSFT)) {
413 shift_interrupted[0] = true;
414 shift_interrupted[1] = true;
417 if (!shift_interrupted[1] && timer_elapsed(scs_timer) < TAPPING_TERM) {
418 register_code(RSPC_KEY);
419 unregister_code(RSPC_KEY);
421 unregister_mods(MOD_BIT(KC_RSFT));
427 shift_interrupted[0] = true;
428 shift_interrupted[1] = true;
433 return process_action_kb(record);
436 const bool ascii_to_qwerty_shift_lut[0x80] PROGMEM = {
437 0, 0, 0, 0, 0, 0, 0, 0,
438 0, 0, 0, 0, 0, 0, 0, 0,
439 0, 0, 0, 0, 0, 0, 0, 0,
440 0, 0, 0, 0, 0, 0, 0, 0,
441 0, 1, 1, 1, 1, 1, 1, 0,
442 1, 1, 1, 1, 0, 0, 0, 0,
443 0, 0, 0, 0, 0, 0, 0, 0,
444 0, 0, 1, 0, 1, 0, 1, 1,
445 1, 1, 1, 1, 1, 1, 1, 1,
446 1, 1, 1, 1, 1, 1, 1, 1,
447 1, 1, 1, 1, 1, 1, 1, 1,
448 1, 1, 1, 0, 0, 0, 1, 1,
449 0, 0, 0, 0, 0, 0, 0, 0,
450 0, 0, 0, 0, 0, 0, 0, 0,
451 0, 0, 0, 0, 0, 0, 0, 0,
452 0, 0, 0, 1, 1, 1, 1, 0
455 const uint8_t ascii_to_qwerty_keycode_lut[0x80] PROGMEM = {
456 0, 0, 0, 0, 0, 0, 0, 0,
457 KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
458 0, 0, 0, 0, 0, 0, 0, 0,
459 0, 0, 0, KC_ESC, 0, 0, 0, 0,
460 KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
461 KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
462 KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
463 KC_8, KC_9, KC_SCLN, KC_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
464 KC_2, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
465 KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
466 KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
467 KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
468 KC_GRV, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G,
469 KC_H, KC_I, KC_J, KC_K, KC_L, KC_M, KC_N, KC_O,
470 KC_P, KC_Q, KC_R, KC_S, KC_T, KC_U, KC_V, KC_W,
471 KC_X, KC_Y, KC_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
474 /* for users whose OSes are set to Colemak */
476 #include "keymap_colemak.h"
478 const bool ascii_to_colemak_shift_lut[0x80] PROGMEM = {
479 0, 0, 0, 0, 0, 0, 0, 0,
480 0, 0, 0, 0, 0, 0, 0, 0,
481 0, 0, 0, 0, 0, 0, 0, 0,
482 0, 0, 0, 0, 0, 0, 0, 0,
483 0, 1, 1, 1, 1, 1, 1, 0,
484 1, 1, 1, 1, 0, 0, 0, 0,
485 0, 0, 0, 0, 0, 0, 0, 0,
486 0, 0, 1, 0, 1, 0, 1, 1,
487 1, 1, 1, 1, 1, 1, 1, 1,
488 1, 1, 1, 1, 1, 1, 1, 1,
489 1, 1, 1, 1, 1, 1, 1, 1,
490 1, 1, 1, 0, 0, 0, 1, 1,
491 0, 0, 0, 0, 0, 0, 0, 0,
492 0, 0, 0, 0, 0, 0, 0, 0,
493 0, 0, 0, 0, 0, 0, 0, 0,
494 0, 0, 0, 1, 1, 1, 1, 0
497 const uint8_t ascii_to_colemak_keycode_lut[0x80] PROGMEM = {
498 0, 0, 0, 0, 0, 0, 0, 0,
499 KC_BSPC, KC_TAB, KC_ENT, 0, 0, 0, 0, 0,
500 0, 0, 0, 0, 0, 0, 0, 0,
501 0, 0, 0, KC_ESC, 0, 0, 0, 0,
502 KC_SPC, KC_1, KC_QUOT, KC_3, KC_4, KC_5, KC_7, KC_QUOT,
503 KC_9, KC_0, KC_8, KC_EQL, KC_COMM, KC_MINS, KC_DOT, KC_SLSH,
504 KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7,
505 KC_8, KC_9, CM_SCLN, CM_SCLN, KC_COMM, KC_EQL, KC_DOT, KC_SLSH,
506 KC_2, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G,
507 CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O,
508 CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W,
509 CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_6, KC_MINS,
510 KC_GRV, CM_A, CM_B, CM_C, CM_D, CM_E, CM_F, CM_G,
511 CM_H, CM_I, CM_J, CM_K, CM_L, CM_M, CM_N, CM_O,
512 CM_P, CM_Q, CM_R, CM_S, CM_T, CM_U, CM_V, CM_W,
513 CM_X, CM_Y, CM_Z, KC_LBRC, KC_BSLS, KC_RBRC, KC_GRV, KC_DEL
518 void send_string(const char *str) {
521 uint8_t ascii_code = pgm_read_byte(str);
522 if (!ascii_code) break;
523 keycode = pgm_read_byte(&ascii_to_qwerty_keycode_lut[ascii_code]);
524 if (pgm_read_byte(&ascii_to_qwerty_shift_lut[ascii_code])) {
525 register_code(KC_LSFT);
526 register_code(keycode);
527 unregister_code(keycode);
528 unregister_code(KC_LSFT);
531 register_code(keycode);
532 unregister_code(keycode);
538 void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
539 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
546 void tap_random_base64(void) {
547 #if defined(__AVR_ATmega32U4__)
548 uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64;
550 uint8_t key = rand() % 64;
554 register_code(KC_LSFT);
555 register_code(key + KC_A);
556 unregister_code(key + KC_A);
557 unregister_code(KC_LSFT);
560 register_code(key - 26 + KC_A);
561 unregister_code(key - 26 + KC_A);
565 unregister_code(KC_0);
568 register_code(key - 53 + KC_1);
569 unregister_code(key - 53 + KC_1);
572 register_code(KC_LSFT);
573 register_code(KC_EQL);
574 unregister_code(KC_EQL);
575 unregister_code(KC_LSFT);
578 register_code(KC_SLSH);
579 unregister_code(KC_SLSH);
584 void matrix_init_quantum() {
585 #ifdef BACKLIGHT_ENABLE
586 backlight_init_ports();
591 void matrix_scan_quantum() {
596 #ifdef TAP_DANCE_ENABLE
597 matrix_scan_tap_dance();
607 #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_PIN)
609 static const uint8_t backlight_pin = BACKLIGHT_PIN;
611 #if BACKLIGHT_PIN == B7
612 # define COM1x1 COM1C1
614 #elif BACKLIGHT_PIN == B6
615 # define COM1x1 COM1B1
617 #elif BACKLIGHT_PIN == B5
618 # define COM1x1 COM1A1
621 # define NO_BACKLIGHT_CLOCK
624 #ifndef BACKLIGHT_ON_STATE
625 #define BACKLIGHT_ON_STATE 0
628 __attribute__ ((weak))
629 void backlight_init_ports(void)
632 // Setup backlight pin as output and output to on state.
634 _SFR_IO8((backlight_pin >> 4) + 1) |= _BV(backlight_pin & 0xF);
635 #if BACKLIGHT_ON_STATE == 0
637 _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
640 _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF);
643 #ifndef NO_BACKLIGHT_CLOCK
644 // Use full 16-bit resolution.
647 // I could write a wall of text here to explain... but TL;DW
648 // Go read the ATmega32u4 datasheet.
649 // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
651 // Pin PB7 = OCR1C (Timer 1, Channel C)
652 // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
653 // (i.e. start high, go low when counter matches.)
654 // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
655 // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
657 TCCR1A = _BV(COM1x1) | _BV(WGM11); // = 0b00001010;
658 TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
662 #ifdef BACKLIGHT_BREATHING
663 breathing_defaults();
667 __attribute__ ((weak))
668 void backlight_set(uint8_t level)
670 // Prevent backlight blink on lowest level
671 #if BACKLIGHT_ON_STATE == 0
673 _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
676 _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF);
680 #ifndef NO_BACKLIGHT_CLOCK
681 // Turn off PWM control on backlight pin, revert to output low.
682 TCCR1A &= ~(_BV(COM1x1));
685 #if BACKLIGHT_ON_STATE == 0
687 _SFR_IO8((backlight_pin >> 4) + 2) |= _BV(backlight_pin & 0xF);
690 _SFR_IO8((backlight_pin >> 4) + 2) &= ~_BV(backlight_pin & 0xF);
694 #ifndef NO_BACKLIGHT_CLOCK
695 else if ( level == BACKLIGHT_LEVELS ) {
696 // Turn on PWM control of backlight pin
697 TCCR1A |= _BV(COM1x1);
698 // Set the brightness
702 // Turn on PWM control of backlight pin
703 TCCR1A |= _BV(COM1x1);
704 // Set the brightness
705 OCR1x = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2));
709 #ifdef BACKLIGHT_BREATHING
710 breathing_intensity_default();
715 #ifdef BACKLIGHT_BREATHING
717 #define BREATHING_NO_HALT 0
718 #define BREATHING_HALT_OFF 1
719 #define BREATHING_HALT_ON 2
721 static uint8_t breath_intensity;
722 static uint8_t breath_speed;
723 static uint16_t breathing_index;
724 static uint8_t breathing_halt;
726 void breathing_enable(void)
728 if (get_backlight_level() == 0)
734 // Set breathing_index to be at the midpoint (brightest point)
735 breathing_index = 0x20 << breath_speed;
738 breathing_halt = BREATHING_NO_HALT;
740 // Enable breathing interrupt
741 TIMSK1 |= _BV(OCIE1A);
744 void breathing_pulse(void)
746 if (get_backlight_level() == 0)
752 // Set breathing_index to be at the midpoint + 1 (brightest point)
753 breathing_index = 0x21 << breath_speed;
756 breathing_halt = BREATHING_HALT_ON;
758 // Enable breathing interrupt
759 TIMSK1 |= _BV(OCIE1A);
762 void breathing_disable(void)
764 // Disable breathing interrupt
765 TIMSK1 &= ~_BV(OCIE1A);
766 backlight_set(get_backlight_level());
769 void breathing_self_disable(void)
771 if (get_backlight_level() == 0)
773 breathing_halt = BREATHING_HALT_OFF;
777 breathing_halt = BREATHING_HALT_ON;
780 //backlight_set(get_backlight_level());
783 void breathing_toggle(void)
787 if (get_backlight_level() == 0)
793 // Set breathing_index to be at the midpoint + 1 (brightest point)
794 breathing_index = 0x21 << breath_speed;
797 breathing_halt = BREATHING_NO_HALT;
800 // Toggle breathing interrupt
801 TIMSK1 ^= _BV(OCIE1A);
803 // Restore backlight level
806 backlight_set(get_backlight_level());
810 bool is_breathing(void)
812 return (TIMSK1 && _BV(OCIE1A));
815 void breathing_intensity_default(void)
817 //breath_intensity = (uint8_t)((uint16_t)100 * (uint16_t)get_backlight_level() / (uint16_t)BACKLIGHT_LEVELS);
818 breath_intensity = ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2));
821 void breathing_intensity_set(uint8_t value)
823 breath_intensity = value;
826 void breathing_speed_default(void)
831 void breathing_speed_set(uint8_t value)
833 bool is_breathing_now = is_breathing();
834 uint8_t old_breath_speed = breath_speed;
836 if (is_breathing_now)
838 // Disable breathing interrupt
839 TIMSK1 &= ~_BV(OCIE1A);
842 breath_speed = value;
844 if (is_breathing_now)
846 // Adjust index to account for new speed
847 breathing_index = (( (uint8_t)( (breathing_index) >> old_breath_speed ) ) & 0x3F) << breath_speed;
849 // Enable breathing interrupt
850 TIMSK1 |= _BV(OCIE1A);
855 void breathing_speed_inc(uint8_t value)
857 if ((uint16_t)(breath_speed - value) > 10 )
859 breathing_speed_set(0);
863 breathing_speed_set(breath_speed - value);
867 void breathing_speed_dec(uint8_t value)
869 if ((uint16_t)(breath_speed + value) > 10 )
871 breathing_speed_set(10);
875 breathing_speed_set(breath_speed + value);
879 void breathing_defaults(void)
881 breathing_intensity_default();
882 breathing_speed_default();
883 breathing_halt = BREATHING_NO_HALT;
886 /* Breathing Sleep LED brighness(PWM On period) table
887 * (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle
889 * http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63
890 * (0..63).each {|x| p ((sin(x/64.0*PI)**8)*255).to_i }
892 static const uint8_t breathing_table[64] PROGMEM = {
893 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10,
894 15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252,
895 255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23,
896 15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
899 ISR(TIMER1_COMPA_vect)
901 // OCR1x = (pgm_read_byte(&breathing_table[ ( (uint8_t)( (breathing_index++) >> breath_speed ) ) & 0x3F ] )) * breath_intensity;
904 uint8_t local_index = ( (uint8_t)( (breathing_index++) >> breath_speed ) ) & 0x3F;
906 if (((breathing_halt == BREATHING_HALT_ON) && (local_index == 0x20)) || ((breathing_halt == BREATHING_HALT_OFF) && (local_index == 0x3F)))
908 // Disable breathing interrupt
909 TIMSK1 &= ~_BV(OCIE1A);
912 OCR1x = (uint16_t)(((uint16_t)pgm_read_byte(&breathing_table[local_index]) * 257)) >> breath_intensity;
922 __attribute__ ((weak))
923 void backlight_init_ports(void)
928 __attribute__ ((weak))
929 void backlight_set(uint8_t level)
937 // Functions for spitting out values
940 void send_dword(uint32_t number) { // this might not actually work
941 uint16_t word = (number >> 16);
943 send_word(number & 0xFFFFUL);
946 void send_word(uint16_t number) {
947 uint8_t byte = number >> 8;
949 send_byte(number & 0xFF);
952 void send_byte(uint8_t number) {
953 uint8_t nibble = number >> 4;
955 send_nibble(number & 0xF);
958 void send_nibble(uint8_t number) {
962 unregister_code(KC_0);
965 register_code(KC_1 + (number - 1));
966 unregister_code(KC_1 + (number - 1));
969 register_code(KC_A + (number - 0xA));
970 unregister_code(KC_A + (number - 0xA));
976 __attribute__((weak))
977 uint16_t hex_to_keycode(uint8_t hex)
981 } else if (hex < 0xA) {
982 return KC_1 + (hex - 0x1);
984 return KC_A + (hex - 0xA);
988 void api_send_unicode(uint32_t unicode) {
991 dword_to_bytes(unicode, chunk);
992 MT_SEND_DATA(DT_UNICODE, chunk, 5);
996 __attribute__ ((weak))
997 void led_set_user(uint8_t usb_led) {
1001 __attribute__ ((weak))
1002 void led_set_kb(uint8_t usb_led) {
1003 led_set_user(usb_led);
1006 __attribute__ ((weak))
1007 void led_init_ports(void)
1012 __attribute__ ((weak))
1013 void led_set(uint8_t usb_led)
1018 // // Using PE6 Caps Lock LED
1019 // if (usb_led & (1<<USB_LED_CAPS_LOCK))
1029 // PORTE &= ~(1<<6);
1032 led_set_kb(usb_led);
1036 //------------------------------------------------------------------------------
1037 // Override these functions in your keymap file to play different tunes on
1038 // different events such as startup and bootloader jump
1040 __attribute__ ((weak))
1041 void startup_user() {}
1043 __attribute__ ((weak))
1044 void shutdown_user() {}
1046 //------------------------------------------------------------------------------