1
0

fantastic60: Change to fit the new softpwm APIs

This commit is contained in:
Kai Ryu 2016-04-27 09:35:31 +09:00
parent 23013088aa
commit c54fdb366b
3 changed files with 33 additions and 9 deletions

View File

@ -46,6 +46,7 @@ void backlight_set(uint8_t level)
breathing_led_disable(BACKLIGHT); breathing_led_disable(BACKLIGHT);
backlight_brightness = pgm_read_byte(&backlight_table[level]); backlight_brightness = pgm_read_byte(&backlight_table[level]);
softpwm_led_set(BACKLIGHT, backlight_brightness); softpwm_led_set(BACKLIGHT, backlight_brightness);
softpwm_led_enable(BACKLIGHT);
rgb_set_brightness(backlight_brightness); rgb_set_brightness(backlight_brightness);
break; break;
case 4: case 4:
@ -56,6 +57,7 @@ void backlight_set(uint8_t level)
#endif #endif
breathing_led_enable(BACKLIGHT); breathing_led_enable(BACKLIGHT);
breathing_led_set_duration(6 - level); breathing_led_set_duration(6 - level);
softpwm_led_enable(BACKLIGHT);
break; break;
#ifdef FADING_LED_ENABLE #ifdef FADING_LED_ENABLE
case 7: case 7:
@ -63,12 +65,14 @@ void backlight_set(uint8_t level)
breathing_led_disable(BACKLIGHT); breathing_led_disable(BACKLIGHT);
fading_led_set_direction(BACKLIGHT, FADING_LED_FADE_IN); fading_led_set_direction(BACKLIGHT, FADING_LED_FADE_IN);
fading_led_set_duration(3); fading_led_set_duration(3);
softpwm_led_enable(BACKLIGHT);
break; break;
case 8: case 8:
fading_led_enable(BACKLIGHT); fading_led_enable(BACKLIGHT);
breathing_led_disable(BACKLIGHT); breathing_led_disable(BACKLIGHT);
fading_led_set_direction(BACKLIGHT, FADING_LED_FADE_OUT); fading_led_set_direction(BACKLIGHT, FADING_LED_FADE_OUT);
fading_led_set_duration(3); fading_led_set_duration(3);
softpwm_led_enable(BACKLIGHT);
break; break;
#endif #endif
case 0: case 0:
@ -79,6 +83,7 @@ void backlight_set(uint8_t level)
breathing_led_disable(BACKLIGHT); breathing_led_disable(BACKLIGHT);
backlight_brightness = 0; backlight_brightness = 0;
softpwm_led_set(BACKLIGHT, backlight_brightness); softpwm_led_set(BACKLIGHT, backlight_brightness);
softpwm_led_disable(BACKLIGHT);
break; break;
} }
#else #else

View File

@ -83,13 +83,13 @@ void matrix_init(void)
if ((PINC & (1<<PC7)) == 0) { if ((PINC & (1<<PC7)) == 0) {
ps2_mouse_enabled = 1; ps2_mouse_enabled = 1;
#ifdef SOFTPWM_LED_ENABLE #ifdef SOFTPWM_LED_ENABLE
softpwm_led_disable(); softpwm_disable();
#endif #endif
} }
else { else {
ps2_mouse_enabled = 0; ps2_mouse_enabled = 0;
#ifdef SOFTPWM_LED_ENABLE #ifdef SOFTPWM_LED_ENABLE
softpwm_led_enable(); softpwm_enable();
#endif #endif
} }
PORTC &= ~(1<<PC7); PORTC &= ~(1<<PC7);

View File

@ -37,7 +37,9 @@ static void rgb_read_config(void);
static void rgb_write_color(void); static void rgb_write_color(void);
static void rgb_read_color(void); static void rgb_read_color(void);
static void rgb_set_level(uint8_t level); static void rgb_set_level(uint8_t level);
static void rgb_refresh(rgb_color_t *rgb); static void rgb_led_enable(void);
static void rgb_led_disable(void);
static void rgb_led_refresh(rgb_color_t *rgb);
static void hsb_to_rgb(uint16_t hue, uint8_t saturation, uint8_t brightness, rgb_color_t *rgb); static void hsb_to_rgb(uint16_t hue, uint8_t saturation, uint8_t brightness, rgb_color_t *rgb);
void rgb_init(void) void rgb_init(void)
@ -143,7 +145,7 @@ void rgb_color_increase(uint8_t color)
else { else {
*c += 16; *c += 16;
} }
rgb_refresh(&rgb_color); rgb_led_refresh(&rgb_color);
rgb_write_color(); rgb_write_color();
} }
} }
@ -161,7 +163,7 @@ void rgb_color_decrease(uint8_t color)
else { else {
*c -= 16; *c -= 16;
} }
rgb_refresh(&rgb_color); rgb_led_refresh(&rgb_color);
rgb_write_color(); rgb_write_color();
} }
} }
@ -173,10 +175,12 @@ void rgb_set_level(uint8_t level)
case RGB_OFF: case RGB_OFF:
rgb_fading_enable = 0; rgb_fading_enable = 0;
rgb_brightness = 0; rgb_brightness = 0;
rgb_refresh(&rgb_color_off); rgb_led_refresh(&rgb_color_off);
rgb_led_disable();
break; break;
case RGB_FIXED: case RGB_FIXED:
rgb_refresh(&rgb_color); rgb_led_refresh(&rgb_color);
rgb_led_enable();
break; break;
case RGB_FADE: case RGB_FADE:
if (backlight_config.enable) { if (backlight_config.enable) {
@ -188,6 +192,7 @@ void rgb_set_level(uint8_t level)
rgb_brightness = 16; rgb_brightness = 16;
} }
rgb_fading_enable = 1; rgb_fading_enable = 1;
rgb_led_enable();
break; break;
} }
} }
@ -197,7 +202,21 @@ void rgb_set_brightness(uint8_t brightness)
rgb_brightness = brightness; rgb_brightness = brightness;
} }
void rgb_refresh(rgb_color_t *rgb) void rgb_led_enable(void)
{
for (uint8_t i = 0; i < 3; i++) {
softpwm_led_enable(i + 1);
}
}
void rgb_led_disable(void)
{
for (uint8_t i = 0; i < 3; i++) {
softpwm_led_disable(i + 1);
}
}
void rgb_led_refresh(rgb_color_t *rgb)
{ {
for (uint8_t i = 0; i < 3; i++) { for (uint8_t i = 0; i < 3; i++) {
softpwm_led_set(i + 1, rgb->raw[i]); softpwm_led_set(i + 1, rgb->raw[i]);
@ -231,7 +250,7 @@ void rgb_fading(void)
step = 0; step = 0;
rgb_hue = hue; rgb_hue = hue;
hsb_to_rgb(rgb_hue, rgb_saturation, rgb_brightness, &color); hsb_to_rgb(rgb_hue, rgb_saturation, rgb_brightness, &color);
rgb_refresh(&color); rgb_led_refresh(&color);
if (++hue >= 768) { if (++hue >= 768) {
hue = 0; hue = 0;
} }