Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

Commit

Permalink
Merge pull request #5 from GeorgetownMakerHubOrg/capacitive-touch-upload
Browse files Browse the repository at this point in the history
Leverage Capacitive Touch for Upgrade
  • Loading branch information
cmpadden committed Jul 2, 2019
2 parents 86290d0 + 0ed17aa commit fa0d139
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 61 deletions.
4 changes: 4 additions & 0 deletions config-generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@

# Sleep time for wake/sleep cycle in milliseconds
SLEEP = 60 * 1000

# Capacitive Touch Parameters
TOUCH_PIN = 14
TOUCH_THRESHOLD = 100
44 changes: 44 additions & 0 deletions main.py
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)
61 changes: 0 additions & 61 deletions main~.py

This file was deleted.

0 comments on commit fa0d139

Please sign in to comment.