aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Cullin <chris@miplace.com>2021-07-13 01:51:23 +1000
committerGitHub <noreply@github.com>2021-07-12 08:51:23 -0700
commit9c74fd14bc9777ec45cc93fa57bf83ab17b988db (patch)
treee82c74183f7413e303f6afa247bcd54a106bfc6f
parent4706231831b7b5926052ee1affc7f38a165c7761 (diff)
downloadqmk_firmware-9c74fd14bc9777ec45cc93fa57bf83ab17b988db.tar.gz
qmk_firmware-9c74fd14bc9777ec45cc93fa57bf83ab17b988db.zip
Enable g_is31_leds PROGMEM for RGB Matrix IS31FL3737 driver (#13480)
-rw-r--r--docs/feature_rgb_matrix.md2
-rw-r--r--drivers/issi/is31fl3737.c9
-rw-r--r--keyboards/mt84/mt84.c40
-rw-r--r--keyboards/planck/ez/ez.c2
-rw-r--r--tmk_core/common/progmem.h1
5 files changed, 30 insertions, 24 deletions
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md
index 675b7a1be..be763ee02 100644
--- a/docs/feature_rgb_matrix.md
+++ b/docs/feature_rgb_matrix.md
@@ -171,7 +171,7 @@ Currently only a single drivers is supported, but it would be trivial to support
171Define these arrays listing all the LEDs in your `<keyboard>.c`: 171Define these arrays listing all the LEDs in your `<keyboard>.c`:
172 172
173```c 173```c
174const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { 174const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
175/* Refer to IS31 manual for these locations 175/* Refer to IS31 manual for these locations
176 * driver 176 * driver
177 * | R location 177 * | R location
diff --git a/drivers/issi/is31fl3737.c b/drivers/issi/is31fl3737.c
index 8647c93cc..e40bfa0d7 100644
--- a/drivers/issi/is31fl3737.c
+++ b/drivers/issi/is31fl3737.c
@@ -19,6 +19,7 @@
19#include "is31fl3737.h" 19#include "is31fl3737.h"
20#include "i2c_master.h" 20#include "i2c_master.h"
21#include "wait.h" 21#include "wait.h"
22#include "progmem.h"
22 23
23// This is a 7-bit address, that gets left-shifted and bit 0 24// This is a 7-bit address, that gets left-shifted and bit 0
24// set to 0 for write, 1 for read (as per I2C protocol) 25// set to 0 for write, 1 for read (as per I2C protocol)
@@ -153,7 +154,9 @@ void IS31FL3737_init(uint8_t addr) {
153 154
154void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { 155void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
155 if (index >= 0 && index < DRIVER_LED_TOTAL) { 156 if (index >= 0 && index < DRIVER_LED_TOTAL) {
156 is31_led led = g_is31_leds[index]; 157 // copy the led config from progmem to SRAM
158 is31_led led;
159 memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
157 160
158 g_pwm_buffer[led.driver][led.r] = red; 161 g_pwm_buffer[led.driver][led.r] = red;
159 g_pwm_buffer[led.driver][led.g] = green; 162 g_pwm_buffer[led.driver][led.g] = green;
@@ -169,7 +172,9 @@ void IS31FL3737_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
169} 172}
170 173
171void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue) { 174void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue) {
172 is31_led led = g_is31_leds[index]; 175 // copy the led config from progmem to SRAM
176 is31_led led;
177 memcpy_P(&led, (&g_is31_leds[index]), sizeof(led));
173 178
174 uint8_t control_register_r = led.r / 8; 179 uint8_t control_register_r = led.r / 8;
175 uint8_t control_register_g = led.g / 8; 180 uint8_t control_register_g = led.g / 8;
diff --git a/keyboards/mt84/mt84.c b/keyboards/mt84/mt84.c
index d9f509e14..e15a1ff95 100644
--- a/keyboards/mt84/mt84.c
+++ b/keyboards/mt84/mt84.c
@@ -1,22 +1,22 @@
1 /* Copyright 2020 MT<704340378@qq.com> 1 /* Copyright 2020 MT<704340378@qq.com>
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or 5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version. 6 * (at your option) any later version.
7 * 7 *
8 * This program is distributed in the hope that it will be useful, 8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License 13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16#include "mt84.h" 16#include "mt84.h"
17 17
18#ifdef RGB_MATRIX_ENABLE 18#ifdef RGB_MATRIX_ENABLE
19const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { 19const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
20 /* Refer to IS31 manual for these locations 20 /* Refer to IS31 manual for these locations
21 * driver 21 * driver
22 * | R location 22 * | R location
@@ -40,7 +40,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
40 {1, D_12, E_12, F_12}, 40 {1, D_12, E_12, F_12},
41 {1, G_12, H_12, I_12}, 41 {1, G_12, H_12, I_12},
42 {1, J_12, K_12, L_12}, 42 {1, J_12, K_12, L_12},
43 43
44 {0, A_1, B_1, C_1}, 44 {0, A_1, B_1, C_1},
45 {0, D_1, E_1, F_1}, 45 {0, D_1, E_1, F_1},
46 {0, G_1, H_1, I_1}, 46 {0, G_1, H_1, I_1},
@@ -72,7 +72,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
72 {1, A_7, B_7, C_7}, 72 {1, A_7, B_7, C_7},
73 {1, D_7, E_7, F_7}, 73 {1, D_7, E_7, F_7},
74 {1, G_7, H_7, I_7}, 74 {1, G_7, H_7, I_7},
75 75
76 {0, A_3, B_3, C_3}, 76 {0, A_3, B_3, C_3},
77 {0, D_3, E_3, F_3}, 77 {0, D_3, E_3, F_3},
78 {0, G_3, H_3, I_3}, 78 {0, G_3, H_3, I_3},
@@ -87,7 +87,7 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
87 {1, J_3, K_3, L_3}, 87 {1, J_3, K_3, L_3},
88 {1, A_8, B_8, C_8}, 88 {1, A_8, B_8, C_8},
89 {1, G_8, H_8, I_8}, 89 {1, G_8, H_8, I_8},
90 90
91 {0, A_4, B_4, C_4}, 91 {0, A_4, B_4, C_4},
92 {0, D_4, E_4, F_4}, 92 {0, D_4, E_4, F_4},
93 {0, G_4, H_4, I_4}, 93 {0, G_4, H_4, I_4},
@@ -130,7 +130,7 @@ led_config_t g_led_config = {{
130 { 9, 52 }, { 27, 52 }, { 43, 52 }, { 59, 52 }, { 75, 52 }, { 91, 52 }, { 107, 52 }, { 123, 52 }, { 139, 52 }, { 155, 52 }, { 171, 52 }, { 187, 52 }, { 212, 52 }, { 224, 52 }, 130 { 9, 52 }, { 27, 52 }, { 43, 52 }, { 59, 52 }, { 75, 52 }, { 91, 52 }, { 107, 52 }, { 123, 52 }, { 139, 52 }, { 155, 52 }, { 171, 52 }, { 187, 52 }, { 212, 52 }, { 224, 52 },
131{ 2, 64 }, { 18, 64 }, { 33, 64 }, { 93, 64 }, { 150, 64 }, { 165, 64 }, { 180, 64 }, { 195, 64 }, { 210, 64 }, { 224, 64 } 131{ 2, 64 }, { 18, 64 }, { 33, 64 }, { 93, 64 }, { 150, 64 }, { 165, 64 }, { 180, 64 }, { 195, 64 }, { 210, 64 }, { 224, 64 }
132}, { 132}, {
133 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 133 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
134 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 134 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
135 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 135 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
136 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 136 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c
index 8c498a552..818dc6658 100644
--- a/keyboards/planck/ez/ez.c
+++ b/keyboards/planck/ez/ez.c
@@ -19,7 +19,7 @@
19 19
20keyboard_config_t keyboard_config; 20keyboard_config_t keyboard_config;
21#ifdef RGB_MATRIX_ENABLE 21#ifdef RGB_MATRIX_ENABLE
22const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { 22const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = {
23/* Refer to IS31 manual for these locations 23/* Refer to IS31 manual for these locations
24 * driver 24 * driver
25 * | R location 25 * | R location
diff --git a/tmk_core/common/progmem.h b/tmk_core/common/progmem.h
index 4e4771e52..3a7a16968 100644
--- a/tmk_core/common/progmem.h
+++ b/tmk_core/common/progmem.h
@@ -3,6 +3,7 @@
3#if defined(__AVR__) 3#if defined(__AVR__)
4# include <avr/pgmspace.h> 4# include <avr/pgmspace.h>
5#else 5#else
6# include <string.h>
6# define PROGMEM 7# define PROGMEM
7# define PSTR(x) x 8# define PSTR(x) x
8# define PGM_P const char* 9# define PGM_P const char*