@@ -506,8 +506,6 @@ void Pixel_FadeSet_capability( TriggerMacro *trigger, uint8_t state, uint8_t sta
506
506
void Pixel_FadeLayerHighlight_capability ( TriggerMacro * trigger , uint8_t state , uint8_t stateType , uint8_t * args )
507
507
{
508
508
CapabilityState cstate = KLL_CapabilityState ( state , stateType );
509
- // TODO (HaaTa): FIXME
510
- return ;
511
509
512
510
switch ( cstate )
513
511
{
@@ -550,13 +548,26 @@ void Pixel_FadeLayerHighlight_capability( TriggerMacro *trigger, uint8_t state,
550
548
// Get argument
551
549
uint16_t layer = * (uint16_t * )(& args [0 ]);
552
550
551
+ // Ignore if an invalid layer
552
+ if ( layer >= LayerNum )
553
+ {
554
+ return ;
555
+ }
556
+
553
557
// Lookup layer
554
558
const Layer * layer_map = & LayerIndex [layer ];
555
559
556
560
// Lookup list of keys in layer
557
561
for ( uint8_t key = layer_map -> first ; key <= layer_map -> last ; key ++ )
558
562
{
559
563
uint8_t index = key - layer_map -> first ;
564
+
565
+ // Skip 0 index, as scancodes start at 1
566
+ if ( index == 0 )
567
+ {
568
+ continue ;
569
+ }
570
+
560
571
// If the first entry in trigger list is a 0, ignore (otherwise, key is in layer)
561
572
if ( layer_map -> triggerMap [index ][0 ] == 0 )
562
573
{
@@ -566,8 +577,14 @@ void Pixel_FadeLayerHighlight_capability( TriggerMacro *trigger, uint8_t state,
566
577
// Lookup pixel associated with scancode (remember -1 as all pixels and scancodes start at 1, not 0)
567
578
uint16_t pixel = Pixel_ScanCodeToPixel [key - 1 ];
568
579
569
- // Set pixel to group #4 (index 3)
570
- Pixel_pixel_fade_profile [pixel - 1 ] = 3 ;
580
+ // If pixel is 0, ignore
581
+ if ( pixel == 0 )
582
+ {
583
+ continue ;
584
+ }
585
+
586
+ // Set pixel to group #4
587
+ Pixel_pixel_fade_profile [pixel - 1 ] = 4 ;
571
588
}
572
589
}
573
590
@@ -1997,7 +2014,7 @@ void Pixel_SecondaryProcessing()
1997
2014
// Select profile
1998
2015
uint8_t profile_in = Pixel_pixel_fade_profile [pxin ];
1999
2016
2000
- // Nothing to do (fade disabled for this pixel)
2017
+ // Nothing to do
2001
2018
if ( profile_in == 0 )
2002
2019
{
2003
2020
continue ;
@@ -2014,6 +2031,7 @@ void Pixel_SecondaryProcessing()
2014
2031
// Lookup PixelBuf containing the channel
2015
2032
uint16_t chan = elem -> indices [ch ];
2016
2033
PixelBuf * buf = LED_bufferMap ( chan );
2034
+ PixelBuf * bufin = Pixel_bufferMap ( chan );
2017
2035
2018
2036
// Lookup memory location
2019
2037
// Then apply fade depending on the current position
@@ -2040,7 +2058,7 @@ void Pixel_SecondaryProcessing()
2040
2058
break ;
2041
2059
}
2042
2060
2043
- val = (uint8_t )((uint16_t * )buf -> data )[chan - buf -> offset ];
2061
+ val = (uint8_t )((uint16_t * )bufin -> data )[chan - bufin -> offset ];
2044
2062
if (gamma_enabled ) {
2045
2063
val = gamma_table [val ];
2046
2064
}
@@ -2051,7 +2069,7 @@ void Pixel_SecondaryProcessing()
2051
2069
// On hold time
2052
2070
case PixelPeriodIndex_On :
2053
2071
if (gamma_enabled ) {
2054
- val = (uint8_t )((uint16_t * )buf -> data )[chan - buf -> offset ];
2072
+ val = (uint8_t )((uint16_t * )bufin -> data )[chan - bufin -> offset ];
2055
2073
val = gamma_table [val ];
2056
2074
((uint16_t * )buf -> data )[chan - buf -> offset ] = (uint8_t )val ;
2057
2075
}
@@ -2064,6 +2082,11 @@ void Pixel_SecondaryProcessing()
2064
2082
// If the previous config was disabled, do not set to 0
2065
2083
if ( prev -> start == 0 && prev -> end == 0 )
2066
2084
{
2085
+ val = (uint8_t )((uint16_t * )bufin -> data )[chan - bufin -> offset ];
2086
+ if (gamma_enabled ) {
2087
+ val = gamma_table [val ];
2088
+ }
2089
+ ((uint16_t * )buf -> data )[chan - buf -> offset ] = (uint8_t )val ;
2067
2090
break ;
2068
2091
}
2069
2092
@@ -2072,7 +2095,7 @@ void Pixel_SecondaryProcessing()
2072
2095
val = 0 ;
2073
2096
if ( prev -> start != 0 )
2074
2097
{
2075
- val = (uint8_t )((uint16_t * )buf -> data )[chan - buf -> offset ];
2098
+ val = (uint8_t )((uint16_t * )bufin -> data )[chan - bufin -> offset ];
2076
2099
if (gamma_enabled ) {
2077
2100
val = gamma_table [val ];
2078
2101
}
0 commit comments