staryu: Update codes to support v1.4 hardware
This commit is contained in:
parent
b2163eddcc
commit
42bf46523a
@ -35,7 +35,7 @@ uint8_t backlight_brightness;
|
|||||||
|
|
||||||
void backlight_set(uint8_t level)
|
void backlight_set(uint8_t level)
|
||||||
{
|
{
|
||||||
softpwm_led_enable();
|
softpwm_enable();
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -20,10 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
|
|
||||||
/* USB Device descriptor parameter */
|
/* USB Device descriptor parameter */
|
||||||
#define VENDOR_ID 0x8133
|
#define VENDOR_ID 0x1209
|
||||||
#define PRODUCT_ID 0x0120
|
#define PRODUCT_ID 0x2333
|
||||||
#define DEVICE_VER 0x0103
|
#define DEVICE_VER 0x0104
|
||||||
#define MANUFACTURER Noukensha
|
#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
|
||||||
|
|
||||||
@ -43,6 +43,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
/* number of backlight levels */
|
/* number of backlight levels */
|
||||||
#define BACKLIGHT_LEVELS 7
|
#define BACKLIGHT_LEVELS 7
|
||||||
|
#define CUSTOM_LED_ENABLE
|
||||||
|
#define RGB_LED_ENABLE
|
||||||
|
|
||||||
/* number of LEDs */
|
/* number of LEDs */
|
||||||
#define LED_COUNT 6
|
#define LED_COUNT 6
|
||||||
|
@ -20,11 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
|
|
||||||
/* USB Device descriptor parameter */
|
/* USB Device descriptor parameter */
|
||||||
#define VENDOR_ID 0x8133
|
#define VENDOR_ID 0x1209
|
||||||
#define PRODUCT_ID 0x0120
|
#define PRODUCT_ID 0x2333
|
||||||
#define DEVICE_VER 0x0103
|
#define DEVICE_VER 0x0104
|
||||||
#define MANUFACTURER Noukensha
|
#define MANUFACTURER K.T.E.C.
|
||||||
#define PRODUCT Staryu
|
#define PRODUCT Staryu Lite
|
||||||
#define DESCRIPTION t.m.k. keyboard firmware for Staryu
|
#define DESCRIPTION t.m.k. keyboard firmware for Staryu
|
||||||
|
|
||||||
/* key matrix size */
|
/* key matrix size */
|
||||||
@ -43,6 +43,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
/* number of backlight levels */
|
/* number of backlight levels */
|
||||||
#define BACKLIGHT_LEVELS 7
|
#define BACKLIGHT_LEVELS 7
|
||||||
|
#define CUSTOM_LED_ENABLE
|
||||||
|
#define RGB_LED_ENABLE
|
||||||
|
|
||||||
/* number of LEDs */
|
/* number of LEDs */
|
||||||
#define LED_COUNT 6
|
#define LED_COUNT 6
|
||||||
|
@ -22,11 +22,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "rgb.h"
|
#include "rgb.h"
|
||||||
#include "light_ws2812.h"
|
#include "light_ws2812.h"
|
||||||
|
|
||||||
|
#ifdef RGB_LED_ENABLE
|
||||||
|
|
||||||
volatile static uint8_t rgb_fading_enable = 0;
|
volatile static uint8_t rgb_fading_enable = 0;
|
||||||
static rgb_config_t rgb_config;
|
static rgb_config_t rgb_config;
|
||||||
|
static struct cRGB rgb_color[RGB_LED_COUNT];
|
||||||
static uint16_t rgb_hue = 0;
|
static uint16_t rgb_hue = 0;
|
||||||
static uint8_t rgb_saturation = 255;
|
static uint8_t rgb_saturation = 255;
|
||||||
static uint8_t rgb_brightness = 16;
|
static uint8_t rgb_brightness = 16;
|
||||||
|
static uint8_t rgb_rainbow = 0;
|
||||||
|
|
||||||
extern backlight_config_t backlight_config;
|
extern backlight_config_t backlight_config;
|
||||||
extern uint8_t backlight_brightness;
|
extern uint8_t backlight_brightness;
|
||||||
@ -118,12 +122,21 @@ void rgb_step(void)
|
|||||||
|
|
||||||
void rgb_set_level(uint8_t level)
|
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) {
|
if (level <= RGB_WHITE) {
|
||||||
rgb_fading_enable = 0;
|
rgb_fading_enable = 0;
|
||||||
if (level == RGB_OFF) {
|
rgb_rainbow = 0;
|
||||||
rgb_brightness = 0;
|
if (level != RGB_OFF) {
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (level == RGB_WHITE) {
|
if (level == RGB_WHITE) {
|
||||||
rgb_saturation = 0;
|
rgb_saturation = 0;
|
||||||
}
|
}
|
||||||
@ -144,23 +157,41 @@ void rgb_set_level(uint8_t level)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rgb_saturation = 255;
|
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)
|
void rgb_set_brightness(uint8_t brightness)
|
||||||
{
|
{
|
||||||
rgb_brightness = brightness;
|
if (rgb_config.enable) {
|
||||||
rgb_refresh();
|
rgb_brightness = brightness;
|
||||||
|
rgb_refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rgb_refresh(void)
|
void rgb_refresh(void)
|
||||||
{
|
{
|
||||||
struct cRGB rgb_color[1];
|
struct cRGB rgb;
|
||||||
hsb_to_rgb(rgb_hue, rgb_saturation, rgb_brightness, rgb_color);
|
uint16_t hue;
|
||||||
ws2812_setleds(rgb_color, 1);
|
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)
|
void hue_to_rgb(uint16_t hue, struct cRGB *rgb)
|
||||||
{
|
{
|
||||||
uint8_t hi = hue / 60;
|
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;
|
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/
|
* original code: https://blog.adafruit.com/2012/03/14/constant-brightness-hsb-to-rgb-algorithm/
|
||||||
@ -208,3 +240,5 @@ void rgb_fading(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -38,14 +38,14 @@ enum {
|
|||||||
RGB_BLUE,
|
RGB_BLUE,
|
||||||
RGB_MAGENTA,
|
RGB_MAGENTA,
|
||||||
RGB_WHITE,
|
RGB_WHITE,
|
||||||
RGB_FADE_SLOW,
|
RGB_FADE,
|
||||||
RGB_FADE_MID,
|
RGB_RAINBOW,
|
||||||
RGB_FADE_FAST,
|
RGB_LEVELS = RGB_RAINBOW
|
||||||
RGB_LEVELS = RGB_FADE_FAST
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EECONFIG_RGB (uint8_t *)7
|
#define EECONFIG_RGB (uint8_t *)7
|
||||||
#define RGB_UNCONFIGURED 0xFF
|
#define RGB_UNCONFIGURED 0xFF
|
||||||
|
#define RGB_LED_COUNT 16
|
||||||
|
|
||||||
void rgb_init(void);
|
void rgb_init(void);
|
||||||
void rgb_toggle(void);
|
void rgb_toggle(void);
|
||||||
|
Reference in New Issue
Block a user