Code :
////////UPDATE 02 = RPM AVAIBLE
volatile byte half_revolutions;
unsigned int rpm;
unsigned long timeold;
float vout = 0.0;
float vin = 0.0;
int v=0;
int i =0;
int ect=0;
float R1 =100000 ; // !! resistance of R1 !!
float R2 = 47000; // !! resistance of R2 !!
int volt = 0;
int lambda=0; //
float AFR=0;
int Map=0;
float Psi=0;
float psia=0;
float psig=0;
float vaccum=0;
float mBar=0;
float mV=0;
int ValueTPS=0;
int Tps=0;
float VoltTPS=0;
double V_IN = 5.0; //Alimentation électrique
//Information de la thermistance
double Rref = 10000.0; //Résistance de référence à 25°C
double A_1 = 3.354016E-3;
double B_1 = 2.569850E-4;
double C_1 = 2.620131E-6;
double D_1 = 6.383091E-8;
double SteinhartHart(double R){
//Division de l'équation en 4 parties. La premiere est
//uniquement A1
double equationB1 = B_1 * log(R/Rref);
double equationC1 = C_1 * pow(log(R/Rref), 2);
double equationD1 = D_1 * pow(log(R/Rref), 3);
double equation = A_1 + equationB1 + equationC1 + equationD1;
return pow(equation, -1); }
//Bouton Poussoir
const int bp=5;
boolean vbp=0;
boolean vbpmem=0;
int mode = 0;
//Nombre de mode
int nbrmode=10;
byte data[128] ; // Para guardar las lecturas
byte index = 0 ;
//________________________________________________________________________________//
/* Uncomment this block to use hardware SPI
#define OLED_DC 6
#define OLED_CS 7
#define OLED_RESET 8
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
*/
#include <math.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// If using software SPI (the default case):
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13
#define OLED_CS_2 4
#define OLED_RESET_2 3
Adafruit_SSD1306 display1(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
Adafruit_SSD1306 display2(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET_2, OLED_CS_2);
#define honda_HEIGHT 32
#define honda_WIDTH 128
const unsigned char honda [] PROGMEM = {
// bleed logo honda
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x07, 0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x07, 0xc0, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x40, 0x00, 0x03, 0xe0, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xf8, 0x00, 0x01, 0xf8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7e, 0x00, 0x01, 0xfc, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x80, 0x01, 0xfe, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0xe0, 0x07, 0xff, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x03, 0xff, 0xfc, 0x7f, 0x81, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, 0x00, 0xff, 0xc0, 0x0f, 0xc6, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x93, 0x00, 0x3f, 0xc0, 0x00, 0x7a, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0xc0, 0x1f, 0xc0, 0x0f, 0x0a, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x70, 0x07, 0xe3, 0xe0, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x1e, 0x00, 0x7c, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x03, 0xff, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x01, 0x48, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x01, 0x48, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x01, 0x48, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x03, 0x48, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x03, 0xd8, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x58, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0xb0, 0x00, 0xc0, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0xc0, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0xc0, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
void setup() {
Serial.begin(9600);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display1.begin();
display2.begin();
for (int i =0 ; i<128 ; i++) // Ponemso a 0 el array
data[i] = 0 ;
pinMode(bp, INPUT_PULLUP);
attachInterrupt(0, rpm_fun, RISING);
half_revolutions = 0;
rpm = 0;
timeold = 0;
}
void loop ()
{
vbp= digitalRead(bp); //Lecture de l'état du BP
if ((vbp != vbpmem)&&(vbp == LOW)) //si on appuie sur le BP
{
mode++; //On incrémente la variable mode
}
vbpmem=vbp; //on mémorise l'état du bouton
if (mode == nbrmode) //Qd la variable mode vaut nbrmode on la repasse à zéro (ie quand on attend le dernier mode)
{
mode=0;
}
switch (mode) //Application du mode
{
case 0:
display1.clearDisplay();
display2.clearDisplay();
Start();
break;
case 1:
display1.clearDisplay();
display2.clearDisplay();
TempEcIa();
TempExtBatt();
delay(400);
break;
case 2:
display1.clearDisplay();
display2.clearDisplay();
Lambda();
delay(200);
break;
case 3:
display1.clearDisplay();
display2.clearDisplay();
//display2.display();
MAP();
TPS();
delay(200);
break;
case 4:
display1.clearDisplay();
display2.clearDisplay();
display2.display();
Rpm();
///////////
break;
case 5:
display1.clearDisplay();
display2.clearDisplay();
//display2.display();
graphbatt();
graphbattlinea();
//graphect();
////////////////
break;
case 6:
display1.clearDisplay();
display2.clearDisplay();
display2.display();
graphect();
///////////////////
break;
case 7:
display1.clearDisplay();
display2.clearDisplay();
display2.display();
graphiat();
///////////////////
break;
case 8:
display1.clearDisplay();
display2.clearDisplay();
graphVo2();
grapho2linea();
break;
}
}
void Start()
{
display1.drawBitmap(0, 0, honda, 128, 32, 1);
display2.drawBitmap(0, 0, honda, 128, 32, 1);
display1.display();
display2.display();
}
void TempEcIa() // Engine coolant Temp sensor (A0)
{ // Intake Air Temp sensor (A1)
double ECT = analogRead(A0); //ENGINE COOLANT TEMPERATURE // Calcul de la tension sur la borne analogique
double V = (ECT / 1024) * V_IN;
double Rth = (Rref * V )/(V_IN - V); //Calcul de la résistance de la thermistance
//Serial.print("Rth = ");
//Serial.print(Rth);
double kelvin = SteinhartHart(Rth);//Calcul de la température en kelvin( Steinhart and Hart)
double celsius = kelvin - 273.15+8; //Conversion en celsius (+8 coeff yolo)
//Serial.print("Ohm - T = ");
double IATb = analogRead(A1); // INTAKE AIR TEMPERATURE
double VAb = IATb / 1024 * V_IN;
double RthAb = (Rref * VAb ) / (V_IN - VAb);
double kelvinAb = SteinhartHart(RthAb);
double celsiusAb = kelvinAb - 273.15+6.5;
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("ECT:");display1.print(celsius);
display1.setTextSize(1);
display1.println("\xf7""c");
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,16);
display1.print("IAT:");display1.print(celsiusAb);
display1.setTextSize(1);
display1.println("\xf7""c");
display1.display();
}
void TempExtBatt() // Outdoor Temperature IAT sensor or another (A2)
{ // Battery Voltage (A3)
display1.clearDisplay();
double IAT = analogRead(A2);
double VA = IAT / 1024 * V_IN;
double RthA = (Rref * VA ) / (V_IN - VA);
double kelvinA = SteinhartHart(RthA);
double celsiusA = kelvinA - 273.15+6.5;
volt = analogRead(A3);
vout = (volt * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2)); // Calcul pont diviseur
display2.setTextColor(WHITE);
display2.setCursor(0,0);
display2.setTextSize(2);
display2.print("T");
display2.setCursor(9,7);
display2.setTextSize(1);
display2.print("ext");
display2.setTextSize(2);
display2.setCursor(27,1);
display2.print(":");
display2.setCursor(39,1);
display2.print(celsiusA);
display2.setTextSize(1);
display2.println("\xf7""c");
display2.setTextColor(WHITE);
display2.setTextSize(2);
display2.setCursor(0,16);
display2.print("V");
display2.setTextSize(1);
display2.setCursor(13,23);
display2.print("batt");
display2.setTextSize(2);
display2.setCursor(37,16);
display2.print(":");
display2.setTextSize(2);
display2.setCursor(49,16);
display2.print(vin);
display2.setTextSize(1);
//display2.setCursor(110,23);
display2.println("V");
display2.display();
}
void Lambda() //o2Sensor narrow band, 1Volt o2signal (A4)
{
if (half_revolutions >= 24) {
//Update RPM every 20 counts, increase this for better RPM resolution,
//decrease for faster update
rpm = 30*100/(millis() - timeold)*half_revolutions;
timeold = millis();
half_revolutions = 0;
}
//analogReference(INTERNAL1V1);
lambda = analogRead(A4);
mV=lambda*4.88;
AFR = (lambda-0)*(11.78-17.66)/(1023-0)+17.7 ;
display2.setTextSize(2);
display2.setTextColor(WHITE);
display2.setCursor(0,0);
display2.print("\xE5:");display2.println(AFR);
display2.setTextSize(2);
display2.setTextColor(WHITE);
display2.setCursor(0,16);
display2.print("Rpm:");display2.println(rpm, DEC);
display2.display();
display2.clearDisplay();
display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.println(lambda);
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,16);
display1.print("V:");display1.print(mV);
display1.setTextSize(1);
display1.println("mV");
display1.display();
}
void MAP() //Manifold Absolute Pressure sensor (A5)
{
Map = analogRead(A5);
Psi = (Map-.32)*(10.94-(-13.9))/(1023+ (-13.9));
psig = Psi-14.7;
vaccum = psig*2.036021;
mBar = psig * 0.0689475729; // Convert from psi to bar
//Psi = ((((float)Map/(float)1023+0.04)/0.004)*0.145)-10.15;
//(Map-0.5)*(1023-167.77)/(4.5-0.5)+167.77;
//psia = (Psi-167.77)*(10.6-0.01)/(1023-167.77)+0.01;
//((Map * (0.005) /(0.022)+20)*(0.145)-10.15);
//display2.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("Psi:");display1.print(psig);
//display2.setTextSize(1);
//display2.println("b");
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,16);
display1.print("Vac:");display1.print(vaccum);
//display2.setTextSize(1);
//display2.println("");
display1.display();
//display2.clearDisplay();
}
void TPS() // TPS= Throttle Position Switch (A6)
{ display1.clearDisplay();
int ValueTPS = analogRead(A6);
float VoltTPS=(ValueTPS*5.0)/1024.0;
int Tps = map(ValueTPS,0,1023,-18,103)+5;
display2.setTextSize(2);
display2.setCursor(0,0);
display2.print("TPS:");display2.print(Tps);
display2.setTextSize(1);
display2.println("%");
display2.setTextSize(2);
display2.setCursor(0,16);
display2.print("V");
display2.setTextSize(1);
display2.setCursor(13,23);
display2.print("TPS");
display2.setTextSize(2);
display2.setCursor(37,16);
display2.print(":");
display2.setTextSize(2);
display2.setCursor(49,16);
display2.print(VoltTPS);
display2.setTextSize(1);
//display2.setCursor(110,23);
display2.println("V");
display2.display();
}
void rpm_fun()
{
half_revolutions++;
//Each rotation, this interrupt function is run twice
}
void Rpm()
{
//display2.clearDisplay();
// display1.display();
if (half_revolutions >= 24) {
//Update RPM every 20 counts, increase this for better RPM resolution,
//decrease for faster update
rpm = 30*100/(millis() - timeold)*half_revolutions;
timeold = millis();
half_revolutions = 0;
//Serial.println(rpm,DEC);
}
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("Rpm:");display1.println(rpm, DEC);
//draw the bar graph
display1.fillRect(rpm/100, 25, 128 - rpm/100, 6, BLACK);
display1.fillRect(0, 25, rpm/100, 6, WHITE);
for (i = 1; i < 13; i++)
{
display1.fillRect(i * 10, 25, 2, 6, BLACK);
}
display1.display();
//display1.clearDisplay();
delay(100);
}
void graphbatt()
{
display2.clearDisplay();
volt = analogRead(A3);
vout = (volt * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
v = volt / 7.99;
display1.setTextSize(1);
// note set the background color or the old text will still display
display1.setTextColor(WHITE, BLACK);
display1.setCursor(17, 0);
display1.println("BATTERY VOLTAGE");
//display1.println(Format(v * 7.99 / 204.6, 0, 3));
display1.setCursor(43, 12);
display1.print(vin);display1.println("V");
//draw the bar graph
display1.fillRect(v, 25, 128 - v, 6, BLACK);
display1.fillRect(0, 25, v, 6, WHITE);
for (i = 1; i < 13; i++)
{
display1.fillRect(i * 10, 25, 2, 6, BLACK);
}
display1.display();
}
void grapho2linea()
{
display1.clearDisplay();
display2.clearDisplay();
index = index % 128 ;
data[index] = 16 * analogRead(A4)/(128) ;// (128) resolution
index++ ;
lambda = analogRead(A4);
int AFR = (lambda * 4.88);
byte i = index ;
for (byte x = 0 ; x<128 ; x++)
{
i = i % 128 ;
//display2.drawPixel( x, data[i++], 1);
display2.drawLine(x, data[i], x-1, data[i-1], 1);
i++ ;
}
display2.setTextSize(1);
display2.setTextColor(WHITE);
display2.setCursor(12,25);
display2.print("O2 Sensor:");display2.print(AFR);
display2.print(" mV");
display2.display();
delay(10);
}
void graphVo2()
{
display2.clearDisplay();
volt = analogRead(A4);
vout =volt*4.88; //(volt * 5.0) / 1024.0;
//vin = vout / (R2/(R1+R2));
v = volt / 1.59; //1.99= (1023/4)/128
display1.setTextSize(1);
display1.setTextColor(WHITE, BLACK);// note set the background color or the old text will still display
display1.setCursor(13, 0);
display1.println("O2 SENSOR VOLTAGE");
//display1.println(Format(v * 7.99 / 204.6, 0, 3));
display1.setCursor(35, 12);
display1.print(vout);display1.println(" mV");
//draw the bar graph
display1.fillRect(v, 25, 128 - v, 6, BLACK);
display1.fillRect(0, 25, v, 6, WHITE);
for (i = 1; i < 13; i++)
{
display1.fillRect(i * 10, 25, 2, 6, BLACK);
}
display1.display();
}
void graphbattlinea()
{
display1.clearDisplay();
display2.clearDisplay();
index = index % 128 ;
data[index] = 16 * analogRead(A3)/(1024) ;
index++ ;
volt = analogRead(A3);
vout = (volt * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
v = volt / 7.99;
byte i = index ;
for (byte x = 0 ; x<128 ; x++)
{
i = i % 128 ;
display2.drawPixel( x, data[i++], 1);
//display2.drawLine(x, data[i], x-1, data[i-1], 1);
//i++ ;
}
display2.setTextSize(1);
display2.setTextColor(WHITE);
display2.setCursor(5,23);
display2.print("Batt Voltage:");display2.print(vin);
display2.print("V");
display2.display();
delay(10);
}
void graphect()
{
display2.clearDisplay();
double ECT = analogRead(A0); //ENGINE COOLANT TEMPERATURE // Calcul de la tension sur la borne analogique
v= ECT/3.99;
double V = (ECT / 1024) * V_IN;
double Rth = (Rref * V )/(V_IN - V); //Calcul de la résistance de la thermistance
//Serial.print("Rth = ");
//Serial.print(Rth);
double kelvin = SteinhartHart(Rth);//Calcul de la température en kelvin( Steinhart and Hart)
double celsius = kelvin - 273.15+8; //Conversion en celsius (+8 coeff yolo)
//Serial.print("Ohm - T = ");
display1.setTextSize(1);
// note set the background color or the old text will still display
display1.setTextColor(WHITE, BLACK);
display1.setCursor(6, 0);
display1.println("ENGINE COOLANT TEMP");
//display1.println(Format(v * 7.99 / 204.6, 0, 3));
display1.setCursor(35, 12);
display1.print(celsius);display1.println("\xf7""C");
//draw the bar graph
display1.fillRect(v, 25, v, 6, BLACK); //pour tension display1.fillRect(0, 25, 128-v , 6, WHITE)
display1.fillRect(0, 25, 128-v , 6, WHITE); // display1.fillRect(0, 25, v , 6, WHITE)
for (i = 1; i < 13; i++)
{
display1.fillRect(i * 10, 25, 2, 6, BLACK);
}
display1.display();
}
void graphectlinea()
{
}
void graphiat()
{
display2.clearDisplay();
double IATb = analogRead(A1); //calcul de la tension sur la borne analogique
v= IATb/3.99;
double V = (IATb / 1024) * V_IN;
double Rth = (Rref * V )/(V_IN - V); //Calcul de la résistance de la thermistance
//Serial.print("Rth = ");
//Serial.print(Rth);
double kelvin = SteinhartHart(Rth);//Calcul de la température en kelvin( Steinhart and Hart)
double celsius = kelvin - 273.15+8; //Conversion en celsius (+8 coeff yolo)
//Serial.print("Ohm - T = ");
display1.setTextSize(1);
// note set the background color or the old text will still display
display1.setTextColor(WHITE, BLACK);
display1.setCursor(17, 0);
display1.println("INTAKE AIR TEMP");
//display1.println(Format(v * 7.99 / 204.6, 0, 3));
display1.setCursor(35, 12);
display1.print(celsius);display1.println("\xf7""C");
//draw the bar graph
display1.fillRect(v, 25, v, 6, BLACK); //TEMP//// pour TENSION ecrire display1.fillRect(0, 25, 128-v , 6, WHITE)
display1.fillRect(0, 25, 128-v , 6, WHITE); // display1.fillRect(0, 25, v , 6, WHITE)
for (i = 1; i < 13; i++)
{
display1.fillRect(i * 10, 25, 2, 6, BLACK);
}
display1.display();
}
void graphiatlinea()
{
}
void graphmap()
{
display2.clearDisplay();
Map = analogRead(A5);
Psi = (Map-.32)*(10.94-(-13.9))/(1023+ (-13.9));
psig = Psi-14.7;
//(Map-0.5)*(1023-167.77)/(4.5-0.5)+167.77;
//psia = (Psi-167.77)*(10.6-0.01)/(1023-167.77)+0.01;
//Psi = ((((float)Map/(float)1023+0.04)/0.004)*0.145)-10.15;
//((Map * (0.005) /(0.022)+20)*(0.145)-10.15); // Calculate psi from raw value
v=Map/7.99;
display1.setTextSize(1);
display1.setTextColor(WHITE);
display1.setCursor(2, 0);
display1.println("Manifold Absolute Pressure");
//display1.println(Format(v * 7.99 / 204.6, 0, 3));
display1.setCursor(43, 12);
display1.print(psig);display1.println("");
//draw the bar graph
display1.fillRect(v, 25, 128 - v, 6, BLACK);
display1.fillRect(0, 25, v, 6, WHITE);
for (i = 1; i < 13; i++)
{
display1.fillRect(i * 10, 25, 2, 6, BLACK);
}
display1.display();
//display2.clearDisplay();
display2.setTextSize(2);
display2.setTextColor(WHITE);
display2.setCursor(0,0);
display2.print("Psi:");display2.print(Psi);
display2.setTextSize(1);
display2.println("b");
}
void testscrolltext(void) {
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(10,0);
display1.clearDisplay();
display1.drawBitmap(0, 0, honda, 128, 64, 1);
display1.display();
display1.startscrollright(0x00, 0x0F);
delay(2000);
display1.stopscroll();
delay(1000);
display1.startscrollleft(0x00, 0x0F);
delay(2000);
display1.stopscroll();
delay(1000);
display1.startscrolldiagright(0x00, 0x07);
delay(2000);
display1.startscrolldiagleft(0x00, 0x07);
delay(2000);
display1.stopscroll();
}
/*if (AFR > 1000) //&& AFR < 1000)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("Rich");
}
if (AFR > 945 && AFR <= 1000)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("12");
}
if (AFR > 900 && AFR <= 945)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("12.5");
}
if (AFR > 855 && AFR <= 900)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("13.2");
}
if (AFR > 810 && AFR <= 855)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("13.8");
}
if (AFR > 540 && AFR <= 810)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("14.3");
}
if (AFR > 225 && AFR <= 540)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("14.4");
}
if (AFR > 180 && AFR <= 225)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("14.7");
}
if (AFR > 135 && AFR <= 180)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("14.9");
}
if (AFR > 45 && AFR <= 135)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("15");
}
if (AFR <45)
{display1.clearDisplay();
display1.setTextSize(2);
display1.setTextColor(WHITE);
display1.setCursor(0,0);
display1.print("\xE5:");display1.print("Learn");
}*/