Update: WiFi RSSI, animated eyes, date in clock mode

This commit is contained in:
UA1ZBE
2026-05-15 14:22:43 +03:00
parent 2a8a192f3a
commit 37d3bc0d4c
8 changed files with 24818 additions and 24469 deletions

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -59,6 +59,34 @@ void reconnect() {
} }
} }
void drawEyes(int frame) {
int eyeY = 8;
int leftX = 28;
int rightX = 68;
int eyeW = 26;
int eyeH = 20;
int pupilX = sin(frame * 0.3) * 4;
int pupilY = cos(frame * 0.2) * 3;
int blink = frame % 50;
int openH = (blink > 46) ? 2 : eyeH;
int pupilR = (blink > 46) ? 0 : 4;
for (int i = 0; i < 2; i++) {
int x = (i == 0) ? leftX : rightX;
u8g2.drawEllipse(x + eyeW / 2, eyeY + openH / 2, eyeW / 2, openH / 2, U8G2_DRAW_ALL);
}
if (pupilR > 0) {
u8g2.drawFilledEllipse(leftX + eyeW / 2 + pupilX, eyeY + eyeH / 2 + pupilY, pupilR, pupilR);
u8g2.drawFilledEllipse(rightX + eyeW / 2 + pupilX, eyeY + eyeH / 2 + pupilY, pupilR, pupilR);
u8g2.drawFilledEllipse(leftX + eyeW / 2 + pupilX, eyeY + eyeH / 2 + pupilY, pupilR - 2, pupilR - 2);
u8g2.drawFilledEllipse(rightX + eyeW / 2 + pupilX, eyeY + eyeH / 2 + pupilY, pupilR - 2, pupilR - 2);
}
u8g2.drawStr(5, 52, "Connecting...");
}
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
Wire.begin(21, 22); Wire.begin(21, 22);
@@ -96,15 +124,16 @@ void setup() {
u8g2.sendBuffer(); u8g2.sendBuffer();
delay(1500); delay(1500);
u8g2.clearBuffer();
u8g2.drawStr(5, 40, "Connecting...");
u8g2.sendBuffer();
Serial.println("Connecting to WiFi..."); Serial.println("Connecting to WiFi...");
int eyeFrame = 0;
WiFi.begin(ssid, password); WiFi.begin(ssid, password);
int attempts = 0; int attempts = 0;
while (WiFi.status() != WL_CONNECTED && attempts < 30) { while (WiFi.status() != WL_CONNECTED && attempts < 30) {
u8g2.clearBuffer();
drawEyes(eyeFrame);
u8g2.sendBuffer();
eyeFrame++;
delay(500); delay(500);
Serial.print("."); Serial.print(".");
attempts++; attempts++;
@@ -112,13 +141,19 @@ void setup() {
if (WiFi.status() != WL_CONNECTED) { if (WiFi.status() != WL_CONNECTED) {
Serial.println("\nTrying backup WiFi..."); Serial.println("\nTrying backup WiFi...");
eyeFrame = 0;
u8g2.clearBuffer(); u8g2.clearBuffer();
u8g2.drawStr(5, 40, "Backup WiFi..."); u8g2.drawStr(5, 40, "Backup WiFi...");
u8g2.sendBuffer(); u8g2.sendBuffer();
delay(1500);
WiFi.begin(ssid2, password2); WiFi.begin(ssid2, password2);
attempts = 0; attempts = 0;
while (WiFi.status() != WL_CONNECTED && attempts < 30) { while (WiFi.status() != WL_CONNECTED && attempts < 30) {
u8g2.clearBuffer();
drawEyes(eyeFrame);
u8g2.sendBuffer();
eyeFrame++;
delay(500); delay(500);
Serial.print("."); Serial.print(".");
attempts++; attempts++;
@@ -220,12 +255,15 @@ void drawTime() {
sprintf(dateStr, "%02d.%02d.%04d", timeinfo->tm_mday, timeinfo->tm_mon + 1, timeinfo->tm_year + 1900); sprintf(dateStr, "%02d.%02d.%04d", timeinfo->tm_mday, timeinfo->tm_mon + 1, timeinfo->tm_year + 1900);
u8g2.clearBuffer(); u8g2.clearBuffer();
u8g2.setFont(u8g2_font_ncenB14_tr); u8g2.setFont(u8g2_font_5x7_tr);
int16_t cw = u8g2.getStrWidth("CLOCK"); char rssiStr[10];
u8g2.drawStr((128 - cw) / 2, 18, "CLOCK"); int rssi = WiFi.RSSI();
sprintf(rssiStr, "Wifi: %d dBm", rssi);
int16_t ww = u8g2.getStrWidth(rssiStr);
u8g2.drawStr((128 - ww) / 2, 10, rssiStr);
u8g2.setFont(u8g2_font_ncenB24_tr); u8g2.setFont(u8g2_font_ncenB24_tr);
int16_t w = u8g2.getStrWidth(timeStr); int16_t w = u8g2.getStrWidth(timeStr);
u8g2.drawStr((128 - w) / 2, 50, timeStr); u8g2.drawStr((128 - w) / 2, 45, timeStr);
u8g2.setFont(u8g2_font_5x7_tr); u8g2.setFont(u8g2_font_5x7_tr);
int16_t dw = u8g2.getStrWidth(dateStr); int16_t dw = u8g2.getStrWidth(dateStr);
u8g2.drawStr((128 - dw) / 2, 62, dateStr); u8g2.drawStr((128 - dw) / 2, 62, dateStr);