Merge branch 'master' of github.com:qmk/qmk_firmware into planck_rev6
This commit is contained in:
commit
4fdc9badd3
504 changed files with 16974 additions and 3495 deletions
|
|
@ -46,7 +46,6 @@ __attribute__ ((weak))
|
|||
const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90};
|
||||
|
||||
rgblight_config_t rgblight_config;
|
||||
rgblight_config_t inmem_config;
|
||||
|
||||
LED_TYPE led[RGBLED_NUM];
|
||||
uint8_t rgblight_inited = 0;
|
||||
|
|
@ -169,7 +168,7 @@ void rgblight_init(void) {
|
|||
#endif
|
||||
|
||||
if (rgblight_config.enable) {
|
||||
rgblight_mode(rgblight_config.mode);
|
||||
rgblight_mode_noeeprom(rgblight_config.mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +225,7 @@ uint32_t rgblight_get_mode(void) {
|
|||
return rgblight_config.mode;
|
||||
}
|
||||
|
||||
void rgblight_mode(uint8_t mode) {
|
||||
void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
|
||||
if (!rgblight_config.enable) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -237,8 +236,12 @@ void rgblight_mode(uint8_t mode) {
|
|||
} else {
|
||||
rgblight_config.mode = mode;
|
||||
}
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
xprintf("rgblight mode: %u\n", rgblight_config.mode);
|
||||
if (write_to_eeprom) {
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
xprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode);
|
||||
} else {
|
||||
xprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode);
|
||||
}
|
||||
if (rgblight_config.mode == 1) {
|
||||
#ifdef RGBLIGHT_ANIMATIONS
|
||||
rgblight_timer_disable();
|
||||
|
|
@ -262,11 +265,20 @@ void rgblight_mode(uint8_t mode) {
|
|||
rgblight_timer_disable();
|
||||
#endif
|
||||
}
|
||||
rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
|
||||
rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
|
||||
}
|
||||
|
||||
void rgblight_mode(uint8_t mode) {
|
||||
rgblight_mode_eeprom_helper(mode, true);
|
||||
}
|
||||
|
||||
void rgblight_mode_noeeprom(uint8_t mode) {
|
||||
rgblight_mode_eeprom_helper(mode, false);
|
||||
}
|
||||
|
||||
|
||||
void rgblight_toggle(void) {
|
||||
xprintf("rgblight toggle: rgblight_config.enable = %u\n", !rgblight_config.enable);
|
||||
xprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable);
|
||||
if (rgblight_config.enable) {
|
||||
rgblight_disable();
|
||||
}
|
||||
|
|
@ -275,17 +287,34 @@ void rgblight_toggle(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void rgblight_toggle_noeeprom(void) {
|
||||
xprintf("rgblight toggle [NOEEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable);
|
||||
if (rgblight_config.enable) {
|
||||
rgblight_disable_noeeprom();
|
||||
}
|
||||
else {
|
||||
rgblight_enable_noeeprom();
|
||||
}
|
||||
}
|
||||
|
||||
void rgblight_enable(void) {
|
||||
rgblight_config.enable = 1;
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
xprintf("rgblight enable: rgblight_config.enable = %u\n", rgblight_config.enable);
|
||||
// No need to update EEPROM here. rgblight_mode() will do that, actually
|
||||
//eeconfig_update_rgblight(rgblight_config.raw);
|
||||
xprintf("rgblight enable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
|
||||
rgblight_mode(rgblight_config.mode);
|
||||
}
|
||||
|
||||
void rgblight_enable_noeeprom(void) {
|
||||
rgblight_config.enable = 1;
|
||||
xprintf("rgblight enable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
|
||||
rgblight_mode_noeeprom(rgblight_config.mode);
|
||||
}
|
||||
|
||||
void rgblight_disable(void) {
|
||||
rgblight_config.enable = 0;
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
xprintf("rgblight disable: rgblight_config.enable = %u\n", rgblight_config.enable);
|
||||
xprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
|
||||
#ifdef RGBLIGHT_ANIMATIONS
|
||||
rgblight_timer_disable();
|
||||
#endif
|
||||
|
|
@ -293,6 +322,17 @@ void rgblight_disable(void) {
|
|||
rgblight_set();
|
||||
}
|
||||
|
||||
void rgblight_disable_noeeprom(void) {
|
||||
rgblight_config.enable = 0;
|
||||
xprintf("rgblight disable [noEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
|
||||
#ifdef RGBLIGHT_ANIMATIONS
|
||||
rgblight_timer_disable();
|
||||
#endif
|
||||
_delay_ms(50);
|
||||
rgblight_set();
|
||||
}
|
||||
|
||||
|
||||
// Deals with the messy details of incrementing an integer
|
||||
uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) {
|
||||
int16_t new_value = value;
|
||||
|
|
@ -366,23 +406,22 @@ void rgblight_decrease_speed(void) {
|
|||
eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
|
||||
}
|
||||
|
||||
void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
|
||||
inmem_config.raw = rgblight_config.raw;
|
||||
void rgblight_sethsv_noeeprom_old(uint16_t hue, uint8_t sat, uint8_t val) {
|
||||
if (rgblight_config.enable) {
|
||||
LED_TYPE tmp_led;
|
||||
sethsv(hue, sat, val, &tmp_led);
|
||||
inmem_config.hue = hue;
|
||||
inmem_config.sat = sat;
|
||||
inmem_config.val = val;
|
||||
// dprintf("rgblight set hue [MEMORY]: %u,%u,%u\n", inmem_config.hue, inmem_config.sat, inmem_config.val);
|
||||
rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
|
||||
}
|
||||
}
|
||||
void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
|
||||
|
||||
void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) {
|
||||
if (rgblight_config.enable) {
|
||||
if (rgblight_config.mode == 1) {
|
||||
// same static color
|
||||
rgblight_sethsv_noeeprom(hue, sat, val);
|
||||
LED_TYPE tmp_led;
|
||||
sethsv(hue, sat, val, &tmp_led);
|
||||
rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
|
||||
} else {
|
||||
// all LEDs in same color
|
||||
if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) {
|
||||
|
|
@ -407,11 +446,23 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
|
|||
rgblight_config.hue = hue;
|
||||
rgblight_config.sat = sat;
|
||||
rgblight_config.val = val;
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
|
||||
if (write_to_eeprom) {
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
|
||||
} else {
|
||||
xprintf("rgblight set hsv [NOEEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
|
||||
rgblight_sethsv_eeprom_helper(hue, sat, val, true);
|
||||
}
|
||||
|
||||
void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
|
||||
rgblight_sethsv_eeprom_helper(hue, sat, val, false);
|
||||
}
|
||||
|
||||
uint16_t rgblight_get_hue(void) {
|
||||
return rgblight_config.hue;
|
||||
}
|
||||
|
|
@ -554,7 +605,7 @@ void rgblight_effect_breathing(uint8_t interval) {
|
|||
|
||||
// http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
|
||||
val = (exp(sin((pos/255.0)*M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER/M_E)*(RGBLIGHT_EFFECT_BREATHE_MAX/(M_E-1/M_E));
|
||||
rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, val);
|
||||
rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val);
|
||||
pos = (pos + 1) % 256;
|
||||
}
|
||||
void rgblight_effect_rainbow_mood(uint8_t interval) {
|
||||
|
|
@ -565,7 +616,7 @@ void rgblight_effect_rainbow_mood(uint8_t interval) {
|
|||
return;
|
||||
}
|
||||
last_timer = timer_read();
|
||||
rgblight_sethsv_noeeprom(current_hue, rgblight_config.sat, rgblight_config.val);
|
||||
rgblight_sethsv_noeeprom_old(current_hue, rgblight_config.sat, rgblight_config.val);
|
||||
current_hue = (current_hue + 1) % 360;
|
||||
}
|
||||
void rgblight_effect_rainbow_swirl(uint8_t interval) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue