запущен тест между есп с перемычкой
This commit is contained in:
@@ -37,7 +37,7 @@ void Display::fit(char *s) {
|
||||
}
|
||||
}
|
||||
|
||||
void Display::show(const char *a, const char *b) {
|
||||
void Display::show(const char *a, const char *b, uint32_t progress, uint32_t progressTotal) {
|
||||
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.
|
||||
@@ -45,16 +45,39 @@ void Display::show(const char *a, const char *b) {
|
||||
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();
|
||||
oled_.setCursor(0, 19); oled_.print(two);
|
||||
if (progressTotal) {
|
||||
if (progress > progressTotal) progress = progressTotal;
|
||||
const uint16_t width = static_cast<uint16_t>(
|
||||
(static_cast<uint64_t>(progress) * 128U + progressTotal - 1U) / progressTotal);
|
||||
if (width) oled_.drawFastHLine(0, 31, width, SSD1306_WHITE);
|
||||
}
|
||||
oled_.display();
|
||||
}
|
||||
|
||||
void Display::formatFrequency(float hz, char *out, size_t n) {
|
||||
float value = hz; const char *suffix = "Hz";
|
||||
if (hz >= 1000000.0f) { value = hz / 1000000.0f; suffix = "M"; }
|
||||
if (hz >= 999950.0f) { value = hz / 1000000.0f; suffix = "M"; }
|
||||
else if (hz >= 1000.0f) { value = hz / 1000.0f; suffix = "k"; }
|
||||
if (fabsf(value - roundf(value)) < 0.005f) snprintf(out, n, "%.0f%s", value, suffix);
|
||||
else if (fabsf(value * 10.0f - roundf(value * 10.0f)) < 0.005f) snprintf(out, n, "%.1f%s", value, suffix);
|
||||
else snprintf(out, n, "%.2f%s", value, suffix);
|
||||
if (suffix[0] == 'M' && fabsf(value - roundf(value)) < 0.0005f)
|
||||
snprintf(out, n, "%.0f%s", value, suffix);
|
||||
else if (value >= 100.0f) snprintf(out, n, "%.1f%s", value, suffix);
|
||||
else if (value >= 10.0f) snprintf(out, n, "%.2f%s", value, suffix);
|
||||
else snprintf(out, n, "%.3f%s", value, suffix);
|
||||
}
|
||||
|
||||
void Display::formatTestFrequency(uint32_t hz, char *out, size_t n) {
|
||||
if (hz >= 1000000U && hz % 1000000U == 0)
|
||||
snprintf(out, n, "%luM", hz / 1000000U);
|
||||
else if (hz >= 1000U && hz % 1000U == 0)
|
||||
snprintf(out, n, "%luk", hz / 1000U);
|
||||
else if (hz >= 1000U) {
|
||||
const float khz = hz / 1000.0f;
|
||||
if (khz >= 100.0f) snprintf(out, n, "%.1fk", khz);
|
||||
else if (khz >= 10.0f) snprintf(out, n, "%.2fk", khz);
|
||||
else snprintf(out, n, "%.3fk", khz);
|
||||
} else
|
||||
snprintf(out, n, "%lu", hz);
|
||||
}
|
||||
|
||||
void Display::formatDuration(uint64_t us, char *out, size_t n) {
|
||||
|
||||
Reference in New Issue
Block a user