#include <SSD1306.h>
OLEDDisplay *display=new SSD1306(0x3c,21,22);
const int logo_width=32,logo_height=32;
static uint8_t logo_bits[]={
0x00, 0xFF, 0x01, 0x00, 0xC0, 0xFF, 0x07, 0x00, 0xE0, 0xFF, 0x1F, 0x00,
0xF0, 0xFF, 0x3F, 0x00, 0xF8, 0xFF, 0x7F, 0x00, 0xFC, 0xFF, 0xFF, 0x00,
0xFE, 0xFF, 0xFF, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0x01,
0xEF, 0xCF, 0xCF, 0x01, 0x83, 0x83, 0x07, 0x03, 0x01, 0x03, 0x03, 0x03,
0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x06, 0x03, 0x81, 0x01,
0x0C, 0x82, 0xC1, 0x00, 0x18, 0xE6, 0x7F, 0x00, 0x30, 0xF6, 0xFF, 0x07,
0xE0, 0x1F, 0x00, 0x0C, 0xF0, 0xFC, 0x1F, 0x38, 0x90, 0x8D, 0x3F, 0x60,
0xF0, 0xFF, 0x63, 0x00, 0xF8, 0xFF, 0xC3, 0x01, 0x08, 0xCA, 0x00, 0x01,
0xF8, 0xFF, 0x03, 0x00, 0xF0, 0xFF, 0x03, 0x00, 0x30, 0x30, 0x00, 0x00,
0xE0, 0xFF, 0x03, 0x00, 0xC0, 0xFF, 0x03, 0x00, 0x00, 0x03, 0x00, 0x78,
0x00, 0xFE, 0xFF, 0x0F, 0x00, 0xFC, 0xFF, 0x01
};
int packetsReceived=0, dt=1;
char stationID[]="ABCDABCD",
version[]="1.2.03";
String freq="403700000", lastLog="controllo agg";
void updateDisplay() {
display->clear();
display->setFont(ArialMT_Plain_16);
display->setTextAlignment(TEXT_ALIGN_LEFT);
float v;
display->drawProgressBar(0, 0, 90, 8, 40);
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->setFont(ArialMT_Plain_10);
display->drawString(127, 0, dt>0 ? "FIX" : "NOFIX");
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0, 12, stationID);
display->setFont(ArialMT_Plain_16);
String f=freq.substring(0,3)+"."+freq.substring(3,6);
display->drawString(0,30,f);
display->drawString(1,30,f);
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->drawString(126, 12, version);
display->drawString(126, 30, String(packetsReceived));
display->drawString(127, 30, String(packetsReceived));
display->setTextAlignment(TEXT_ALIGN_LEFT);
// display->setFont(ArialMT_Plain_10);
// display->drawString(0, 52, IpAddress2String(server));
display->setFont(ArialMT_Plain_16);
display->drawString(65, 30, String("/-\\|"[millis() % 4000 / 1000]));
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(ArialMT_Plain_10);
display->drawString(0, 52, lastLog);
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->setFont(ArialMT_Plain_16);
display->drawString(127, 48, String(-122 / 2)+"dBm");
display->display();
}
void setup() {
Serial.begin(115200);
Serial.println(String(1.23456789,7));
display->init();
display->flipScreenVertically();
display->invertDisplay();
display->clear();
display->drawXbm((128-logo_width)/2,1,logo_width,logo_height,logo_bits);
display->setFont(ArialMT_Plain_16);
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(64,32,"rdzTrovaLaSonda");
display->drawString(65,32,"rdzTrovaLaSonda");
display->drawString(64,47,"0.10");
display->drawString(65,47,"0.10");
display->display();
delay(3000);
display->normalDisplay();
updateDisplay();
}
void loop() {
delay(1000); // this speeds up the simulation
}