ESP8266 increase number of discovery relays

This commit is contained in:
Theo Arends 2023-02-09 16:02:06 +01:00
parent 134c839244
commit 5d3f2cc316
3 changed files with 17 additions and 15 deletions

View File

@ -45,22 +45,24 @@ const uint32_t POWER_SIZE = 32; // Power (relay) bit count
* Constants * Constants
\*********************************************************************************************/ \*********************************************************************************************/
// Why 28? Because in addition to relays there may be lights and uint32_t bitmap can hold up to 32 devices
#ifdef ESP8266 #ifdef ESP8266
const uint8_t MAX_RELAYS = 8; // Max number of relays (up to 28) const uint8_t MAX_RELAYS = 8; // Max number of relays selectable on GPIO
const uint8_t MAX_INTERLOCKS = 4; // Max number of interlock groups (up to MAX_INTERLOCKS_SET) const uint8_t MAX_INTERLOCKS = 4; // Max number of interlock groups (up to MAX_INTERLOCKS_SET)
const uint8_t MAX_SWITCHES = 8; // Max number of switches (up to MAX_SWITCHES_SET) const uint8_t MAX_SWITCHES = 8; // Max number of switches selectable on GPIO
const uint8_t MAX_KEYS = 8; // Max number of keys or buttons (up to 28) const uint8_t MAX_KEYS = 8; // Max number of keys or buttons selectable on GPIO
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
const uint8_t MAX_RELAYS = 28; // Max number of relays (up to 28) const uint8_t MAX_RELAYS = 28; // Max number of relays selectable on GPIO
const uint8_t MAX_INTERLOCKS = 14; // Max number of interlock groups (up to MAX_INTERLOCKS_SET) const uint8_t MAX_INTERLOCKS = 14; // Max number of interlock groups (up to MAX_INTERLOCKS_SET)
const uint8_t MAX_SWITCHES = 28; // Max number of switches (up to MAX_SWITCHES_SET) const uint8_t MAX_SWITCHES = 28; // Max number of switches selectable on GPIO
const uint8_t MAX_KEYS = 28; // Max number of keys or buttons (up to 28) const uint8_t MAX_KEYS = 28; // Max number of keys or buttons selectable on GPIO
#endif // ESP32 #endif // ESP32
const uint8_t MAX_RELAYS_SET = 28; // Max number of relays
const uint8_t MAX_KEYS_SET = 28; // Max number of keys const uint8_t MAX_KEYS_SET = 28; // Max number of keys
// Changes to the following MAX_ defines will impact settings layout // Changes to the following MAX_ defines will impact settings layout
const uint8_t MAX_INTERLOCKS_SET = 14; // Max number of interlock groups (MAX_RELAYS / 2) const uint8_t MAX_INTERLOCKS_SET = 14; // Max number of interlock groups (MAX_RELAYS_SET / 2)
const uint8_t MAX_SWITCHES_SET = 28; // Max number of switches const uint8_t MAX_SWITCHES_SET = 28; // Max number of switches
const uint8_t MAX_LEDS = 4; // Max number of leds const uint8_t MAX_LEDS = 4; // Max number of leds
const uint8_t MAX_PWMS_LEGACY = 5; // Max number of PWM channels in first settings block - Legacy limit for ESP8266, but extended for ESP32 (see below) const uint8_t MAX_PWMS_LEGACY = 5; // Max number of PWM channels in first settings block - Legacy limit for ESP8266, but extended for ESP32 (see below)

View File

@ -88,7 +88,7 @@ void TasDiscoverMessage(void) {
SettingsText(SET_MQTTPREFIX2), SettingsText(SET_MQTTPREFIX2),
SettingsText(SET_MQTTPREFIX3)); SettingsText(SET_MQTTPREFIX3));
uint8_t light_idx = MAX_RELAYS + 1; // Will store the starting position of the lights uint8_t light_idx = MAX_RELAYS_SET + 1; // Will store the starting position of the lights
uint8_t light_subtype = 0; uint8_t light_subtype = 0;
bool light_controller_isCTRGBLinked = false; bool light_controller_isCTRGBLinked = false;
#ifdef USE_LIGHT #ifdef USE_LIGHT
@ -107,9 +107,9 @@ void TasDiscoverMessage(void) {
} }
#endif // USE_LIGHT #endif // USE_LIGHT
uint16_t Relay[MAX_RELAYS] = { 0 }; // Base array to store the relay type uint16_t Relay[MAX_RELAYS_SET] = { 0 }; // Base array to store the relay type
uint16_t Shutter[MAX_RELAYS] = { 0 }; // Array to store a temp list for shutters uint16_t Shutter[MAX_RELAYS_SET] = { 0 }; // Array to store a temp list for shutters
for (uint32_t i = 0; i < MAX_RELAYS; i++) { for (uint32_t i = 0; i < MAX_RELAYS_SET; i++) {
if (i < TasmotaGlobal.devices_present) { if (i < TasmotaGlobal.devices_present) {
#ifdef USE_SHUTTER #ifdef USE_SHUTTER

View File

@ -282,7 +282,7 @@ void HassDiscoverMessage(void) {
SettingsText(SET_MQTTPREFIX2), SettingsText(SET_MQTTPREFIX2),
SettingsText(SET_MQTTPREFIX3)); SettingsText(SET_MQTTPREFIX3));
uint8_t light_idx = MAX_RELAYS + 1; // Will store the starting position of the lights uint8_t light_idx = MAX_RELAYS_SET + 1; // Will store the starting position of the lights
uint8_t light_subtype = 0; uint8_t light_subtype = 0;
bool light_controller_isCTRGBLinked = false; bool light_controller_isCTRGBLinked = false;
#ifdef USE_LIGHT #ifdef USE_LIGHT
@ -301,9 +301,9 @@ void HassDiscoverMessage(void) {
} }
#endif // USE_LIGHT #endif // USE_LIGHT
uint16_t Relay[MAX_RELAYS] = { 0 }; // Base array to store the relay type uint16_t Relay[MAX_RELAYS_SET] = { 0 }; // Base array to store the relay type
uint16_t Shutter[MAX_RELAYS] = { 0 }; // Array to store a temp list for shutters uint16_t Shutter[MAX_RELAYS_SET] = { 0 }; // Array to store a temp list for shutters
for (uint32_t i = 0; i < MAX_RELAYS; i++) { for (uint32_t i = 0; i < MAX_RELAYS_SET; i++) {
if (i < TasmotaGlobal.devices_present) { if (i < TasmotaGlobal.devices_present) {
#ifdef USE_SHUTTER #ifdef USE_SHUTTER