#include <WiFi.h>
#include "time.h"
#include <NTPClient.h>
const char* ssid = "Wokwi-GUEST";
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 7200;
const int daylightOffset_sec = 3600;
#define ENABLE_GxEPD2_GFX 0
#include <GxEPD2_BW.h>
// #include <GxEPD2_3C.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "img.h"
#define EPD_CS 5
#define EPD_DC 4
#define EPD_RST 2
#define EPD_BUSY 15
GxEPD2_BW<GxEPD2_290_BS, GxEPD2_290_BS::HEIGHT> display(GxEPD2_290_BS(/*CS=5*/ 5, /*DC=*/ 0, /*RES=*/ 2, /*BUSY=*/ 15)); // DEPG0290BS 128x296, SSD1680
const uint16_t COLOR_ACCENT = GxEPD_BLACK;
void setup() {
Serial.begin(115200);
//connect to WiFi
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(" Connected to network!");
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
display.init(115200,true,50,false);
display.setRotation(1);
display.firstPage();
do{
display.drawInvertedBitmap(5, 7, bitmap_copaci, 170, 108, GxEPD_BLACK);
// display.drawInvertedBitmap(200, 10, bitmap_soare, 39, 39, COLOR_ACCENT);
}
while (display.nextPage());
}
void loop() {
struct tm timeinfo;
if(!getLocalTime(&timeinfo)){
Serial.println("Failed to obtain time");
return;
}
int x = 100;
int y = 100;
int w = 60;
int h = 10;
display.setFont(&FreeMonoBold9pt7b);
display.setTextColor(COLOR_ACCENT);
display.setPartialWindow(x, y, w, h);
display.firstPage();
do{
display.setCursor(185, 110);
// display.print("13:45");
display.print(timeinfo.tm_hour);
display.print(":");
display.print(timeinfo.tm_min);
}
while (display.nextPage());
// display.displayWindow(x, y, w, h);
delay(30000);
}
Loading
epaper-2in9
epaper-2in9