From 82ef09b684fd62935f8fba7e82280724e909e56e Mon Sep 17 00:00:00 2001 From: Jason2866 Date: Fri, 5 Apr 2019 08:41:26 +0200 Subject: [PATCH] Make MI Desk Lamp default off Mi Desk Lamp can be activated in my_user_config.h by setting uncommenting //#define ROTARY_V1 --- sonoff/my_user_config.h | 1 + sonoff/sonoff.ino | 4 ++++ sonoff/sonoff_template.h | 4 ++++ sonoff/support_rotary.ino | 6 ++++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index 5ba994a4b..6e62e3031 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -369,6 +369,7 @@ #define TUYA_DIMMER_ID 0 // Default dimmer Id #define USE_ARMTRONIX_DIMMERS // Add support for Armtronix Dimmers (+1k4 code) #define USE_PS_16_DZ // Add support for PS-16-DZ Dimmer +//#define ROTARY_V1 // Add support for MI Desk Lamp //#define USE_AZ7798 // Add support for AZ-Instrument 7798 CO2 datalogger (+1k6 code) //#define USE_PN532_HSU // Add support for PN532 using HSU (Serial) interface (+1k8 code, 140 bytes mem) // #define USE_PN532_CAUSE_EVENTS // Cause event execution for PN532_UID= and PN532_DATA=[if defined] (+ 30 bytes code) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index e85a26af2..c53510ada 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -2507,7 +2507,9 @@ void GpioInit(void) ButtonInit(); SwitchInit(); +#ifdef ROTARY_V1 RotaryInit(); +#endif #ifdef USE_WS2812 if (!light_type && (pin[GPIO_WS2812] < 99)) { // RGB led @@ -2700,7 +2702,9 @@ void loop(void) ButtonLoop(); SwitchLoop(); +#ifdef ROTARY_V1 RotaryLoop(); +#endif if (TimeReached(state_50msecond)) { SetNextTimeInterval(state_50msecond, 50); diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index b50c2184b..fbe5cd931 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -583,10 +583,12 @@ const uint8_t kGpioNiceList[] PROGMEM = { GPIO_SM16716_DAT, // SM16716 DATA GPIO_SM16716_SEL, // SM16716 SELECT #endif // USE_SM16716 +#ifdef ROTARY_V1 GPIO_ROT1A, // Rotary switch1 A Pin GPIO_ROT1B, // Rotary switch1 B Pin GPIO_ROT2A, // Rotary switch2 A Pin GPIO_ROT2B, // Rotary switch2 B Pin +#endif GPIO_ARIRFRCV, // AliLux RF Receive input #ifdef USE_HRE GPIO_HRE_CLOCK, @@ -656,7 +658,9 @@ const uint8_t kModuleNiceList[MAXMODULE] PROGMEM = { ARILUX_LC11, ZENGGE_ZF_WF017, HUAFAN_SS, +#ifdef ROTARY_V1 MI_DESK_LAMP, +#endif KMC_70011, AILIGHT, // Light Bulbs PHILIPS, diff --git a/sonoff/support_rotary.ino b/sonoff/support_rotary.ino index db88d8378..c04889a3f 100644 --- a/sonoff/support_rotary.ino +++ b/sonoff/support_rotary.ino @@ -17,8 +17,7 @@ along with this program. If not, see . */ -#define ROTARY_V1 -#ifdef ROTARY_V1 + /*********************************************************************************************\ * Rotary support \*********************************************************************************************/ @@ -31,6 +30,9 @@ uint8_t rotary_last_position = 128; uint8_t interrupts_in_use = 0; uint8_t rotary_changed = 0; +//#define ROTARY_V1 +#ifdef ROTARY_V1 + /********************************************************************************************/ void update_position(void)