Refactor ESP32 support

This commit is contained in:
Theo Arends 2020-06-24 15:58:56 +02:00
parent 7600a81c8e
commit ff327106be
3 changed files with 7 additions and 13 deletions

View File

@ -1265,11 +1265,7 @@ uint32_t ValidPin(uint32_t pin, uint32_t gpio)
bool ValidGPIO(uint32_t pin, uint32_t gpio)
{
#ifdef ESP8266
return (GPIO_USER == ValidPin(pin, gpio)); // Only allow GPIO_USER pins
#else // ESP32
return (GPIO_USER == ValidPin(pin, gpio >> 5)); // Only allow GPIO_USER pins
#endif // ESP8266 - ESP32
return (GPIO_USER == ValidPin(pin, BGPIO(gpio))); // Only allow GPIO_USER pins
}
#ifdef ESP8266

View File

@ -1113,10 +1113,8 @@ void CmndGpio(void)
}
}
char sindex[4] = { 0 };
#ifdef ESP8266
uint32_t sensor_name_idx = sensor_type;
#else // ESP32
uint32_t sensor_name_idx = sensor_type >> 5;
uint32_t sensor_name_idx = BGPIO(sensor_type);
#ifdef ESP32
uint32_t nice_list_search = sensor_type & 0xFFE0;
for (uint32_t j = 0; j < ARRAY_SIZE(kGpioNiceList); j++) {
uint32_t nls_idx = pgm_read_word(kGpioNiceList + j);
@ -1125,7 +1123,7 @@ void CmndGpio(void)
break;
}
}
#endif // ESP8266 - ESP32
#endif // ESP32
const char *sensor_names = kSensorNames;
if (sensor_name_idx > GPIO_FIX_START) {
sensor_name_idx = sensor_name_idx - GPIO_FIX_START -1;
@ -1156,7 +1154,7 @@ void CmndGpios(void)
uint32_t ridx = midx;
#else // ESP32
uint32_t ridx = pgm_read_word(kGpioNiceList + i) & 0xFFE0;
uint32_t midx = ridx >> 5;
uint32_t midx = BGPIO(ridx);
#endif // ESP8266 - ESP32
if ((XdrvMailbox.payload != 255) && GetUsedInModule(midx, cmodule.io)) { continue; }
if (!jsflg) {

View File

@ -1728,7 +1728,7 @@ void HandleTemplateConfiguration(void)
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE_NO_INDEX, AGPIO(GPIO_USER), D_SENSOR_USER); // }2'255'>User}3
}
uint32_t ridx = pgm_read_word(kGpioNiceList + i) & 0xFFE0;
uint32_t midx = ridx >> 5;
uint32_t midx = BGPIO(ridx);
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE_NO_INDEX, ridx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames));
#endif // ESP8266 - ESP32
}
@ -1905,7 +1905,7 @@ void HandleModuleConfiguration(void)
}
#else // ESP32
uint32_t ridx = pgm_read_word(kGpioNiceList + i) & 0xFFE0;
midx = ridx >> 5;
midx = BGPIO(ridx);
if (!GetUsedInModule(midx, cmodule.io)) {
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE_NO_INDEX, ridx, GetTextIndexed(stemp, sizeof(stemp), midx, kSensorNames));
}