Skip to content

Commit

Permalink
Initial fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mtnorthcott committed Aug 21, 2016
1 parent c09ff14 commit fcde064
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
10 changes: 7 additions & 3 deletions interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def __init__(self):
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

for id in GPIO_OUT.values():
GPIO.setup(id, GPIO.OUT)

for id in GPIO_IN.values():
GPIO.setup(id, GPIO.IN)

self.is_green = False
self.is_orange = False
self.is_red = False
Expand All @@ -51,6 +57,7 @@ def __init__(self):
self.reset_all()

def reset_all(self):
self.buzz()
for id in GPIO_OUT.values():
GPIO.output(id, OFF)
self.is_green = False
Expand All @@ -59,19 +66,16 @@ def reset_all(self):

def set_green(self):
if self.is_green: return
self.buzz()
self.reset_all()
GPIO.output(ID_LED_GREEN, ON)

def set_orange(self):
if self.is_orange: return
self.buzz()
self.reset_all()
GPIO.output(ID_LED_ORANGE, ON)

def set_red(self):
if self.is_red: return
self.buzz()
self.reset_all()
self.is_red = True
thr = threading.Thread(target=self._red_subroutine, args=(conf.BUZZER_DURATION))
Expand Down
9 changes: 5 additions & 4 deletions lcd.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Northcott Monitor
# Written by Matthew Northcott
# 20-08-2016
# Python 3.4.3

__author__ = "Matthew Northcott"

# Spot Price Monitor
# Created by Matthew Northcott
# 21-08-2016
# Python 3.4.3

# IMPORTS
import RPi.GPIO as GPIO
Expand Down
10 changes: 2 additions & 8 deletions monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@
class Monitor(object):
def __init__(self, url):
self.webpage = webpage.Webpage(url)
self._open_webpage(url)
self.webpage.open()
self.update_values()

def _open_webpage(self, url):
success = self.webpage.open()


def update_values(self):
pass

Expand Down Expand Up @@ -192,13 +188,11 @@ def mainloop(self, length):

def main():
mon = MonitorInterface()
mon.mainloop(0)


if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
finally:
RPi.GPIO.cleanup()
GPIO.cleanup()
11 changes: 6 additions & 5 deletions webpage.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Northcott Monitor
# Written by Matthew Northcott
# 20-08-2016
# Python 3.4.3

__author__ = "Matthew Northcott"

# Spot Pricer
# Created by Matthew Northcott
# 27-02-2016
# Python 3.4.3

# IMPORTS
import urllib.request, urllib.error
Expand All @@ -13,7 +14,7 @@
import queue

# GLOBALS
HEADERS = {'User-Agent': 'Mozilla/5.0'}
HEADERS = { 'User-Agent': 'Mozilla/5.0' }

# MAIN
class Webpage(object):
Expand Down

0 comments on commit fcde064

Please sign in to comment.