mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-01-06 01:19:38 +00:00
PROGMEM led mappings
This commit is contained in:
parent
283660f55a
commit
7661682787
@ -28,7 +28,7 @@ def _append_lighting_map(lines, feature, spec):
|
|||||||
ifdef_prefix = PREFIX_MAP[feature]['ifdef']
|
ifdef_prefix = PREFIX_MAP[feature]['ifdef']
|
||||||
def_prefix = PREFIX_MAP[feature]['def']
|
def_prefix = PREFIX_MAP[feature]['def']
|
||||||
|
|
||||||
lines.append(f'static uint8_t {feature}_effect_map[][2] = {{')
|
lines.append(f'static const uint8_t {feature}_effect_map[][2] PROGMEM = {{')
|
||||||
for id, obj in spec.get('effects', {}).items():
|
for id, obj in spec.get('effects', {}).items():
|
||||||
define = obj['define']
|
define = obj['define']
|
||||||
offset = f' + {obj["offset"]}' if obj['offset'] else ''
|
offset = f' + {obj["offset"]}' if obj['offset'] else ''
|
||||||
@ -54,16 +54,16 @@ def _append_lighting_map(lines, feature, spec):
|
|||||||
f'''
|
f'''
|
||||||
uint8_t {feature}2xap(uint8_t val) {{
|
uint8_t {feature}2xap(uint8_t val) {{
|
||||||
for(uint8_t i = 0; i < ARRAY_SIZE({feature}_effect_map); i++) {{
|
for(uint8_t i = 0; i < ARRAY_SIZE({feature}_effect_map); i++) {{
|
||||||
if ({feature}_effect_map[i][1] == val)
|
if (pgm_read_byte(&{feature}_effect_map[i][1]) == val)
|
||||||
return {feature}_effect_map[i][0];
|
return pgm_read_byte(&{feature}_effect_map[i][0]);
|
||||||
}}
|
}}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
uint8_t xap2{feature}(uint8_t val) {{
|
uint8_t xap2{feature}(uint8_t val) {{
|
||||||
for(uint8_t i = 0; i < ARRAY_SIZE({feature}_effect_map); i++) {{
|
for(uint8_t i = 0; i < ARRAY_SIZE({feature}_effect_map); i++) {{
|
||||||
if ({feature}_effect_map[i][0] == val)
|
if (pgm_read_byte(&{feature}_effect_map[i][0]) == val)
|
||||||
return {feature}_effect_map[i][1];
|
return pgm_read_byte(&{feature}_effect_map[i][1]);
|
||||||
}}
|
}}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}}'''
|
}}'''
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 QMK
|
// Copyright 2023 QMK
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -31,7 +31,7 @@
|
|||||||
#define ENABLE_LED_MATRIX_SOLID
|
#define ENABLE_LED_MATRIX_SOLID
|
||||||
|
|
||||||
#ifdef RGBLIGHT_ENABLE
|
#ifdef RGBLIGHT_ENABLE
|
||||||
static uint8_t rgblight_effect_map[][2] = {
|
static const uint8_t rgblight_effect_map[][2] PROGMEM = {
|
||||||
|
|
||||||
#ifdef RGBLIGHT_EFFECT_STATIC_LIGHT
|
#ifdef RGBLIGHT_EFFECT_STATIC_LIGHT
|
||||||
{ 0x00, RGBLIGHT_MODE_STATIC_LIGHT},
|
{ 0x00, RGBLIGHT_MODE_STATIC_LIGHT},
|
||||||
@ -204,16 +204,16 @@ static uint8_t rgblight_effect_map[][2] = {
|
|||||||
|
|
||||||
uint8_t rgblight2xap(uint8_t val) {
|
uint8_t rgblight2xap(uint8_t val) {
|
||||||
for(uint8_t i = 0; i < ARRAY_SIZE(rgblight_effect_map); i++) {
|
for(uint8_t i = 0; i < ARRAY_SIZE(rgblight_effect_map); i++) {
|
||||||
if (rgblight_effect_map[i][1] == val)
|
if (pgm_read_byte(&rgblight_effect_map[i][1]) == val)
|
||||||
return rgblight_effect_map[i][0];
|
return pgm_read_byte(&rgblight_effect_map[i][0]);
|
||||||
}
|
}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t xap2rgblight(uint8_t val) {
|
uint8_t xap2rgblight(uint8_t val) {
|
||||||
for(uint8_t i = 0; i < ARRAY_SIZE(rgblight_effect_map); i++) {
|
for(uint8_t i = 0; i < ARRAY_SIZE(rgblight_effect_map); i++) {
|
||||||
if (rgblight_effect_map[i][0] == val)
|
if (pgm_read_byte(&rgblight_effect_map[i][0]) == val)
|
||||||
return rgblight_effect_map[i][1];
|
return pgm_read_byte(&rgblight_effect_map[i][1]);
|
||||||
}
|
}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
@ -389,7 +389,7 @@ enum { ENABLED_RGBLIGHT_EFFECTS = 0
|
|||||||
};
|
};
|
||||||
#endif //RGBLIGHT_ENABLE
|
#endif //RGBLIGHT_ENABLE
|
||||||
#ifdef RGB_MATRIX_ENABLE
|
#ifdef RGB_MATRIX_ENABLE
|
||||||
static uint8_t rgb_matrix_effect_map[][2] = {
|
static const uint8_t rgb_matrix_effect_map[][2] PROGMEM = {
|
||||||
|
|
||||||
#ifdef ENABLE_RGB_MATRIX_SOLID_COLOR
|
#ifdef ENABLE_RGB_MATRIX_SOLID_COLOR
|
||||||
{ 0x00, RGB_MATRIX_SOLID_COLOR},
|
{ 0x00, RGB_MATRIX_SOLID_COLOR},
|
||||||
@ -612,16 +612,16 @@ static uint8_t rgb_matrix_effect_map[][2] = {
|
|||||||
|
|
||||||
uint8_t rgb_matrix2xap(uint8_t val) {
|
uint8_t rgb_matrix2xap(uint8_t val) {
|
||||||
for(uint8_t i = 0; i < ARRAY_SIZE(rgb_matrix_effect_map); i++) {
|
for(uint8_t i = 0; i < ARRAY_SIZE(rgb_matrix_effect_map); i++) {
|
||||||
if (rgb_matrix_effect_map[i][1] == val)
|
if (pgm_read_byte(&rgb_matrix_effect_map[i][1]) == val)
|
||||||
return rgb_matrix_effect_map[i][0];
|
return pgm_read_byte(&rgb_matrix_effect_map[i][0]);
|
||||||
}
|
}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t xap2rgb_matrix(uint8_t val) {
|
uint8_t xap2rgb_matrix(uint8_t val) {
|
||||||
for(uint8_t i = 0; i < ARRAY_SIZE(rgb_matrix_effect_map); i++) {
|
for(uint8_t i = 0; i < ARRAY_SIZE(rgb_matrix_effect_map); i++) {
|
||||||
if (rgb_matrix_effect_map[i][0] == val)
|
if (pgm_read_byte(&rgb_matrix_effect_map[i][0]) == val)
|
||||||
return rgb_matrix_effect_map[i][1];
|
return pgm_read_byte(&rgb_matrix_effect_map[i][1]);
|
||||||
}
|
}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
@ -847,7 +847,7 @@ enum { ENABLED_RGB_MATRIX_EFFECTS = 0
|
|||||||
};
|
};
|
||||||
#endif //RGB_MATRIX_ENABLE
|
#endif //RGB_MATRIX_ENABLE
|
||||||
#ifdef LED_MATRIX_ENABLE
|
#ifdef LED_MATRIX_ENABLE
|
||||||
static uint8_t led_matrix_effect_map[][2] = {
|
static const uint8_t led_matrix_effect_map[][2] PROGMEM = {
|
||||||
|
|
||||||
#ifdef ENABLE_LED_MATRIX_SOLID
|
#ifdef ENABLE_LED_MATRIX_SOLID
|
||||||
{ 0x00, LED_MATRIX_SOLID},
|
{ 0x00, LED_MATRIX_SOLID},
|
||||||
@ -963,16 +963,16 @@ static uint8_t led_matrix_effect_map[][2] = {
|
|||||||
|
|
||||||
uint8_t led_matrix2xap(uint8_t val) {
|
uint8_t led_matrix2xap(uint8_t val) {
|
||||||
for(uint8_t i = 0; i < ARRAY_SIZE(led_matrix_effect_map); i++) {
|
for(uint8_t i = 0; i < ARRAY_SIZE(led_matrix_effect_map); i++) {
|
||||||
if (led_matrix_effect_map[i][1] == val)
|
if (pgm_read_byte(&led_matrix_effect_map[i][1]) == val)
|
||||||
return led_matrix_effect_map[i][0];
|
return pgm_read_byte(&led_matrix_effect_map[i][0]);
|
||||||
}
|
}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t xap2led_matrix(uint8_t val) {
|
uint8_t xap2led_matrix(uint8_t val) {
|
||||||
for(uint8_t i = 0; i < ARRAY_SIZE(led_matrix_effect_map); i++) {
|
for(uint8_t i = 0; i < ARRAY_SIZE(led_matrix_effect_map); i++) {
|
||||||
if (led_matrix_effect_map[i][0] == val)
|
if (pgm_read_byte(&led_matrix_effect_map[i][0]) == val)
|
||||||
return led_matrix_effect_map[i][1];
|
return pgm_read_byte(&led_matrix_effect_map[i][1]);
|
||||||
}
|
}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
@ -1090,3 +1090,4 @@ enum { ENABLED_LED_MATRIX_EFFECTS = 0
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
#endif //LED_MATRIX_ENABLE
|
#endif //LED_MATRIX_ENABLE
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user