-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Steamswitch has now 3 modes: off, switch or trigger removed double pinmode declaration for Steamswitch
- Loading branch information
Showing
3 changed files
with
73 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* @file steamswitchvoid.h | ||
* | ||
* @brief | ||
*/ | ||
|
||
/** | ||
* @brief Digtalswitch input pin for STEAM SWITCH | ||
*/ | ||
|
||
int laststeamswitchTrigger = LOW; // the previous reading from the input pin | ||
int buttonStateSteamTrigger; // the current reading from the input pin | ||
unsigned long lastDebounceTimeSteamTrigger = 0; // the last time the output pin was toggled | ||
unsigned long debounceDelaySteamTrigger = 50; // the debounce time; increase if the output flickers | ||
|
||
void checksteamswitch() { | ||
#if STEAMSWITCHTYPE == 1 | ||
// Set steamON to 1 when steamswitch is HIGH | ||
if (digitalRead(PIN_STEAMSWITCH) == HIGH) { | ||
steamON = 1; | ||
} | ||
|
||
// if activated via web interface then steamFirstON == 1, prevent override | ||
if (digitalRead(PIN_STEAMSWITCH) == LOW && steamFirstON == 0) { | ||
steamON = 0; | ||
} | ||
#endif | ||
|
||
#if STEAMSWITCHTYPE == 2 // TRIGGER | ||
int reading = digitalRead(PIN_STEAMSWITCH); | ||
|
||
if (reading != laststeamswitchTrigger) { | ||
// reset the debouncing timer | ||
lastDebounceTimeSteamTrigger = millis(); | ||
} | ||
|
||
if ((millis() - lastDebounceTimeSteamTrigger) > debounceDelaySteamTrigger) { | ||
// whatever the reading is at, it's been there for longer than the debounce | ||
// delay, so take it as the actual current state: | ||
|
||
// if the button state has changed: | ||
if (reading != buttonStateSteamTrigger) { | ||
buttonStateSteamTrigger = reading; | ||
|
||
// only toggle heating power if the new button state is HIGH | ||
if (buttonStateSteamTrigger == HIGH) { | ||
if (steamON == 0) { | ||
Serial.println("Turn Steam ON"); | ||
steamON = 1; | ||
} else { | ||
Serial.println("Turn Steam OFF"); | ||
steamON = 0; | ||
} | ||
} | ||
} | ||
} | ||
|
||
laststeamswitchTrigger = reading; | ||
|
||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters