BMDatalogger V1.0.5 - Updated code for Nano + I2C

This commit is contained in:
BM Devs 2017-04-05 08:43:18 -04:00 committed by GitHub
parent 113e60a887
commit 843d147621
3 changed files with 29 additions and 27 deletions

View File

@ -59,21 +59,21 @@ Ecu::Ecu(){
} }
void Ecu::Connect() { void Ecu::Connect() {
Serial3.begin(38400); Serial.begin(38400);
Error = false; Error = false;
} }
void Ecu::Disconnect() { void Ecu::Disconnect() {
Serial3.end(); Serial.end();
Error = false; Error = false;
} }
bool Ecu::GetJ12Cut() { bool Ecu::GetJ12Cut() {
J12_Cut = true; J12_Cut = true;
Serial3.write((byte) 171); Serial.write((byte) 171);
if ((int) Serial3.read() != 205) { if ((int) Serial.read() != 205) {
//Serial3.end(); //Serial.end();
J12_Cut = false; J12_Cut = false;
Error = true; Error = true;
} }
@ -81,25 +81,25 @@ bool Ecu::GetJ12Cut() {
} }
void Ecu::GetData(){ void Ecu::GetData(){
while(Serial3.available()) { while(Serial.available()) {
for (int i = 0; i < Array_Size; i++){ for (int i = 0; i < Array_Size; i++){
Datalog_Bytes[i] = Serial3.read(); Datalog_Bytes[i] = Serial.read();
delay(1); delay(1);
} }
} }
Serial3.flush(); Serial.flush();
Serial3.write(" "); Serial.write(" ");
} }
void Ecu::SendRead(){ void Ecu::SendRead(){
unsigned long PreviousTimeRead = millis(); unsigned long PreviousTimeRead = millis();
Serial3.flush(); Serial.flush();
Serial3.write(" "); Serial.write(" ");
unsigned long PreviousTime = millis(); unsigned long PreviousTime = millis();
unsigned long Time = millis() - PreviousTime; unsigned long Time = millis() - PreviousTime;
while(Serial3.available() != Array_Size && (Time < Timeout_Time)) Time = millis() - PreviousTime; while(Serial.available() != Array_Size && (Time < Timeout_Time)) Time = millis() - PreviousTime;
if (Time >= Timeout_Time) { if (Time >= Timeout_Time) {
for (int i = 0; i < Array_Size; i++) for (int i = 0; i < Array_Size; i++)
@ -110,7 +110,7 @@ void Ecu::SendRead(){
} }
for (int i = 0; i < Array_Size; i++){ for (int i = 0; i < Array_Size; i++){
Datalog_Bytes[i] = Serial3.read(); Datalog_Bytes[i] = Serial.read();
delay(1); delay(1);
} }
@ -120,17 +120,17 @@ void Ecu::SendRead(){
} }
/*void Ecu::Send(){ /*void Ecu::Send(){
Serial3.flush(); Serial.flush();
Serial3.write(" "); Serial.write(" ");
} }
void Ecu::Read(){ void Ecu::Read(){
Error = false; Error = false;
unsigned long PreviousTimeRead = millis(); unsigned long PreviousTimeRead = millis();
if (Serial3.available() >= Array_Size) { if (Serial.available() >= Array_Size) {
for (int i = 0; i < Array_Size; i++){ for (int i = 0; i < Array_Size; i++){
Datalog_Bytes[i] = Serial3.read(); Datalog_Bytes[i] = Serial.read();
//delay(1); //delay(1);
} }
} else { } else {
@ -144,9 +144,9 @@ void Ecu::ReadAvailable(){
Error = false; Error = false;
unsigned long PreviousTimeRead = millis(); unsigned long PreviousTimeRead = millis();
if (Serial3.available() > 0) { if (Serial.available() > 0) {
for (int i = 0; i < Serial3.available(); i++){ for (int i = 0; i < Serial.available(); i++){
Datalog_Bytes[i] = Serial3.read(); Datalog_Bytes[i] = Serial.read();
//delay(1); //delay(1);
} }
} else { } else {
@ -157,7 +157,7 @@ void Ecu::ReadAvailable(){
} }
int Ecu::GetAvailable() { int Ecu::GetAvailable() {
return (int) Serial3.available(); return (int) Serial.available();
} }
int Ecu::GetReadTime() { int Ecu::GetReadTime() {

View File

@ -47,7 +47,7 @@
//##################################################### //#####################################################
//##################################################### //#####################################################
String VersionStr = "V1.0.4"; String VersionStr = "V1.0.5";
bool BypassJ12Error = false; bool BypassJ12Error = false;
bool Is20x04Screen = false; //Set to True is you run on a 20x04 Screen otherwise its a 16x02 bool Is20x04Screen = false; //Set to True is you run on a 20x04 Screen otherwise its a 16x02
int InjectorsSize = 450; int InjectorsSize = 450;
@ -55,17 +55,19 @@ int TrannyType = 5;
//Load Modules //Load Modules
#include "Wire.h" #include "Wire.h"
#include "LiquidCrystal.h" //#include "LiquidCrystal.h"
#include <LiquidCrystal_I2C.h>
#include "Ecu.h" #include "Ecu.h"
#include <LcdBarGraph.h> //#include <LcdBarGraph.h>
#include <stdio.h> #include <stdio.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
Ecu ecu; Ecu ecu;
//Set Inputs //Set Inputs
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); //LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int TopButton = 6; LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int BottomButton = 5; int TopButton = 7;
int BottomButton = 6;
//Buttons Vars //Buttons Vars
#define ON 1 #define ON 1

BIN
NewliquidCrystal_1.3.4.zip Normal file

Binary file not shown.