#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Fast I2C / TWI
int progress = 0;
int potentio = 0;
char buffer [20];
int string_width;
void setup() {
pinMode(A0, INPUT);
u8g.setFont(u8g_font_tpssb);
u8g.setColorIndex(1);
}
void loop() {
progress = analogRead(A0);
dtostrf(potentio/10.0,1,1,buffer);
sprintf(buffer,"%s%s", buffer, "°C");
potentio = map(analogRead(A0),0,1023,-200,1200);
u8g.firstPage();
do {
u8g.drawStr(40, 10, "COOLANT"); // main name
string_width=u8g.getStrWidth(buffer); //value
u8g.drawStr(64-string_width/2,30,buffer); //value
u8g.drawFrame(15,39,100,15); //box for progress bar
u8g.drawBox(15, 39, map(progress,0,1023,0,100), 15); // progress bar filling
} while ( u8g.nextPage() );
}