Global: add new unit related options

1. `--<module>-space-before-unit`
2. `--duration-abbreviation`
3. various code refactoring and cleanups
This commit is contained in:
李通洲
2025-07-30 14:30:36 +08:00
parent 8be419cfd6
commit a0174e8666
33 changed files with 556 additions and 174 deletions
+17
View File
@@ -0,0 +1,17 @@
#include "frequency.h"
bool ffFreqAppendNum(uint32_t mhz, FFstrbuf* result)
{
if (mhz == 0)
return false;
const FFOptionsDisplay* options = &instance.config.display;
const char* space = options->freqSpaceBeforeUnit == FF_SPACE_BEFORE_UNIT_NEVER ? "" : " ";
int8_t ndigits = options->freqNdigits;
if (ndigits >= 0)
ffStrbufAppendF(result, "%.*f%sGHz", ndigits, mhz / 1000., space);
else
ffStrbufAppendF(result, "%u%sMHz", (unsigned) mhz, space);
return true;
}