Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of __flash within LED drivers #21343

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/feature_led_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Currently only 4 drivers are supported, but it would be trivial to support for m
Define these arrays listing all the LEDs in your `<keyboard>.c`:

```c
const is31_led __flash g_is31_leds[LED_MATRIX_LED_COUNT] = {
const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | LED address
Expand All @@ -158,7 +158,7 @@ Eg `#define ISSI_MANUAL_SCALING 3`
Then Define the array listing all the LEDs you want to override in your `<keyboard>.c`:

```c
const is31_led __flash g_is31_scaling[ISSI_MANUAL_SCALING] = {
const is31_led PROGMEM g_is31_scaling[ISSI_MANUAL_SCALING] = {
* LED Index
* | Scaling
* | | */
Expand Down
4 changes: 2 additions & 2 deletions docs/feature_rgb_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ Currently only 4 drivers are supported, but it would be trivial to support for m
Define these arrays listing all the LEDs in your `<keyboard>.c`:

```c
const is31_led __flash g_is31_leds[RGB_MATRIX_LED_COUNT] = {
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations
* driver
* | R location
Expand All @@ -406,7 +406,7 @@ Eg `#define ISSI_MANUAL_SCALING 3`
Then Define the array listing all the LEDs you want to override in your `<keyboard>.c`:

```c
const is31_led __flash g_is31_scaling[ISSI_MANUAL_SCALING] = {
const is31_led PROGMEM g_is31_scaling[ISSI_MANUAL_SCALING] = {
* LED Index
* | R scaling
* | | G scaling
Expand Down
6 changes: 4 additions & 2 deletions drivers/led/issi/is31fl3733-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ void IS31FL3733_init(uint8_t addr, uint8_t sync) {
}

void IS31FL3733_set_value(int index, uint8_t value) {
is31_led led;
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[index];
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));

if (g_pwm_buffer[led.driver][led.v] == value) {
return;
Expand All @@ -211,7 +212,8 @@ void IS31FL3733_set_value_all(uint8_t value) {
}

void IS31FL3733_set_led_control_register(uint8_t index, bool value) {
is31_led led = g_is31_leds[index];
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));

uint8_t control_register = led.v / 8;
uint8_t bit_value = led.v % 8;
Expand Down
2 changes: 1 addition & 1 deletion drivers/led/issi/is31fl3733-simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef struct is31_led {
uint8_t v;
} __attribute__((packed)) is31_led;

extern const is31_led __flash g_is31_leds[LED_MATRIX_LED_COUNT];
extern const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT];

void IS31FL3733_init(uint8_t addr, uint8_t sync);
bool IS31FL3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
Expand Down
22 changes: 15 additions & 7 deletions drivers/led/issi/is31flcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,14 @@ void IS31FL_common_update_pwm_register(uint8_t addr, uint8_t index) {

#ifdef ISSI_MANUAL_SCALING
void IS31FL_set_manual_scaling_buffer(void) {
is31_led led;
is31_led scale;
for (int i = 0; i < ISSI_MANUAL_SCALING; i++) {
is31_led scale = g_is31_scaling[i];
memcpy_P(&scale, (&g_is31_scaling[i]), sizeof(scale));

# ifdef RGB_MATRIX_ENABLE
if (scale.driver >= 0 && scale.driver < RGB_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[scale.driver];
memcpy_P(&led, (&g_is31_leds[scale.driver]), sizeof(led));

if (g_scaling_buffer[led.driver][led.r] = scale.r && g_scaling_buffer[led.driver][led.g] = scale.g && g_scaling_buffer[led.driver][led.b] = scale.b) {
return;
Expand All @@ -147,7 +150,7 @@ void IS31FL_set_manual_scaling_buffer(void) {
g_scaling_buffer[led.driver][led.b] = scale.b;
# elif defined(LED_MATRIX_ENABLE)
if (scale.driver >= 0 && scale.driver < LED_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[scale.driver];
memcpy_P(&led, (&g_is31_leds[scale.driver]), sizeof(led));

if (g_scaling_buffer[led.driver][led.v] == scale.v) {
return;
Expand Down Expand Up @@ -175,7 +178,8 @@ void IS31FL_common_update_scaling_register(uint8_t addr, uint8_t index) {
// Colour is set by adjusting PWM register
void IS31FL_RGB_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[index];
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));

g_pwm_buffer[led.driver][led.r] = red;
g_pwm_buffer[led.driver][led.g] = green;
Expand All @@ -192,7 +196,8 @@ void IS31FL_RGB_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {

// Setup Scaling register that decides the peak current of each LED
void IS31FL_RGB_set_scaling_buffer(uint8_t index, bool red, bool green, bool blue) {
is31_led led = g_is31_leds[index];
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
if (red) {
g_scaling_buffer[led.driver][led.r] = ISSI_SCAL_RED;
} else {
Expand All @@ -214,7 +219,8 @@ void IS31FL_RGB_set_scaling_buffer(uint8_t index, bool red, bool green, bool blu
#elif defined(LED_MATRIX_ENABLE)
// LED Matrix Specific scripts
void IS31FL_simple_set_scaling_buffer(uint8_t index, bool value) {
is31_led led = g_is31_leds[index];
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
if (value) {
g_scaling_buffer[led.driver][led.v] = ISSI_SCAL_LED;
} else {
Expand All @@ -225,7 +231,9 @@ void IS31FL_simple_set_scaling_buffer(uint8_t index, bool value) {

void IS31FL_simple_set_brightness(int index, uint8_t value) {
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
is31_led led = g_is31_leds[index];
is31_led led;
memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));

g_pwm_buffer[led.driver][led.v] = value;
g_pwm_buffer_update_required[led.driver] = true;
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/led/issi/is31flcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ typedef struct is31_led {
uint8_t b;
} __attribute__((packed)) is31_led;

extern const is31_led __flash g_is31_leds[RGB_MATRIX_LED_COUNT];
extern const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT];

#elif defined(LED_MATRIX_ENABLE)
typedef struct is31_led {
uint8_t driver;
uint8_t v;
} __attribute__((packed)) is31_led;

extern const is31_led __flash g_is31_leds[LED_MATRIX_LED_COUNT];
extern const is31_led PROGMEM g_is31_leds[LED_MATRIX_LED_COUNT];
#endif

#ifdef ISSI_MANUAL_SCALING
extern const is31_led __flash g_is31_scaling[];
extern const is31_led PROGMEM g_is31_scaling[];
void IS31FL_set_manual_scaling_buffer(void);
#endif

Expand Down