mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 11:16:34 +00:00
Merge branch 'development' into release
This commit is contained in:
commit
f829b28ef1
@ -55,8 +55,11 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
||||
- Change Settings text handling allowing variable length text within a total text pool of 699 characters
|
||||
- Change Smoother ``Fade`` using 100Hz instead of 20Hz animation (#7179)
|
||||
- Change number of rule ``Var``s and ``Mem``s from 5 to 16 (#4933)
|
||||
- Change number of ``FriendlyName``s from 4 to 8
|
||||
- Add commands ``WebButton1`` until ``WebButton16`` to support user defined GUI button text (#7166)
|
||||
- Add support for max 150 characters in most command parameter strings (#3686, #4754)
|
||||
- Add support for GPS as NTP server by Christian Baars and Adrian Scillato
|
||||
- Add support for ``AdcParam`` parameters to control ADC0 Moisture formula by Federico Leoni (#7309)
|
||||
- Add Zigbee coalesce sensor attributes into a single message
|
||||
- Add Zigbee better support for Xiaomi Double Switch and Xiaomi Vibration sensor
|
||||
- Add Deepsleep start delay based on Teleperiod if ``Teleperiod`` differs from 10 or 300
|
||||
|
@ -9,7 +9,10 @@
|
||||
### 8.0.0.2 20191223
|
||||
|
||||
- Changed Settings variable namings
|
||||
- Change number of ``FriendlyName``s from 4 to 8
|
||||
- Add Zigbee better support for Xiaomi Double Switch and Xiaomi Vibration sensor
|
||||
- Add support for ``AdcParam`` parameters to control ADC0 Moisture formula by Federico Leoni (#7309)
|
||||
- Add commands ``WebButton1`` until ``WebButton16`` to support user defined GUI button text (#7166)
|
||||
|
||||
### 8.0.0.1 20191221
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
#define D_JSON_COUNT "Count"
|
||||
#define D_JSON_COUNTER "Counter"
|
||||
#define D_JSON_CURRENT "Current" // As in Voltage and Current
|
||||
#define D_JSON_DARKNESS "Darkness"
|
||||
#define D_JSON_DATA "Data"
|
||||
#define D_JSON_DISTANCE "Distance"
|
||||
#define D_JSON_DNSSERVER "DNSServer"
|
||||
@ -99,6 +100,7 @@
|
||||
#define D_JSON_MEMORY_ERROR "Memory error"
|
||||
#define D_JSON_MINIMAL "minimal"
|
||||
#define D_JSON_MODEL "Model"
|
||||
#define D_JSON_MOISTURE "Moisture"
|
||||
#define D_JSON_MQTT_COUNT "MqttCount"
|
||||
#define D_JSON_NO "No"
|
||||
#define D_JSON_NOISE "Noise"
|
||||
@ -332,6 +334,7 @@
|
||||
#define D_CMND_WEBREFRESH "WebRefresh"
|
||||
#define D_CMND_WEBSEND "WebSend"
|
||||
#define D_CMND_WEBCOLOR "WebColor"
|
||||
#define D_CMND_WEBBUTTON "WebButton"
|
||||
#define D_CMND_WEBSENSOR "WebSensor"
|
||||
#define D_CMND_EMULATION "Emulation"
|
||||
#define D_CMND_SENDMAIL "Sendmail"
|
||||
@ -457,7 +460,6 @@
|
||||
#define D_CMND_LONGITUDE "Longitude"
|
||||
|
||||
// Commands xdrv_16_tuyadimmer.ino
|
||||
|
||||
#define D_CMND_TUYA_MCU "TuyaMCU"
|
||||
#define D_CMND_TUYA_MCU_SEND_STATE "TuyaSend"
|
||||
#define D_JSON_TUYA_MCU_RECEIVED "TuyaReceived"
|
||||
@ -484,34 +486,33 @@
|
||||
#define D_CMND_ZIGBEE_SEND "ZigbeeSend"
|
||||
#define D_JSON_ZIGBEE_ZCL_SENT "ZigbeeZCLSent"
|
||||
|
||||
// Commands xdrv_25_A4988_Stepper.ino
|
||||
#ifdef USE_A4988_STEPPER
|
||||
#define D_CMND_MOTOR "MOTOR"
|
||||
#define D_JSON_MOTOR_MOVE "doMove"
|
||||
#define D_JSON_MOTOR_ROTATE "doRotate"
|
||||
#define D_JSON_MOTOR_TURN "doTurn"
|
||||
#define D_JSON_MOTOR_SPR "setSPR"
|
||||
#define D_JSON_MOTOR_RPM "setRPM"
|
||||
#define D_JSON_MOTOR_MIS "setMIS"
|
||||
#endif
|
||||
// Commands xdrv_25_A4988_Stepper.ino
|
||||
#define D_CMND_MOTOR "MOTOR"
|
||||
#define D_JSON_MOTOR_MOVE "doMove"
|
||||
#define D_JSON_MOTOR_ROTATE "doRotate"
|
||||
#define D_JSON_MOTOR_TURN "doTurn"
|
||||
#define D_JSON_MOTOR_SPR "setSPR"
|
||||
#define D_JSON_MOTOR_RPM "setRPM"
|
||||
#define D_JSON_MOTOR_MIS "setMIS"
|
||||
|
||||
// Commands xdrv_27_Shutter.ino
|
||||
#ifdef USE_SHUTTER
|
||||
#define D_PRFX_SHUTTER "Shutter"
|
||||
#define D_CMND_SHUTTER_OPEN "Open"
|
||||
#define D_CMND_SHUTTER_CLOSE "Close"
|
||||
#define D_CMND_SHUTTER_STOP "Stop"
|
||||
#define D_CMND_SHUTTER_POSITION "Position"
|
||||
#define D_CMND_SHUTTER_OPENTIME "OpenDuration"
|
||||
#define D_CMND_SHUTTER_CLOSETIME "CloseDuration"
|
||||
#define D_CMND_SHUTTER_RELAY "Relay"
|
||||
#define D_CMND_SHUTTER_SETHALFWAY "SetHalfway"
|
||||
#define D_CMND_SHUTTER_SETCLOSE "SetClose"
|
||||
#define D_CMND_SHUTTER_INVERT "Invert"
|
||||
#define D_CMND_SHUTTER_CLIBRATION "Calibration"
|
||||
#define D_CMND_SHUTTER_MOTORDELAY "MotorDelay"
|
||||
#define D_CMND_SHUTTER_FREQUENCY "Frequency"
|
||||
#endif
|
||||
// Commands xdrv_27_Shutter.ino
|
||||
#define D_PRFX_SHUTTER "Shutter"
|
||||
#define D_CMND_SHUTTER_OPEN "Open"
|
||||
#define D_CMND_SHUTTER_CLOSE "Close"
|
||||
#define D_CMND_SHUTTER_STOP "Stop"
|
||||
#define D_CMND_SHUTTER_POSITION "Position"
|
||||
#define D_CMND_SHUTTER_OPENTIME "OpenDuration"
|
||||
#define D_CMND_SHUTTER_CLOSETIME "CloseDuration"
|
||||
#define D_CMND_SHUTTER_RELAY "Relay"
|
||||
#define D_CMND_SHUTTER_SETHALFWAY "SetHalfway"
|
||||
#define D_CMND_SHUTTER_SETCLOSE "SetClose"
|
||||
#define D_CMND_SHUTTER_INVERT "Invert"
|
||||
#define D_CMND_SHUTTER_CLIBRATION "Calibration"
|
||||
#define D_CMND_SHUTTER_MOTORDELAY "MotorDelay"
|
||||
#define D_CMND_SHUTTER_FREQUENCY "Frequency"
|
||||
|
||||
// Commands xsns_02_analog.ino
|
||||
#define D_CMND_ADCPARAM "AdcParam"
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
@ -589,6 +590,7 @@ const char JSON_SNS_TEMP[] PROGMEM = ",\"%s\":{\"" D_JSON_TEMPERATURE "\":%s}";
|
||||
const char JSON_SNS_TEMPHUM[] PROGMEM = ",\"%s\":{\"" D_JSON_TEMPERATURE "\":%s,\"" D_JSON_HUMIDITY "\":%s}";
|
||||
|
||||
const char JSON_SNS_ILLUMINANCE[] PROGMEM = ",\"%s\":{\"" D_JSON_ILLUMINANCE "\":%d}";
|
||||
const char JSON_SNS_MOISTURE[] PROGMEM = ",\"%s\":{\"" D_JSON_MOISTURE "\":%d}";
|
||||
|
||||
const char JSON_SNS_GNGPM[] PROGMEM = ",\"%s\":{\"" D_JSON_TOTAL_USAGE "\":%s,\"" D_JSON_FLOWRATE "\":%s}";
|
||||
|
||||
@ -618,6 +620,8 @@ const char HTTP_SNS_CO2[] PROGMEM = "{s}%s " D_CO2 "{m}%d " D_UNIT_PARTS_PER_MIL
|
||||
const char HTTP_SNS_CO2EAVG[] PROGMEM = "{s}%s " D_ECO2 "{m}%d " D_UNIT_PARTS_PER_MILLION "{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
const char HTTP_SNS_GALLONS[] PROGMEM = "{s}%s " D_TOTAL_USAGE "{m}%s " D_UNIT_GALLONS " {e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
const char HTTP_SNS_GPM[] PROGMEM = "{s}%s " D_FLOW_RATE "{m}%s " D_UNIT_GALLONS_PER_MIN" {e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
const char HTTP_SNS_MOISTURE[] PROGMEM = "{s}%s " D_MOISTURE "{m}%d %%{e}"; // {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
|
||||
|
||||
const char S_MAIN_MENU[] PROGMEM = D_MAIN_MENU;
|
||||
const char S_CONFIGURATION[] PROGMEM = D_CONFIGURATION;
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Светлина"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Модул"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "неколкократно натискане"
|
||||
#define D_NOISE "Шум"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Světlo"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Modul"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "několikeré-stisknutí"
|
||||
#define D_NOISE "Hluk"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Licht"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Modul"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "Mehrfachdruck"
|
||||
#define D_NOISE "Lautstärke"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Φως"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Μονάδα"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "ανίχνευση για πολλαπλά πατήματα"
|
||||
#define D_NOISE "Θόρυβος"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Light"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Module"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "multi-press"
|
||||
#define D_NOISE "Noise"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Luz"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Módulo"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "multi-press"
|
||||
#define D_NOISE "Ruido"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Lumière"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Module"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "multi-pression"
|
||||
#define D_NOISE "Bruit"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "אור"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "מודול"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "לחיצה מרובה"
|
||||
#define D_NOISE "רעש"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Fény"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Modul"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "több lenyomás"
|
||||
#define D_NOISE "Zaj"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Luce"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Modulo"
|
||||
#define D_MOISTURE "Umidità"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "multi-pressione"
|
||||
#define D_NOISE "Rumore"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "밝게"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "모듈"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "multi-press"
|
||||
#define D_NOISE "소음"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Licht"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Module"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "meervoudig"
|
||||
#define D_NOISE "Lawaai"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Światło"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Moduł"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "Wielokrotne naciśnięcie"
|
||||
#define D_NOISE "Szum"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Luz"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Módulo"
|
||||
#define D_MOISTURE "Umidade"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "multi-pressão"
|
||||
#define D_NOISE "Ruído"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Luz"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Módulo"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "multi-pressão"
|
||||
#define D_NOISE "Ruído"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Свет"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Модуль"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "многократное нажатие"
|
||||
#define D_NOISE "Шум"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Svetlo"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Modul"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "multi-stlačenie"
|
||||
#define D_NOISE "Hluk"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Ljus"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Modul"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "fler tryck"
|
||||
#define D_NOISE "Oväsen"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Işık"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Modül"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "multi-press"
|
||||
#define D_NOISE "Noise"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "Світло"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "Модуль"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "Багаторазове натискання"
|
||||
#define D_NOISE "Шум"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "灯"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "模块"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "多次按键"
|
||||
#define D_NOISE "嘈杂"
|
||||
|
@ -113,6 +113,7 @@
|
||||
#define D_LIGHT "燈"
|
||||
#define D_LWT "LWT"
|
||||
#define D_MODULE "模組"
|
||||
#define D_MOISTURE "Moisture"
|
||||
#define D_MQTT "MQTT"
|
||||
#define D_MULTI_PRESS "多次按鍵"
|
||||
#define D_NOISE "雜訊"
|
||||
|
@ -337,7 +337,7 @@ struct SYSCFG {
|
||||
SysBitfield3 flag3; // 3A0
|
||||
uint8_t switchmode[MAX_SWITCHES]; // 3A4 (6.0.0b - moved from 0x4CA)
|
||||
|
||||
char ex_friendlyname[MAX_FRIENDLYNAMES][33]; // 3AC
|
||||
char ex_friendlyname[4][33]; // 3AC
|
||||
char ex_switch_topic[33]; // 430
|
||||
|
||||
char serial_delimiter; // 451
|
||||
|
@ -551,13 +551,14 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me)
|
||||
|
||||
char* SettingsText(uint32_t index)
|
||||
{
|
||||
if (index >= SET_MAX) {
|
||||
return nullptr; // Setting not supported - internal error
|
||||
}
|
||||
|
||||
char* position = Settings.text_pool;
|
||||
for (;index > 0; index--) {
|
||||
while (*position++ != '\0') { }
|
||||
|
||||
if (index >= SET_MAX) {
|
||||
position += settings_text_size -1; // Setting not supported - internal error - return empty string
|
||||
} else {
|
||||
for (;index > 0; index--) {
|
||||
while (*position++ != '\0') { }
|
||||
}
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
@ -1311,7 +1311,7 @@ void CmndFriendlyname(void)
|
||||
} else {
|
||||
snprintf_P(stemp1, sizeof(stemp1), PSTR(FRIENDLY_NAME "%d"), XdrvMailbox.index);
|
||||
}
|
||||
SettingsUpdateText(SET_FRIENDLYNAME1 + XdrvMailbox.index -1, (SC_DEFAULT == Shortcut()) ? stemp1 : XdrvMailbox.data);
|
||||
SettingsUpdateText(SET_FRIENDLYNAME1 + XdrvMailbox.index -1, ('"' == XdrvMailbox.data[0]) ? "" : (SC_DEFAULT == Shortcut()) ? stemp1 : XdrvMailbox.data);
|
||||
}
|
||||
ResponseCmndIdxChar(SettingsText(SET_FRIENDLYNAME1 + XdrvMailbox.index -1));
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ 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
|
||||
const uint8_t MAX_PULSETIMERS = 8; // Max number of supported pulse timers
|
||||
const uint8_t MAX_FRIENDLYNAMES = 4; // Max number of Friendly names
|
||||
const uint8_t MAX_DOMOTICZ_IDX = 4; // Max number of Domoticz device, key and switch indices
|
||||
const uint8_t MAX_DOMOTICZ_SNS_IDX = 12; // Max number of Domoticz sensors indices
|
||||
const uint8_t MAX_KNX_GA = 10; // Max number of KNX Group Addresses to read that can be set
|
||||
@ -73,7 +72,11 @@ const uint8_t MAX_PCF8574 = 8; // 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
|
||||
|
||||
// Changes to the following MAX_ defines need to be in line with enum SettingsTextIndex
|
||||
const uint8_t MAX_RULE_MEMS = 16; // Max number of saved vars
|
||||
const uint8_t MAX_FRIENDLYNAMES = 8; // Max number of Friendly names
|
||||
const uint8_t MAX_BUTTON_TEXT = 16; // Max number of GUI button labels
|
||||
|
||||
const uint8_t MAX_HUE_DEVICES = 15; // Max number of Philips Hue device per emulation
|
||||
|
||||
const char MQTT_TOKEN_PREFIX[] PROGMEM = "%prefix%"; // To be substituted by mqtt_prefix[x]
|
||||
@ -287,13 +290,9 @@ enum SettingsTextIndex { SET_OTAURL,
|
||||
SET_MEM1, SET_MEM2, SET_MEM3, SET_MEM4, SET_MEM5, SET_MEM6, SET_MEM7, SET_MEM8,
|
||||
SET_MEM9, SET_MEM10, SET_MEM11, SET_MEM12, SET_MEM13, SET_MEM14, SET_MEM15, SET_MEM16,
|
||||
SET_FRIENDLYNAME1, SET_FRIENDLYNAME2, SET_FRIENDLYNAME3, SET_FRIENDLYNAME4,
|
||||
|
||||
// SET_FRIENDLYNAME5, SET_FRIENDLYNAME6, SET_FRIENDLYNAME7, SET_FRIENDLYNAME8, // Future extension
|
||||
// SET_BUTTON1, SET_BUTTON2, SET_BUTTON3, SET_BUTTON4, // Future extension
|
||||
// SET_BUTTON5, SET_BUTTON6, SET_BUTTON7, SET_BUTTON8, // Future extension
|
||||
// SET_BUTTON9, SET_BUTTON10, SET_BUTTON11, SET_BUTTON12, // Future extension
|
||||
// SET_BUTTON13, SET_BUTTON14, SET_BUTTON15, SET_BUTTON16, // Future extension
|
||||
|
||||
SET_FRIENDLYNAME5, SET_FRIENDLYNAME6, SET_FRIENDLYNAME7, SET_FRIENDLYNAME8,
|
||||
SET_BUTTON1, SET_BUTTON2, SET_BUTTON3, SET_BUTTON4, SET_BUTTON5, SET_BUTTON6, SET_BUTTON7, SET_BUTTON8,
|
||||
SET_BUTTON9, SET_BUTTON10, SET_BUTTON11, SET_BUTTON12, SET_BUTTON13, SET_BUTTON14, SET_BUTTON15, SET_BUTTON16,
|
||||
SET_MAX };
|
||||
|
||||
enum CommandSource { SRC_IGNORE, SRC_MQTT, SRC_RESTART, SRC_BUTTON, SRC_SWITCH, SRC_BACKLOG, SRC_SERIAL, SRC_WEBGUI, SRC_WEBCOMMAND, SRC_WEBCONSOLE, SRC_PULSETIMER,
|
||||
|
@ -311,6 +311,7 @@ enum UserSelectableAdc0 {
|
||||
ADC0_LIGHT, // Light sensor
|
||||
ADC0_BUTTON, // Button
|
||||
ADC0_BUTTON_INV,
|
||||
ADC0_MOIST, // Moisture
|
||||
// ADC0_SWITCH, // Switch
|
||||
// ADC0_SWITCH_INV,
|
||||
ADC0_END };
|
||||
@ -326,6 +327,7 @@ const char kAdc0Names[] PROGMEM =
|
||||
D_SENSOR_NONE "|" D_ANALOG_INPUT "|"
|
||||
D_TEMPERATURE "|" D_LIGHT "|"
|
||||
D_SENSOR_BUTTON "|" D_SENSOR_BUTTON "i|"
|
||||
D_MOISTURE "|"
|
||||
// D_SENSOR_SWITCH "|" D_SENSOR_SWITCH "i|"
|
||||
;
|
||||
|
||||
|
@ -1014,7 +1014,7 @@ void HandleRoot(void)
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_MAIN_MENU);
|
||||
|
||||
char stemp[10];
|
||||
char stemp[33];
|
||||
|
||||
WSContentStart_P(S_MAIN_MENU);
|
||||
#ifdef USE_SCRIPT_WEB_DISPLAY
|
||||
@ -1106,14 +1106,19 @@ void HandleRoot(void)
|
||||
WSContentSend_P(PSTR("<tr>"));
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
if (IsModuleIfan()) {
|
||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 36, 1, D_BUTTON_TOGGLE, "");
|
||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 36, 1,
|
||||
(strlen(SettingsText(SET_BUTTON1))) ? SettingsText(SET_BUTTON1) : D_BUTTON_TOGGLE,
|
||||
"");
|
||||
for (uint32_t i = 0; i < MaxFanspeed(); i++) {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("%d"), i);
|
||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 16, i +2, stemp, "");
|
||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 16, i +2,
|
||||
(strlen(SettingsText(SET_BUTTON2 + i))) ? SettingsText(SET_BUTTON2 + i) : stemp,
|
||||
"");
|
||||
}
|
||||
} else {
|
||||
#endif // USE_SONOFF_IFAN
|
||||
for (uint32_t idx = 1; idx <= devices_present; idx++) {
|
||||
bool set_button = ((idx <= MAX_BUTTON_TEXT) && strlen(SettingsText(SET_BUTTON1 + idx -1)));
|
||||
#ifdef USE_SHUTTER
|
||||
if (Settings.flag3.shutter_mode) { // SetOption80 - Enable shutter support
|
||||
bool shutter_used = false;
|
||||
@ -1124,13 +1129,17 @@ void HandleRoot(void)
|
||||
}
|
||||
}
|
||||
if (shutter_used) {
|
||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / devices_present, idx, (idx % 2) ? "▲" : "▼" , "");
|
||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / devices_present, idx,
|
||||
(set_button) ? SettingsText(SET_BUTTON1 + idx -1) : (idx % 2) ? "▲" : "▼",
|
||||
"");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif // USE_SHUTTER
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR(" %d"), idx);
|
||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / devices_present, idx, (devices_present < 5) ? D_BUTTON_TOGGLE : "", (devices_present > 1) ? stemp : "");
|
||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / devices_present, idx,
|
||||
(set_button) ? SettingsText(SET_BUTTON1 + idx -1) : (devices_present < 5) ? D_BUTTON_TOGGLE : "",
|
||||
(set_button) ? "" : (devices_present > 1) ? stemp : "");
|
||||
}
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
}
|
||||
@ -1146,7 +1155,9 @@ void HandleRoot(void)
|
||||
if (idx > 0) { WSContentSend_P(PSTR("</tr><tr>")); }
|
||||
for (uint32_t j = 0; j < 4; j++) {
|
||||
idx++;
|
||||
WSContentSend_P(PSTR("<td style='width:25%%'><button onclick='la(\"&k=%d\");'>%d</button></td>"), idx, idx); // &k is related to WebGetArg("k", tmp, sizeof(tmp));
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("%d"), idx);
|
||||
WSContentSend_P(PSTR("<td style='width:25%%'><button onclick='la(\"&k=%d\");'>%s</button></td>"), idx, // &k is related to WebGetArg("k", tmp, sizeof(tmp));
|
||||
(strlen(SettingsText(SET_BUTTON1 + idx -1))) ? SettingsText(SET_BUTTON1 + idx -1) : stemp);
|
||||
}
|
||||
}
|
||||
WSContentSend_P(PSTR("</tr></table>"));
|
||||
@ -1846,6 +1857,7 @@ void OtherSaveSettings(void)
|
||||
char tmp[TOPSZ];
|
||||
char webindex[5];
|
||||
char friendlyname[TOPSZ];
|
||||
char message[LOGSZ];
|
||||
|
||||
WebGetArg("wp", tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_WEBPWD, (!strlen(tmp)) ? "" : (strchr(tmp,'*')) ? SettingsText(SET_WEBPWD) : tmp);
|
||||
@ -1854,15 +1866,17 @@ void OtherSaveSettings(void)
|
||||
WebGetArg("b2", tmp, sizeof(tmp));
|
||||
Settings.flag2.emulation = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
#endif // USE_EMULATION
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_OTHER D_MQTT_ENABLE " %s, " D_CMND_EMULATION " %d, " D_CMND_FRIENDLYNAME), GetStateText(Settings.flag.mqtt_enabled), Settings.flag2.emulation);
|
||||
|
||||
snprintf_P(message, sizeof(message), PSTR(D_LOG_OTHER D_MQTT_ENABLE " %s, " D_CMND_EMULATION " %d, " D_CMND_FRIENDLYNAME), GetStateText(Settings.flag.mqtt_enabled), Settings.flag2.emulation);
|
||||
for (uint32_t i = 0; i < MAX_FRIENDLYNAMES; i++) {
|
||||
snprintf_P(webindex, sizeof(webindex), PSTR("a%d"), i);
|
||||
WebGetArg(webindex, tmp, sizeof(tmp));
|
||||
snprintf_P(friendlyname, sizeof(friendlyname), PSTR(FRIENDLY_NAME"%d"), i +1);
|
||||
SettingsUpdateText(SET_FRIENDLYNAME1 +i, (!strlen(tmp)) ? (i) ? friendlyname : FRIENDLY_NAME : tmp);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%s%s %s"), log_data, (i) ? "," : "", SettingsText(SET_FRIENDLYNAME1 +i));
|
||||
snprintf_P(message, sizeof(message), PSTR("%s%s %s"), message, (i) ? "," : "", SettingsText(SET_FRIENDLYNAME1 +i));
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P(LOG_LEVEL_INFO, message);
|
||||
|
||||
WebGetArg("t1", tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) { // {"NAME":"12345678901234","GPIO":[255,255,255,255,255,255,255,255,255,255,255,255,255],"FLAG":255,"BASE":255}
|
||||
char svalue[128];
|
||||
@ -2730,7 +2744,8 @@ const char kWebCommands[] PROGMEM = "|" // No prefix
|
||||
#ifdef USE_SENDMAIL
|
||||
D_CMND_SENDMAIL "|"
|
||||
#endif
|
||||
D_CMND_WEBSERVER "|" D_CMND_WEBPASSWORD "|" D_CMND_WEBLOG "|" D_CMND_WEBREFRESH "|" D_CMND_WEBSEND "|" D_CMND_WEBCOLOR "|" D_CMND_WEBSENSOR "|" D_CMND_CORS;
|
||||
D_CMND_WEBSERVER "|" D_CMND_WEBPASSWORD "|" D_CMND_WEBLOG "|" D_CMND_WEBREFRESH "|" D_CMND_WEBSEND "|" D_CMND_WEBCOLOR "|"
|
||||
D_CMND_WEBSENSOR "|" D_CMND_WEBBUTTON "|" D_CMND_CORS;
|
||||
|
||||
void (* const WebCommand[])(void) PROGMEM = {
|
||||
#ifdef USE_EMULATION
|
||||
@ -2739,7 +2754,8 @@ void (* const WebCommand[])(void) PROGMEM = {
|
||||
#ifdef USE_SENDMAIL
|
||||
&CmndSendmail,
|
||||
#endif
|
||||
&CmndWebServer, &CmndWebPassword, &CmndWeblog, &CmndWebRefresh, &CmndWebSend, &CmndWebColor, &CmndWebSensor, &CmndCors };
|
||||
&CmndWebServer, &CmndWebPassword, &CmndWeblog, &CmndWebRefresh, &CmndWebSend, &CmndWebColor,
|
||||
&CmndWebSensor, &CmndWebButton, &CmndCors };
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Commands
|
||||
@ -2860,6 +2876,24 @@ void CmndWebSensor(void)
|
||||
ResponseJsonEnd();
|
||||
}
|
||||
|
||||
void CmndWebButton(void)
|
||||
{
|
||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_BUTTON_TEXT)) {
|
||||
if (!XdrvMailbox.usridx) {
|
||||
mqtt_data[0] = '\0';
|
||||
for (uint32_t i = 0; i < MAX_BUTTON_TEXT; i++) {
|
||||
ResponseAppend_P(PSTR("%c\"WebButton%d\":\"%s\""), (i) ? ',' : '{', i +1, SettingsText(SET_BUTTON1 +i));
|
||||
}
|
||||
ResponseJsonEnd();
|
||||
} else {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
SettingsUpdateText(SET_BUTTON1 + XdrvMailbox.index -1, ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data);
|
||||
}
|
||||
ResponseCmndIdxChar(SettingsText(SET_BUTTON1 + XdrvMailbox.index -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CmndCors(void)
|
||||
{
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
|
@ -32,9 +32,7 @@ const char kMqttCommands[] PROGMEM = "|" // No prefix
|
||||
#if defined(USE_MQTT_TLS) && !defined(USE_MQTT_TLS_CA_CERT)
|
||||
D_CMND_MQTTFINGERPRINT "|"
|
||||
#endif
|
||||
#if !defined(USE_MQTT_TLS) || !defined(USE_MQTT_AWS_IOT) // user and password are disabled with AWS IoT
|
||||
D_CMND_MQTTUSER "|" D_CMND_MQTTPASSWORD "|"
|
||||
#endif
|
||||
#if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT)
|
||||
D_CMND_TLSKEY "|"
|
||||
#endif
|
||||
@ -46,9 +44,7 @@ void (* const MqttCommand[])(void) PROGMEM = {
|
||||
#if defined(USE_MQTT_TLS) && !defined(USE_MQTT_TLS_CA_CERT)
|
||||
&CmndMqttFingerprint,
|
||||
#endif
|
||||
#if !defined(USE_MQTT_TLS) || !defined(USE_MQTT_AWS_IOT) // user and password are disabled with AWS IoT
|
||||
&CmndMqttUser, &CmndMqttPassword,
|
||||
#endif
|
||||
#if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT)
|
||||
&CmndTlsKey,
|
||||
#endif
|
||||
@ -640,7 +636,6 @@ void MqttReconnect(void)
|
||||
#endif
|
||||
#if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT)
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "AWS IoT endpoint: %s"), SettingsText(SET_MQTT_HOST));
|
||||
//if (MqttClient.connect(mqtt_client, nullptr, nullptr, nullptr, 0, false, nullptr)) {
|
||||
if (MqttClient.connect(mqtt_client, nullptr, nullptr, stopic, 1, false, mqtt_data, MQTT_CLEAN_SESSION)) {
|
||||
#else
|
||||
if (MqttClient.connect(mqtt_client, mqtt_user, mqtt_pwd, stopic, 1, true, mqtt_data, MQTT_CLEAN_SESSION)) {
|
||||
@ -737,7 +732,6 @@ void CmndMqttFingerprint(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(USE_MQTT_TLS) || !defined(USE_MQTT_AWS_IOT) // user and password are disabled with AWS IoT
|
||||
void CmndMqttUser(void)
|
||||
{
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
@ -757,7 +751,6 @@ void CmndMqttPassword(void)
|
||||
Response_P(S_JSON_COMMAND_ASTERISK, XdrvMailbox.command);
|
||||
}
|
||||
}
|
||||
#endif // USE_MQTT_AWS_IOT
|
||||
|
||||
void CmndMqttlog(void)
|
||||
{
|
||||
@ -1171,10 +1164,8 @@ const char HTTP_FORM_MQTT1[] PROGMEM =
|
||||
"<p><b>" D_PORT "</b> (" STR(MQTT_PORT) ")<br><input id='ml' placeholder='" STR(MQTT_PORT) "' value='%d'></p>"
|
||||
"<p><b>" D_CLIENT "</b> (%s)<br><input id='mc' placeholder='%s' value='%s'></p>";
|
||||
const char HTTP_FORM_MQTT2[] PROGMEM =
|
||||
#if !defined(USE_MQTT_TLS) || !defined(USE_MQTT_AWS_IOT) // user and password disabled with AWS IoT
|
||||
"<p><b>" D_USER "</b> (" MQTT_USER ")<br><input id='mu' placeholder='" MQTT_USER "' value='%s'></p>"
|
||||
"<p><b>" D_PASSWORD "</b><input type='checkbox' onclick='sp(\"mp\")'><br><input id='mp' type='password' placeholder='" D_PASSWORD "' value='" D_ASTERISK_PWD "'></p>"
|
||||
#endif // USE_MQTT_AWS_IOT
|
||||
"<p><b>" D_TOPIC "</b> = %%topic%% (%s)<br><input id='mt' placeholder='%s' value='%s'></p>"
|
||||
"<p><b>" D_FULL_TOPIC "</b> (%s)<br><input id='mf' placeholder='%s' value='%s'></p>";
|
||||
|
||||
|
@ -733,12 +733,13 @@ void HandleTimerConfiguration(void)
|
||||
void TimerSaveSettings(void)
|
||||
{
|
||||
char tmp[MAX_TIMERS *12]; // Need space for MAX_TIMERS x 10 digit numbers separated by a comma
|
||||
char message[LOGSZ];
|
||||
Timer timer;
|
||||
|
||||
Settings.flag3.timers_enable = WebServer->hasArg("e0"); // CMND_TIMERS
|
||||
WebGetArg("t0", tmp, sizeof(tmp));
|
||||
char *p = tmp;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_CMND_TIMERS " %d"), Settings.flag3.timers_enable); // CMND_TIMERS
|
||||
snprintf_P(message, sizeof(message), PSTR(D_LOG_MQTT D_CMND_TIMERS " %d"), Settings.flag3.timers_enable); // CMND_TIMERS
|
||||
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
|
||||
timer.data = strtol(p, &p, 10);
|
||||
p++; // Skip comma
|
||||
@ -747,9 +748,9 @@ void TimerSaveSettings(void)
|
||||
Settings.timer[i].data = timer.data;
|
||||
if (flag) TimerSetRandomWindow(i);
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%s,0x%08X"), log_data, Settings.timer[i].data);
|
||||
snprintf_P(message, sizeof(message), PSTR("%s,0x%08X"), message, Settings.timer[i].data);
|
||||
}
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, message);
|
||||
}
|
||||
#endif // USE_TIMERS_WEB
|
||||
#endif // USE_WEBSERVER
|
||||
|
@ -1400,8 +1400,7 @@ bool evaluateLogicalExpression(const char * expression, int len)
|
||||
memcpy(expbuff, expression, len);
|
||||
expbuff[len] = '\0';
|
||||
|
||||
//snprintf_P(log_data, sizeof(log_data), PSTR("EvalLogic: |%s|"), expbuff);
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("EvalLogic: |%s|"), expbuff);
|
||||
char * pointer = expbuff;
|
||||
LinkedList<bool> values;
|
||||
LinkedList<int8_t> logicOperators;
|
||||
@ -1527,8 +1526,7 @@ void ExecuteCommandBlock(const char * commands, int len)
|
||||
memcpy(cmdbuff, commands, len);
|
||||
cmdbuff[len] = '\0';
|
||||
|
||||
//snprintf_P(log_data, sizeof(log_data), PSTR("ExecCmd: |%s|"), cmdbuff);
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ExecCmd: |%s|"), cmdbuff);
|
||||
char oneCommand[len + 1]; //To put one command
|
||||
int insertPosition = 0; //When insert into backlog, we should do it by 0, 1, 2 ...
|
||||
char * pos = cmdbuff;
|
||||
|
@ -2203,8 +2203,7 @@ void Replace_Cmd_Vars(char *srcbuf,char *dstbuf,uint16_t dstsize) {
|
||||
|
||||
void toLog(const char *str) {
|
||||
if (!str) return;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%s"),str);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P(LOG_LEVEL_INFO, str);
|
||||
}
|
||||
|
||||
|
||||
@ -2681,8 +2680,7 @@ int16_t Run_Scripter(const char *type, int8_t tlen, char *js) {
|
||||
}
|
||||
cmd[count]=*lp++;
|
||||
}
|
||||
//snprintf_P(log_data, sizeof(log_data), tmp);
|
||||
//AddLog(LOG_LEVEL_INFO);
|
||||
//AddLog_P(LOG_LEVEL_INFO, tmp);
|
||||
// replace vars in cmd
|
||||
char *tmp=cmdmem+SCRIPT_CMDMEM/2;
|
||||
Replace_Cmd_Vars(cmd,tmp,SCRIPT_CMDMEM/2);
|
||||
@ -2694,8 +2692,7 @@ int16_t Run_Scripter(const char *type, int8_t tlen, char *js) {
|
||||
} else {
|
||||
if (!sflag) {
|
||||
tasm_cmd_activ=1;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("Script: performs \"%s\""), tmp);
|
||||
AddLog(glob_script_mem.script_loglevel&0x7f);
|
||||
AddLog_P2(glob_script_mem.script_loglevel&0x7f, PSTR("Script: performs \"%s\""), tmp);
|
||||
} else if (sflag==2) {
|
||||
// allow recursive call
|
||||
} else {
|
||||
@ -3544,8 +3541,7 @@ void ScriptSaveSettings(void) {
|
||||
if (bitRead(Settings.rule_enabled, 0)) {
|
||||
int16_t res=Init_Scripter();
|
||||
if (res) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("script init error: %d"),res);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("script init error: %d"), res);
|
||||
return;
|
||||
}
|
||||
Run_Scripter(">B",2,0);
|
||||
|
@ -124,8 +124,7 @@ void Ssd1306PrintLog(void)
|
||||
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
|
||||
DisplayFillScreen(last_row);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
|
||||
|
||||
renderer->println(disp_screen_buffer[last_row]);
|
||||
renderer->Updateframe();
|
||||
|
@ -119,8 +119,7 @@ void SH1106PrintLog(void)
|
||||
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
|
||||
DisplayFillScreen(last_row);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
|
||||
|
||||
renderer->println(disp_screen_buffer[last_row]);
|
||||
renderer->Updateframe();
|
||||
|
@ -112,8 +112,7 @@ void SSD1351PrintLog(void)
|
||||
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
|
||||
DisplayFillScreen(last_row);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
|
||||
|
||||
renderer->println(disp_screen_buffer[last_row]);
|
||||
renderer->Updateframe();
|
||||
|
@ -66,6 +66,12 @@ void AdcInit(void)
|
||||
Settings.adc_param2 = ANALOG_LDR_LUX_CALC_SCALAR;
|
||||
Settings.adc_param3 = ANALOG_LDR_LUX_CALC_EXPONENT * 10000;
|
||||
}
|
||||
else if (ADC0_MOIST == my_adc0) {
|
||||
Settings.adc_param_type = ADC0_MOIST;
|
||||
Settings.adc_param1 = 0;
|
||||
Settings.adc_param2 = 1023;
|
||||
Settings.adc_param3 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,6 +119,20 @@ uint16_t AdcGetLux(void)
|
||||
return (uint16_t)ldrLux;
|
||||
}
|
||||
|
||||
uint16_t AdcGetMoist(void)
|
||||
// formula for calibration: value, fromLow, fromHigh, toHigh, toLow
|
||||
// Example: 632, 0, 1023, 100, 0
|
||||
// int( ( ( (<param2> - <analogue-value>) / ( <param2> - <param1> ) ) * ( <param3> - <param4> ) ) + <param4> )
|
||||
// double amoist = ((Settings.adc_param2 - (double)adc) / (Settings.adc_param2 - Settings.adc_param1) * 100;
|
||||
// int((((1023 - <analog-reading>) / ( 1023 - 0 )) * ( 100 - 0 )) + 0 )
|
||||
|
||||
{
|
||||
int adc = AdcRead(2);
|
||||
double amoist = ((double)Settings.adc_param2 - (double)adc) / ((double)Settings.adc_param2 - (double)Settings.adc_param1) * 100;
|
||||
//double amoist = ((1023 - (double)adc) / 1023) * 100;
|
||||
return (uint16_t)amoist;
|
||||
}
|
||||
|
||||
void AdcEverySecond(void)
|
||||
{
|
||||
if (ADC0_TEMP == my_adc0) {
|
||||
@ -173,6 +193,17 @@ void AdcShow(bool json)
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
WSContentSend_PD(HTTP_SNS_ILLUMINANCE, "", adc_light);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
else if (ADC0_MOIST == my_adc0) {
|
||||
uint16_t adc_moist = AdcGetMoist();
|
||||
|
||||
if (json) {
|
||||
ResponseAppend_P(JSON_SNS_MOISTURE, "ANALOG", adc_moist);
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
WSContentSend_PD(HTTP_SNS_MOISTURE, "", adc_moist);
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
}
|
||||
@ -182,7 +213,6 @@ void AdcShow(bool json)
|
||||
* Commands
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define D_CMND_ADCPARAM "AdcParam"
|
||||
const char kAdcCommands[] PROGMEM = "|" // No prefix
|
||||
D_CMND_ADC "|" D_CMND_ADCS "|" D_CMND_ADCPARAM;
|
||||
|
||||
@ -217,7 +247,7 @@ void CmndAdcs(void)
|
||||
void CmndAdcParam(void)
|
||||
{
|
||||
if (XdrvMailbox.data_len) {
|
||||
if ((ADC0_TEMP == XdrvMailbox.payload) || (ADC0_LIGHT == XdrvMailbox.payload)) {
|
||||
if ((ADC0_TEMP == XdrvMailbox.payload) || (ADC0_LIGHT == XdrvMailbox.payload) || (ADC0_MOIST == XdrvMailbox.payload)) {
|
||||
// if ((XdrvMailbox.payload == my_adc0) && ((ADC0_TEMP == my_adc0) || (ADC0_LIGHT == my_adc0))) {
|
||||
if (strstr(XdrvMailbox.data, ",") != nullptr) { // Process parameter entry
|
||||
char sub_string[XdrvMailbox.data_len +1];
|
||||
@ -227,10 +257,13 @@ void CmndAdcParam(void)
|
||||
// Settings.adc_param_type = my_adc0;
|
||||
Settings.adc_param1 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
|
||||
Settings.adc_param2 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 3), nullptr, 10);
|
||||
Settings.adc_param3 = (int)(CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 4)) * 10000);
|
||||
if (!ADC0_MOIST == XdrvMailbox.payload) {
|
||||
Settings.adc_param3 = (int)(CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 4)) * 10000);
|
||||
}
|
||||
} else { // Set default values based on current adc type
|
||||
// AdcParam 2
|
||||
// AdcParam 3
|
||||
// AdcParam 6
|
||||
Settings.adc_param_type = 0;
|
||||
AdcInit();
|
||||
}
|
||||
@ -246,8 +279,14 @@ void CmndAdcParam(void)
|
||||
}
|
||||
char param3[33];
|
||||
dtostrfd(((double)Settings.adc_param3)/10000, precision, param3);
|
||||
Response_P(PSTR("{\"" D_CMND_ADCPARAM "\":[%d,%d,%d,%s]}"),
|
||||
Settings.adc_param_type, Settings.adc_param1, Settings.adc_param2, param3);
|
||||
if ((ADC0_TEMP == my_adc0) || (ADC0_LIGHT == my_adc0)) {
|
||||
Response_P(PSTR("{\"" D_CMND_ADCPARAM "\":[%d,%d,%d,%s]}"),
|
||||
Settings.adc_param_type, Settings.adc_param1, Settings.adc_param2, param3);
|
||||
}
|
||||
else if (ADC0_MOIST == my_adc0) {
|
||||
Response_P(PSTR("{\"" D_CMND_ADCPARAM "\":[%d,%d,%d]}"),
|
||||
Settings.adc_param_type, Settings.adc_param1, Settings.adc_param2);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
@ -263,7 +302,7 @@ bool Xsns02(uint8_t function)
|
||||
result = DecodeCommand(kAdcCommands, AdcCommand);
|
||||
break;
|
||||
default:
|
||||
if ((ADC0_INPUT == my_adc0) || (ADC0_TEMP == my_adc0) || (ADC0_LIGHT == my_adc0)) {
|
||||
if ((ADC0_INPUT == my_adc0) || (ADC0_TEMP == my_adc0) || (ADC0_LIGHT == my_adc0) || (ADC0_MOIST == my_adc0)) {
|
||||
switch (function) {
|
||||
#ifdef USE_RULES
|
||||
case FUNC_EVERY_250_MSECOND:
|
||||
|
@ -75,8 +75,7 @@ void Max4409Detect(void)
|
||||
|
||||
if ((I2cValidRead8(&buffer1, max44009_address, REG_LOWER_THRESHOLD)) &&
|
||||
(I2cValidRead8(&buffer2, max44009_address, REG_THRESHOLD_TIMER))) {
|
||||
//snprintf(log_data, sizeof(log_data), "MAX44009 %x: %x, %x", max44009_address, (int)buffer1, (int)buffer2);
|
||||
//AddLog(LOG_LEVEL_DEBUG_MORE);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR("MAX44009 %x: %x, %x"), max44009_address, (int)buffer1, (int)buffer2);
|
||||
if ((0x00 == buffer1) &&
|
||||
(0xFF == buffer2)) {
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
#define XSNS_42 42
|
||||
#define XI2C_29 29 // See I2CDEVICES.md
|
||||
|
||||
//#define SCD30_DEBUG
|
||||
|
||||
#define SCD30_ADDRESS 0x61
|
||||
|
||||
#define SCD30_MAX_MISSED_READS 3
|
||||
@ -118,24 +120,23 @@ void Scd30Update(void)
|
||||
scd30ErrorState = SCD30_STATE_ERROR_DATA_CRC;
|
||||
scd30CrcError_count++;
|
||||
#ifdef SCD30_DEBUG
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: CRC error, CRC error: %ld, CO2 zero: %ld, good: %ld, no data: %ld, sc30_reset: %ld, i2c_reset: %ld", scd30CrcError_count, scd30Co2Zero_count, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: CRC error, CRC error: %ld, CO2 zero: %ld, good: %ld, no data: %ld, sc30_reset: %ld, i2c_reset: %ld"),
|
||||
scd30CrcError_count, scd30Co2Zero_count, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ERROR_SCD30_CO2_ZERO:
|
||||
scd30Co2Zero_count++;
|
||||
#ifdef SCD30_DEBUG
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: CO2 zero, CRC error: %ld, CO2 zero: %ld, good: %ld, no data: %ld, sc30_reset: %ld, i2c_reset: %ld", scd30CrcError_count, scd30Co2Zero_count, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: CO2 zero, CRC error: %ld, CO2 zero: %ld, good: %ld, no data: %ld, sc30_reset: %ld, i2c_reset: %ld"),
|
||||
scd30CrcError_count, scd30Co2Zero_count, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count);
|
||||
#endif
|
||||
break;
|
||||
|
||||
default: {
|
||||
scd30ErrorState = SCD30_STATE_ERROR_READ_MEAS;
|
||||
#ifdef SCD30_DEBUG
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: Update: ReadMeasurement error: 0x%lX, counter: %ld", error, scd30Loop_count);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: Update: ReadMeasurement error: 0x%lX, counter: %ld"), error, scd30Loop_count);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -147,10 +148,9 @@ void Scd30Update(void)
|
||||
case SCD30_STATE_ERROR_DATA_CRC: {
|
||||
//scd30IsDataValid = false;
|
||||
#ifdef SCD30_DEBUG
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld", scd30ErrorState, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: got CRC error, try again, counter: %ld", scd30Loop_count);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld"),
|
||||
scd30ErrorState, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: got CRC error, try again, counter: %ld"), scd30Loop_count);
|
||||
#endif
|
||||
scd30ErrorState = ERROR_SCD30_NO_ERROR;
|
||||
}
|
||||
@ -159,17 +159,15 @@ void Scd30Update(void)
|
||||
case SCD30_STATE_ERROR_READ_MEAS: {
|
||||
//scd30IsDataValid = false;
|
||||
#ifdef SCD30_DEBUG
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld", scd30ErrorState, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: not answering, sending soft reset, counter: %ld", scd30Loop_count);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld"),
|
||||
scd30ErrorState, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: not answering, sending soft reset, counter: %ld"), scd30Loop_count);
|
||||
#endif
|
||||
scd30Reset_count++;
|
||||
error = scd30.softReset();
|
||||
if (error) {
|
||||
#ifdef SCD30_DEBUG
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: resetting got error: 0x%lX", error);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: resetting got error: 0x%lX"), error);
|
||||
#endif
|
||||
error >>= 8;
|
||||
if (error == 4) {
|
||||
@ -186,18 +184,16 @@ void Scd30Update(void)
|
||||
case SCD30_STATE_ERROR_SOFT_RESET: {
|
||||
//scd30IsDataValid = false;
|
||||
#ifdef SCD30_DEBUG
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld", scd30ErrorState, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: clearing i2c bus");
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: in error state: %d, good: %ld, no data: %ld, sc30 reset: %ld, i2c reset: %ld"),
|
||||
scd30ErrorState, scd30GoodMeas_count, scd30DataNotAvailable_count, scd30Reset_count, i2cReset_count);
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("SCD30: clearing i2c bus"));
|
||||
#endif
|
||||
i2cReset_count++;
|
||||
error = scd30.clearI2CBus();
|
||||
if (error) {
|
||||
scd30ErrorState = SCD30_STATE_ERROR_I2C_RESET;
|
||||
#ifdef SCD30_DEBUG
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: error clearing i2c bus: 0x%lX", error);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: error clearing i2c bus: 0x%lX"), error);
|
||||
#endif
|
||||
} else {
|
||||
scd30ErrorState = ERROR_SCD30_NO_ERROR;
|
||||
@ -342,8 +338,7 @@ bool Scd30CommandSensor()
|
||||
if (error)
|
||||
{
|
||||
#ifdef SCD30_DEBUG
|
||||
snprintf_P(log_data, sizeof(log_data), "SCD30: error getting FW version: 0x%lX", error);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("SCD30: error getting FW version: 0x%lX"), error);
|
||||
#endif
|
||||
serviced = false;
|
||||
}
|
||||
|
@ -397,22 +397,17 @@ void ChirpEvery100MSecond(void)
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
// normaly in i18n.h
|
||||
|
||||
#define D_JSON_MOISTURE "Moisture"
|
||||
#define D_JSON_DARKNESS "Darkness"
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
// {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
|
||||
const char HTTP_SNS_MOISTURE[] PROGMEM = "{s} " D_JSON_MOISTURE "{m}%s %{e}";
|
||||
const char HTTP_SNS_DARKNESS[] PROGMEM = "{s} " D_JSON_DARKNESS "{m}%s %{e}";
|
||||
const char HTTP_SNS_CHIRPVER[] PROGMEM = "{s} CHIRP-sensor %u at address{m}0x%x{e}"
|
||||
"{s} FW-version{m}%s {e}"; ;
|
||||
const char HTTP_SNS_CHIRPSLEEP[] PROGMEM = "{s} {m} is sleeping ...{e}";
|
||||
const char HTTP_SNS_DARKNESS[] PROGMEM = "{s} " D_JSON_DARKNESS "{m}%s %%{e}";
|
||||
const char HTTP_SNS_CHIRPVER[] PROGMEM = "{s} CHIRP-sensor %u at address{m}0x%x{e}"
|
||||
"{s} FW-version{m}%s {e}"; ;
|
||||
const char HTTP_SNS_CHIRPSLEEP[] PROGMEM = "{s} {m} is sleeping ...{e}";
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
void ChirpShow(bool json)
|
||||
@ -420,8 +415,6 @@ void ChirpShow(bool json)
|
||||
for (uint32_t i = 0; i < chirp_found_sensors; i++) {
|
||||
if (chirp_sensor[i].version) {
|
||||
// convert double values to string
|
||||
char str_moisture[33];
|
||||
dtostrfd(chirp_sensor[i].moisture, 0, str_moisture);
|
||||
char str_temperature[33];
|
||||
double t_temperature = ((double) chirp_sensor[i].temperature )/10.0;
|
||||
dtostrfd(t_temperature, Settings.flag2.temperature_resolution, str_temperature);
|
||||
@ -434,9 +427,10 @@ void ChirpShow(bool json)
|
||||
else{
|
||||
sprintf(str_version, "%x", chirp_sensor[i].version);
|
||||
}
|
||||
|
||||
if (json) {
|
||||
if(!chirp_sensor[i].explicitSleep) {
|
||||
ResponseAppend_P(PSTR(",\"%s%u\":{\"" D_JSON_MOISTURE "\":%s"),chirp_name, i, str_moisture);
|
||||
ResponseAppend_P(PSTR(",\"%s%u\":{\"" D_JSON_MOISTURE "\":%d"), chirp_name, i, chirp_sensor[i].moisture);
|
||||
if(chirp_sensor[i].temperature!=-1){ // this is the error code -> no temperature
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_TEMPERATURE "\":%s"),str_temperature);
|
||||
}
|
||||
@ -447,9 +441,11 @@ void ChirpShow(bool json)
|
||||
}
|
||||
#ifdef USE_DOMOTICZ
|
||||
if (0 == tele_period) {
|
||||
DomoticzTempHumSensor(str_temperature, str_moisture);
|
||||
DomoticzSensor(DZ_ILLUMINANCE,chirp_sensor[i].light); // this is not LUX!!
|
||||
}
|
||||
char str_moisture[33];
|
||||
dtostrfd(chirp_sensor[i].moisture, 0, str_moisture);
|
||||
DomoticzTempHumSensor(str_temperature, str_moisture);
|
||||
DomoticzSensor(DZ_ILLUMINANCE,chirp_sensor[i].light); // this is not LUX!!
|
||||
}
|
||||
#endif // USE_DOMOTICZ
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
@ -458,10 +454,10 @@ void ChirpShow(bool json)
|
||||
WSContentSend_PD(HTTP_SNS_CHIRPSLEEP);
|
||||
}
|
||||
else {
|
||||
WSContentSend_PD(HTTP_SNS_MOISTURE, str_moisture);
|
||||
WSContentSend_PD(HTTP_SNS_MOISTURE, "", chirp_sensor[i].moisture);
|
||||
WSContentSend_PD(HTTP_SNS_DARKNESS, str_light);
|
||||
if(chirp_sensor[i].temperature!=-1){ // this is the error code -> no temperature
|
||||
WSContentSend_PD(HTTP_SNS_TEMP, " ",str_temperature, TempUnit());
|
||||
if (chirp_sensor[i].temperature!=-1) { // this is the error code -> no temperature
|
||||
WSContentSend_PD(HTTP_SNS_TEMP, "", str_temperature, TempUnit());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user