mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	[esp8266] Store GPIO initialization arrays in PROGMEM to save RAM
This commit is contained in:
		| @@ -58,8 +58,8 @@ extern "C" void resetPins() {  // NOLINT | |||||||
|  |  | ||||||
| #ifdef USE_ESP8266_EARLY_PIN_INIT | #ifdef USE_ESP8266_EARLY_PIN_INIT | ||||||
|   for (int i = 0; i < 16; i++) { |   for (int i = 0; i < 16; i++) { | ||||||
|     uint8_t mode = ESPHOME_ESP8266_GPIO_INITIAL_MODE[i]; |     uint8_t mode = pgm_read_byte(&ESPHOME_ESP8266_GPIO_INITIAL_MODE[i]); | ||||||
|     uint8_t level = ESPHOME_ESP8266_GPIO_INITIAL_LEVEL[i]; |     uint8_t level = pgm_read_byte(&ESPHOME_ESP8266_GPIO_INITIAL_LEVEL[i]); | ||||||
|     if (mode != 255) |     if (mode != 255) | ||||||
|       pinMode(i, mode);  // NOLINT |       pinMode(i, mode);  // NOLINT | ||||||
|     if (level != 255) |     if (level != 255) | ||||||
|   | |||||||
| @@ -3,9 +3,10 @@ | |||||||
| #ifdef USE_ESP8266 | #ifdef USE_ESP8266 | ||||||
|  |  | ||||||
| #include <cstdint> | #include <cstdint> | ||||||
|  | #include <pgmspace.h> | ||||||
|  |  | ||||||
| extern const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_MODE[16]; | extern const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_MODE[16] PROGMEM; | ||||||
| extern const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_LEVEL[16]; | extern const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_LEVEL[16] PROGMEM; | ||||||
|  |  | ||||||
| namespace esphome { | namespace esphome { | ||||||
| namespace esp8266 {}  // namespace esp8266 | namespace esp8266 {}  // namespace esp8266 | ||||||
|   | |||||||
| @@ -199,11 +199,11 @@ async def add_pin_initial_states_array(): | |||||||
|  |  | ||||||
|     cg.add_global( |     cg.add_global( | ||||||
|         cg.RawExpression( |         cg.RawExpression( | ||||||
|             f"const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_MODE[16] = {{{initial_modes_s}}}" |             f"const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_MODE[16] PROGMEM = {{{initial_modes_s}}}" | ||||||
|         ) |         ) | ||||||
|     ) |     ) | ||||||
|     cg.add_global( |     cg.add_global( | ||||||
|         cg.RawExpression( |         cg.RawExpression( | ||||||
|             f"const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_LEVEL[16] = {{{initial_levels_s}}}" |             f"const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_LEVEL[16] PROGMEM = {{{initial_levels_s}}}" | ||||||
|         ) |         ) | ||||||
|     ) |     ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user