работает с перемычкой на 1МГц 2%

This commit is contained in:
2026-08-06 15:53:32 +03:00
parent 1edc420b77
commit f52f65686d
11 changed files with 207 additions and 55 deletions

View File

@@ -35,9 +35,12 @@ void Display::show(const char *a, const char *b) {
}
void Display::formatFrequency(float hz, char *out, size_t n) {
if (hz >= 1000000.0f) snprintf(out, n, "%.2fM", hz / 1000000.0f);
else if (hz >= 1000.0f) snprintf(out, n, "%.2fk", hz / 1000.0f);
else snprintf(out, n, "%.0fHz", hz);
float value = hz; const char *suffix = "Hz";
if (hz >= 1000000.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);
}
void Display::formatDuration(uint64_t us, char *out, size_t n) {