Skip to content

Commit

Permalink
Changed Sonoff 4CH Pro definitions to support built-in interlock mode
Browse files Browse the repository at this point in the history
  • Loading branch information
xoseperez committed Jan 9, 2018
1 parent eb00a4d commit 5ed7d55
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions code/espurna/config/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,37 @@
#define BUTTON3_RELAY 3
#define BUTTON4_RELAY 4

// Sonoff 4CH Pro uses a secondary STM32 microcontroller to handle
// buttons and relays, but it also forwards button presses to the ESP8285.
// This allows ESPurna to handle button presses -almost- the same way
// as with other devices except:
// * Double click seems to break/disable the button on the STM32 side
// * With S6 switch to 1 (self-locking and inching modes) everything's OK
// * With S6 switch to 0 (interlock mode) if there is a relay ON
// and you click on another relay button, the STM32 sends a "press"
// event for the button of the first relay (to turn it OFF) but it
// does not send a "release" event. It's like it's holding the
// button down since you can see it is still LOW.
// Whatever reason the result is that it may actually perform a
// long click or long-long click.
// The configuration below make the button toggle the relay on press events
// and disables any possibly harmful combination with S6 set to 0.
// If you are sure you will only use S6 to 1 you can comment the
// BUTTON1_LNGCLICK and BUTTON1_LNGLNGCLICK options below to recover the
// AP mode and factory reset functionalities.

#define BUTTON1_PRESS BUTTON_MODE_TOGGLE
#define BUTTON1_CLICK BUTTON_MODE_NONE
#define BUTTON1_DBLCLICK BUTTON_MODE_NONE
#define BUTTON1_LNGCLICK BUTTON_MODE_NONE
#define BUTTON1_LNGLNGCLICK BUTTON_MODE_NONE
#define BUTTON2_PRESS BUTTON_MODE_TOGGLE
#define BUTTON2_CLICK BUTTON_MODE_NONE
#define BUTTON3_PRESS BUTTON_MODE_TOGGLE
#define BUTTON3_CLICK BUTTON_MODE_NONE
#define BUTTON4_PRESS BUTTON_MODE_TOGGLE
#define BUTTON4_CLICK BUTTON_MODE_NONE

// Relays
#define RELAY1_PIN 12
#define RELAY2_PIN 5
Expand Down

0 comments on commit 5ed7d55

Please sign in to comment.