Updating effect function api for future extensions
This commit is contained in:
		
							parent
							
								
									8073da5dea
								
							
						
					
					
						commit
						161c4b21dc
					
				
					 21 changed files with 66 additions and 68 deletions
				
			
		| 
						 | 
				
			
			@ -5,7 +5,7 @@ extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		|||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
// alphas = color1, mods = color2
 | 
			
		||||
bool rgb_matrix_alphas_mods(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_alphas_mods(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@
 | 
			
		|||
 | 
			
		||||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_breathing(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_breathing(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters;
 | 
			
		|||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		||||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_cycle_all(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_cycle_all(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters;
 | 
			
		|||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		||||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_cycle_left_right(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_cycle_left_right(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters;
 | 
			
		|||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		||||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_cycle_up_down(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_cycle_up_down(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@
 | 
			
		|||
    #define RGB_DIGITAL_RAIN_DROPS 24
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_digital_rain(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_digital_rain(effect_params_t* params) {
 | 
			
		||||
  // algorithm ported from https://github.com/tremby/Kaleidoscope-LEDEffect-DigitalRain
 | 
			
		||||
  const uint8_t drop_ticks           = 28;
 | 
			
		||||
  const uint8_t pure_green_intensity = 0xd0;
 | 
			
		||||
| 
						 | 
				
			
			@ -16,7 +16,7 @@ bool rgb_matrix_digital_rain(bool init, uint8_t iter) {
 | 
			
		|||
  static uint8_t map[MATRIX_COLS][MATRIX_ROWS] = {{0}};
 | 
			
		||||
  static uint8_t drop = 0;
 | 
			
		||||
 | 
			
		||||
  if (init) {
 | 
			
		||||
  if (params->init) {
 | 
			
		||||
    rgb_matrix_set_color_all(0, 0, 0);
 | 
			
		||||
    memset(map, 0, sizeof map);
 | 
			
		||||
    drop = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters;
 | 
			
		|||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		||||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_dual_beacon(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_dual_beacon(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@
 | 
			
		|||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		||||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_gradient_up_down(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_gradient_up_down(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,8 +11,8 @@ static void jellybean_raindrops_set_color(int i) {
 | 
			
		|||
  rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_jellybean_raindrops(bool init, uint8_t iter) {
 | 
			
		||||
  if (!init) {
 | 
			
		||||
bool rgb_matrix_jellybean_raindrops(effect_params_t* params) {
 | 
			
		||||
  if (!params->init) {
 | 
			
		||||
    // Change one LED every tick, make sure speed is not 0
 | 
			
		||||
    if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) {
 | 
			
		||||
      jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters;
 | 
			
		|||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		||||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_rainbow_beacon(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_rainbow_beacon(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters;
 | 
			
		|||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		||||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_rainbow_moving_chevron(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters;
 | 
			
		|||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		||||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_rainbow_pinwheels(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,8 +21,8 @@ static void raindrops_set_color(int i) {
 | 
			
		|||
  rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_raindrops(bool init, uint8_t iter) {
 | 
			
		||||
  if (!init) {
 | 
			
		||||
bool rgb_matrix_raindrops(effect_params_t* params) {
 | 
			
		||||
  if (!params->init) {
 | 
			
		||||
    // Change one LED every tick, make sure speed is not 0
 | 
			
		||||
    if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
 | 
			
		||||
      raindrops_set_color(rand() % DRIVER_LED_TOTAL);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
 | 
			
		||||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_solid_color(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_solid_color(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
extern last_hit_t g_last_hit_tracker;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_solid_reactive(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_solid_reactive(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { rgb_matrix_config.hue, 255, rgb_matrix_config.val };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
extern last_hit_t g_last_hit_tracker;
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_solid_reactive_simple(bool init, uint8_t iter) {
 | 
			
		||||
bool rgb_matrix_solid_reactive_simple(effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		|||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
extern last_hit_t g_last_hit_tracker;
 | 
			
		||||
 | 
			
		||||
static bool rgb_matrix_solid_multisplash_range(uint8_t start, uint8_t iter) {
 | 
			
		||||
static bool rgb_matrix_solid_multisplash_range(uint8_t start, effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
 | 
			
		||||
| 
						 | 
				
			
			@ -30,12 +30,12 @@ static bool rgb_matrix_solid_multisplash_range(uint8_t start, uint8_t iter) {
 | 
			
		|||
  return led_max < DRIVER_LED_TOTAL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_solid_multisplash(bool init, uint8_t iter) {
 | 
			
		||||
  return rgb_matrix_solid_multisplash_range(0, iter);
 | 
			
		||||
bool rgb_matrix_solid_multisplash(effect_params_t* params) {
 | 
			
		||||
  return rgb_matrix_solid_multisplash_range(0, params);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_solid_splash(bool init, uint8_t iter) {
 | 
			
		||||
  return rgb_matrix_solid_multisplash_range(qsub8(g_last_hit_tracker.count, 1), iter);
 | 
			
		||||
bool rgb_matrix_solid_splash(effect_params_t* params) {
 | 
			
		||||
  return rgb_matrix_solid_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
 | 
			
		|||
extern rgb_config_t rgb_matrix_config;
 | 
			
		||||
extern last_hit_t g_last_hit_tracker;
 | 
			
		||||
 | 
			
		||||
static bool rgb_matrix_multisplash_range(uint8_t start, uint8_t iter) {
 | 
			
		||||
static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params) {
 | 
			
		||||
  RGB_MATRIX_USE_LIMITS(led_min, led_max);
 | 
			
		||||
 | 
			
		||||
  HSV hsv = { 0, rgb_matrix_config.sat, 0 };
 | 
			
		||||
| 
						 | 
				
			
			@ -32,12 +32,12 @@ static bool rgb_matrix_multisplash_range(uint8_t start, uint8_t iter) {
 | 
			
		|||
  return led_max < DRIVER_LED_TOTAL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_multisplash(bool init, uint8_t iter) {
 | 
			
		||||
  return rgb_matrix_multisplash_range(0, iter);
 | 
			
		||||
bool rgb_matrix_multisplash(effect_params_t* params) {
 | 
			
		||||
  return rgb_matrix_multisplash_range(0, params);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool rgb_matrix_splash(bool init, uint8_t iter) {
 | 
			
		||||
  return rgb_matrix_multisplash_range(qsub8(g_last_hit_tracker.count, 1), iter);
 | 
			
		||||
bool rgb_matrix_splash(effect_params_t* params) {
 | 
			
		||||
  return rgb_matrix_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue