Prep drivers for management

Prep drivers for management
This commit is contained in:
Theo Arends 2018-11-07 10:30:03 +01:00
parent f14491afb6
commit 9fef82736d
20 changed files with 54 additions and 50 deletions

View File

@ -67,7 +67,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t user_esp8285_enable : 1; // bit 1 (v6.1.1.14) uint32_t user_esp8285_enable : 1; // bit 1 (v6.1.1.14)
uint32_t time_append_timezone : 1; // bit 2 (v6.2.1.2) uint32_t time_append_timezone : 1; // bit 2 (v6.2.1.2)
uint32_t gui_hostname_ip : 1; // bit 3 (v6.2.1.20) uint32_t gui_hostname_ip : 1; // bit 3 (v6.2.1.20)
uint32_t tuya_apply_o20 : 1; uint32_t tuya_apply_o20 : 1; // bit 4 (v6.3.0.4)
uint32_t spare05 : 1; uint32_t spare05 : 1;
uint32_t spare06 : 1; uint32_t spare06 : 1;
uint32_t spare07 : 1; uint32_t spare07 : 1;
@ -320,12 +320,12 @@ struct SYSCFG {
uint16_t mcp230xx_int_timer; // 718 uint16_t mcp230xx_int_timer; // 718
uint8_t rgbwwTable[5]; // 71A uint8_t rgbwwTable[5]; // 71A
byte free_71F[109]; // 71F byte free_71F[117]; // 71F
uint32_t monitors; // 78C uint32_t drivers[3]; // 794
uint32_t displays; // 790 uint32_t monitors; // 7A0
uint32_t drivers[4]; // 794 uint32_t sensors[3]; // 7A4
uint32_t sensors[4]; // 7A4 uint32_t displays; // 7B0
uint32_t energy_kWhtotal_time; // 7B4 uint32_t energy_kWhtotal_time; // 7B4
unsigned long weight_item; // 7B8 Weight of one item in gram * 10 unsigned long weight_item; // 7B8 Weight of one item in gram * 10

View File

@ -636,7 +636,7 @@ void SettingsDefaultSet2()
Settings.rgbwwTable[j] = 255; Settings.rgbwwTable[j] = 255;
} }
memset(&Settings.monitors, 0xFF, 40); // Enable all possible monitors, displays, drivers and sensors memset(&Settings.drivers, 0xFF, 32); // Enable all possible monitors, displays, drivers and sensors
} }
/********************************************************************************************/ /********************************************************************************************/
@ -849,7 +849,7 @@ void SettingsDelta()
Settings.timezone_minutes = 0; Settings.timezone_minutes = 0;
} }
if (Settings.version < 0x06030004) { if (Settings.version < 0x06030004) {
memset(&Settings.monitors, 0xFF, 40); // Enable all possible monitors, displays, drivers and sensors memset(&Settings.drivers, 0xFF, 32); // Enable all possible monitors, displays, drivers and sensors
} }
Settings.version = VERSION; Settings.version = VERSION;

View File

@ -52,8 +52,8 @@ typedef unsigned long power_t; // Power (Relay) type
#define MAX_KNX_CB 10 // Max number of KNX Group Addresses to write that can be set #define MAX_KNX_CB 10 // Max number of KNX Group Addresses to write that can be set
#define MAX_XNRG_DRIVERS 32 // Max number of allowed energy drivers #define MAX_XNRG_DRIVERS 32 // Max number of allowed energy drivers
#define MAX_XDSP_DRIVERS 32 // Max number of allowed display drivers #define MAX_XDSP_DRIVERS 32 // Max number of allowed display drivers
#define MAX_XDRV_DRIVERS 100 // Max number of allowed driver drivers #define MAX_XDRV_DRIVERS 96 // Max number of allowed driver drivers
#define MAX_XSNS_DRIVERS 100 // Max number of allowed sensor drivers #define MAX_XSNS_DRIVERS 96 // Max number of allowed sensor drivers
#define MAX_RULE_MEMS 5 // Max number of saved vars #define MAX_RULE_MEMS 5 // Max number of saved vars
#define MAX_RULE_SETS 3 // Max number of rule sets of size 512 characters #define MAX_RULE_SETS 3 // Max number of rule sets of size 512 characters
#define MAX_RULE_SIZE 512 // Max number of characters in rules #define MAX_RULE_SIZE 512 // Max number of characters in rules

