#include "U8glib.h"
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_WIDTH 128
#define OLED_HEIGHT 64
#define OLED_ADDR 0x3C
Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT);
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Fast I2C / TWI
// ' fuel pressure symbol', 24x24px
const unsigned char epd_bitmap__fuel_pressure_symbol [] PROGMEM = {
0x01, 0x83, 0x00, 0x01, 0x83, 0x00, 0x01, 0x83, 0x00, 0x01, 0x83, 0x00, 0x01, 0x83, 0x00, 0x01,
0x83, 0x00, 0x03, 0x01, 0x80, 0x06, 0x00, 0xc0, 0x0c, 0x00, 0x60, 0x18, 0x00, 0x30, 0xf2, 0x10,
0x9e, 0x02, 0x28, 0x80, 0x02, 0x28, 0x80, 0xfe, 0x44, 0xfe, 0x02, 0x44, 0x80, 0x02, 0x44, 0x80,
0xf2, 0x38, 0x9e, 0x18, 0x00, 0x30, 0x0c, 0x00, 0x60, 0x06, 0x00, 0xc0, 0x03, 0x01, 0x80, 0x01,
0x83, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x38, 0x00
};
// 'path18', 40x34px
const unsigned char epd_bitmap_path18 [] PROGMEM = {
0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
0x60, 0x18, 0x06, 0x00, 0x00, 0x60, 0x18, 0x06, 0x00, 0x00, 0x60, 0x18, 0x06, 0x00, 0x00, 0x67,
0xff, 0xe6, 0x00, 0x00, 0x67, 0xff, 0xe6, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00,
0x06, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x60, 0x18, 0x06,
0x00, 0x00, 0x60, 0x18, 0x06, 0x00, 0x00, 0x60, 0x24, 0x06, 0x00, 0x00, 0x60, 0x66, 0x06, 0x00,
0x00, 0x60, 0x42, 0x06, 0x00, 0x04, 0x60, 0x81, 0x06, 0x20, 0xfe, 0x60, 0x81, 0x06, 0x7f, 0x83,
0x61, 0x00, 0x86, 0x83, 0x81, 0xe1, 0x00, 0x87, 0x81, 0xff, 0x63, 0x00, 0x86, 0xff, 0x06, 0x61,
0x00, 0x86, 0x60, 0x04, 0x61, 0x00, 0x86, 0x20, 0x00, 0x61, 0x00, 0x86, 0x00, 0x00, 0x60, 0x83,
0x06, 0x00, 0x00, 0x60, 0x7e, 0x06, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x06,
0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00,
0x00, 0x7f, 0xff, 0xfe, 0x00, 0x00, 0x7f, 0xff, 0xfe, 0x00
};
int sensorVpin=A3;
int readVal;
float V2;
int delayT=250;
float psi;
int progress = 0;
void setup() {
u8g.setFont(u8g_font_tpssb);
u8g.setColorIndex(1);
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("psi");
}
void loop() {
u8g.firstPage();
do {
// u8g.drawStr(25, 50, "Progress Bar");
// u8g.drawFrame(0, 10, 128, 20);
// u8g.drawBox(10, 15, progress, 10);
// } while ( u8g.nextPage() );
// 'fuelpressure2', 37x32px
u8g.drawBitmapP( 1, 29, 40 / 8, 34, epd_bitmap_path18);
} while (u8g.nextPage() );
readVal=analogRead(sensorVpin);
V2=(5./1023.)*readVal;
Serial.println(V2);
delay(delayT);
float psi = (V2 - 0.5) * (30.0) / (4.5 - 0.5);
Serial.println(psi);
delay(delayT);
display.setTextSize(2.5);
display.setTextColor(WHITE);
display.setCursor(50, 16);
display.println(psi);
display.display();
delay(delayT);
display.clearDisplay();
}