diff --git a/Adafruit_CircuitPython_SSD1306 b/Adafruit_CircuitPython_SSD1306 new file mode 160000 index 00000000..3e6b7f13 --- /dev/null +++ b/Adafruit_CircuitPython_SSD1306 @@ -0,0 +1 @@ +Subproject commit 3e6b7f13a406cc210718ff19704319c783e96740 diff --git a/BACKRG__.TTF b/BACKRG__.TTF new file mode 100644 index 00000000..c4293e2d Binary files /dev/null and b/BACKRG__.TTF differ diff --git a/PRSANSR.TTF b/PRSANSR.TTF new file mode 100644 index 00000000..86c11466 Binary files /dev/null and b/PRSANSR.TTF differ diff --git a/b.ttf b/b.ttf new file mode 100644 index 00000000..c4293e2d Binary files /dev/null and b/b.ttf differ diff --git a/display.py b/display.py new file mode 100644 index 00000000..bf18fba4 --- /dev/null +++ b/display.py @@ -0,0 +1,37 @@ +import board +import digitalio +from PIL import Image, ImageDraw, ImageFont +import adafruit_ssd1306 +import sys +# Setting some variables for our reset pin etc. +RESET_PIN = digitalio.DigitalInOut(board.D4) + +# Very important... This lets py-gaugette 'know' what pins to use in order to reset the display +i2c = board.I2C() +display = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3c, reset=RESET_PIN) + +# Clear display. +display.fill(0) +display.show() + +# Load a font in 2 different sizes. +font = ImageFont.truetype('/home/pi/python-OBD/b.ttf', 28) + +image = Image.new('1', (display.width, display.height)) +draw = ImageDraw.Draw(image) +draw.text((0, 30), '!olleH', font=font, fill=255) +display.image(image) +display.show() + +x = sys.argv[1] +# Draw the text +# draw.text((34, 0), 'Hello!', font=font, fill=255) +#draw.text("Hello",34,0,color=0xFF0000,font_name=font) + +#display.text(x,0,34,0xFFFFF, font_name=font, size=2) + + + +# Display image +display.show() + diff --git a/font5x8.bin b/font5x8.bin new file mode 100644 index 00000000..9a0563ba Binary files /dev/null and b/font5x8.bin differ diff --git a/obdmac b/obdmac new file mode 100644 index 00000000..a35b2910 --- /dev/null +++ b/obdmac @@ -0,0 +1 @@ +00:1D:A5:03:1E:12 diff --git a/output.txt b/output.txt new file mode 100644 index 00000000..e69de29b diff --git a/test.py b/test.py new file mode 100644 index 00000000..d5a9ee39 --- /dev/null +++ b/test.py @@ -0,0 +1,89 @@ +import obd +import sys +import os +import time +import math +import subprocess +#obd.logger.setLevel(obd.logging.DEBUG) +from threading import * + +ports = obd.scan_serial() +#print (ports) +connection = obd.OBD(fast=True, timeout=30, check_voltage=False) # auto-connects to USB or RF port + +cmd = obd.commands.SPEED # select an OBD command (sensor) + +response = connection.query(cmd) # send the command, and parse the response + +#print(response.value) # returns unit-bearing values thanks to Pint +#print(response.value.to("mph")) # user-friendly unit conversions +screen_lock = Semaphore(value=1) +speed = 0 +rpm = 0 +middle = "" +msg = "" + +#rpmarr = [6786,5554,3334,6753,3256] +#speedarr = [20,30,40,60,80] + +def speedandrpm(): + global speed + global rpm + while(True): + time.sleep(0.2) + screen_lock.acquire() + try: + rpm = int(connection.query(obd.commands.RPM).value.magnitude) + print(rpm) + speed = int(connection.query(cmd).value.magnitude) + except: + print('RPM, Speed read error') + screen_lock.release() + print(speed) + +def voicerec(): + #time.sleep(10) + global middle + global msg + while(True): + msg = porcupineproc.stdout.readline().rstrip('\n') + if msg == 'picovoice': + print('picovoice detected') + screen_lock.acquire() + middle = str(connection.query(obd.commands.FUEL_LEVEL).value.magnitude) + screen_lock.release() + elif msg == 'porcupine': + screen_lock.acquire() + middle = str(connection.query(obd.commands.RUN_TIME).value.magnitude) + screen_lock.release() + #process.poll() + print(middle) + +def runGUI(): + time.sleep(20) + global speed + global rpm + global middle + while(True): + time.sleep(.1) + screen_lock.acquire() + val = str(speed)+','+str(rpm) + ',' + middle + '\n' + guiprocess.stdin.write(val) + screen_lock.release() + #print(val) + +t1 = Thread(target = speedandrpm) +porcupineproc = subprocess.Popen(['python3', '../porcupine-pi/demo/python/porcupine_demo_mic.py', '--keywords=porcupine,picovoice','--input_audio_device_index', '3'], stdout=subprocess.PIPE, universal_newlines=True) +t2 = Thread(target = voicerec) +guiprocess = subprocess.Popen(['python3', '../SeniorDesignGUI/GUI.py'], stdin=subprocess.PIPE, bufsize=1, universal_newlines=True, cwd='../SeniorDesignGUI/') +t3 = Thread(target = runGUI) +t2.start() +t1.start() +t3.start() + + + +#listener.close() + + +