#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// declare an SSD1306 display object connected to I2C
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
int callibrating_screen(){
oled.clearDisplay();
oled.setTextSize(2); // text size
oled.setTextColor(WHITE); // text color
oled.setCursor(20,10); // position to display
oled.println("Zeroing"); // text to display
oled.display();
oled.setTextSize(2); // text size
oled.setTextColor(WHITE); // text color
oled.setCursor(15,33); // position to display
oled.println("sensor..."); // text to display
oled.display();
delay(1000);
oled.clearDisplay();
}
int callibration_done(){
oled.setTextSize(2); // text size
oled.setTextColor(WHITE); // text color
oled.setCursor(20,10); // position to display
oled.println("Process"); // text to display
oled.setTextSize(2); // text size
oled.setTextColor(WHITE); // text color
oled.setCursor(5,33); // position to display
oled.println("Completed!"); // text to display
oled.display();
oled.clearDisplay();
delay(1000);
}
int error_1(){
oled.setTextSize(2);
oled.setCursor(18, 25); // position to display
oled.println("LOW FiO2"); // text to display
oled.display();
delay(500);
oled.clearDisplay();
oled.display();
delay(1000);
}
int error_2(){
oled.setTextSize(2);
oled.setCursor(10, 25); // position to display
oled.println("HIGH FiO2"); // text to display
oled.display();
delay(500);
oled.clearDisplay();
oled.display();
delay(1000);
}
int error_3() {
oled.setTextSize(2);
oled.setCursor(4, 22); // position to display
oled.println("Sensor not"); // text to display
oled.setTextSize(2);
oled.setCursor(10, 40); // position to display
oled.println("connected"); // text to display
oled.display();
delay(1000);
oled.clearDisplay();
}
int error_4() {
oled.setTextSize(2);
oled.setCursor(25, 24); // position to display
oled.println("Battery"); // text to display
oled.setTextSize(2);
oled.setCursor(40, 44); // position to display
oled.println("Low!"); // text to display
oled.display();
delay(2000);
oled.clearDisplay();
}
void setup() {
Serial.begin(9600);
//SSD1306_clear(oled_buf);
// initialize OLED display with address 0x3C for 128x64
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
while (true);
}
}
void loop(){
callibrating_screen();
callibration_done();
error_1();
error_2();
error_3();
error_4();
}