Skip to content

Commit ae72ca2

Browse files
committed
First Commit
Basic underlaying framework and functional program trimmed for content.
0 parents  commit ae72ca2

File tree

11 files changed

+641
-0
lines changed

11 files changed

+641
-0
lines changed

babs.otf

61.8 KB
Binary file not shown.

background.png

11.5 KB
Loading

controlpanel.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# External module imports
2+
import RPi.GPIO as GPIO
3+
import time
4+
5+
# Pin Definitons:
6+
led1 = 16 # Broadcom pin 18 (P1 pin 12)
7+
led2 = 20 # Broadcom pin 23 (P1 pin 16)
8+
led3 = 21 # Broadcom pin 17 (P1 pin 11)
9+
10+
buta = 13
11+
butb = 19
12+
butc = 26
13+
14+
dc = 95 # duty cycle (0-100) for PWM pin
15+
16+
# Pin Setup:
17+
GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme
18+
GPIO.setup(led1, GPIO.OUT) # LED pin set as output
19+
GPIO.setup(led2, GPIO.OUT) # LED pin set as output
20+
GPIO.setup(led3, GPIO.OUT) # LED pin set as output
21+
GPIO.setup(buta, GPIO.IN) # PWM pin set as output
22+
GPIO.setup(butb, GPIO.IN) # PWM pin set as output
23+
GPIO.setup(butc, GPIO.IN) # PWM pin set as output
24+
25+
# Initial state for LEDs:
26+
GPIO.output(led1, GPIO.LOW)
27+
GPIO.output(led2, GPIO.LOW)
28+
GPIO.output(led3, GPIO.LOW)
29+
30+
31+
def leda_on():
32+
GPIO.output(led1, GPIO.HIGH)
33+
34+
def ledb_on():
35+
GPIO.output(led2, GPIO.HIGH)
36+
37+
def ledc_on():
38+
GPIO.output(led3, GPIO.HIGH)
39+
40+
def leda_off():
41+
GPIO.output(led1, GPIO.LOW)
42+
43+
def ledb_off():
44+
GPIO.output(led2, GPIO.LOW)
45+
46+
def ledc_off():
47+
GPIO.output(led3, GPIO.LOW)
48+
49+
flip = 0
50+
51+
try:
52+
while 1:
53+
if flip == 0:
54+
leda_on()
55+
ledb_off()
56+
ledc_off()
57+
if flip == 1:
58+
leda_off()
59+
ledb_on()
60+
ledc_off()
61+
if flip == 2:
62+
leda_off()
63+
ledb_off()
64+
ledc_on()
65+
flip = flip + 1
66+
67+
if flip > 2:
68+
flip = 0
69+
time.sleep(1)
70+
71+
except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:
72+
GPIO.cleanup() # cleanup all GPIO

getcpu.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from __future__ import division
2+
import copy
3+
import math
4+
import sys
5+
import os
6+
import psutil
7+
import time
8+
9+
10+
11+
12+
def sensorget():
13+
sensordict = {'humidity': 0, 'temp':0, 'humidtemp':0, 'pressuretemp':0,'pressure':0,'compass':0}
14+
sensordict['humidity'] = psutil.cpu_percent()
15+
sensordict['temp'] = psutil.cpu_percent()
16+
sensordict['humidtemp'] = psutil.cpu_percent()
17+
sensordict['pressuretemp'] = psutil.cpu_percent()
18+
sensordict['pressure'] = psutil.cpu_percent()
19+
sensordict['compass'] = psutil.cpu_percent()
20+
return sensordict
21+
22+
def printscreen(sensordict):
23+
print("Temperature: %s C" % sensordict['temp'])
24+
print("Temperature from humidity: %s C" % sensordict['humidtemp'])
25+
print("Temperature from pressure: %s C" % sensordict['pressuretemp'])
26+
print("Pressure: %s Millibars" % sensordict['pressure'])
27+
print("Humidity: %s %%rH" % sensordict['humidity'])
28+
print("North: %s" % sensordict['compass'])
29+

