Files
fastfetch/src/common/impl/frequency.c
T

27 lines
745 B
C
Raw Normal View History

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;
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) {
ffStrbufAppendDouble(result, mhz / 1000., ndigits, true);
2026-03-29 09:28:49 +08:00
if (spaceBeforeUnit) {
ffStrbufAppendC(result, ' ');
}
ffStrbufAppendS(result, "GHz");
2026-03-29 09:28:49 +08:00
} else {
ffStrbufAppendUInt(result, mhz);
2026-03-29 09:28:49 +08:00
if (spaceBeforeUnit) {
ffStrbufAppendC(result, ' ');
}
ffStrbufAppendS(result, "MHz");
}
2025-07-30 14:30:36 +08:00
return true;
}