remove rgblight_update_hook(), add RGBLIGHT_SPLIT_SET_CHANGE_XXXX

rgblight_update_hook() is too large.
change to simple flag setting.
pull/5020/head
mtei 6 years ago
parent f69e57f1b6
commit 2ab340da54

@ -156,28 +156,10 @@ void rgblight_check_config(void) {
#ifdef RGBLIGHT_SPLIT #ifdef RGBLIGHT_SPLIT
/* for split keyboard master side */ /* for split keyboard master side */
/* Overwrite with individual code of keyboard. */ /* Overwrite with individual code of keyboard. */
__attribute__ ((weak))
void rgblight_update_hook(rgblight_config_t *config, rgblight_status_t *status, bool write_to_eeprom) {
static rgblight_config_t config_old = {};
rgblight_status_t status_old = {};
if( config != NULL ) { #define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_mode = 1
if( config_old.enable != config->enable || config_old.mode != config->mode ) { #define RGBLIGHT_SPLIT_SET_CHANGE_HSVS rgblight_status.change_hsvs = 1
rgblight_status.change_mode = 1; #define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE rgblight_status.change_timer_enabled = 1
}
if( config_old.hue != config->hue || config_old.sat != config->sat ||
config_old.val != config->val || config_old.speed != config->speed ) {
rgblight_status.change_hsvs = 1;
}
config_old = *config;
}
if( status != NULL ) {
if( status_old.timer_enabled != status->timer_enabled ) {
rgblight_status.change_mode = 1;
}
status_old.timer_enabled = status->timer_enabled;
}
}
/* for split keyboard slave side */ /* for split keyboard slave side */
/* Call from keyboard individual code. */ /* Call from keyboard individual code. */
@ -191,7 +173,9 @@ void rgblight_update_sync(rgblight_config_t *config, rgblight_status_t *status,
// } // }
} }
#else #else
#define rgblight_update_hook(dummy1,dummy2,dummy3) #define RGBLIGHT_SPLIT_SET_CHANGE_MODE
#define RGBLIGHT_SPLIT_SET_CHANGE_HSVS
#define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE
#endif #endif
@ -343,6 +327,7 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
} else { } else {
rgblight_config.mode = mode; rgblight_config.mode = mode;
} }
RGBLIGHT_SPLIT_SET_CHANGE_MODE;
if (write_to_eeprom) { if (write_to_eeprom) {
eeconfig_update_rgblight(rgblight_config.raw); eeconfig_update_rgblight(rgblight_config.raw);
xprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode); xprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode);
@ -411,7 +396,6 @@ void rgblight_disable(void) {
#ifdef RGBLIGHT_USE_TIMER #ifdef RGBLIGHT_USE_TIMER
rgblight_timer_disable(); rgblight_timer_disable();
#endif #endif
rgblight_update_hook(&rgblight_config, NULL, true);
wait_ms(50); wait_ms(50);
rgblight_set(); rgblight_set();
} }
@ -422,7 +406,6 @@ void rgblight_disable_noeeprom(void) {
#ifdef RGBLIGHT_USE_TIMER #ifdef RGBLIGHT_USE_TIMER
rgblight_timer_disable(); rgblight_timer_disable();
#endif #endif
rgblight_update_hook(&rgblight_config, NULL, false);
wait_ms(50); wait_ms(50);
rgblight_set(); rgblight_set();
} }
@ -529,13 +512,13 @@ void rgblight_decrease_val(void) {
} }
void rgblight_increase_speed(void) { void rgblight_increase_speed(void) {
rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 ); rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 );
rgblight_update_hook(&rgblight_config, NULL, true); RGBLIGHT_SPLIT_SET_CHANGE_HSVS;
eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
} }
void rgblight_decrease_speed(void) { void rgblight_decrease_speed(void) {
rgblight_config.speed = decrement( rgblight_config.speed, 1, 0, 3 ); rgblight_config.speed = decrement( rgblight_config.speed, 1, 0, 3 );
rgblight_update_hook(&rgblight_config, NULL, true); RGBLIGHT_SPLIT_SET_CHANGE_HSVS;
eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this
} }
@ -596,10 +579,14 @@ void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool
} }
#endif #endif
} }
if( rgblight_config.hue != hue ||
rgblight_config.sat != sat ||
rgblight_config.val != val ) {
RGBLIGHT_SPLIT_SET_CHANGE_HSVS;
}
rgblight_config.hue = hue; rgblight_config.hue = hue;
rgblight_config.sat = sat; rgblight_config.sat = sat;
rgblight_config.val = val; rgblight_config.val = val;
rgblight_update_hook(&rgblight_config, NULL, write_to_eeprom);
if (write_to_eeprom) { if (write_to_eeprom) {
eeconfig_update_rgblight(rgblight_config.raw); eeconfig_update_rgblight(rgblight_config.raw);
xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
@ -749,21 +736,21 @@ void rgblight_timer_init(void) {
// SREG = sreg; // SREG = sreg;
rgblight_status.timer_enabled = true; rgblight_status.timer_enabled = true;
rgblight_update_hook(NULL, &rgblight_status, false); RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
} }
void rgblight_timer_enable(void) { void rgblight_timer_enable(void) {
rgblight_status.timer_enabled = true; rgblight_status.timer_enabled = true;
rgblight_update_hook(NULL, &rgblight_status, false); RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
dprintf("TIMER3 enabled.\n"); dprintf("TIMER3 enabled.\n");
} }
void rgblight_timer_disable(void) { void rgblight_timer_disable(void) {
rgblight_status.timer_enabled = false; rgblight_status.timer_enabled = false;
rgblight_update_hook(NULL, &rgblight_status, false); RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
dprintf("TIMER3 disabled.\n"); dprintf("TIMER3 disabled.\n");
} }
void rgblight_timer_toggle(void) { void rgblight_timer_toggle(void) {
rgblight_status.timer_enabled ^= rgblight_status.timer_enabled; rgblight_status.timer_enabled ^= rgblight_status.timer_enabled;
rgblight_update_hook(NULL, &rgblight_status, false); RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE;
dprintf("TIMER3 toggled.\n"); dprintf("TIMER3 toggled.\n");
} }

@ -167,6 +167,7 @@ typedef struct _rgblight_status_t {
bool timer_enabled; bool timer_enabled;
bool change_mode; // change mode or enable bool change_mode; // change mode or enable
bool change_hsvs; // change hue, sat, val or speed bool change_hsvs; // change hue, sat, val or speed
bool change_timer_enabled;
// TODO: add animation syncronizing // TODO: add animation syncronizing
// (with integrate timer processing.) // (with integrate timer processing.)
} rgblight_status_t; } rgblight_status_t;

Loading…
Cancel
Save