This repository has been archived by the owner on Apr 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from GeorgetownMakerHubOrg/capacitive-touch-upload
Leverage Capacitive Touch for Upgrade
- Loading branch information
Showing
3 changed files
with
48 additions
and
61 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,44 @@ | ||
# GNU General Public License <https://www.gnu.org/licenses> | ||
# STIA436 Course - Spring 2019 | ||
# Professor Colin McCormick & Father Chris Wagner | ||
# Copyright (c) 2019 F. Pascal Girard | ||
|
||
import machine | ||
from machine import Timer, TouchPad, Pin | ||
from config import TOUCH_PIN, TOUCH_THRESHOLD | ||
|
||
|
||
TIMER_0 = Timer(0) | ||
TOUCH_PAD = TouchPad(Pin(TOUCH_PIN)) | ||
|
||
|
||
def run(timer): | ||
|
||
touch_value = TOUCH_PAD.read() | ||
print("Touch Value: {}, Touch Threshold {}".format(touch_value, TOUCH_THRESHOLD)) | ||
|
||
# When the touch value is above the threshold, then it is not being touched | ||
if touch_value > TOUCH_THRESHOLD: | ||
print("Running Sensors...") | ||
import wake | ||
|
||
wake.main() | ||
else: | ||
print("Starting AP and Web REPL...") | ||
import webrepl | ||
import iot | ||
|
||
iot.init_sta(False) | ||
iot.init_ap(True) | ||
webrepl.start() | ||
|
||
|
||
if machine.reset_cause() == machine.DEEPSLEEP_RESET: | ||
print("Woke from a deep sleep...") | ||
import wake | ||
|
||
wake.main() | ||
|
||
else: # an opportunity to enter WebREPL after hard reset | ||
print("Hard reset") | ||
TIMER_0.init(period=5000, mode=Timer.ONE_SHOT, callback=run) |