Increase number of button GPIOs from 4 to 8

This commit is contained in:
Theo Arends 2021-02-05 12:27:59 +01:00
parent 8b0e45a58b
commit 6836455bbe
6 changed files with 23 additions and 17 deletions

View File

@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
## [9.2.0.6]
### Changed
- Increase number of switch GPIOs from 8 to 28
- Increase number of button GPIOs from 4 to 8
## [9.2.0.5] 20210205
### Changed

View File

@ -122,6 +122,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
- 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
- Increase number of button GPIOs from 4 to 8
### Fixed
- Redesign syslog and mqttlog using log buffer [#10164](https://github.com/arendst/Tasmota/issues/10164)

View File

@ -664,7 +664,7 @@ struct {
int ex_adc_param4; // FD8 Free since 9.0.0.1
uint32_t shutter_button[MAX_KEYS]; // FDC
uint32_t shutter_button[MAX_SHUTTER_KEYS]; // FDC
uint32_t i2c_drivers[3]; // FEC I2cDriver
uint32_t cfg_timestamp; // FF8
uint32_t cfg_crc32; // FFC

View File

@ -34,18 +34,20 @@ const char kMultiPress[] PROGMEM =
struct BUTTON {
uint32_t debounce = 0; // Button debounce timer
uint32_t no_pullup_mask = 0; // key no pullup flag (1 = no pullup)
uint32_t inverted_mask = 0; // Key inverted flag (1 = inverted)
#ifdef ESP32
uint32_t touch_mask = 0; // Touch flag (1 = inverted)
#endif // ESP32
uint16_t hold_timer[MAX_KEYS] = { 0 }; // Timer for button hold
uint16_t dual_code = 0; // Sonoff dual received code
uint8_t last_state[MAX_KEYS] = { NOT_PRESSED, NOT_PRESSED, NOT_PRESSED, NOT_PRESSED }; // Last button states
uint8_t last_state[MAX_KEYS]; // Last button states
uint8_t window_timer[MAX_KEYS] = { 0 }; // Max time between button presses to record press count
uint8_t press_counter[MAX_KEYS] = { 0 }; // Number of button presses within Button.window_timer
uint8_t dual_receive_count = 0; // Sonoff dual input flag
uint8_t no_pullup_mask = 0; // key no pullup flag (1 = no pullup)
uint8_t inverted_mask = 0; // Key inverted flag (1 = inverted)
#ifdef ESP32
uint8_t touch_mask = 0; // Touch flag (1 = inverted)
uint8_t touch_hits[MAX_KEYS] = { 0 }; // Hits in a row to filter out noise
#endif // ESP32
uint8_t present = 0; // Number of buttons found flag
@ -55,7 +57,7 @@ struct BUTTON {
struct TOUCH_BUTTON {
uint8_t pin_threshold = TOUCH_PIN_THRESHOLD;
uint8_t hit_threshold = TOUCH_HIT_THRESHOLD;
uint8_t calibration = 0; // Bitfield
uint32_t calibration = 0; // Bitfield
} TOUCH_BUTTON;
#endif // ESP32
@ -83,6 +85,7 @@ void ButtonInit(void) {
}
#endif // ESP8266
for (uint32_t i = 0; i < MAX_KEYS; i++) {
Button.last_state[i] = NOT_PRESSED;
if (PinUsed(GPIO_KEY1, i)) {
Button.present++;
#ifdef ESP8266

View File

@ -54,13 +54,12 @@ const uint8_t MAX_RELAYS = 8; // Max number of relays
#ifdef ESP32
const uint8_t MAX_RELAYS = 28; // Max number of relays
#endif // ESP32
const uint8_t MAX_KEYS = 8; // Max number of keys or buttons
// Changes to the following MAX_ defines will impact settings layout
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_SWITCHES = 28; // Max number of switches
const uint8_t MAX_LEDS = 4; // Max number of leds
const uint8_t MAX_KEYS = 4; // Max number of keys or buttons
const uint8_t MAX_PWMS = 5; // Max number of PWM channels
const uint8_t MAX_COUNTERS = 4; // Max number of counter sensors
const uint8_t MAX_TIMERS = 16; // Max number of Timers
@ -75,6 +74,8 @@ const uint8_t MAX_XDRV_DRIVERS = 96; // Max number of allowed driver driv
const uint8_t MAX_XSNS_DRIVERS = 96; // Max number of allowed sensor drivers
const uint8_t MAX_I2C_DRIVERS = 96; // Max number of allowed i2c drivers
const uint8_t MAX_SHUTTERS = 4; // Max number of shutters
const uint8_t MAX_SHUTTER_RELAYS = 8; // Max number of shutter relays
const uint8_t MAX_SHUTTER_KEYS = 4; // Max number of shutter keys or buttons
const uint8_t MAX_PCF8574 = 4; // Max number of PCF8574 devices
const uint8_t MAX_RULE_SETS = 3; // Max number of rule sets of size 512 characters
const uint16_t MAX_RULE_SIZE = 512; // Max number of characters in rules

View File

@ -673,7 +673,7 @@ void ShutterRelayChanged(void)
bool ShutterButtonIsSimultaneousHold(uint32_t button_index, uint32_t shutter_index) {
// check for simultaneous shutter button hold
uint32 min_shutterbutton_hold_timer = -1; // -1 == max(uint32)
for (uint32_t i = 0; i < MAX_KEYS; i++) {
for (uint32_t i = 0; i < MAX_SHUTTER_KEYS; i++) {
if ((button_index != i) && (Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) == shutter_index) && (Button.hold_timer[i] < min_shutterbutton_hold_timer))
min_shutterbutton_hold_timer = Button.hold_timer[i];
}
@ -722,7 +722,7 @@ void ShutterButtonHandler(void)
// check for simultaneous shutter button hold
if (ShutterButtonIsSimultaneousHold(button_index, shutter_index)) {
// simultaneous shutter button hold detected
for (uint32_t i = 0; i < MAX_KEYS; i++)
for (uint32_t i = 0; i < MAX_SHUTTER_KEYS; i++)
if ((Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) == shutter_index))
Button.press_counter[i] = 99; // Remember to discard further action for press & hold within button timings
press_index = 0;
@ -755,7 +755,7 @@ void ShutterButtonHandler(void)
if (Button.press_counter[button_index]<99) {
// check for simultaneous shutter button press
uint32 min_shutterbutton_press_counter = -1; // -1 == max(uint32)
for (uint32_t i = 0; i < MAX_KEYS; i++) {
for (uint32_t i = 0; i < MAX_SHUTTER_KEYS; i++) {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: ShutterButton[i] %ld, ShutterIndex %d, ButtonPressCounter[i] %d, minShutterButtonPressCounter %d, i %d"),
Settings.shutter_button[i], shutter_index, Button.press_counter[i] , min_shutterbutton_press_counter, i);
if ((button_index != i) && (Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) == shutter_index) && (i != button_index) && (Button.press_counter[i] < min_shutterbutton_press_counter)) {
@ -767,7 +767,7 @@ void ShutterButtonHandler(void)
// simultaneous shutter button press detected
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Simultanous press detected"));
press_index = Button.press_counter[button_index];
for (uint32_t i = 0; i < MAX_KEYS; i++)
for (uint32_t i = 0; i < MAX_SHUTTER_KEYS; i++)
if ((Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) != shutter_index))
Button.press_counter[i] = 99; // Remember to discard further action for press & hold within button timings
buttonState = SHT_PRESSED_MULTI_SIMULTANEOUS;
@ -787,7 +787,7 @@ void ShutterButtonHandler(void)
if ((!Settings.flag.button_restrict) && (((press_index>=5) && (press_index<=7)) || (buttonState == SHT_PRESSED_EXT_HOLD) || (buttonState == SHT_PRESSED_EXT_HOLD_SIMULTANEOUS))){
// check number of buttons for this shutter
uint8_t shutter_index_num_buttons = 0;
for (uint32_t i = 0; i < MAX_KEYS; i++) {
for (uint32_t i = 0; i < MAX_SHUTTER_KEYS; i++) {
if ((Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) == shutter_index)) {
shutter_index_num_buttons++;
}
@ -1292,7 +1292,7 @@ void CmndShutterButton(void)
if (button_index) {
if (button_index==-1) {
// remove all buttons for this shutter
for (uint32_t i=0 ; i < MAX_KEYS ; i++)
for (uint32_t i=0 ; i < MAX_SHUTTER_KEYS ; i++)
if ((Settings.shutter_button[i]&0x3) == (XdrvMailbox.index-1))
Settings.shutter_button[i] = 0;
} else {
@ -1305,8 +1305,8 @@ void CmndShutterButton(void)
}
}
}
char setting_chr[30*MAX_KEYS] = "-", *setting_chr_ptr = setting_chr;
for (uint32_t i=0 ; i < MAX_KEYS ; i++) {
char setting_chr[30*MAX_SHUTTER_KEYS] = "-", *setting_chr_ptr = setting_chr;
for (uint32_t i=0 ; i < MAX_SHUTTER_KEYS ; i++) {
setting = Settings.shutter_button[i];
if ((setting&(1<<31)) && ((setting&0x3) == (XdrvMailbox.index-1))) {
if (*setting_chr_ptr == 0)