#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1//We are using the same reset as the esp32 board
#define SCREEN_ADDRESS 0x3c
Adafruit_SSD1306 display(SCREEN_WIDTH,SCREEN_HEIGHT,&Wire,OLED_RESET);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
if(! display.begin(SSD1306_SWITCHCAPVCC,SCREEN_ADDRESS)){
Serial.println(F("SSD1306 allocation failed"));//F means we are storing this print line in flash memory not in the ram because ram is limited in esp32
for(;;);//this is an infinite for loop loop,in previous cases we have to specify the conditions between those semi colons but here they are not specified bcz of that this is a infinite for loop
}
//turn on the display
display.display();
delay(2000);
//clear the display
display.clearDisplay();
//display a custom message
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,0);//specifies where the cursor has to be when starting the print(0,0) are x and y coordinates
//display.println(F("Welcome to medibox"));
//display.display();
}
void loop() {
mostrar_oled();
delay(1000); // this speeds up the simulation
}
void mostrar_oled(){
display.clearDisplay();
display.drawProgressBar(0, 5, 120, 5, medida_2);
display.println(64, 11, String(medida_2) + " cm");
//display.drawProgressBar(0, 38, 120, 5, medida_1);
display.println(64, 42, String(medida_1) + " cm");
display.display();
}