aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index e60378afe..326c8370b 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -296,6 +296,9 @@ bool process_record_quantum(keyrecord_t *record) {
296#ifdef JOYSTICK_ENABLE 296#ifdef JOYSTICK_ENABLE
297 process_joystick(keycode, record) && 297 process_joystick(keycode, record) &&
298#endif 298#endif
299#ifdef PROGRAMMABLE_BUTTON_ENABLE
300 process_programmable_button(keycode, record) &&
301#endif
299 true)) { 302 true)) {
300 return false; 303 return false;
301 } 304 }
@@ -480,3 +483,99 @@ void api_send_unicode(uint32_t unicode) {
480__attribute__((weak)) void startup_user() {} 483__attribute__((weak)) void startup_user() {}
481 484
482__attribute__((weak)) void shutdown_user() {} 485__attribute__((weak)) void shutdown_user() {}
486
487/** \brief Run keyboard level Power down
488 *
489 * FIXME: needs doc
490 */
491__attribute__((weak)) void suspend_power_down_user(void) {}
492/** \brief Run keyboard level Power down
493 *
494 * FIXME: needs doc
495 */
496__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
497
498void suspend_power_down_quantum(void) {
499#ifndef NO_SUSPEND_POWER_DOWN
500// Turn off backlight
501# ifdef BACKLIGHT_ENABLE
502 backlight_set(0);
503# endif
504
505# ifdef LED_MATRIX_ENABLE
506 led_matrix_task();
507# endif
508# ifdef RGB_MATRIX_ENABLE
509 rgb_matrix_task();
510# endif
511
512 // Turn off LED indicators
513 uint8_t leds_off = 0;
514# if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
515 if (is_backlight_enabled()) {
516 // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
517 leds_off |= (1 << USB_LED_CAPS_LOCK);
518 }
519# endif
520 led_set(leds_off);
521
522// Turn off audio
523# ifdef AUDIO_ENABLE
524 stop_all_notes();
525# endif
526
527// Turn off underglow
528# if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
529 rgblight_suspend();
530# endif
531
532# if defined(LED_MATRIX_ENABLE)
533 led_matrix_set_suspend_state(true);
534# endif
535# if defined(RGB_MATRIX_ENABLE)
536 rgb_matrix_set_suspend_state(true);
537# endif
538
539# ifdef OLED_ENABLE
540 oled_off();
541# endif
542# ifdef ST7565_ENABLE
543 st7565_off();
544# endif
545#endif
546}
547
548/** \brief run user level code immediately after wakeup
549 *
550 * FIXME: needs doc
551 */
552__attribute__((weak)) void suspend_wakeup_init_user(void) {}
553
554/** \brief run keyboard level code immediately after wakeup
555 *
556 * FIXME: needs doc
557 */
558__attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); }
559
560__attribute__((weak)) void suspend_wakeup_init_quantum(void) {
561// Turn on backlight
562#ifdef BACKLIGHT_ENABLE
563 backlight_init();
564#endif
565
566 // Restore LED indicators
567 led_set(host_keyboard_leds());
568
569// Wake up underglow
570#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
571 rgblight_wakeup();
572#endif
573
574#if defined(LED_MATRIX_ENABLE)
575 led_matrix_set_suspend_state(false);
576#endif
577#if defined(RGB_MATRIX_ENABLE)
578 rgb_matrix_set_suspend_state(false);
579#endif
580 suspend_wakeup_init_kb();
581}