fantastic60: Fix bugs regarding backlight and RGB LED
- Bug fixes - Change driving of backlight led to active high - Handle typing led only when backlight is on - Handle rgb increase/decrease only in rgb fixed mode - Add setting rgb brightness when swiching backlight level
This commit is contained in:
parent
2dce1236b7
commit
712510350c
@ -47,6 +47,7 @@ void backlight_set(uint8_t level)
|
||||
breathing_led_disable(BACKLIGHT);
|
||||
backlight_brightness = pgm_read_byte(&backlight_table[level]);
|
||||
softpwm_led_set(BACKLIGHT, backlight_brightness);
|
||||
rgb_set_brightness(backlight_brightness);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
@ -63,11 +64,13 @@ void backlight_set(uint8_t level)
|
||||
breathing_led_disable(BACKLIGHT);
|
||||
fading_led_set_direction(BACKLIGHT, FADING_LED_FADE_IN);
|
||||
fading_led_set_duration(3);
|
||||
break;
|
||||
case 8:
|
||||
fading_led_enable(BACKLIGHT);
|
||||
breathing_led_disable(BACKLIGHT);
|
||||
fading_led_set_direction(BACKLIGHT, FADING_LED_FADE_OUT);
|
||||
fading_led_set_duration(3);
|
||||
break;
|
||||
#endif
|
||||
case 0:
|
||||
default:
|
||||
@ -105,7 +108,12 @@ void softpwm_led_init()
|
||||
|
||||
void softpwm_led_on(uint8_t index)
|
||||
{
|
||||
PORTF &= ~((1<<PF7) >> index);
|
||||
if (index) {
|
||||
PORTF &= ~((1<<PF7) >> index);
|
||||
}
|
||||
else {
|
||||
PORTF |= (1<<PF7);
|
||||
}
|
||||
/*
|
||||
switch (index) {
|
||||
case 0:
|
||||
@ -126,7 +134,12 @@ void softpwm_led_on(uint8_t index)
|
||||
|
||||
void softpwm_led_off(uint8_t index)
|
||||
{
|
||||
PORTF |= ((1<<PF7) >> index);
|
||||
if (index) {
|
||||
PORTF |= ((1<<PF7) >> index);
|
||||
}
|
||||
else {
|
||||
PORTF &= ~(1<<PF7);
|
||||
}
|
||||
/*
|
||||
switch (index) {
|
||||
case 0:
|
||||
@ -150,16 +163,18 @@ void softpwm_led_off(uint8_t index)
|
||||
#ifdef FADING_LED_ENABLE
|
||||
void action_keyevent(keyevent_t event)
|
||||
{
|
||||
if (backlight_config.level == 7) {
|
||||
if (event.pressed) {
|
||||
fading_led_set_delay(BACKLIGHT, 64);
|
||||
softpwm_led_decrease(BACKLIGHT, 32);
|
||||
if (backlight_config.enable) {
|
||||
if (backlight_config.level == 7) {
|
||||
if (event.pressed) {
|
||||
fading_led_set_delay(BACKLIGHT, 64);
|
||||
softpwm_led_decrease(BACKLIGHT, 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (backlight_config.level == 8) {
|
||||
if (event.pressed) {
|
||||
fading_led_set_delay(BACKLIGHT, 64);
|
||||
softpwm_led_increase(BACKLIGHT, 32);
|
||||
if (backlight_config.level == 8) {
|
||||
if (event.pressed) {
|
||||
fading_led_set_delay(BACKLIGHT, 64);
|
||||
softpwm_led_increase(BACKLIGHT, 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,31 +137,35 @@ void rgb_step(void)
|
||||
|
||||
void rgb_color_increase(uint8_t color)
|
||||
{
|
||||
uint8_t *c = &rgb_color.raw[color];
|
||||
if (*c >= 240) {
|
||||
*c = 255;
|
||||
if (rgb_config.level == RGB_FIXED) {
|
||||
uint8_t *c = &rgb_color.raw[color];
|
||||
if (*c >= 240) {
|
||||
*c = 255;
|
||||
}
|
||||
else {
|
||||
*c += 16;
|
||||
}
|
||||
rgb_refresh(&rgb_color);
|
||||
rgb_write_color();
|
||||
}
|
||||
else {
|
||||
*c += 16;
|
||||
}
|
||||
rgb_refresh(&rgb_color);
|
||||
rgb_write_color();
|
||||
}
|
||||
|
||||
void rgb_color_decrease(uint8_t color)
|
||||
{
|
||||
uint8_t *c = &rgb_color.raw[color];
|
||||
if (*c > 240) {
|
||||
*c = 240;
|
||||
if (rgb_config.level == RGB_FIXED) {
|
||||
uint8_t *c = &rgb_color.raw[color];
|
||||
if (*c > 240) {
|
||||
*c = 240;
|
||||
}
|
||||
else if (*c < 16) {
|
||||
*c = 0;
|
||||
}
|
||||
else {
|
||||
*c -= 16;
|
||||
}
|
||||
rgb_refresh(&rgb_color);
|
||||
rgb_write_color();
|
||||
}
|
||||
else if (*c < 16) {
|
||||
*c = 0;
|
||||
}
|
||||
else {
|
||||
*c -= 16;
|
||||
}
|
||||
rgb_refresh(&rgb_color);
|
||||
rgb_write_color();
|
||||
}
|
||||
|
||||
void rgb_set_level(uint8_t level)
|
||||
|
Reference in New Issue
Block a user