Add SetOption comments to code

This commit is contained in:
Theo Arends 2019-11-03 13:51:22 +01:00
parent 58959349fe
commit 4b49979274
22 changed files with 84 additions and 72 deletions

View File

@ -85,7 +85,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t ex_tuya_dimmer_min_limit : 1; // bit 19 (v6.6.0.5) - SetOption69 - Limits Tuya dimmers to minimum of 10% (25) when enabled.
uint32_t energy_weekend : 1; // bit 20 (v6.6.0.8) - CMND_TARIFF
uint32_t dds2382_model : 1; // bit 21 (v6.6.0.14) - SetOption71 - Select different Modbus registers for Active Energy (#6531)
uint32_t hardware_energy_total : 1; // bit 22 (v6.6.0.15) - SetOption72 - Enable / Disable hardware energy total counter as reference (#6561)
uint32_t hardware_energy_total : 1; // bit 22 (v6.6.0.15) - SetOption72 - Enable hardware energy total counter as reference (#6561)
uint32_t cors_enabled : 1; // bit 23 (v7.0.0.1) - SetOption73 - Enable HTTP CORS
uint32_t ds18x20_internal_pullup : 1; // bit 24 (v7.0.0.1) - SetOption74 - Enable internal pullup for single DS18x20 sensor
uint32_t grouptopic_mode : 1; // bit 25 (v7.0.0.1) - SetOption75 - GroupTopic replaces %topic% (0) or fixed topic cmnd/grouptopic (1)

View File

