diff --git a/keyboard/staryu/backlight.c b/keyboard/staryu/backlight.c
index 7c924946..3469fd08 100644
--- a/keyboard/staryu/backlight.c
+++ b/keyboard/staryu/backlight.c
@@ -35,7 +35,7 @@ uint8_t backlight_brightness;
void backlight_set(uint8_t level)
{
- softpwm_led_enable();
+ softpwm_enable();
switch (level) {
case 1:
case 2:
diff --git a/keyboard/staryu/config.h b/keyboard/staryu/config.h
index c5420f5a..7d174304 100644
--- a/keyboard/staryu/config.h
+++ b/keyboard/staryu/config.h
@@ -20,10 +20,10 @@ along with this program. If not, see .
/* USB Device descriptor parameter */
-#define VENDOR_ID 0x8133
-#define PRODUCT_ID 0x0120
-#define DEVICE_VER 0x0103
-#define MANUFACTURER Noukensha
+#define VENDOR_ID 0x1209
+#define PRODUCT_ID 0x2333
+#define DEVICE_VER 0x0104
+#define MANUFACTURER K.T.E.C.
#define PRODUCT Staryu
#define DESCRIPTION t.m.k. keyboard firmware for Staryu
@@ -43,6 +43,8 @@ along with this program. If not, see .
/* number of backlight levels */
#define BACKLIGHT_LEVELS 7
+#define CUSTOM_LED_ENABLE
+#define RGB_LED_ENABLE
/* number of LEDs */
#define LED_COUNT 6
diff --git a/keyboard/staryu/config_lite.h b/keyboard/staryu/config_lite.h
index befdaad9..8942d809 100644
--- a/keyboard/staryu/config_lite.h
+++ b/keyboard/staryu/config_lite.h
@@ -20,11 +20,11 @@ along with this program. If not, see .
/* USB Device descriptor parameter */
-#define VENDOR_ID 0x8133
-#define PRODUCT_ID 0x0120
-#define DEVICE_VER 0x0103
-#define MANUFACTURER Noukensha
-#define PRODUCT Staryu
+#define VENDOR_ID 0x1209
+#define PRODUCT_ID 0x2333
+#define DEVICE_VER 0x0104
+#define MANUFACTURER K.T.E.C.
+#define PRODUCT Staryu Lite
#define DESCRIPTION t.m.k. keyboard firmware for Staryu
/* key matrix size */
@@ -43,6 +43,8 @@ along with this program. If not, see .
/* number of backlight levels */
#define BACKLIGHT_LEVELS 7
+#define CUSTOM_LED_ENABLE
+#define RGB_LED_ENABLE
/* number of LEDs */
#define LED_COUNT 6
diff --git a/keyboard/staryu/rgb.c b/keyboard/staryu/rgb.c
index 13dc8856..6a8caa18 100644
--- a/keyboard/staryu/rgb.c
+++ b/keyboard/staryu/rgb.c
@@ -22,11 +22,15 @@ along with this program. If not, see .
#include "rgb.h"
#include "light_ws2812.h"
+#ifdef RGB_LED_ENABLE
+
volatile static uint8_t rgb_fading_enable = 0;
static rgb_config_t rgb_config;
+static struct cRGB rgb_color[RGB_LED_COUNT];
static uint16_t rgb_hue = 0;
static uint8_t rgb_saturation = 255;
static uint8_t rgb_brightness = 16;
+static uint8_t rgb_rainbow = 0;
extern backlight_config_t backlight_config;
extern uint8_t backlight_brightness;
@@ -118,12 +122,21 @@ void rgb_step(void)
void rgb_set_level(uint8_t level)
{
+ if (level == RGB_OFF) {
+ rgb_brightness = 0;
+ }
+ else if (backlight_config.enable) {
+ if (backlight_config.level >= 1 && backlight_config.level <= 3) {
+ rgb_brightness = backlight_brightness;
+ }
+ }
+ else {
+ rgb_brightness = 16;
+ }
if (level <= RGB_WHITE) {
rgb_fading_enable = 0;
- if (level == RGB_OFF) {
- rgb_brightness = 0;
- }
- else {
+ rgb_rainbow = 0;
+ if (level != RGB_OFF) {
if (level == RGB_WHITE) {
rgb_saturation = 0;
}
@@ -144,23 +157,41 @@ void rgb_set_level(uint8_t level)
}
else {
rgb_saturation = 255;
- rgb_fading_enable = 3 - (level - RGB_FADE_SLOW);
+ rgb_fading_enable = 1;
+ rgb_rainbow = (level >= RGB_RAINBOW) ? 1 : 0;
}
}
void rgb_set_brightness(uint8_t brightness)
{
- rgb_brightness = brightness;
- rgb_refresh();
+ if (rgb_config.enable) {
+ rgb_brightness = brightness;
+ rgb_refresh();
+ }
}
void rgb_refresh(void)
{
- struct cRGB rgb_color[1];
- hsb_to_rgb(rgb_hue, rgb_saturation, rgb_brightness, rgb_color);
- ws2812_setleds(rgb_color, 1);
+ struct cRGB rgb;
+ uint16_t hue;
+ uint8_t i;
+ if (rgb_rainbow) {
+ for (i = 0; i < RGB_LED_COUNT; i++) {
+ hue = rgb_hue + (768 / RGB_LED_COUNT) * i;
+ hsb_to_rgb(hue, rgb_saturation, rgb_brightness, &rgb);
+ rgb_color[i] = rgb;
+ }
+ }
+ else {
+ hsb_to_rgb(rgb_hue, rgb_saturation, rgb_brightness, &rgb);
+ for (i = 0; i < RGB_LED_COUNT; i++) {
+ rgb_color[i] = rgb;
+ }
+ }
+ ws2812_setleds(rgb_color, RGB_LED_COUNT);
}
+#if 0
void hue_to_rgb(uint16_t hue, struct cRGB *rgb)
{
uint8_t hi = hue / 60;
@@ -175,6 +206,7 @@ void hue_to_rgb(uint16_t hue, struct cRGB *rgb)
case 5: rgb->r = 255; rgb->g = 0; rgb->b = q; break;
}
}
+#endif
/*
* original code: https://blog.adafruit.com/2012/03/14/constant-brightness-hsb-to-rgb-algorithm/
@@ -208,3 +240,5 @@ void rgb_fading(void)
}
}
}
+
+#endif
diff --git a/keyboard/staryu/rgb.h b/keyboard/staryu/rgb.h
index 0cca98d1..ba77fb0f 100644
--- a/keyboard/staryu/rgb.h
+++ b/keyboard/staryu/rgb.h
@@ -38,14 +38,14 @@ enum {
RGB_BLUE,
RGB_MAGENTA,
RGB_WHITE,
- RGB_FADE_SLOW,
- RGB_FADE_MID,
- RGB_FADE_FAST,
- RGB_LEVELS = RGB_FADE_FAST
+ RGB_FADE,
+ RGB_RAINBOW,
+ RGB_LEVELS = RGB_RAINBOW
};
#define EECONFIG_RGB (uint8_t *)7
#define RGB_UNCONFIGURED 0xFF
+#define RGB_LED_COUNT 16
void rgb_init(void);
void rgb_toggle(void);