popn: rest of the new cab lights (#651)

## Link to GitHub Issue or related Pull Request, if one exists
#618 

## Description of change
Add rest of the LED strip lights.

## Testing
Tested U region.
This commit is contained in:
bicarus
2026-04-18 22:17:20 -07:00
committed by GitHub
parent 26b3b64794
commit 6838e69ebe
7 changed files with 107 additions and 10 deletions
+12 -3
View File
@@ -9,7 +9,7 @@ namespace tapeledutils {
}
// for bi2x-style byte array of all colors and LEDs at once
rgb_float3_t pick_color_from_led_tape(uint8_t *data, size_t data_size) {
static rgb_float3_t pick_color_from_led_tape_internal(uint8_t *data, size_t data_size, uint8_t divisor) {
rgb_float3_t result = {0.f, 0.f, 0.f};
if (TAPE_LED_ALGORITHM == TAPE_LED_USE_AVERAGE) {
@@ -25,7 +25,7 @@ namespace tapeledutils {
}
// normalize
const float avg_mult = 1.f / (data_size * 255);
const float avg_mult = 1.f / (data_size * divisor);
result.r = avg_ri * avg_mult;
result.g = avg_gi * avg_mult;
result.b = avg_bi * avg_mult;
@@ -50,7 +50,7 @@ namespace tapeledutils {
}
// normalize
const float single_mult = 1.f / 255;
const float single_mult = 1.f / divisor;
result.r = color[0] * single_mult;
result.g = color[1] * single_mult;
result.b = color[2] * single_mult;
@@ -58,6 +58,15 @@ namespace tapeledutils {
return result;
}
rgb_float3_t pick_color_from_led_tape(tape_led &light, uint8_t *data, size_t data_size) {
const auto max_value = (light.max_value > 0) ? light.max_value : 0xFF;
return pick_color_from_led_tape_internal(data, data_size, max_value);
}
rgb_float3_t pick_color_from_led_tape(uint8_t *data, size_t data_size) {
return pick_color_from_led_tape_internal(data, data_size, 0xFF);
}
// for bi2a-style that calls for each individual LED
size_t get_led_index_using_avg_algo(size_t data_size) {
size_t index_to_use;