@ -495,7 +495,7 @@ char IndexSeparator()
return separators[Settings.flag3.use_underscore];
*/
if (Settings.flag3.use_underscore) {
if (Settings.flag3.use_underscore) { // SetOption64 - Enable "_" instead of "-" as sensor index separator
return '_';
} else {
return '-';
@ -1102,7 +1102,7 @@ uint8_t ValidPin(uint32_t pin, uint32_t gpio)
if (FlashPin(pin)) {
result = GPIO_NONE; // Disable flash pins GPIO6, GPIO7, GPIO8 and GPIO11
}
if ((WEMOS == Settings.module) && (!Settings.flag3.user_esp8285_enable)) {
if ((WEMOS == Settings.module) && (!Settings.flag3.user_esp8285_enable)) { // SetOption51 - Enable ESP8285 user GPIO's
if ((pin == 9) || (pin == 10)) { result = GPIO_NONE; } // Disable possible flash GPIO9 and GPIO10
}
return result;

View File

@ -485,11 +485,11 @@ void CmndState(void)
{
mqtt_data[0] = '\0';
MqttShowState();
if (Settings.flag3.hass_tele_on_power) {
if (Settings.flag3.hass_tele_on_power) { // SetOption59 - Send tele/%topic%/STATE in addition to stat/%topic%/RESULT
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_STATE), MQTT_TELE_RETAIN);
}
#ifdef USE_HOME_ASSISTANT
if (Settings.flag.hass_discovery) { // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59)
if (Settings.flag.hass_discovery) { // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59)
HAssPublishStatus();
}
#endif // USE_HOME_ASSISTANT

View File

@ -198,7 +198,7 @@ String GetDateAndTime(uint8_t time_type)
break;
}
String dt = GetDT(time); // 2017-03-07T11:08:02
if (Settings.flag3.time_append_timezone && (DT_LOCAL == time_type)) {
if (Settings.flag3.time_append_timezone && (DT_LOCAL == time_type)) { // SetOption52 - Append timezone to JSON time
dt += GetTimeZone(); // 2017-03-07T11:08:02-07:00
}
return dt; // 2017-03-07T11:08:02-07:00

View File

@ -125,10 +125,10 @@ void WiFiSetSleepMode(void)
// Sleep explanation: https://github.com/esp8266/Arduino/blob/3f0c601cfe81439ce17e9bd5d28994a7ed144482/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp#L255
#if defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
#else // Enabled in 2.3.0, 2.4.0 and stage
if (sleep && Settings.flag3.sleep_normal) {
WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times
if (sleep && Settings.flag3.sleep_normal) { // SetOption60 - Enable normal sleep instead of dynamic sleep
WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times
} else {
WiFi.setSleepMode(WIFI_MODEM_SLEEP); // Disable sleep (Esp8288/Arduino core and sdk default)
WiFi.setSleepMode(WIFI_MODEM_SLEEP); // Disable sleep (Esp8288/Arduino core and sdk default)
}
#endif
}
@ -407,7 +407,7 @@ void WifiCheckIp(void)
}
}
if (Wifi.retry) {
if (Settings.flag3.use_wifi_scan) {
if (Settings.flag3.use_wifi_scan) { // SetOption56 - Scan wifi network at restart for configured AP's
if (Wifi.retry_init == Wifi.retry) {
Wifi.scan_state = 1; // Select scanned SSID
}
@ -472,7 +472,7 @@ void WifiCheck(uint8_t param)
#endif // LWIP_IPV6=1
WifiSetState(1);
if (Settings.flag3.use_wifi_rescan) {
if (Settings.flag3.use_wifi_rescan) { // SetOption57 - Scan wifi network every 44 minutes for configured AP's
if (!(uptime % (60 * WIFI_RESCAN_MINUTES))) {
Wifi.scan_state = 2;
}
@ -486,7 +486,7 @@ void WifiCheck(uint8_t param)
#endif // FIRMWARE_MINIMAL
#ifdef USE_DISCOVERY
if (Settings.flag3.mdns_enabled) {
if (Settings.flag3.mdns_enabled) { // SetOption55 - Control mDNS service
if (!Wifi.mdns_begun) {
// if (mdns_delayed_start) {
// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_ATTEMPTING_CONNECTION));

View File

@ -294,7 +294,7 @@ char* GetGroupTopic_P(char *stopic, const char* subtopic)
{
// SetOption75 0: %prefix%/nothing/%topic% = cmnd/nothing/<grouptopic>/#
// SetOption75 1: cmnd/<grouptopic>
return GetTopic_P(stopic, (Settings.flag3.grouptopic_mode) ? CMND +8 : CMND, Settings.mqtt_grptopic, subtopic);
return GetTopic_P(stopic, (Settings.flag3.grouptopic_mode) ? CMND +8 : CMND, Settings.mqtt_grptopic, subtopic); // SetOption75 - GroupTopic replaces %topic% (0) or fixed topic cmnd/grouptopic (1)
}
char* GetFallbackTopic_P(char *stopic, const char* subtopic)
@ -535,8 +535,11 @@ bool SendKey(uint32_t key, uint32_t device, uint32_t state)
if (CLEAR_RETAIN == state) {
mqtt_data[0] = '\0';
} else {
if ((Settings.flag3.button_switch_force_local || !strcmp(mqtt_topic, key_topic) || !strcmp(Settings.mqtt_grptopic, key_topic)) && (POWER_TOGGLE == state)) {
state = ~(power >> (device -1)) &1; // POWER_OFF or POWER_ON
if ((Settings.flag3.button_switch_force_local || // SetOption61 - Force local operation when button/switch topic is set
!strcmp(mqtt_topic, key_topic) ||
!strcmp(Settings.mqtt_grptopic, key_topic)) &&
(POWER_TOGGLE == state)) {
state = ~(power >> (device -1)) &1; // POWER_OFF or POWER_ON
}
snprintf_P(mqtt_data, sizeof(mqtt_data), GetStateText(state));
}
@ -549,7 +552,7 @@ bool SendKey(uint32_t key, uint32_t device, uint32_t state)
#ifdef USE_DOMOTICZ
}
#endif // USE_DOMOTICZ
result = !Settings.flag3.button_switch_force_local;
result = !Settings.flag3.button_switch_force_local; // SetOption61 - Force local operation when button/switch topic is set
} else {
Response_P(PSTR("{\"%s%d\":{\"State\":%d}}"), (key) ? "Switch" : "Button", device, state);
result = XdrvRulesProcess();
@ -644,7 +647,7 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source)
#ifdef USE_KNX
KnxUpdatePowerState(device, power);
#endif // USE_KNX
if (publish_power && Settings.flag3.hass_tele_on_power) {
if (publish_power && Settings.flag3.hass_tele_on_power) { // SetOption59 - Send tele/%topic%/STATE in addition to stat/%topic%/RESULT
MqttPublishTeleState();
}
if (device <= MAX_PULSETIMERS) { // Restart PulseTime if powered On
@ -716,7 +719,8 @@ void MqttShowState(void)
#endif
ResponseAppend_P(PSTR(",\"" D_JSON_HEAPSIZE "\":%d,\"SleepMode\":\"%s\",\"Sleep\":%u,\"LoadAvg\":%u,\"MqttCount\":%u"),
ESP.getFreeHeap()/1024, GetTextIndexed(stemp1, sizeof(stemp1), Settings.flag3.sleep_normal, kSleepMode), sleep, loop_load_avg, MqttConnectCount());
ESP.getFreeHeap()/1024, GetTextIndexed(stemp1, sizeof(stemp1), Settings.flag3.sleep_normal, kSleepMode), // SetOption60 - Enable normal sleep instead of dynamic sleep
sleep, loop_load_avg, MqttConnectCount());
for (uint32_t i = 1; i <= devices_present; i++) {
#ifdef USE_LIGHT
@ -1546,7 +1550,7 @@ void setup(void)
if (Settings.param[P_BOOT_LOOP_OFFSET]) {
// Disable functionality as possible cause of fast restart within BOOT_LOOP_TIME seconds (Exception, WDT or restarts)
if (RtcReboot.fast_reboot_count > Settings.param[P_BOOT_LOOP_OFFSET]) { // Restart twice
Settings.flag3.user_esp8285_enable = 0; // Disable ESP8285 Generic GPIOs interfering with flash SPI
Settings.flag3.user_esp8285_enable = 0; // SetOption51 - Enable ESP8285 user GPIO's - Disable ESP8285 Generic GPIOs interfering with flash SPI
if (RtcReboot.fast_reboot_count > Settings.param[P_BOOT_LOOP_OFFSET] +1) { // Restart 3 times
for (uint32_t i = 0; i < MAX_RULE_SETS; i++) {
if (bitRead(Settings.rule_stop, i)) {
@ -1624,7 +1628,7 @@ void setup(void)
// Issue #526 and #909
for (uint32_t i = 0; i < devices_present; i++) {
if (!Settings.flag3.no_power_feedback) { // #5594 and #5663
if (!Settings.flag3.no_power_feedback) { // SetOption63 - Don't scan relay power state at restart - #5594 and #5663
if ((i < MAX_RELAYS) && (pin[GPIO_REL1 +i] < 99)) {
bitWrite(power, i, digitalRead(pin[GPIO_REL1 +i]) ^ bitRead(rel_inverted, i));
}
@ -1718,15 +1722,15 @@ void loop(void)
uint32_t my_activity = millis() - my_sleep;
if (Settings.flag3.sleep_normal) {
// yield(); // yield == delay(0), delay contains yield, auto yield in loop
delay(sleep); // https://github.com/esp8266/Arduino/issues/2021
if (Settings.flag3.sleep_normal) { // SetOption60 - Enable normal sleep instead of dynamic sleep
// yield(); // yield == delay(0), delay contains yield, auto yield in loop
delay(sleep); // https://github.com/esp8266/Arduino/issues/2021
} else {
if (my_activity < (uint32_t)sleep) {
delay((uint32_t)sleep - my_activity); // Provide time for background tasks like wifi
delay((uint32_t)sleep - my_activity); // Provide time for background tasks like wifi
} else {
if (global_state.wifi_down) {
delay(my_activity /2); // If wifi down and my_activity > setoption36 then force loop delay to 1/3 of my_activity period
delay(my_activity /2); // If wifi down and my_activity > setoption36 then force loop delay to 1/3 of my_activity period
}
}
}

View File

@ -669,7 +669,7 @@ bool HttpCheckPriviledgedAccess(bool autorequestauth = true)
void HttpHeaderCors(void)
{
if (Settings.flag3.cors_enabled) {
if (Settings.flag3.cors_enabled) { // SetOption73 - Enable HTTP CORS
WebServer->sendHeader(F("Access-Control-Allow-Origin"), F("*"));
}
}
@ -834,7 +834,7 @@ void WSContentSendStyle_P(const char* formatP, ...)
#endif
WebColor(COL_TITLE),
ModuleName().c_str(), Settings.friendlyname[0]);
if (Settings.flag3.gui_hostname_ip) {
if (Settings.flag3.gui_hostname_ip) { // SetOption53 - Show hostanme and IP address in GUI main menu
bool lip = (static_cast<uint32_t>(WiFi.localIP()) != 0);
bool sip = (static_cast<uint32_t>(WiFi.softAPIP()) != 0);
WSContentSend_P(PSTR("<h4>%s%s (%s%s%s)</h4>"), // sonoff.local (192.168.2.12, 192.168.4.1)
@ -991,7 +991,7 @@ void HandleRoot(void)
if (devices_present) {
#ifdef USE_LIGHT
if (light_type) {
if (!Settings.flag3.pwm_multi_channels) { // SetOption68 0
if (!Settings.flag3.pwm_multi_channels) { // SetOption68 0 - Enable multi-channels PWM instead of Color PWM
if ((LST_COLDWARM == (light_type &7)) || (LST_RGBWC == (light_type &7))) {
// Cold - Warm &t related to lb("t", value) and WebGetArg("t", tmp, sizeof(tmp));
WSContentSend_P(HTTP_MSG_SLIDER1, F(D_COLDLIGHT), F(D_WARMLIGHT),
@ -1000,7 +1000,7 @@ void HandleRoot(void)
// Dark - Bright &d related to lb("d", value) and WebGetArg("d", tmp, sizeof(tmp));
WSContentSend_P(HTTP_MSG_SLIDER1, F(D_DARKLIGHT), F(D_BRIGHTLIGHT),
1, 100, Settings.light_dimmer, 'd');
} else { // Settings.flag3.pwm_multi_channels - SetOption68 1
} else { // Settings.flag3.pwm_multi_channels - SetOption68 1 - Enable multi-channels PWM instead of Color PWM
uint32_t pwm_channels = (light_type & 7) > LST_MAX ? LST_MAX : (light_type & 7);
for (uint32_t i = 0; i < pwm_channels; i++) {
snprintf_P(stemp, sizeof(stemp), PSTR("c%d"), i);
@ -1012,7 +1012,7 @@ void HandleRoot(void)
}
#endif
#ifdef USE_SHUTTER
if (Settings.flag3.shutter_mode) { // SetOption80 1
if (Settings.flag3.shutter_mode) { // SetOption80 - Enable shutter support
for (uint32_t i = 0; i < shutters_present; i++) {
WSContentSend_P(HTTP_MSG_SLIDER2, F(D_CLOSE), F(D_OPEN),
0, 100, Settings.shutter_position[i], 'u', i+1);
@ -1927,8 +1927,8 @@ void HandleInformation(void)
#endif // USE_EMULATION
#ifdef USE_DISCOVERY
WSContentSend_P(PSTR("}1" D_MDNS_DISCOVERY "}2%s"), (Settings.flag3.mdns_enabled) ? D_ENABLED : D_DISABLED);
if (Settings.flag3.mdns_enabled) {
WSContentSend_P(PSTR("}1" D_MDNS_DISCOVERY "}2%s"), (Settings.flag3.mdns_enabled) ? D_ENABLED : D_DISABLED); // SetOption55 - Control mDNS service
if (Settings.flag3.mdns_enabled) { // SetOption55 - Control mDNS service
#ifdef WEBSERVER_ADVERTISE
WSContentSend_P(PSTR("}1" D_MDNS_ADVERTISE "}2" D_WEB_SERVER));
#else

View File

@ -134,7 +134,7 @@ bool EnergyTariff1Active() // Off-Peak hours
dst = 1;
}
if (Settings.tariff[0][dst] != Settings.tariff[1][dst]) {
if (Settings.flag3.energy_weekend && ((RtcTime.day_of_week == 1) ||
if (Settings.flag3.energy_weekend && ((RtcTime.day_of_week == 1) || // CMND_TARIFF
(RtcTime.day_of_week == 7))) {
return true;
}
@ -199,7 +199,8 @@ void EnergyUpdateTotal(float value, bool kwh)
Energy.kWhtoday = (unsigned long)((value - Energy.start_energy) * multiplier);
}
if ((Energy.total < (value - 0.01)) && Settings.flag3.hardware_energy_total) { // We subtract a little offset to avoid continuous updates
if ((Energy.total < (value - 0.01)) && // We subtract a little offset to avoid continuous updates
Settings.flag3.hardware_energy_total) { // SetOption72 - Enable hardware energy total counter as reference (#6561)
RtcSettings.energy_kWhtotal = (unsigned long)((value * multiplier) - Energy.kWhtoday_offset - Energy.kWhtoday);
Settings.energy_kWhtotal = RtcSettings.energy_kWhtotal;
Energy.total = (float)(RtcSettings.energy_kWhtotal + Energy.kWhtoday_offset + Energy.kWhtoday) / 100000;
@ -613,13 +614,13 @@ void CmndTariff(void)
}
}
else if (XdrvMailbox.index == 9) {
Settings.flag3.energy_weekend = XdrvMailbox.payload & 1;
Settings.flag3.energy_weekend = XdrvMailbox.payload & 1; // CMND_TARIFF
}
Response_P(PSTR("{\"%s\":{\"Off-Peak\":{\"STD\":\"%s\",\"DST\":\"%s\"},\"Standard\":{\"STD\":\"%s\",\"DST\":\"%s\"},\"Weekend\":\"%s\"}}"),
XdrvMailbox.command,
GetMinuteTime(Settings.tariff[0][0]).c_str(),GetMinuteTime(Settings.tariff[0][1]).c_str(),
GetMinuteTime(Settings.tariff[1][0]).c_str(),GetMinuteTime(Settings.tariff[1][1]).c_str(),
GetStateText(Settings.flag3.energy_weekend));
GetStateText(Settings.flag3.energy_weekend)); // CMND_TARIFF
}
void CmndPowerCal(void)

View File

@ -1127,10 +1127,10 @@ bool LightModuleInit(void)
}
// post-process for lights
if (Settings.flag3.pwm_multi_channels) {
if (Settings.flag3.pwm_multi_channels) { // SetOption68 - Enable multi-channels PWM instead of Color PWM
uint32_t pwm_channels = (light_type & 7) > LST_MAX ? LST_MAX : (light_type & 7);
if (0 == pwm_channels) { pwm_channels = 1; }
devices_present += pwm_channels - 1; // add the pwm channels controls at the end
devices_present += pwm_channels - 1; // add the pwm channels controls at the end
} else if ((Settings.param[P_RGB_REMAP] & 128) && (LST_RGBW <= (light_type & 7))) {
// if RGBW or RGBCW, and SetOption37 >= 128, we manage RGB and W separately, hence adding a device
devices_present++;
@ -1143,7 +1143,7 @@ void LightInit(void)
{
Light.device = devices_present;
Light.subtype = (light_type & 7) > LST_MAX ? LST_MAX : (light_type & 7); // Always 0 - LST_MAX (5)
Light.pwm_multi_channels = Settings.flag3.pwm_multi_channels;
Light.pwm_multi_channels = Settings.flag3.pwm_multi_channels; // SetOption68 - Enable multi-channels PWM instead of Color PWM
if (LST_RGBW <= Light.subtype) {
// only change if RGBW or RGBCW
@ -1458,7 +1458,9 @@ void LightPreparePower(void)
#endif // USE_DOMOTICZ
}
if (Settings.flag3.hass_tele_on_power) { MqttPublishTeleState(); }
if (Settings.flag3.hass_tele_on_power) { // SetOption59 - Send tele/%topic%/STATE in addition to stat/%topic%/RESULT
MqttPublishTeleState();
}
#ifdef DEBUG_LIGHT
AddLog_P2(LOG_LEVEL_DEBUG, "LightPreparePower End power=%d Light.power=%d", power, Light.power);
@ -2122,7 +2124,9 @@ void CmndScheme(void)
LightPowerOn();
Light.strip_timer_counter = 0;
// Publish state message for Hass
if (Settings.flag3.hass_tele_on_power) { MqttPublishTeleState(); }
if (Settings.flag3.hass_tele_on_power) { // SetOption59 - Send tele/%topic%/STATE in addition to stat/%topic%/RESULT
MqttPublishTeleState();
}
}
ResponseCmndNumber(Settings.light_scheme);
}

View File

@ -150,7 +150,7 @@ void IrReceiveCheck(void)
ResponseAppend_P(PSTR(",\"" D_JSON_IR_HASH "\":%s"), svalue);
}
if (Settings.flag3.receive_raw) {
if (Settings.flag3.receive_raw) { // SetOption58 - Add IR Raw data to JSON message
ResponseAppend_P(PSTR(",\"" D_JSON_IR_RAWDATA "\":["));
uint16_t i;
for (i = 1; i < results.rawlen; i++) {

View File

@ -208,7 +208,7 @@ void IrReceiveCheck(void)
ir_lasttime = now;
Response_P(PSTR("{\"" D_JSON_IRRECEIVED "\":%s"), sendIRJsonState(results).c_str());
if (Settings.flag3.receive_raw) {
if (Settings.flag3.receive_raw) { // SetOption58 - Add IR Raw data to JSON message
ResponseAppend_P(PSTR(",\"" D_JSON_IR_RAWDATA "\":["));
uint16_t i;
for (i = 1; i < results.rawlen; i++) {

View File

@ -267,7 +267,8 @@ void TimerEverySecond(void)
{
if (RtcTime.valid) {
if (!RtcTime.hour && !RtcTime.minute && !RtcTime.second) { TimerSetRandomWindows(); } // Midnight
if (Settings.flag3.timers_enable && (uptime > 60) && (RtcTime.minute != timer_last_minute)) { // Execute from one minute after restart every minute only once
if (Settings.flag3.timers_enable && // CMND_TIMERS
(uptime > 60) && (RtcTime.minute != timer_last_minute)) { // Execute from one minute after restart every minute only once
timer_last_minute = RtcTime.minute;
int32_t time = (RtcTime.hour *60) + RtcTime.minute;
uint8_t days = 1 << (RtcTime.day_of_week -1);
@ -461,14 +462,14 @@ void CmndTimers(void)
{
if (XdrvMailbox.data_len) {
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) {
Settings.flag3.timers_enable = XdrvMailbox.payload;
Settings.flag3.timers_enable = XdrvMailbox.payload; // CMND_TIMERS
}
if (XdrvMailbox.payload == 2) {
Settings.flag3.timers_enable = !Settings.flag3.timers_enable;
Settings.flag3.timers_enable = !Settings.flag3.timers_enable; // CMND_TIMERS
}
}
ResponseCmndStateText(Settings.flag3.timers_enable);
ResponseCmndStateText(Settings.flag3.timers_enable); // CMND_TIMERS
MqttPublishPrefixTopic_P(RESULT_OR_STAT, XdrvMailbox.command);
uint32_t jsflg = 0;
@ -717,7 +718,7 @@ void HandleTimerConfiguration(void)
WSContentSend_P(HTTP_TIMER_SCRIPT5, MAX_TIMERS, devices_present);
WSContentSend_P(HTTP_TIMER_SCRIPT6, devices_present);
WSContentSendStyle_P(HTTP_TIMER_STYLE, WebColor(COL_FORM));
WSContentSend_P(HTTP_FORM_TIMER1, (Settings.flag3.timers_enable) ? " checked" : "");
WSContentSend_P(HTTP_FORM_TIMER1, (Settings.flag3.timers_enable) ? " checked" : ""); // CMND_TIMERS
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
WSContentSend_P(PSTR("%s%u"), (i > 0) ? "," : "", Settings.timer[i].data);
}
@ -738,10 +739,10 @@ void TimerSaveSettings(void)
char tmp[MAX_TIMERS *12]; // Need space for MAX_TIMERS x 10 digit numbers separated by a comma
Timer timer;
Settings.flag3.timers_enable = WebServer->hasArg("e0");
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);
snprintf_P(log_data, sizeof(log_data), 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

View File

@ -358,7 +358,7 @@ void HAssAnnounceSwitches(void)
// Check if MQTT message will be ON/OFF or TOGGLE
if (Settings.switchmode[switch_index] == FOLLOW || Settings.switchmode[switch_index] == FOLLOW_INV ||
Settings.flag3.button_switch_force_local ||
Settings.flag3.button_switch_force_local || // SetOption61 - Force local operation when button/switch topic is set
!strcmp(mqtt_topic, sw_topic) || !strcmp(Settings.mqtt_grptopic, sw_topic))
{
toggle = 0; // MQTT message will be ON/OFF
@ -390,7 +390,7 @@ void HAssAnnounceButtons(void)
}
// Check if MQTT message will be ON/OFF or TOGGLE
if (Settings.flag3.button_switch_force_local ||
if (Settings.flag3.button_switch_force_local || // SetOption61 - Force local operation when button/switch topic is set
!strcmp(mqtt_topic, key_topic) || !strcmp(Settings.mqtt_grptopic, key_topic))
{
toggle = 0; // MQTT message will be ON/OFF
@ -575,7 +575,7 @@ void HAssDiscovery(void)
if (Settings.flag.hass_discovery) { // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59)
Settings.flag.mqtt_response = 0; // SetOption4 - Switch between MQTT RESULT or COMMAND - Response always as RESULT and not as uppercase command
Settings.flag.decimal_text = 1; // SetOption17 - Switch between decimal or hexadecimal output - Respond with decimal color values
Settings.flag3.hass_tele_on_power = 1; // send tele/STATE message as stat/RESULT
Settings.flag3.hass_tele_on_power = 1; // SetOption59 - Send tele/%topic%/STATE in addition to stat/%topic%/RESULT - send tele/STATE message as stat/RESULT
// Settings.light_scheme = 0; // To just control color it needs to be Scheme 0
if (strcmp_P(Settings.mqtt_fulltopic, PSTR("%topic%/%prefix%/"))) {
strncpy_P(Settings.mqtt_fulltopic, PSTR("%topic%/%prefix%/"), sizeof(Settings.mqtt_fulltopic));

View File

@ -445,7 +445,8 @@ void TuyaProcessStatePacket(void) {
if (fnId == TUYA_MCU_FUNC_DIMMER) {
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Dim State=%d"), packetValue);
Tuya.new_dim = changeUIntScale(packetValue, 0, Settings.dimmer_hw_max, 0, 100);
if ((power || Settings.flag3.tuya_apply_o20) && (Tuya.new_dim > 0) && (abs(Tuya.new_dim - Settings.light_dimmer) > 1)) {
if ((power || Settings.flag3.tuya_apply_o20) && // SetOption54 - Apply SetOption20 settings to Tuya device
(Tuya.new_dim > 0) && (abs(Tuya.new_dim - Settings.light_dimmer) > 1)) {
Tuya.ignore_dim = true;
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), Tuya.new_dim );
@ -610,7 +611,7 @@ bool TuyaModuleSelected(void)
if (TuyaGetDpId(TUYA_MCU_FUNC_LOWPOWER_MODE) != 0) {
Tuya.low_power_mode = true;
Settings.flag3.fast_power_cycle_disable = true;
Settings.flag3.fast_power_cycle_disable = true; // SetOption65 - Disable fast power cycle detection for device reset
}
UpdateDevices();
@ -680,7 +681,7 @@ void TuyaSerialInput(void)
ResponseAppend_P(PSTR("}}"));
if (Settings.flag3.tuya_serial_mqtt_publish) {
if (Settings.flag3.tuya_serial_mqtt_publish) { // SetOption66 - Enable TuyaMcuReceived messages over Mqtt
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED));
} else {
AddLog_P(LOG_LEVEL_DEBUG, mqtt_data);

View File

@ -246,7 +246,7 @@ char prev_y_str[24] = "\0";
uint8_t getLocalLightSubtype(uint8_t device) {
if (light_type) {
if (device >= Light.device) {
if (Settings.flag3.pwm_multi_channels) {
if (Settings.flag3.pwm_multi_channels) { // SetOption68 - Enable multi-channels PWM instead of Color PWM
return LST_SINGLE; // If SetOption68, each channel acts like a dimmer
} else {
return Light.subtype; // the actual light
@ -576,7 +576,7 @@ void HueLights(String *path)
}
if (light_type && (local_light_subtype >= LST_SINGLE)) {
if (!Settings.flag3.pwm_multi_channels) {
if (!Settings.flag3.pwm_multi_channels) { // SetOption68 - Enable multi-channels PWM instead of Color PWM
light_state.getHSB(&hue, &sat, nullptr);
bri = light_state.getBri(); // get the combined bri for CT and RGB, not only the RGB one
ct = light_state.getCT();
@ -685,7 +685,7 @@ void HueLights(String *path)
} else
#endif
if (light_type && (local_light_subtype > LST_NONE)) { // not relay
if (!Settings.flag3.pwm_multi_channels) {
if (!Settings.flag3.pwm_multi_channels) { // SetOption68 - Enable multi-channels PWM instead of Color PWM
if (g_gotct) {
light_controller.changeCTB(ct, bri);
} else {

View File

@ -135,7 +135,7 @@ void SonoffIfanReceived(void)
}
if (6 == mode) {
// AA 55 01 06 00 01 01 09 - Buzzer
Settings.flag3.buzzer_enable = !Settings.flag3.buzzer_enable; // SetOption67
Settings.flag3.buzzer_enable = !Settings.flag3.buzzer_enable; // SetOption67 - Enable buzzer when available
}
if (7 == mode) {
// AA 55 01 07 00 01 01 0A - Rf long press - forget RF codes

View File

@ -80,7 +80,7 @@ void BuzzerBeep(uint32_t count) {
void BuzzerEnabledBeep(uint32_t count, uint32_t duration)
{
if (Settings.flag3.buzzer_enable) { // SetOption67
if (Settings.flag3.buzzer_enable) { // SetOption67 - Enable buzzer when available
BuzzerBeep(count, duration, 1, 0);
}
}

View File

@ -316,7 +316,8 @@ bool ShutterState(uint8_t device)
{
device--;
device &= 3;
return (Settings.flag3.shutter_mode && (Shutter.mask & (1 << (Settings.shutter_startrelay[device]-1))) );
return (Settings.flag3.shutter_mode && // SetOption80 - Enable shutter support
(Shutter.mask & (1 << (Settings.shutter_startrelay[device]-1))) );
}
void ShutterStartInit(uint8_t index, uint8_t direction, int32_t target_pos)
@ -638,7 +639,7 @@ bool Xdrv27(uint8_t function)
{
bool result = false;
if (Settings.flag3.shutter_mode) { // SetOption80 1
if (Settings.flag3.shutter_mode) { // SetOption80 - Enable shutter support
switch (function) {
case FUNC_PRE_INIT:
ShutterInit();

View File

@ -113,7 +113,7 @@ void Pcf8574Init()
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PCF: I2C shift i %d: %d. Powerstate: %d, devices_present: %d"), i,_result, Settings.power>>i&1, devices_present);
if (_result > 0) {
Pcf8574.pin[devices_present] = i + 8 * idx;
bitWrite(rel_inverted, devices_present, Settings.flag3.pcf8574_ports_inverted);
bitWrite(rel_inverted, devices_present, Settings.flag3.pcf8574_ports_inverted); // SetOption81 - Invert all ports on PCF8574 devices
devices_present++;
Pcf8574.max_connected_ports++;
}
@ -159,7 +159,7 @@ void HandlePcf8574(void)
WSContentStart_P(D_CONFIGURE_PCF8574);
WSContentSendStyle();
WSContentSend_P(HTTP_FORM_I2C_PCF8574_1, (Settings.flag3.pcf8574_ports_inverted) ? " checked" : "");
WSContentSend_P(HTTP_FORM_I2C_PCF8574_1, (Settings.flag3.pcf8574_ports_inverted) ? " checked" : ""); // SetOption81 - Invert all ports on PCF8574 devices
WSContentSend_P(HTTP_TABLE100);
for (uint32_t idx = 0; idx < Pcf8574.max_devices; idx++) {
for (uint32_t idx2 = 0; idx2 < 8; idx2++) { // 8 ports on PCF8574
@ -186,7 +186,7 @@ void Pcf8574SaveSettings()
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Start working on Save arguements: inverted:%d")), WebServer->hasArg("b1");
Settings.flag3.pcf8574_ports_inverted = WebServer->hasArg("b1");
Settings.flag3.pcf8574_ports_inverted = WebServer->hasArg("b1"); // SetOption81 - Invert all ports on PCF8574 devices
for (byte idx = 0; idx < Pcf8574.max_devices; idx++) {
byte count=0;
byte n = Settings.pcf8574_config[idx];

View File

@ -355,8 +355,8 @@ void ExsPacketProcess(void)
bool ExsModuleSelected(void)
{
Settings.light_correction = 0;
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
Settings.flag3.pwm_multi_channels = 1;
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
Settings.flag3.pwm_multi_channels = 1; // SetOption68 - Enable multi-channels PWM instead of Color PWM
SetSeriallog(LOG_LEVEL_NONE);
devices_present = +2;

View File

@ -66,7 +66,7 @@ void Dds2382EverySecond(void)
Energy.power_factor[0] = (float)((buffer[35] << 8) + buffer[36]) / 1000.0; // 1.00
Energy.frequency[0] = (float)((buffer[37] << 8) + buffer[38]) / 100.0; // 50.0 Hz
uint8_t offset = 11;
if (Settings.flag3.dds2382_model) {
if (Settings.flag3.dds2382_model) { // SetOption71 - Select different Modbus registers for Active Energy (#6531)
offset = 19;
}
Energy.export_active = (float)((buffer[offset] << 24) + (buffer[offset +1] << 16) + (buffer[offset +2] << 8) + buffer[offset +3]) / 100.0; // 429496729.0 W

View File

@ -74,7 +74,7 @@ uint8_t OneWireReset(void)
uint8_t retries = 125;
//noInterrupts();
pinMode(ds18x20_pin, Settings.flag3.ds18x20_internal_pullup ? INPUT_PULLUP : INPUT);
pinMode(ds18x20_pin, Settings.flag3.ds18x20_internal_pullup ? INPUT_PULLUP : INPUT); // SetOption74 - Enable internal pullup for single DS18x20 sensor
do {
if (--retries == 0) {
return 0;
@ -84,7 +84,7 @@ uint8_t OneWireReset(void)
pinMode(ds18x20_pin, OUTPUT);
digitalWrite(ds18x20_pin, LOW);
delayMicroseconds(480);
pinMode(ds18x20_pin, Settings.flag3.ds18x20_internal_pullup ? INPUT_PULLUP : INPUT);
pinMode(ds18x20_pin, Settings.flag3.ds18x20_internal_pullup ? INPUT_PULLUP : INPUT); // SetOption74 - Enable internal pullup for single DS18x20 sensor
delayMicroseconds(70);
uint8_t r = !digitalRead(ds18x20_pin);
//interrupts();
@ -113,7 +113,7 @@ uint8_t OneWireReadBit(void)
pinMode(ds18x20_pin, OUTPUT);
digitalWrite(ds18x20_pin, LOW);
delayMicroseconds(3);
pinMode(ds18x20_pin, Settings.flag3.ds18x20_internal_pullup ? INPUT_PULLUP : INPUT);
pinMode(ds18x20_pin, Settings.flag3.ds18x20_internal_pullup ? INPUT_PULLUP : INPUT); // SetOption74 - Enable internal pullup for single DS18x20 sensor
delayMicroseconds(10);
uint8_t r = digitalRead(ds18x20_pin);
//interrupts();