1
0

staryu: Reduce brightness of RGB LED to half

This commit is contained in:
Kai Ryu 2016-11-04 12:38:34 +09:00
parent 06ccd085ef
commit d0a4996494

View File

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "light_ws2812.h" #include "light_ws2812.h"
#ifdef RGB_LED_ENABLE #ifdef RGB_LED_ENABLE
#define RGB_BRIGHTNESS_RATIO 2
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;
@ -30,7 +31,7 @@ static struct cRGB rgb_color[RGB_LED_MAX_COUNT];
static uint8_t rgb_count = 1; static uint8_t rgb_count = 1;
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 = 0;
static uint8_t rgb_rainbow = 0; static uint8_t rgb_rainbow = 0;
extern backlight_config_t backlight_config; extern backlight_config_t backlight_config;
@ -143,11 +144,11 @@ void rgb_set_level(uint8_t level)
} }
else if (backlight_config.enable) { else if (backlight_config.enable) {
if (backlight_config.level >= 1 && backlight_config.level <= 3) { if (backlight_config.level >= 1 && backlight_config.level <= 3) {
rgb_brightness = backlight_brightness; rgb_brightness = backlight_brightness / RGB_BRIGHTNESS_RATIO;
} }
} }
else { else {
rgb_brightness = 16; rgb_brightness = 16 / RGB_BRIGHTNESS_RATIO;
} }
if (level <= RGB_WHITE) { if (level <= RGB_WHITE) {
rgb_fading_enable = 0; rgb_fading_enable = 0;
@ -162,11 +163,11 @@ void rgb_set_level(uint8_t level)
} }
if (backlight_config.enable) { if (backlight_config.enable) {
if (backlight_config.level >= 1 && backlight_config.level <= 3) { if (backlight_config.level >= 1 && backlight_config.level <= 3) {
rgb_brightness = backlight_brightness; rgb_brightness = backlight_brightness / RGB_BRIGHTNESS_RATIO;
} }
} }
else { else {
rgb_brightness = 16; rgb_brightness = 16 / RGB_BRIGHTNESS_RATIO;
} }
} }
rgb_refresh(); rgb_refresh();
@ -181,7 +182,7 @@ void rgb_set_level(uint8_t level)
void rgb_set_brightness(uint8_t brightness) void rgb_set_brightness(uint8_t brightness)
{ {
if (rgb_config.enable) { if (rgb_config.enable) {
rgb_brightness = brightness; rgb_brightness = brightness / RGB_BRIGHTNESS_RATIO;
rgb_refresh(); rgb_refresh();
} }
} }