getweather.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import pyowm
2+
import time
3+
4+
5+
def sensorget():
6+
sensordict = {'humidity': 0, 'temp':0, 'humidtemp':0, 'pressuretemp':0,'pressure':0,'compass':0}
7+
8+
owm = pyowm.OWM('f8c43bbd601d39c177afabec2d050d04')
9+
observation = owm.weather_at_place('Toronto,CA')
10+
w = observation.get_weather()
11+
temp = w.get_temperature('celsius')
12+
humidity = w.get_humidity()
13+
pressure = w.get_pressure()
14+
timelast = timenow
15+
16+
17+
sensordict['humidity'] = humidity
18+
sensordict['temp'] = temp['temp']
19+
sensordict['pressure'] = pressure['press']
20+
21+
return sensordict
22+
23+
def printscreen(sensordict):
24+
print("Temperature: %s C" % sensordict['temp'])
25+
print("Temperature from humidity: %s C" % sensordict['humidtemp'])
26+
print("Temperature from pressure: %s C" % sensordict['pressuretemp'])
27+
print("Pressure: %s Millibars" % sensordict['pressure'])
28+
print("Humidity: %s %%rH" % sensordict['humidity'])
29+
print("North: %s" % sensordict['compass'])
30+

gpiobasics.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# External module imports
2+
import RPi.GPIO as GPIO
3+
import pygame
4+
import sys
5+
import time
6+
7+
# Pin Definitons:
8+
led1 = 4 # Broadcom pin 4 (Pi0 pin 7)
9+
led2 = 17 # Broadcom pin 17 (Pi0 pin 11)
10+
led3 = 27 # Broadcom pin 27 (P1 pin 13)
11+
12+
buta = 5
13+
butb = 6
14+
butc = 13
15+
16+
17+
# Pin Setup:
18+
GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme
19+
GPIO.setup(led1, GPIO.OUT) # LED pin set as output
20+
GPIO.setup(led2, GPIO.OUT) # LED pin set as output
21+
GPIO.setup(led3, GPIO.OUT) # LED pin set as output
22+
GPIO.setup(buta, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Circle Button for GPIO23
23+
GPIO.setup(butb, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Square Button for GPIO22
24+
GPIO.setup(butc, GPIO.IN, pull_up_down=GPIO.PUD_UP) #R Button for GPIO4
25+
26+
27+
def cleangpio():
28+
GPIO.cleanup() # cleanup all GPIO
29+
30+
def resetleds():
31+
GPIO.output(led1, GPIO.LOW)
32+
GPIO.output(led2, GPIO.LOW)
33+
GPIO.output(led3, GPIO.LOW)
34+
35+
36+
def leda_on():
37+
GPIO.output(led1, GPIO.HIGH)
38+
39+
def ledb_on():
40+
GPIO.output(led2, GPIO.HIGH)
41+
42+
def ledc_on():
43+
GPIO.output(led3, GPIO.HIGH)
44+
45+
def leda_off():
46+
GPIO.output(led1, GPIO.LOW)
47+
48+
def ledb_off():
49+
GPIO.output(led2, GPIO.LOW)
50+
51+
def ledc_off():
52+
GPIO.output(led3, GPIO.LOW)
53+
54+
def cycleloop():
55+
while True:
56+
try:
57+
leda_on()
58+
time.sleep(0.2)
59+
leda_off()
60+
time.sleep(0.2)
61+
ledb_on()
62+
time.sleep(0.2)
63+
ledb_off()
64+
time.sleep(0.2)
65+
ledc_on()
66+
time.sleep(0.2)
67+
ledc_off()
68+
time.sleep(0.2)
69+
except KeyboardInterrupt:
70+
print("cleaning up")
71+
72+
cleangpio()
73+
print("shutting down")
74+
sys.exit()
75+

insigniablue.png

8.09 KB
Loading

0 commit comments

Comments
 (0)