️ Optimize Sensitive Pins array (except STM32) (#22080)

This commit is contained in:
Scott Lahteine
2021-06-08 19:55:27 -05:00
committed by GitHub
parent 7c5e3b9071
commit 77496c8235
7 changed files with 83 additions and 70 deletions

View File

@@ -282,8 +282,15 @@ bool wait_for_heatup = true;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnarrowing"
#ifdef RUNTIME_ONLY_ANALOG_TO_DIGITAL
static const pin_t sensitive_pins[] PROGMEM = { SENSITIVE_PINS };
#else
template <pin_t ...D>
constexpr pin_t OnlyPins<-2, D...>::table[sizeof...(D)];
#define sensitive_pins OnlyPins<SENSITIVE_PINS>::table
#endif
bool pin_is_protected(const pin_t pin) {
static const pin_t sensitive_pins[] PROGMEM = SENSITIVE_PINS;
LOOP_L_N(i, COUNT(sensitive_pins)) {
pin_t sensitive_pin;
memcpy_P(&sensitive_pin, &sensitive_pins[i], sizeof(pin_t));