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