2026-01-06 09:48:38 +08:00
|
|
|
#include "common/frequency.h"
|
2025-07-30 14:30:36 +08:00
|
|
|
|
2026-03-29 09:28:49 +08:00
|
|
|
bool ffFreqAppendNum(uint32_t mhz, FFstrbuf* result) {
|
|
|
|
|
if (mhz == 0) {
|
2025-07-30 14:30:36 +08:00
|
|
|
return false;
|
2026-03-29 09:28:49 +08:00
|
|
|
}
|
2025-07-30 14:30:36 +08:00
|
|
|
|
|
|
|
|
const FFOptionsDisplay* options = &instance.config.display;
|
2025-08-19 17:22:11 +08:00
|
|
|
bool spaceBeforeUnit = options->freqSpaceBeforeUnit != FF_SPACE_BEFORE_UNIT_NEVER;
|
2025-07-30 14:30:36 +08:00
|
|
|
int8_t ndigits = options->freqNdigits;
|
|
|
|
|
|
2026-03-29 09:28:49 +08:00
|
|
|
if (ndigits >= 0) {
|
2025-09-02 14:12:58 +08:00
|
|
|
ffStrbufAppendDouble(result, mhz / 1000., ndigits, true);
|
2026-03-29 09:28:49 +08:00
|
|
|
if (spaceBeforeUnit) {
|
|
|
|
|
ffStrbufAppendC(result, ' ');
|
|
|
|
|
}
|
2025-08-19 17:22:11 +08:00
|
|
|
ffStrbufAppendS(result, "GHz");
|
2026-03-29 09:28:49 +08:00
|
|
|
} else {
|
2025-08-19 17:22:11 +08:00
|
|
|
ffStrbufAppendUInt(result, mhz);
|
2026-03-29 09:28:49 +08:00
|
|
|
if (spaceBeforeUnit) {
|
|
|
|
|
ffStrbufAppendC(result, ' ');
|
|
|
|
|
}
|
2025-08-19 17:22:11 +08:00
|
|
|
ffStrbufAppendS(result, "MHz");
|
|
|
|
|
}
|
2025-07-30 14:30:36 +08:00
|
|
|
return true;
|
|
|
|
|
}
|