фиксы до работы с перемычкой вместо оптики
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "Display.h"
|
||||
#include "Config.h"
|
||||
#include "Log.h"
|
||||
#include <Wire.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -9,6 +10,7 @@ bool Display::begin() {
|
||||
Wire.begin(GPIO_SDA, GPIO_SCL);
|
||||
ok_ = oled_.begin(SSD1306_SWITCHCAPVCC, OLED_ADDRESS);
|
||||
if (ok_) { oled_.setTextColor(SSD1306_WHITE); oled_.setTextSize(1); }
|
||||
Log::printf("OLED", "initialization %s, I2C address=0x%02X", ok_ ? "OK" : "FAILED", OLED_ADDRESS);
|
||||
return ok_;
|
||||
}
|
||||
|
||||
@@ -22,9 +24,11 @@ void Display::fit(char *s) {
|
||||
}
|
||||
|
||||
void Display::show(const char *a, const char *b) {
|
||||
if (!ok_) return;
|
||||
char one[32], two[32];
|
||||
snprintf(one, sizeof(one), "%s", a ? a : ""); snprintf(two, sizeof(two), "%s", b ? b : "");
|
||||
// Serial is the primary UI mirror and remains available when OLED is absent.
|
||||
Log::printf("UI", "%s | %s", one, two);
|
||||
if (!ok_) return;
|
||||
fit(one); fit(two);
|
||||
oled_.clearDisplay(); oled_.setCursor(0, 3); oled_.print(one);
|
||||
oled_.setCursor(0, 19); oled_.print(two); oled_.display();
|
||||
@@ -41,4 +45,3 @@ void Display::formatDuration(uint64_t us, char *out, size_t n) {
|
||||
if (minutes < 60) snprintf(out, n, "%02llu:%02llu", minutes, (us / 1000000ULL) % 60ULL);
|
||||
else snprintf(out, n, "%llu:%02llu", minutes / 60ULL, minutes % 60ULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user