Files
Horizon-OC/Source/sys-clk-OC/overlay/src/ui/format.h
2021-08-29 15:00:45 +08:00

29 lines
903 B
C++

/*
* --------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
* wrote this file. As long as you retain this notice you can do whatever you
* want with this stuff. If you meet any of us some day, and you think this
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
* --------------------------------------------------------------------------
*/
#pragma once
#include <cstdio>
#define FREQ_DEFAULT_TEXT "Do not override"
static inline std::string formatListFreqMhz(std::uint32_t mhz)
{
if(mhz == 0)
{
return FREQ_DEFAULT_TEXT;
}
char buf[10];
return std::string(buf, snprintf(buf, sizeof(buf), "%u Mhz", mhz));
}
static inline std::string formatListFreqHz(std::uint32_t hz) { return formatListFreqMhz(hz / 1000000); }