1
0

core: Fix sleep_led

This commit is contained in:
tmk 2016-10-12 14:35:53 +09:00
parent e7b8da47ce
commit 5969d6267f
4 changed files with 29 additions and 20 deletions

View File

@ -45,10 +45,17 @@ void sleep_led_disable(void)
TIMSK1 &= ~_BV(OCIE1A);
}
void sleep_led_toggle(void)
__attribute__ ((weak))
void sleep_led_on(void)
{
/* Disable Compare Match Interrupt */
TIMSK1 ^= _BV(OCIE1A);
led_set(1<<USB_LED_CAPS_LOCK);
}
__attribute__ ((weak))
void sleep_led_off(void)
{
led_set(0);
}
@ -86,10 +93,10 @@ ISR(TIMER1_COMPA_vect)
// LED on
if (timer.pwm.count == 0) {
led_set(1<<USB_LED_CAPS_LOCK);
sleep_led_on();
}
// LED off
if (timer.pwm.count == pgm_read_byte(&breathing_table[timer.pwm.index])) {
led_set(0);
sleep_led_off();
}
}

View File

@ -96,7 +96,11 @@ void suspend_idle(uint8_t time)
void suspend_power_down(void)
{
#ifdef SUSPEND_MODE_STANDBY
#ifdef NO_SUSPEND_POWER_DOWN
;
#elif defined(SUSPEND_MODE_NOPOWERSAVE)
;
#elif defined(SUSPEND_MODE_STANDBY)
standby();
#elif defined(SUSPEND_MODE_IDLE)
idle();

View File

@ -182,14 +182,22 @@ static bool command_common(uint8_t code)
{
#ifdef KEYBOARD_LOCK_ENABLE
static host_driver_t *host_driver = 0;
#endif
#ifdef SLEEP_LED_ENABLE
static bool sleep_led_test = false;
#endif
switch (code) {
#ifdef SLEEP_LED_ENABLE
case KC_Z:
// test breathing sleep LED
print("Sleep LED test\n");
sleep_led_toggle();
led_set(host_keyboard_leds());
if (sleep_led_test) {
sleep_led_disable();
led_set(host_keyboard_leds());
} else {
sleep_led_enable();
}
sleep_led_test = !sleep_led_test;
break;
#endif
#ifdef BOOTMAGIC_ENABLE

View File

@ -2,20 +2,10 @@
#define SLEEP_LED_H
#ifdef SLEEP_LED_ENABLE
void sleep_led_init(void);
void sleep_led_enable(void);
void sleep_led_disable(void);
void sleep_led_toggle(void);
#else
#define sleep_led_init()
#define sleep_led_enable()
#define sleep_led_disable()
#define sleep_led_toggle()
#endif
void sleep_led_on(void);
void sleep_led_off(void);
#endif