-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9022ed8
commit 3860ae3
Showing
24 changed files
with
417 additions
and
198 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VUE_APP_API_URL="http://localhost:5000/" |
Binary file not shown.
Binary file not shown.
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,114 @@ | ||
|
||
//Arduino pro micro, .93" I2C OLED use pin 2 for SDA and 3 for SCL ***Look up i2c pins for your controller | ||
|
||
#include <Wire.h> | ||
#include <Adafruit_GFX.h> | ||
#include <Adafruit_SSD1306.h> | ||
#define sensorPin A0 | ||
|
||
int OLED_RESET = 4; | ||
Adafruit_SSD1306 display(OLED_RESET); //driver for the screen | ||
|
||
// bar graph | ||
|
||
float rawval = 0; // Setup raw sensor value | ||
float barboost = 0; // Setup value for boost bar | ||
|
||
// peak | ||
|
||
int boostPeakReset = 4000; // time in milis to reset peak value | ||
float boostPeak = 0.00; | ||
float boostMax = 0.00; | ||
unsigned long boostPeakTimer = 0; | ||
|
||
|
||
|
||
// log | ||
|
||
byte count; | ||
byte sensorArray[128]; | ||
byte drawHeight; | ||
boolean filled = 0; //decide either filled, or dot-display. 0==dot display. | ||
|
||
|
||
//Send Data | ||
|
||
String sender; | ||
String peak; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); // start monitoring raw voltage for calibration | ||
display.begin(SSD1306_SWITCHCAPVCC); // 3.3V power supply | ||
display.clearDisplay(); // Clear the display and ram | ||
display.display(); | ||
delay(2000); // display Adafruit logo for 2 seconds | ||
for (count = 0; count <= 128; count++) //zero all elements | ||
{ | ||
sensorArray[count] = 0; | ||
} | ||
} | ||
|
||
|
||
void loop() // Start loop | ||
{ | ||
|
||
|
||
|
||
int boostmbar = map(analogRead(sensorPin), 21, 961, 100, 2600); | ||
rawval = analogRead(0); // Read MAP sensor raw value on analog port 0 | ||
barboost = (((rawval * 0.19) - 69.45) + 10); // Calculate boost value for the graph | ||
|
||
|
||
|
||
if (boostPeak < boostmbar && boostmbar > 0.50) { | ||
boostPeak = boostmbar; | ||
boostPeakTimer = millis(); | ||
if (boostMax < boostPeak) { | ||
boostMax = boostPeak; | ||
} | ||
} | ||
else if (boostPeak > boostmbar && (millis() - boostPeakTimer) > boostPeakReset) { | ||
boostPeak = 0.00; | ||
} | ||
|
||
|
||
// log | ||
|
||
drawHeight = map(analogRead(A0), 0, 1023, 0, 25 ); | ||
|
||
sensorArray[0] = drawHeight; | ||
|
||
for (count = 55; count <= 128; count++ ) | ||
{ | ||
if (filled == false) | ||
{ | ||
display.drawPixel(count, 71 - sensorArray[count - 55], WHITE); | ||
} | ||
else | ||
display.drawLine(count, 1, count, 71 - sensorArray[count - 55], WHITE); | ||
} | ||
|
||
for (count = 80; count >= 2; count--) // count down from 160 to 2 | ||
{ | ||
sensorArray[count - 1] = sensorArray[count - 2]; | ||
} | ||
; | ||
|
||
display.setTextSize(1); //Display peak boost | ||
display.setCursor(97, 10); | ||
peak = (((boostPeak * 0.001) - 0.865)*14); // 0.97 = 970mbar atmospheric pressure correction | ||
|
||
if ((((boostmbar * 0.001) - 0.865)*14) < 0) { | ||
display.println(((boostmbar * 0.001) - 0.865)*63.2); | ||
sender = "{'psi': "+String(((boostmbar * 0.001) - 0.865)*63.2)+",'peak': "+String(peak)+", 'raw': "+ String(rawval) +"}"; | ||
} | ||
else if ((((boostmbar * 0.001) - 0.865)*14) > 0) { | ||
display.println(((boostmbar * 0.001) - 0.865)*14); // calibrated for a 2.5 bar sensor in Denver (+/- 1psi) | ||
sender = "{'psi': "+String(((boostmbar * 0.001) - 0.865)*14)+", 'peak': "+String(peak)+",'raw': "+ String(rawval) +"}"; | ||
} | ||
|
||
delay(1); | ||
Serial.println(sender); | ||
delay(10); // delay half second between numbers | ||
} |
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,32 @@ | ||
import pynmea2 | ||
import time | ||
import json | ||
from termcolor import colored | ||
from core.serial import PortSerial | ||
|
||
class Analog(): | ||
|
||
def __init__(self, socketio, arduino_path, serial_class): | ||
self.socketio = socketio | ||
self.port_serial = PortSerial(arduino_path, serial_class) | ||
self.PORT = None | ||
|
||
def start(self): | ||
while self.port_serial.set_port(): | ||
print(colored("No Analog Devise connected in "+self.gps_path)) | ||
self.socketio.emit('gpsConnection', {'status': False}) | ||
time.sleep(2) | ||
self.PORT = self.port_serial.PORT | ||
# try: | ||
while True: | ||
self.parse_analog() | ||
# except: | ||
# self.port_serial.close() | ||
# self.start() | ||
|
||
def parse_analog(self): | ||
ard = self.PORT.readline().decode().replace("\r\n","") | ||
analog = eval(ard) | ||
self.socketio.emit('analogConnection', {'status': True}) | ||
self.socketio.emit("analog", {'turbo': {'psi': { 'value': analog['psi'], 'peak': analog['peak'], 'raw': analog['raw'] }, 'bar': {'value': round((analog['psi'] * 0.0689475729317831), 2), 'peak': round((analog['peak'] * 0.0689475729317831), 2) } }}) | ||
time.sleep(0.001) |
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 |
---|---|---|
@@ -1,24 +1,40 @@ | ||
import pynmea2 | ||
import time | ||
from termcolor import colored | ||
from core.serial import PortSerial | ||
|
||
class Gps(): | ||
|
||
def __init__(self, socketio, gps_path, serial_class): | ||
self.socketio = socketio | ||
self.gps_path = gps_path | ||
self.port_serial = PortSerial(gps_path, serial_class) | ||
self.PORT = None | ||
|
||
def start(self): | ||
while self.port_serial.set_port(): | ||
print("No GPS Devise connected in "+self.gps_path) | ||
self.socketio.emit('gps_conection', {'status': False}) | ||
while self.port_serial.set_port(): | ||
print(colored("No GPS Devise connected in "+self.gps_path)) | ||
self.socketio.emit('gpsConnection', {'status': False}) | ||
time.sleep(2) | ||
self.PORT = self.port_serial.PORT | ||
while True: | ||
self.parse_gps() | ||
try: | ||
while True: | ||
self.parse_gps() | ||
except: | ||
self.port_serial.close() | ||
self.start() | ||
|
||
def parse_gps(self): | ||
gps = self.PORT.readline().decode() | ||
if gps.find('GGA') > 0: | ||
msg = pynmea2.parse(gps) | ||
self.socketio.emit('gpsConnection', {'status': True, "signal": self.signal(msg.lat, msg.lon) }) | ||
self.socketio.emit("gps", {"lat": msg.lat, "lat_dir": msg.lat_dir, "lon": msg.lon, "lon_dir": msg.lon_dir, "altitude": msg.altitude, "altitude_long": msg.altitude_units, "sat_numbers": msg.num_sats}) | ||
print ("Timestamp: %s -- Lat: %s %s -- Lon: %s %s -- Altitude: %s %s -- Satellites: %s" % (msg.timestamp,msg.lat,msg.lat_dir,msg.lon,msg.lon_dir,msg.altitude,msg.altitude_units,msg.num_sats)) | ||
|
||
def signal(self, lat, lon): | ||
if lat == "" or lon == "": | ||
return False | ||
else: | ||
return True | ||
|
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
Oops, something went wrong.