Increase number of switch GPIOs from 8 to 28

This commit is contained in:
Theo Arends 2021-02-05 11:58:24 +01:00
parent 14a2c912ee
commit 8b0e45a58b
9 changed files with 36 additions and 18 deletions

View File

@ -3,7 +3,11 @@ All notable changes to this project will be documented in this file.
## [Unreleased] - Development
## [9.2.0.5]
## [9.2.0.6]
### Changed
- Increase number of switch GPIOs from 8 to 28
## [9.2.0.5] 20210205
### Changed
- ESP32 increase number of relay GPIOs from 8 to 28

View File

@ -56,7 +56,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
[Complete list](BUILDS.md) of available feature and sensors.
## Changelog v9.2.0.5
## Changelog v9.2.0.6
### Added
- Command ``CTRange`` to specify the visible CT range the bulb is capable of [#10311](https://github.com/arendst/Tasmota/issues/10311)
- Command ``L1MusicSync <0|Off>|<1|On>|<2|Toggle>, 1..10, 1..100>`` to control Sonoff L1 Music Sync mode sensitivity and speed [#10722](https://github.com/arendst/Tasmota/issues/10722)
@ -121,6 +121,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
- PubSubClient MQTT_SOCKET_TIMEOUT from 15 to 4 seconds
- Domoticz fixed 2 decimals resolution by user selectable ``TempRes``, ``HumRes`` and ``PressRes`` resolutions
- ESP32 increase number of relay GPIOs from 8 to 28
- Increase number of switch GPIOs from 8 to 28
### Fixed
- Redesign syslog and mqttlog using log buffer [#10164](https://github.com/arendst/Tasmota/issues/10164)

View File

@ -433,7 +433,9 @@ struct {
uint16_t blinkcount; // 39C
uint16_t light_rotation; // 39E
SysBitfield3 flag3; // 3A0
uint8_t switchmode[MAX_SWITCHES]; // 3A4
uint8_t ex_switchmode[8]; // 3A4 - Free since 9.2.0.6
myio my_gp; // 3AC 2 x 18 bytes (ESP8266) / 2 x 40 bytes (ESP32)
#ifdef ESP8266
uint16_t gpio16_converted; // 3D0
@ -487,8 +489,9 @@ struct {
uint8_t knx_GA_registered; // 4A5 Number of Group Address to read
uint16_t light_wakeup; // 4A6
uint8_t knx_CB_registered; // 4A8 Number of Group Address to write
uint8_t switchmode[MAX_SWITCHES]; // 4A9
char ex_web_password[33]; // 4A9 Free since 8.0.0.1
uint8_t free_4c5[5]; // 4C5
uint8_t interlock[MAX_INTERLOCKS]; // 4CA

View File

@ -1194,7 +1194,7 @@ void SettingsDelta(void) {
SettingsUpdateText(SET_MQTT_BUTTON_TOPIC, temp12);
SettingsUpdateText(SET_MQTT_GRP_TOPIC, temp13);
SettingsUpdateText(SET_WEBPWD, Settings.ex_web_password);
// SettingsUpdateText(SET_WEBPWD, Settings.ex_web_password);
SettingsUpdateText(SET_CORS, Settings.ex_cors_domain);
SettingsUpdateText(SET_MQTT_FULLTOPIC, Settings.ex_mqtt_fulltopic);
// SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, Settings.ex_switch_topic);
@ -1334,6 +1334,11 @@ void SettingsDelta(void) {
if (Settings.version < 0x09020003) {
Settings.flag3.use_wifi_rescan = true; // As a result of #10395
}
if (Settings.version < 0x09020006) {
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
Settings.switchmode[i] = (i < 8) ? Settings.ex_switchmode[i] : SWITCH_MODE;
}
}
Settings.version = VERSION;
SettingsSave(1);

View File

@ -1651,9 +1651,9 @@ void CmndFriendlyname(void)
}
void CmndSwitchText(void) {
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_SWITCHES)) {
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_SWITCHES_TXT)) {
if (!XdrvMailbox.usridx && !XdrvMailbox.data_len) {
ResponseCmndAll(SET_SWITCH_TXT1, MAX_SWITCHES);
ResponseCmndAll(SET_SWITCH_TXT1, MAX_SWITCHES_TXT);
} else {
if (XdrvMailbox.data_len > 0) {
RemoveSpace(XdrvMailbox.data);

View File

@ -45,7 +45,7 @@ Ticker TickerSwitch;
struct SWITCH {
uint32_t debounce = 0; // Switch debounce timer
uint16_t no_pullup_mask = 0; // Switch pull-up bitmask flags
uint32_t no_pullup_mask = 0; // Switch pull-up bitmask flags
uint8_t state[MAX_SWITCHES] = { 0 };
uint8_t last_state[MAX_SWITCHES]; // Last wall switch states
uint8_t hold_timer[MAX_SWITCHES] = { 0 }; // Timer for wallswitch push button hold
@ -230,19 +230,20 @@ void SwitchHandler(uint32_t mode) {
uint32_t button = Switch.virtual_state[i];
uint32_t switchflag = POWER_TOGGLE +1;
uint32_t mqtt_action = POWER_NONE;
uint32_t switchmode = Settings.switchmode[i];
if (Switch.hold_timer[i] & (((Settings.switchmode[i] == PUSHHOLDMULTI) | (Settings.switchmode[i] == PUSHHOLDMULTI_INV)) ? SM_TIMER_MASK: SM_NO_TIMER_MASK)) {
if (Switch.hold_timer[i] & (((switchmode == PUSHHOLDMULTI) | (switchmode == PUSHHOLDMULTI_INV)) ? SM_TIMER_MASK: SM_NO_TIMER_MASK)) {
Switch.hold_timer[i]--;
if ((Switch.hold_timer[i] & SM_TIMER_MASK) == loops_per_second * Settings.param[P_HOLD_TIME] / 25) {
if ((Settings.switchmode[i] == PUSHHOLDMULTI) & (NOT_PRESSED == Switch.last_state[i])) {
if ((switchmode == PUSHHOLDMULTI) & (NOT_PRESSED == Switch.last_state[i])) {
SendKey(KEY_SWITCH, i +1, POWER_INCREMENT); // Execute command via MQTT
}
if ((Settings.switchmode[i] == PUSHHOLDMULTI_INV) & (PRESSED == Switch.last_state[i])) {
if ((switchmode == PUSHHOLDMULTI_INV) & (PRESSED == Switch.last_state[i])) {
SendKey(KEY_SWITCH, i +1, POWER_INCREMENT); // Execute command via MQTT
}
}
if (0 == (Switch.hold_timer[i] & (((Settings.switchmode[i] == PUSHHOLDMULTI) | (Settings.switchmode[i] == PUSHHOLDMULTI_INV)) ? SM_TIMER_MASK: SM_NO_TIMER_MASK))) {
switch (Settings.switchmode[i]) {
if (0 == (Switch.hold_timer[i] & (((switchmode == PUSHHOLDMULTI) | (switchmode == PUSHHOLDMULTI_INV)) ? SM_TIMER_MASK: SM_NO_TIMER_MASK))) {
switch (switchmode) {
case TOGGLEMULTI:
switchflag = POWER_TOGGLE; // Toggle after hold
break;
@ -284,7 +285,7 @@ void SwitchHandler(uint32_t mode) {
}
if (button != Switch.last_state[i]) { // This implies if ((PRESSED == button) then (NOT_PRESSED == Switch.last_state[i]))
switch (Settings.switchmode[i]) {
switch (switchmode) {
case TOGGLE:
case PUSHBUTTON_TOGGLE:
switchflag = POWER_TOGGLE; // Toggle

View File

@ -743,7 +743,10 @@ void TempHumDewShow(bool json, bool pass_on, const char *types, float f_temperat
}
String GetSwitchText(uint32_t i) {
String switch_text = SettingsText(SET_SWITCH_TXT1 + i);
String switch_text = "";
if (i < MAX_SWITCHES_TXT) {
switch_text = SettingsText(SET_SWITCH_TXT1 + i);
}
if ('\0' == switch_text[0]) {
switch_text = F(D_JSON_SWITCH);
switch_text += String(i+1);

View File

@ -56,7 +56,7 @@ const uint8_t MAX_RELAYS = 28; // Max number of relays
#endif // ESP32
// Changes to the following MAX_ defines will impact settings layout
const uint8_t MAX_SWITCHES = 8; // Max number of switches
const uint8_t MAX_SWITCHES = 28; // Max number of switches
const uint8_t MAX_SHUTTER_RELAYS = 8; // Max number of shutter relays
const uint8_t MAX_INTERLOCKS = 4; // Max number of interlock groups (MAX_RELAYS / 2)
const uint8_t MAX_LEDS = 4; // Max number of leds
@ -95,6 +95,7 @@ const uint8_t MAX_ADCS = 1; // Max number of ESP8266 ADC pins
#ifdef ESP32
const uint8_t MAX_ADCS = 8; // Max number of ESP32 ADC pins (ADC2 pins are unusable with Wifi enabled)
#endif // ESP32
const uint8_t MAX_SWITCHES_TXT = 8; // Max number of switches user text
const uint8_t MAX_HUE_DEVICES = 15; // Max number of Philips Hue device per emulation
const uint8_t MAX_ROTARIES = 2; // Max number of Rotary Encoders
@ -318,7 +319,7 @@ enum SettingsTextIndex { SET_OTAURL,
#ifdef ESP32
SET_ADC_PARAM1, SET_ADC_PARAM2, SET_ADC_PARAM3, SET_ADC_PARAM4, SET_ADC_PARAM5, SET_ADC_PARAM6, SET_ADC_PARAM7, SET_ADC_PARAM8, // MAX_ADCS
#endif // ESP32
SET_SWITCH_TXT1, SET_SWITCH_TXT2, SET_SWITCH_TXT3, SET_SWITCH_TXT4, SET_SWITCH_TXT5, SET_SWITCH_TXT6, SET_SWITCH_TXT7, SET_SWITCH_TXT8, // MAX_SWITCHES
SET_SWITCH_TXT1, SET_SWITCH_TXT2, SET_SWITCH_TXT3, SET_SWITCH_TXT4, SET_SWITCH_TXT5, SET_SWITCH_TXT6, SET_SWITCH_TXT7, SET_SWITCH_TXT8, // MAX_SWITCHES_TXT
SET_SHD_PARAM,
SET_MAX };

View File

@ -20,6 +20,6 @@
#ifndef _TASMOTA_VERSION_H_
#define _TASMOTA_VERSION_H_
const uint32_t VERSION = 0x09020005;
const uint32_t VERSION = 0x09020006;
#endif // _TASMOTA_VERSION_H_