diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 276084707..874fa5e34 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,4 +1,7 @@ -/* 6.5.0.12 20190521 +/* 6.5.0.13 20190527 + * Add command SetOption38 6..255 to set IRReceive protocol detection sensitivity mimizing UNKNOWN protocols (#5853) + * + * 6.5.0.12 20190521 * Add AriLux RF control GPIO option "ALux IrSel" (159) replacing "Led4i" (59) for full LED control (#5709) * Add LED GPIO option "LedLink" (157) and "LedLinki" (158) to select dedicated link status LED (#5709) * Add support for up to four LEDs related to four power outputs. Enabled when "LedLink(i)" is configured too (#5709) diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index 32b656065..690340c86 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -417,7 +417,7 @@ #define USE_IR_RECEIVE // Support for IR receiver (+7k2 code, 264 iram) #define IR_RCV_BUFFER_SIZE 100 // Max number of packets allowed in capture buffer (default 100 (*2 bytes ram)) #define IR_RCV_TIMEOUT 15 // Number of milli-Seconds of no-more-data before we consider a message ended (default 15) - #define IR_RCV_MIN_UNKNOWN_SIZE 6 // Set the smallest sized "UNKNOWN" message packets we actually care about (default 6) + #define IR_RCV_MIN_UNKNOWN_SIZE 6 // Set the smallest sized "UNKNOWN" message packets we actually care about (default 6, max 255) #define USE_WS2812 // WS2812 Led string using library NeoPixelBus (+5k code, +1k mem, 232 iram) - Disable by // #define USE_WS2812_CTYPE NEO_GRB // WS2812 Color type (NEO_RGB, NEO_GRB, NEO_BRG, NEO_RBG, NEO_RGBW, NEO_GRBW) diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 7d957ba14..246b503b5 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -813,6 +813,9 @@ void SettingsDefaultSet2(void) // Settings.energy_kWhtotal = 0; RtcSettings.energy_kWhtotal = 0; + // IRRemote + Settings.param[P_IR_UNKNOW_THRESHOLD] = IR_RCV_MIN_UNKNOWN_SIZE; + // RF Bridge // for (uint8_t i = 0; i < 17; i++) { Settings.rf_code[i][0] = 0; } memcpy_P(Settings.rf_code[0], kDefaultRfCode, 9); @@ -1168,6 +1171,9 @@ void SettingsDelta(void) if (Settings.version < 0x0605000A) { Settings.my_adc0 = ADC0_NONE; } + if (Settings.version < 0x0605000D) { + Settings.param[P_IR_UNKNOW_THRESHOLD] = IR_RCV_MIN_UNKNOWN_SIZE; + } Settings.version = VERSION; SettingsSave(1); diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 8be609155..d7d4ef905 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -236,7 +236,7 @@ enum ButtonStates { PRESSED, NOT_PRESSED }; enum Shortcuts { SC_CLEAR, SC_DEFAULT, SC_USER }; -enum SettingsParmaIndex {P_HOLD_TIME, P_MAX_POWER_RETRY, P_TUYA_DIMMER_ID, P_MDNS_DELAYED_START, P_BOOT_LOOP_OFFSET, P_RGB_REMAP, P_MAX_PARAM8}; // Max is PARAM8_SIZE (18) - SetOption32 until SetOption49 +enum SettingsParmaIndex {P_HOLD_TIME, P_MAX_POWER_RETRY, P_TUYA_DIMMER_ID, P_MDNS_DELAYED_START, P_BOOT_LOOP_OFFSET, P_RGB_REMAP, P_IR_UNKNOW_THRESHOLD, P_MAX_PARAM8}; // Max is PARAM8_SIZE (18) - SetOption32 until SetOption49 enum DomoticzSensors {DZ_TEMP, DZ_TEMP_HUM, DZ_TEMP_HUM_BARO, DZ_POWER_ENERGY, DZ_ILLUMINANCE, DZ_COUNT, DZ_VOLTAGE, DZ_CURRENT, DZ_AIRQUALITY, DZ_MAX_SENSORS}; diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 48145fb2f..905e8b3ea 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -851,6 +851,11 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len) case P_RGB_REMAP: LightUpdateColorMapping(); break; +#ifdef USE_IR_RECEIVE + case P_IR_UNKNOW_THRESHOLD: + IrReceiveUpdateThreshold(); + break; +#endif } } } diff --git a/sonoff/sonoff_version.h b/sonoff/sonoff_version.h index e06fab8d0..8b7c27bfc 100644 --- a/sonoff/sonoff_version.h +++ b/sonoff/sonoff_version.h @@ -20,6 +20,6 @@ #ifndef _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_ -const uint32_t VERSION = 0x0605000C; +const uint32_t VERSION = 0x0605000D; #endif // _SONOFF_VERSION_H_ diff --git a/sonoff/xdrv_05_irremote.ino b/sonoff/xdrv_05_irremote.ino index 9f1c33a10..9bd0694e3 100644 --- a/sonoff/xdrv_05_irremote.ino +++ b/sonoff/xdrv_05_irremote.ino @@ -116,11 +116,17 @@ IRrecv *irrecv = nullptr; unsigned long ir_lasttime = 0; +void IrReceiveUpdateThreshold() +{ + if (Settings.param[P_IR_UNKNOW_THRESHOLD] < 6) { Settings.param[P_IR_UNKNOW_THRESHOLD] = 6; } + irrecv->setUnknownThreshold(Settings.param[P_IR_UNKNOW_THRESHOLD]); +} + void IrReceiveInit(void) { // an IR led is at GPIO_IRRECV irrecv = new IRrecv(pin[GPIO_IRRECV], IR_RCV_BUFFER_SIZE, IR_RCV_TIMEOUT, IR_RCV_SAVE_BUFFER); - irrecv->setUnknownThreshold(IR_RCV_MIN_UNKNOWN_SIZE); + irrecv->setUnknownThreshold(Settings.param[P_IR_UNKNOW_THRESHOLD]); irrecv->enableIRIn(); // Start the receiver // AddLog_P(LOG_LEVEL_DEBUG, PSTR("IrReceive initialized"));