Skip to content

Commit 18abef4

Browse files
committed
Enabling per-layer fade profiles
- Layer fade triggers now working - Fixed gamma correction bug when fade profiles are disabled - Enabled Kira ScanCode remapping (was easier to debug fade profiles)
1 parent 0c82595 commit 18abef4

File tree

3 files changed

+237
-237
lines changed

3 files changed

+237
-237
lines changed

Macro/PixelMap/pixel.c

+31-8
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,6 @@ void Pixel_FadeSet_capability( TriggerMacro *trigger, uint8_t state, uint8_t sta
506506
void Pixel_FadeLayerHighlight_capability( TriggerMacro *trigger, uint8_t state, uint8_t stateType, uint8_t *args )
507507
{
508508
CapabilityState cstate = KLL_CapabilityState( state, stateType );
509-
// TODO (HaaTa): FIXME
510-
return;
511509

512510
switch ( cstate )
513511
{
@@ -550,13 +548,26 @@ void Pixel_FadeLayerHighlight_capability( TriggerMacro *trigger, uint8_t state,
550548
// Get argument
551549
uint16_t layer = *(uint16_t*)(&args[0]);
552550

551+
// Ignore if an invalid layer
552+
if ( layer >= LayerNum )
553+
{
554+
return;
555+
}
556+
553557
// Lookup layer
554558
const Layer *layer_map = &LayerIndex[layer];
555559

556560
// Lookup list of keys in layer
557561
for ( uint8_t key = layer_map->first; key <= layer_map->last; key++ )
558562
{
559563
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+
560571
// If the first entry in trigger list is a 0, ignore (otherwise, key is in layer)
561572
if ( layer_map->triggerMap[index][0] == 0 )
562573
{
@@ -566,8 +577,14 @@ void Pixel_FadeLayerHighlight_capability( TriggerMacro *trigger, uint8_t state,
566577
// Lookup pixel associated with scancode (remember -1 as all pixels and scancodes start at 1, not 0)
567578
uint16_t pixel = Pixel_ScanCodeToPixel[key - 1];
568579

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;
571588
}
572589
}
573590

@@ -1997,7 +2014,7 @@ void Pixel_SecondaryProcessing()
19972014
// Select profile
19982015
uint8_t profile_in = Pixel_pixel_fade_profile[pxin];
19992016

2000-
// Nothing to do (fade disabled for this pixel)
2017+
// Nothing to do
20012018
if ( profile_in == 0 )
20022019
{
20032020
continue;
@@ -2014,6 +2031,7 @@ void Pixel_SecondaryProcessing()
20142031
// Lookup PixelBuf containing the channel
20152032
uint16_t chan = elem->indices[ch];
20162033
PixelBuf *buf = LED_bufferMap( chan );
2034+
PixelBuf *bufin = Pixel_bufferMap( chan );
20172035

20182036
// Lookup memory location
20192037
// Then apply fade depending on the current position
@@ -2040,7 +2058,7 @@ void Pixel_SecondaryProcessing()
20402058
break;
20412059
}
20422060

2043-
val = (uint8_t)((uint16_t*)buf->data)[chan - buf->offset];
2061+
val = (uint8_t)((uint16_t*)bufin->data)[chan - bufin->offset];
20442062
if (gamma_enabled) {
20452063
val = gamma_table[val];
20462064
}
@@ -2051,7 +2069,7 @@ void Pixel_SecondaryProcessing()
20512069
// On hold time
20522070
case PixelPeriodIndex_On:
20532071
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];
20552073
val = gamma_table[val];
20562074
((uint16_t*)buf->data)[chan - buf->offset] = (uint8_t)val;
20572075
}
@@ -2064,6 +2082,11 @@ void Pixel_SecondaryProcessing()
20642082
// If the previous config was disabled, do not set to 0
20652083
if ( prev->start == 0 && prev->end == 0 )
20662084
{
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;
20672090
break;
20682091
}
20692092

@@ -2072,7 +2095,7 @@ void Pixel_SecondaryProcessing()
20722095
val = 0;
20732096
if ( prev->start != 0 )
20742097
{
2075-
val = (uint8_t)((uint16_t*)buf->data)[chan - buf->offset];
2098+
val = (uint8_t)((uint16_t*)bufin->data)[chan - bufin->offset];
20762099
if (gamma_enabled) {
20772100
val = gamma_table[val];
20782101
}

Scan/Devices/MatrixARMPeriodic/matrix_scan.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ uint8_t Matrix_single_scan()
291291

292292
// Check bounds, before attempting to scan
293293
// 1-indexed as ScanCode 0 is not used
294-
if ( key + 1 > MaxScanCode_KLL )
294+
if ( key_disp > MaxScanCode_KLL || key_disp == 0 )
295295
{
296296
continue;
297297
}

0 commit comments

Comments
 (0)