From 6e9602418da3936f065e381cbf361ae020123f36 Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Thu, 28 Jun 2018 14:28:14 +0200 Subject: [PATCH] v6.0.0b - Support up to 8 switches 6.0.0b * Change number of switches from 4 to 8 (#2885, #3086) --- sonoff/_releasenotes.ino | 5 ++++- sonoff/settings.h | 7 +++++-- sonoff/settings.ino | 14 ++++++++++++++ sonoff/sonoff.h | 2 +- sonoff/sonoff.ino | 2 +- sonoff/sonoff_template.h | 6 +++++- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index dc1de954a..d14c2c7db 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,4 +1,7 @@ -/* 6.0.0a +/* 6.0.0b + * Change number of switches from 4 to 8 (#2885, #3086) + * + * 6.0.0a * Add support for APDS9960 proximity sensor (#3051) * Add increment and decrement value to command Counter (#2838) * Add option 0 to command Timers disarming all timers (#2962) diff --git a/sonoff/settings.h b/sonoff/settings.h index 31d139b44..6489b05c5 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -216,8 +216,9 @@ struct SYSCFG { uint16_t blinkcount; // 39C uint16_t light_rotation; // 39E - byte free_3A0[12]; // 3A9 + byte free_3A0[4]; // 3A0 + uint8_t switchmode[MAX_SWITCHES]; // 3A4 (6.0.0b - moved from 0x4CA) char friendlyname[MAX_FRIENDLYNAMES][33]; // 3AC char switch_topic[33]; // 430 char serial_delimiter; // 451 @@ -243,7 +244,9 @@ struct SYSCFG { uint16_t light_wakeup; // 4A6 byte knx_CB_registered; // 4A8 Number of Group Address to write char web_password[33]; // 4A9 - uint8_t switchmode[MAX_SWITCHES]; // 4CA + + uint8_t ex_switchmode[4]; // 4CA Free since 6.0.0a + char ntp_server[3][33]; // 4CE byte ina219_mode; // 531 uint16_t pulse_timer[MAX_PULSETIMERS]; // 532 diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 2b7803304..f472e2685 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -763,6 +763,20 @@ void SettingsDelta() Settings.cfg_size = sizeof(SYSCFG); Settings.cfg_crc = GetSettingsCrc(); } + if (Settings.version < 0x06000002) { + for (byte i = 0; i < MAX_SWITCHES; i++) { + if (i < 4) { + Settings.switchmode[i] = Settings.ex_switchmode[i]; + } else { + Settings.switchmode[i] = SWITCH_MODE; + } + } + for (byte i = 0; i < MAX_GPIO_PIN; i++) { + if (Settings.my_gp.io[i] >= GPIO_SWT5) { // Move up from GPIO_SWT5 to GPIO_KEY1 + Settings.my_gp.io[i] += 4; + } + } + } Settings.version = VERSION; SettingsSave(1); diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 3ad6ee096..1c1f24532 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -37,10 +37,10 @@ typedef unsigned long power_t; // Power (Relay) type \*********************************************************************************************/ // Changes to the following MAX_ defines will impact settings layout +#define MAX_SWITCHES 8 // Max number of switches #define MAX_RELAYS 8 // Max number of relays #define MAX_LEDS 4 // Max number of leds #define MAX_KEYS 4 // Max number of keys or buttons -#define MAX_SWITCHES 4 // Max number of switches #define MAX_PWMS 5 // Max number of PWM channels #define MAX_COUNTERS 4 // Max number of counter sensors #define MAX_TIMERS 16 // Max number of Timers diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index fd5e91275..344d64967 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -25,7 +25,7 @@ - Select IDE Tools - Flash Size: "1M (no SPIFFS)" ====================================================*/ -#define VERSION 0x06000001 // 6.0.0a +#define VERSION 0x06000002 // 6.0.0b // Location specific includes #include // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index f97c32203..b2907d079 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -35,6 +35,10 @@ enum UserSelectablePins { GPIO_SWT2, GPIO_SWT3, GPIO_SWT4, + GPIO_SWT5, + GPIO_SWT6, + GPIO_SWT7, + GPIO_SWT8, GPIO_KEY1, // Button usually connected to GPIO0 GPIO_KEY2, GPIO_KEY3, @@ -124,7 +128,7 @@ const char kSensorNames[] PROGMEM = D_SENSOR_I2C_SCL "|" D_SENSOR_I2C_SDA "|" D_SENSOR_WS2812 "|" D_SENSOR_IRSEND "|" - D_SENSOR_SWITCH "1|" D_SENSOR_SWITCH "2|" D_SENSOR_SWITCH "3|" D_SENSOR_SWITCH "4|" + D_SENSOR_SWITCH "1|" D_SENSOR_SWITCH "2|" D_SENSOR_SWITCH "3|" D_SENSOR_SWITCH "4|" D_SENSOR_SWITCH "5|" D_SENSOR_SWITCH "6|" D_SENSOR_SWITCH "7|" D_SENSOR_SWITCH "8|" D_SENSOR_BUTTON "1|" D_SENSOR_BUTTON "2|" D_SENSOR_BUTTON "3|" D_SENSOR_BUTTON "4|" D_SENSOR_RELAY "1|" D_SENSOR_RELAY "2|" D_SENSOR_RELAY "3|" D_SENSOR_RELAY "4|" D_SENSOR_RELAY "5|" D_SENSOR_RELAY "6|" D_SENSOR_RELAY "7|" D_SENSOR_RELAY "8|" D_SENSOR_RELAY "1i|" D_SENSOR_RELAY "2i|" D_SENSOR_RELAY "3i|" D_SENSOR_RELAY "4i|" D_SENSOR_RELAY "5i|" D_SENSOR_RELAY "6i|" D_SENSOR_RELAY "7i|" D_SENSOR_RELAY "8i|"