@ -226,7 +226,7 @@ void disp_pixel_setup(void)
while ( cur < lede )
{
cur - > px = ( cur - > x - disp . left ) / disp . width * 100 ;
cur - > py = ( cur - > y - disp . top ) / disp . height * 100 ;
cur - > py = ( cur - > y - disp . bottom ) / disp . height * 100 ;
* cur - > rgb . r = 0 ;
* cur - > rgb . g = 0 ;
* cur - > rgb . b = 0 ;
@ -244,6 +244,7 @@ void led_matrix_prepare(void)
uint8_t led_enabled ;
float led_animation_speed ;
uint8_t led_animation_direction ;
uint8_t led_animation_orientation ;
uint8_t led_animation_breathing ;
uint8_t led_animation_breathe_cur ;
uint8_t breathe_step ;
@ -263,7 +264,7 @@ void led_matrix_run(void)
float ro ;
float go ;
float bo ;
float p x ;
float p o ;
uint8_t led_this_run = 0 ;
led_setup_t * f = ( led_setup_t * ) led_setups [ led_animation_id ] ;
@ -325,59 +326,68 @@ void led_matrix_run(void)
//Act on LED
for ( fcur = 0 ; fcur < fmax ; fcur + + )
{
px = led_cur - > px ;
float pxmod ;
pxmod = ( float ) ( disp . frame % ( uint32_t ) ( 1000.0f / led_animation_speed ) ) / 10.0f * led_animation_speed ;
if ( led_animation_orientation )
{
po = led_cur - > py ;
}
else
{
po = led_cur - > px ;
}
float pomod ;
pomod = ( float ) ( disp . frame % ( uint32_t ) ( 1000.0f / led_animation_speed ) ) / 10.0f * led_animation_speed ;
//Add in any moving effects
if ( ( ! led_animation_direction & & f [ fcur ] . ef & EF_SCR_R ) | | ( led_animation_direction & & ( f [ fcur ] . ef & EF_SCR_L ) ) )
{
pxmod * = 100.0f ;
pxmod = ( uint32_t ) pxmod % 10000 ;
pxmod / = 100.0f ;
p o mod * = 100.0f ;
p omod = ( uint32_t ) po mod % 10000 ;
p o mod / = 100.0f ;
px - = pxmod ;
p o - = po mod;
if ( p x > 100 ) px - = 100 ;
else if ( p x < 0 ) px + = 100 ;
if ( p o > 100 ) po - = 100 ;
else if ( p o < 0 ) po + = 100 ;
}
else if ( ( ! led_animation_direction & & f [ fcur ] . ef & EF_SCR_L ) | | ( led_animation_direction & & ( f [ fcur ] . ef & EF_SCR_R ) ) )
{
p x mod * = 100.0f ;
p xmod = ( uint32_t ) px mod % 10000 ;
p x mod / = 100.0f ;
p x + = px mod;
p o mod * = 100.0f ;
p omod = ( uint32_t ) po mod % 10000 ;
p o mod / = 100.0f ;
p o + = po mod;
if ( p x > 100 ) px - = 100 ;
else if ( p x < 0 ) px + = 100 ;
if ( p o > 100 ) po - = 100 ;
else if ( p o < 0 ) po + = 100 ;
}
//Check if LED's p x is in current frame
if ( p x < f [ fcur ] . hs ) continue ;
if ( p x > f [ fcur ] . he ) continue ;
//Check if LED's p o is in current frame
if ( p o < f [ fcur ] . hs ) continue ;
if ( p o > f [ fcur ] . he ) continue ;
//note: < 0 or > 100 continue
//Calculate the p x within the start-stop percentage for color blending
p x = ( px - f [ fcur ] . hs ) / ( f [ fcur ] . he - f [ fcur ] . hs ) ;
//Calculate the p o within the start-stop percentage for color blending
p o = ( po - f [ fcur ] . hs ) / ( f [ fcur ] . he - f [ fcur ] . hs ) ;
//Add in any color effects
if ( f [ fcur ] . ef & EF_OVER )
{
ro = ( p x * ( f [ fcur ] . re - f [ fcur ] . rs ) ) + f [ fcur ] . rs ; // + 0.5;
go = ( p x * ( f [ fcur ] . ge - f [ fcur ] . gs ) ) + f [ fcur ] . gs ; // + 0.5;
bo = ( p x * ( f [ fcur ] . be - f [ fcur ] . bs ) ) + f [ fcur ] . bs ; // + 0.5;
ro = ( p o * ( f [ fcur ] . re - f [ fcur ] . rs ) ) + f [ fcur ] . rs ; // + 0.5;
go = ( p o * ( f [ fcur ] . ge - f [ fcur ] . gs ) ) + f [ fcur ] . gs ; // + 0.5;
bo = ( p o * ( f [ fcur ] . be - f [ fcur ] . bs ) ) + f [ fcur ] . bs ; // + 0.5;
}
else if ( f [ fcur ] . ef & EF_SUBTRACT )
{
ro - = ( p x * ( f [ fcur ] . re - f [ fcur ] . rs ) ) + f [ fcur ] . rs ; // + 0.5;
go - = ( p x * ( f [ fcur ] . ge - f [ fcur ] . gs ) ) + f [ fcur ] . gs ; // + 0.5;
bo - = ( p x * ( f [ fcur ] . be - f [ fcur ] . bs ) ) + f [ fcur ] . bs ; // + 0.5;
ro - = ( p o * ( f [ fcur ] . re - f [ fcur ] . rs ) ) + f [ fcur ] . rs ; // + 0.5;
go - = ( p o * ( f [ fcur ] . ge - f [ fcur ] . gs ) ) + f [ fcur ] . gs ; // + 0.5;
bo - = ( p o * ( f [ fcur ] . be - f [ fcur ] . bs ) ) + f [ fcur ] . bs ; // + 0.5;
}
else
{
ro + = ( p x * ( f [ fcur ] . re - f [ fcur ] . rs ) ) + f [ fcur ] . rs ; // + 0.5;
go + = ( p x * ( f [ fcur ] . ge - f [ fcur ] . gs ) ) + f [ fcur ] . gs ; // + 0.5;
bo + = ( p x * ( f [ fcur ] . be - f [ fcur ] . bs ) ) + f [ fcur ] . bs ; // + 0.5;
ro + = ( p o * ( f [ fcur ] . re - f [ fcur ] . rs ) ) + f [ fcur ] . rs ; // + 0.5;
go + = ( p o * ( f [ fcur ] . ge - f [ fcur ] . gs ) ) + f [ fcur ] . gs ; // + 0.5;
bo + = ( p o * ( f [ fcur ] . be - f [ fcur ] . bs ) ) + f [ fcur ] . bs ; // + 0.5;
}
}
}
@ -451,6 +461,7 @@ uint8_t led_matrix_init(void)
led_lighting_mode = LED_MODE_NORMAL ;
led_animation_speed = 4.0f ;
led_animation_direction = 0 ;
led_animation_orientation = 0 ;
led_animation_breathing = 0 ;
led_animation_breathe_cur = BREATHE_MIN_STEP ;
breathe_step = 1 ;