mirror of
				https://github.com/mfulz/qmk_firmware.git
				synced 2025-10-31 05:12:33 +01:00 
			
		
		
		
	Enable g_is31_leds PROGMEM for RGB Matrix IS31FL3737 driver (#13480)
This commit is contained in:
		
							parent
							
								
									4706231831
								
							
						
					
					
						commit
						9c74fd14bc
					
				| @ -171,7 +171,7 @@ Currently only a single drivers is supported, but it would be trivial to support | |||||||
| Define these arrays listing all the LEDs in your `<keyboard>.c`: | Define these arrays listing all the LEDs in your `<keyboard>.c`: | ||||||
| 
 | 
 | ||||||
| ```c | ```c | ||||||
| const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { | const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = { | ||||||
| /* Refer to IS31 manual for these locations | /* Refer to IS31 manual for these locations | ||||||
|  *   driver |  *   driver | ||||||
|  *   |  R location |  *   |  R location | ||||||
|  | |||||||
| @ -19,6 +19,7 @@ | |||||||
| #include "is31fl3737.h" | #include "is31fl3737.h" | ||||||
| #include "i2c_master.h" | #include "i2c_master.h" | ||||||
| #include "wait.h" | #include "wait.h" | ||||||
|  | #include "progmem.h" | ||||||
| 
 | 
 | ||||||
| // This is a 7-bit address, that gets left-shifted and bit 0
 | // This is a 7-bit address, that gets left-shifted and bit 0
 | ||||||
| // set to 0 for write, 1 for read (as per I2C protocol)
 | // set to 0 for write, 1 for read (as per I2C protocol)
 | ||||||
| @ -153,7 +154,9 @@ void IS31FL3737_init(uint8_t addr) { | |||||||
| 
 | 
 | ||||||
| void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { | void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { | ||||||
|     if (index >= 0 && index < DRIVER_LED_TOTAL) { |     if (index >= 0 && index < DRIVER_LED_TOTAL) { | ||||||
|         is31_led led = g_is31_leds[index]; |         // copy the led config from progmem to SRAM
 | ||||||
|  |         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.r] = red; | ||||||
|         g_pwm_buffer[led.driver][led.g] = green; |         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) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue) { | void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue) { | ||||||
|     is31_led led = g_is31_leds[index]; |     // copy the led config from progmem to SRAM
 | ||||||
|  |     is31_led led; | ||||||
|  |     memcpy_P(&led, (&g_is31_leds[index]), sizeof(led)); | ||||||
| 
 | 
 | ||||||
|     uint8_t control_register_r = led.r / 8; |     uint8_t control_register_r = led.r / 8; | ||||||
|     uint8_t control_register_g = led.g / 8; |     uint8_t control_register_g = led.g / 8; | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ | |||||||
| #include "mt84.h" | #include "mt84.h" | ||||||
| 
 | 
 | ||||||
| #ifdef RGB_MATRIX_ENABLE | #ifdef RGB_MATRIX_ENABLE | ||||||
| const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { | const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = { | ||||||
|  /* Refer to IS31 manual for these locations
 |  /* Refer to IS31 manual for these locations
 | ||||||
|  *   driver |  *   driver | ||||||
|  *   |  R location |  *   |  R location | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ | |||||||
| 
 | 
 | ||||||
| keyboard_config_t keyboard_config; | keyboard_config_t keyboard_config; | ||||||
| #ifdef RGB_MATRIX_ENABLE | #ifdef RGB_MATRIX_ENABLE | ||||||
| const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { | const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL] = { | ||||||
| /* Refer to IS31 manual for these locations
 | /* Refer to IS31 manual for these locations
 | ||||||
|  *   driver |  *   driver | ||||||
|  *   |  R location |  *   |  R location | ||||||
|  | |||||||
| @ -3,6 +3,7 @@ | |||||||
| #if defined(__AVR__) | #if defined(__AVR__) | ||||||
| #    include <avr/pgmspace.h> | #    include <avr/pgmspace.h> | ||||||
| #else | #else | ||||||
|  | #    include <string.h> | ||||||
| #    define PROGMEM | #    define PROGMEM | ||||||
| #    define PSTR(x) x | #    define PSTR(x) x | ||||||
| #    define PGM_P const char* | #    define PGM_P const char* | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Chris Cullin
						Chris Cullin