|
65 | 65 | #define PIR_LED_ON 3000
|
66 | 66 | #endif
|
67 | 67 | // **********************************************************************************
|
68 |
| -#define LED_RM 15 //digital pin for MIDDLE RED LED |
69 |
| -#define LED_GM 18 //digital pin for MIDDLE GREEN LED |
| 68 | +#define BTNCOUNT 2 //1 or 3 (2 also possible) |
| 69 | +#define BTNT 6 //digital pin of top button |
| 70 | +#define BTNB 4 //digital pin of bottom button |
| 71 | + |
70 | 72 | #define LED_RT 16 //digital pin for TOP RED LED
|
71 | 73 | #define LED_GT 19 //digital pin for TOP GREEN LED
|
72 | 74 | #define LED_RM 15 //digital pin for MIDDLE RED LED
|
| 75 | +//#define LED_GM 18 //digital pin for MIDDLE GREEN LED |
| 76 | +#define LED_RM 15 //digital pin for MIDDLE RED LED |
73 | 77 | #define LED_RB 14 //digital pin for BOTTOM RED LED
|
74 | 78 | #define LED_GB 17 //digital pin for BOTTOM GREEN LE
|
75 | 79 |
|
|
78 | 82 | #define RELAY1_INDEX 0 //index in btn[] array which is associated with the MAIN relay
|
79 | 83 | #define RELAY2_INDEX 1 //index in btn[] array which is associated with the secondary relay (SwitchMote 2x10A only)
|
80 | 84 |
|
81 |
| -#define BTNCOUNT 2 //1 or 3 (2 also possible) |
82 |
| -#define BTNM 5 //digital pin of middle button |
83 |
| -#define BTNT 6 //digital pin of top button |
84 |
| -#define BTNB 4 //digital pin of bottom button |
85 |
| - |
86 | 85 | #define BUTTON_BOUNCE_MS 200 //timespan before another button change can occur
|
87 | 86 | #define SYNC_ENTER 3000 //time required to hold a button before SwitchMote enters [SYNC mode]
|
88 | 87 | #define SYNC_TIME 20000 //max time spent in SYNC mode before returning to normal operation (you got this much time to SYNC 2 SMs, increase if need more time to walk)
|
@@ -154,11 +153,11 @@ unsigned long syncStart=0;
|
154 | 153 | unsigned long now=0;
|
155 | 154 | byte btnIndex=0; // as the sketch loops this index will loop through the available physical buttons
|
156 | 155 | byte mode[] = {ON,ON,ON}; //could use single bytes for efficiency but keeping it separate for clarity
|
157 |
| -byte btn[] = {BTNT, BTNM, BTNB}; |
| 156 | +byte btn[] = {BTNT, BTNB}; |
158 | 157 | byte btnLastState[]={RELEASED,RELEASED,RELEASED};
|
159 | 158 | unsigned long btnLastPress[]={0,0,0};
|
160 |
| -byte btnLEDRED[] = {LED_RT, LED_RM, LED_RB}; |
161 |
| -byte btnLEDGRN[] = {LED_GT, LED_GM, LED_GB}; |
| 159 | +byte btnLEDRED[] = {LED_RT, LED_RB}; |
| 160 | +byte btnLEDGRN[] = {LED_GT, LED_GB}; |
162 | 161 | uint32_t lastSYNC=0; //remember last status change - used to detect & stop loop conditions in circular SYNC scenarios
|
163 | 162 | char * buff="justAnEmptyString";
|
164 | 163 |
|
@@ -193,16 +192,14 @@ void setup(void)
|
193 | 192 | radio.enableAutoPower(ATC_RSSI);
|
194 | 193 | DEBUGln(F("\r\nRFM69_ATC Enabled (Auto Transmission Control)"));
|
195 | 194 | #endif
|
196 |
| - |
197 |
| - |
198 | 195 |
|
199 |
| - pinMode(LED_RM, OUTPUT);pinMode(LED_GM, OUTPUT); |
| 196 | + pinMode(LED_RM, OUTPUT);//pinMode(LED_GM, OUTPUT); |
200 | 197 | pinMode(LED_RT, OUTPUT);pinMode(LED_GT, OUTPUT);
|
201 | 198 | pinMode(LED_RB, OUTPUT);pinMode(LED_GB, OUTPUT);
|
202 | 199 | // by writing HIGH while in INPUT mode, the internal pullup is activated
|
203 | 200 | // the button will read 1 when RELEASED (because of the pullup)
|
204 | 201 | // the button will read 0 when PRESSED (because it's shorted to GND)
|
205 |
| - pinMode(BTNM, INPUT);digitalWrite(BTNM, HIGH); //activate pullup |
| 202 | + //pinMode(BTNM, INPUT);digitalWrite(BTNM, HIGH); //activate pullup |
206 | 203 | pinMode(BTNT, INPUT);digitalWrite(BTNT, HIGH); //activate pullup
|
207 | 204 | pinMode(BTNB, INPUT);digitalWrite(BTNB, HIGH); //activate pullup
|
208 | 205 | pinMode(RELAY1, OUTPUT);
|
@@ -441,7 +438,8 @@ void action(byte whichButtonIndex, byte whatMode, boolean notifyGateway)
|
441 | 438 | DEBUG(F("]:D"));
|
442 | 439 | DEBUG(btn[whichButtonIndex]);
|
443 | 440 | DEBUG(F(" - "));
|
444 |
| - DEBUG(btn[whichButtonIndex]==BTNT?F("TOP: "):btn[whichButtonIndex]==BTNM?F("MAIN: "):btn[whichButtonIndex]==BTNB?F("BOTTOM: "):F("UNKNOWN")); |
| 441 | + //DEBUG(btn[whichButtonIndex]==BTNT?F("TOP: "):btn[whichButtonIndex]==BTNM?F("MAIN: "):btn[whichButtonIndex]==BTNB?F("BOTTOM: "):F("UNKNOWN")); |
| 442 | + DEBUG(btn[whichButtonIndex]==BTNT?F("TOP: "):btn[whichButtonIndex]==BTNB?F("BOTTOM: "):F("UNKNOWN")); |
445 | 443 | DEBUG(whatMode==ON?F("ON "):F("OFF"));
|
446 | 444 |
|
447 | 445 | mode[whichButtonIndex] = whatMode;
|
|
0 commit comments