View File

@ -25,6 +25,8 @@
* Based on source by AlexT (https://github.com/tzapu) * Based on source by AlexT (https://github.com/tzapu)
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_01 1
#define HTTP_REFRESH_TIME 2345 // milliseconds #define HTTP_REFRESH_TIME 2345 // milliseconds
#ifdef USE_RF_FLASH #ifdef USE_RF_FLASH
@ -2009,8 +2011,6 @@ bool WebCommand()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_01
boolean Xdrv01(byte function) boolean Xdrv01(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -17,6 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#define XDRV_02 2
/*********************************************************************************************\ /*********************************************************************************************\
* Select ONE of possible MQTT library types below * Select ONE of possible MQTT library types below
\*********************************************************************************************/ \*********************************************************************************************/
@ -909,8 +911,6 @@ void MqttSaveSettings()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_02
boolean Xdrv02(byte function) boolean Xdrv02(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -51,6 +51,8 @@
* *
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_04 4
#define WS2812_SCHEMES 7 // Number of additional WS2812 schemes supported by xdrv_ws2812.ino #define WS2812_SCHEMES 7 // Number of additional WS2812 schemes supported by xdrv_ws2812.ino
enum LightCommands { enum LightCommands {
@ -1369,8 +1371,6 @@ boolean LightCommand()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_04
boolean Xdrv04(byte function) boolean Xdrv04(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -22,6 +22,8 @@
* IR Remote send and receive using IRremoteESP8266 library * IR Remote send and receive using IRremoteESP8266 library
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_05 5
#include <IRremoteESP8266.h> #include <IRremoteESP8266.h>
// Based on IRremoteESP8266.h enum decode_type_t // Based on IRremoteESP8266.h enum decode_type_t
@ -401,8 +403,6 @@ boolean IrSendCommand()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_05
boolean Xdrv05(byte function) boolean Xdrv05(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -21,6 +21,8 @@
Sonoff RF Bridge 433 Sonoff RF Bridge 433
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_06 6
#define SFB_TIME_AVOID_DUPLICATE 2000 // Milliseconds #define SFB_TIME_AVOID_DUPLICATE 2000 // Milliseconds
enum SonoffBridgeCommands { enum SonoffBridgeCommands {
@ -564,8 +566,6 @@ void SonoffBridgeInit()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_06
boolean Xdrv06(byte function) boolean Xdrv06(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -19,6 +19,8 @@
#ifdef USE_DOMOTICZ #ifdef USE_DOMOTICZ
#define XDRV_07 7
const char DOMOTICZ_MESSAGE[] PROGMEM = "{\"idx\":%d,\"nvalue\":%d,\"svalue\":\"%s\",\"Battery\":%d,\"RSSI\":%d}"; const char DOMOTICZ_MESSAGE[] PROGMEM = "{\"idx\":%d,\"nvalue\":%d,\"svalue\":\"%s\",\"Battery\":%d,\"RSSI\":%d}";
enum DomoticzCommands { CMND_IDX, CMND_KEYIDX, CMND_SWITCHIDX, CMND_SENSORIDX, CMND_UPDATETIMER }; enum DomoticzCommands { CMND_IDX, CMND_KEYIDX, CMND_SWITCHIDX, CMND_SENSORIDX, CMND_UPDATETIMER };
@ -475,8 +477,6 @@ void DomoticzSaveSettings()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_07
boolean Xdrv07(byte function) boolean Xdrv07(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -21,6 +21,9 @@
/*********************************************************************************************\ /*********************************************************************************************\
* Serial Bridge using Software Serial library (TasmotaSerial) * Serial Bridge using Software Serial library (TasmotaSerial)
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_08 8
#define SERIAL_BRIDGE_BUFFER_SIZE 130 #define SERIAL_BRIDGE_BUFFER_SIZE 130
#include <TasmotaSerial.h> #include <TasmotaSerial.h>
@ -127,8 +130,6 @@ boolean SerialBridgeCommand()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_08
boolean Xdrv08(byte function) boolean Xdrv08(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -35,6 +35,8 @@
* *
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_09 9
enum TimerCommands { CMND_TIMER, CMND_TIMERS enum TimerCommands { CMND_TIMER, CMND_TIMERS
#ifdef USE_SUNRISE #ifdef USE_SUNRISE
, CMND_LATITUDE, CMND_LONGITUDE , CMND_LATITUDE, CMND_LONGITUDE
@ -743,8 +745,6 @@ void TimerSaveSettings()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_09
boolean Xdrv09(byte function) boolean Xdrv09(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -63,6 +63,8 @@
* RuleTimer2 100 * RuleTimer2 100
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_10 10
#define D_CMND_RULE "Rule" #define D_CMND_RULE "Rule"
#define D_CMND_RULETIMER "RuleTimer" #define D_CMND_RULETIMER "RuleTimer"
#define D_CMND_EVENT "Event" #define D_CMND_EVENT "Event"
@ -640,8 +642,6 @@ double map_double(double x, double in_min, double in_max, double out_min, double
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_10
boolean Xdrv10(byte function) boolean Xdrv10(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -48,6 +48,8 @@ byte Settings.knx_CB_param[MAX_KNX_CB] Type of Output (set relay, t
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_11 11
#include <esp-knx-ip.h> // KNX Library #include <esp-knx-ip.h> // KNX Library
address_t KNX_physs_addr; // Physical KNX address of this device address_t KNX_physs_addr; // Physical KNX address of this device
@ -1278,8 +1280,6 @@ boolean KnxCommand()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_11
boolean Xdrv11(byte function) boolean Xdrv11(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -19,6 +19,8 @@
#ifdef USE_HOME_ASSISTANT #ifdef USE_HOME_ASSISTANT
#define XDRV_12 12
const char HASS_DISCOVER_RELAY[] PROGMEM = const char HASS_DISCOVER_RELAY[] PROGMEM =
"{\"name\":\"%s\"," // dualr2 1 "{\"name\":\"%s\"," // dualr2 1
"\"command_topic\":\"%s\"," // cmnd/dualr2/POWER2 "\"command_topic\":\"%s\"," // cmnd/dualr2/POWER2
@ -255,8 +257,6 @@ boolean HassCommand()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_12
boolean Xdrv12(byte function) boolean Xdrv12(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -20,6 +20,8 @@
#if defined(USE_I2C) || defined(USE_SPI) #if defined(USE_I2C) || defined(USE_SPI)
#ifdef USE_DISPLAY #ifdef USE_DISPLAY
#define XDRV_13 13
#define DISPLAY_MAX_DRIVERS 16 // Max number of display drivers/models supported by xdsp_interface.ino #define DISPLAY_MAX_DRIVERS 16 // Max number of display drivers/models supported by xdsp_interface.ino
#define DISPLAY_MAX_COLS 40 // Max number of columns allowed with command DisplayCols #define DISPLAY_MAX_COLS 40 // Max number of columns allowed with command DisplayCols
#define DISPLAY_MAX_ROWS 32 // Max number of lines allowed with command DisplayRows #define DISPLAY_MAX_ROWS 32 // Max number of lines allowed with command DisplayRows
@ -1060,8 +1062,6 @@ boolean DisplayCommand()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_13
boolean Xdrv13(byte function) boolean Xdrv13(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -67,6 +67,8 @@
* https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299 * https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_14 14
#include <TasmotaSerial.h> #include <TasmotaSerial.h>
TasmotaSerial *MP3Player; TasmotaSerial *MP3Player;
@ -224,8 +226,6 @@ boolean MP3PlayerCmd(void) {
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_14
boolean Xdrv14(byte function) boolean Xdrv14(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -19,6 +19,8 @@
#ifdef USE_TUYA_DIMMER #ifdef USE_TUYA_DIMMER
#define XDRV_16 16
#ifndef TUYA_DIMMER_ID #ifndef TUYA_DIMMER_ID
#define TUYA_DIMMER_ID 0 #define TUYA_DIMMER_ID 0
#endif #endif
@ -137,7 +139,7 @@ void LightSerialDuty(uint8_t duty)
if (duty < 25) { if (duty < 25) {
duty = 25; // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself duty = 25; // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself
} }
TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty); TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty);
snprintf_P(log_data, sizeof(log_data), PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]); snprintf_P(log_data, sizeof(log_data), PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]);
@ -177,7 +179,7 @@ void TuyaPacketProcess()
switch(tuya_buffer[3]) { switch(tuya_buffer[3]) {
case TUYA_CMD_HEARTBEAT: case TUYA_CMD_HEARTBEAT:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Heartbeat")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Heartbeat"));
if(tuya_buffer[6] == 0){ if(tuya_buffer[6] == 0){
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Detected MCU restart")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Detected MCU restart"));
@ -386,8 +388,6 @@ void TuyaSetWifiLed(){
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_16
boolean Xdrv16(byte function) boolean Xdrv16(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -22,6 +22,8 @@
* RF send and receive using RCSwitch library https://github.com/sui77/rc-switch/ * RF send and receive using RCSwitch library https://github.com/sui77/rc-switch/
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_17 17
#define D_JSON_RF_PROTOCOL "Protocol" #define D_JSON_RF_PROTOCOL "Protocol"
#define D_JSON_RF_BITS "Bits" #define D_JSON_RF_BITS "Bits"
#define D_JSON_RF_DATA "Data" #define D_JSON_RF_DATA "Data"
@ -164,8 +166,6 @@ boolean RfSendCommand()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_17
boolean Xdrv17(byte function) boolean Xdrv17(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -1,5 +1,5 @@
/* /*
xdrv_99_debug.ino - debug support for Sonoff-Tasmota xdrv_95_debug.ino - debug support for Sonoff-Tasmota
Copyright (C) 2018 Theo Arends Copyright (C) 2018 Theo Arends
@ -26,9 +26,14 @@
#endif // DEBUG_THEO #endif // DEBUG_THEO
#ifdef USE_DEBUG_DRIVER #ifdef USE_DEBUG_DRIVER
/*********************************************************************************************\
* Virtual debugging support
\*********************************************************************************************/
#define XDRV_95 95
#ifndef CPU_LOAD_CHECK #ifndef CPU_LOAD_CHECK
#define CPU_LOAD_CHECK 1 // Seconds between each CPU_LOAD log #define CPU_LOAD_CHECK 1 // Seconds between each CPU_LOAD log
#endif #endif
/*********************************************************************************************\ /*********************************************************************************************\
@ -473,9 +478,7 @@ boolean DebugCommand()
* Interface * Interface
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_99 boolean Xdrv95(byte function)
boolean Xdrv99(byte function)
{ {
boolean result = false; boolean result = false;

View File

@ -530,12 +530,12 @@ String XsnsGetSensors()
String data = F("["); String data = F("[");
for (byte i = 0; i < MAX_XSNS_DRIVERS; i++) { for (byte i = 0; i < MAX_XSNS_DRIVERS; i++) {
if (i && (!(i % 10))) { data += F(","); } if (i && (!(i % 16))) { data += F(","); }
if (!(i % 10)) { data += F("\""); } if (!(i % 16)) { data += F("\""); }
state[0] = '-'; state[0] = '-';
if (XsnsPresent(i)) { state[0] = bitRead(Settings.sensors[i / 32], i % 32) ? '1' : '0'; } if (XsnsPresent(i)) { state[0] = bitRead(Settings.sensors[i / 32], i % 32) ? '1' : '0'; }
data += String(state); data += String(state);
if (i && (!((i +1) % 10))) { data += F("\""); } if (i && (!((i +1) % 16))) { data += F("\""); }
} }
data += F("]"); data += F("]");