1
0

staryu: Improve experience of backlight

This commit is contained in:
Kai Ryu 2016-11-04 12:50:53 +09:00
parent d0a4996494
commit f1148804a8
3 changed files with 12 additions and 5 deletions

View File

@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include "backlight.h" #include "backlight.h"
#include "softpwm_led.h" #include "softpwm_led.h"
#include "action.h" #include "hook.h"
#include "timer.h" #include "timer.h"
#include "rgb.h" #include "rgb.h"
@ -45,6 +45,7 @@ void backlight_set(uint8_t level)
backlight_brightness = pgm_read_byte(&backlight_table[level]); backlight_brightness = pgm_read_byte(&backlight_table[level]);
softpwm_led_set_all(backlight_brightness); softpwm_led_set_all(backlight_brightness);
rgb_set_brightness(backlight_brightness); rgb_set_brightness(backlight_brightness);
softpwm_led_enable_all();
break; break;
case 4: case 4:
case 5: case 5:
@ -53,13 +54,16 @@ void backlight_set(uint8_t level)
breathing_led_set_duration(6 - level); breathing_led_set_duration(6 - level);
breathing_led_set_index_all(0); breathing_led_set_index_all(0);
breathing_led_enable_all(); breathing_led_enable_all();
softpwm_led_enable_all();
break; break;
case 7: case 7:
breathing_led_disable_all(); breathing_led_disable_all();
breathing_led_set_duration(1); breathing_led_set_duration(1);
softpwm_led_set_all(0);
fading_led_set_direction_all(FADING_LED_FADE_OUT); fading_led_set_direction_all(FADING_LED_FADE_OUT);
fading_led_set_duration(3); fading_led_set_duration(3);
fading_led_enable_all(); fading_led_enable_all();
softpwm_led_enable_all();
break; break;
case 0: case 0:
default: default:
@ -67,6 +71,7 @@ void backlight_set(uint8_t level)
breathing_led_disable_all(); breathing_led_disable_all();
backlight_brightness = 0; backlight_brightness = 0;
softpwm_led_set_all(backlight_brightness); softpwm_led_set_all(backlight_brightness);
softpwm_led_disable_all();
break; break;
} }
} }
@ -126,13 +131,14 @@ void softpwm_led_off(uint8_t index)
static uint8_t idle_state = 0; static uint8_t idle_state = 0;
static uint16_t idle_last = 0; static uint16_t idle_last = 0;
void action_keyevent(keyevent_t event) void hook_matrix_change(keyevent_t event)
{ {
if (backlight_config.enable) { if (backlight_config.enable) {
if (backlight_config.level == 7) { if (backlight_config.level == 7) {
if (event.pressed) { if (event.pressed) {
if (idle_state > 1) { if (idle_state > 1) {
breathing_led_disable_all(); breathing_led_disable_all();
softpwm_led_set_all(0);
} }
idle_state = 0; idle_state = 0;
uint8_t key = event.key.col + 1; uint8_t key = event.key.col + 1;

View File

@ -21,8 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* USB Device descriptor parameter */ /* USB Device descriptor parameter */
#define VENDOR_ID 0x1209 #define VENDOR_ID 0x1209
#define PRODUCT_ID 0x2333 #define PRODUCT_ID 0x2328
#define DEVICE_VER 0x0104 #define DEVICE_VER 0x0205
#define MANUFACTURER K.T.E.C. #define MANUFACTURER K.T.E.C.
#define PRODUCT Staryu #define PRODUCT Staryu
#define DESCRIPTION t.m.k. keyboard firmware for Staryu #define DESCRIPTION t.m.k. keyboard firmware for Staryu
@ -45,6 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BACKLIGHT_LEVELS 7 #define BACKLIGHT_LEVELS 7
#define CUSTOM_LED_ENABLE #define CUSTOM_LED_ENABLE
#define RGB_LED_ENABLE #define RGB_LED_ENABLE
#define SOFTPWM_LED_FREQ 80
/* number of LEDs */ /* number of LEDs */
#define LED_COUNT 6 #define LED_COUNT 6

@ -1 +1 @@
Subproject commit 85bb7f9de8452c1a4e718ae686f80249a490bc26 Subproject commit a9f231ea07a9e16816cd98f76f77720634eb725e