Skip to content

Commit

Permalink
Itead Sonoff Mini support
Browse files Browse the repository at this point in the history
  • Loading branch information
xoseperez committed Sep 30, 2019
1 parent deb4657 commit 50eda33
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions code/espurna/config/arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
//#define ITEAD_SONOFF_DUAL_R2
//#define ITEAD_SONOFF_IFAN02
//#define ITEAD_SONOFF_LED
//#define ITEAD_SONOFF_MINI
//#define ITEAD_SONOFF_POW
//#define ITEAD_SONOFF_POW_R2
//#define ITEAD_SONOFF_RF
Expand Down
22 changes: 22 additions & 0 deletions code/espurna/config/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,28 @@
#define LED1_PIN 13
#define LED1_PIN_INVERSE 1

#elif defined(ITEAD_SONOFF_MINI)

// Info
#define MANUFACTURER "ITEAD"
#define DEVICE "SONOFF_MINI"

// Buttons
#define BUTTON1_PIN 0
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1
#define BUTTON2_PIN 14
#define BUTTON2_MODE BUTTON_SWITCH | BUTTON_SET_PULLUP | BUTTON_DEFAULT_HIGH
#define BUTTON2_RELAY 1

// Relays
#define RELAY1_PIN 12
#define RELAY1_TYPE RELAY_TYPE_NORMAL

// LEDs
#define LED1_PIN 13
#define LED1_PIN_INVERSE 1

#elif defined(ITEAD_SONOFF_TH)

// Info
Expand Down
12 changes: 12 additions & 0 deletions code/espurna/migrate.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,18 @@ void migrate() {
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);

#elif defined(ITEAD_SONOFF_MINI)

setSetting("board", 99);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("btnGPIO", 1, 4);
setSetting("btnRelay", 1, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);

#else

// Allow users to define new settings without migration config
Expand Down
10 changes: 10 additions & 0 deletions code/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,16 @@ build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RF
upload_port = ${common.ota_upload_port}
upload_flags = ${common.ota_upload_flags}

[env:itead-sonoff-mini]
board = ${common.board_1m}
build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_MINI

[env:itead-sonoff-mini-ota]
board = ${common.board_1m}
build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_MINI
upload_port = ${common.ota_upload_port}
upload_flags = ${common.ota_upload_flags}

[env:itead-sonoff-th]
board = ${common.board_1m}
build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_TH
Expand Down

2 comments on commit 50eda33

@pms77
Copy link

@pms77 pms77 commented on 50eda33 Sep 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Xose,

In the hardware file, shouldn't the Button2_Pin be the 4 instead of 14?

I don't know what is for migrate.ino file, but it seems the pin definition (line 1337) it's for the pin 4 (as it is working in my definition).

Regards,

@xoseperez
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed.
Sorry, didn't check the changes before committing...
Fixed in fe247c7

Please sign in to comment.