bunch of shit clang-tidy and clion made me do
This commit is contained in:
@@ -12,7 +12,7 @@ class LCDDisplay {
|
||||
private:
|
||||
int _lcd = -1;
|
||||
std::string _dev;
|
||||
char writebuf[LCD_LINES * LCD_COLS + 8]; // 4x40 chars + 2x4 setcursor commands
|
||||
char writebuf[LCD_LINES * LCD_COLS + 8]{}; // 4x40 chars + 2x4 setcursor commands
|
||||
static constexpr bool dualDisp = (LCD_LINES * LCD_COLS > 80); // is it dual display device or not, evauluated from the size at compile time
|
||||
|
||||
void open(bool reopen = false);
|
||||
@@ -24,7 +24,7 @@ class LCDDisplay {
|
||||
void writeStr(uint8_t row, uint8_t col, std::string str);
|
||||
|
||||
public:
|
||||
LCDDisplay(std::string dev, uint32_t baud = 0010002); // from termios-baud.h, B115200
|
||||
explicit LCDDisplay(std::string dev, uint32_t baud = 0010002); // from termios-baud.h, B115200
|
||||
~LCDDisplay();
|
||||
|
||||
void clear();
|
||||
@@ -40,7 +40,7 @@ class LCDDisplay {
|
||||
char bar(uint8_t char_id, double value);
|
||||
|
||||
// returns custom char no. c, small enough to define in header
|
||||
constexpr char cc(uint8_t c) { return c % 8; }
|
||||
static constexpr char cc(const uint8_t c) { return c % 8; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace cpu {
|
||||
|
||||
struct cpuSensors {
|
||||
std::string hwmon = "";
|
||||
std::string hwmon;
|
||||
bool zenpower = false;
|
||||
|
||||
int tdie = 0;
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
namespace gpu {
|
||||
|
||||
struct gpuSensors {
|
||||
std::string hwmon = "";
|
||||
std::string hwmon;
|
||||
bool hasGpuMetrics = false;
|
||||
|
||||
float vcore = 0.0f;
|
||||
double vcore = 0.0f;
|
||||
|
||||
uint16_t clock_core = 0;
|
||||
uint16_t clock_mem = 0;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define LOG_HPP
|
||||
|
||||
// comment out to disable logging in general
|
||||
#define applog(level, fmt, ...) _log(level, std::source_location::current(), fmt, ##__VA_ARGS__)
|
||||
#define applog(level, fmt, ...) utils::log(level, std::source_location::current(), fmt, ##__VA_ARGS__)
|
||||
// comment out to disable logging to file
|
||||
// #define LOG_FILE_LOCATION "linuxSmartie.log.gz"
|
||||
|
||||
@@ -19,24 +19,26 @@
|
||||
inline std::mutex fmtx; // file logging mutex
|
||||
#endif
|
||||
|
||||
inline std::mutex cmtx; // console logging mutex
|
||||
enum class LOG { INF, WRN, ERR, DBG, START };
|
||||
|
||||
constexpr std::string_view pFname(std::string_view full) {
|
||||
if (auto pos = full.find(' '); pos != std::string_view::npos)
|
||||
namespace utils {
|
||||
inline std::mutex cmtx; // console logging mutex
|
||||
|
||||
constexpr std::string pFname(std::string_view full) {
|
||||
if (const auto pos = full.find(' '); pos != std::string_view::npos)
|
||||
full.remove_prefix(pos + 1);
|
||||
|
||||
if (auto pos = full.rfind('('); pos != std::string_view::npos)
|
||||
if (const auto pos = full.rfind('('); pos != std::string_view::npos)
|
||||
full.remove_suffix(full.size() - pos);
|
||||
|
||||
return full;
|
||||
return std::string(full);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void _log(LOG level, const std::source_location& loc, std::format_string<Args...> str, Args&&... args) {
|
||||
void log(LOG level, const std::source_location& loc, std::format_string<Args...> str, Args&&... args) {
|
||||
constexpr std::string_view reset = "\033[0m";
|
||||
constexpr std::string_view pattern = "[{}{}{}] ";
|
||||
std::string_view color = "";
|
||||
std::string_view color;
|
||||
|
||||
switch (level) {
|
||||
case LOG::INF:
|
||||
@@ -80,6 +82,7 @@ inline void _log(LOG level, const std::source_location& loc, std::format_string<
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace utils {
|
||||
|
||||
const char FILL_CHAR = ' ';
|
||||
constexpr char fill_char = ' ';
|
||||
|
||||
enum just { right,
|
||||
left };
|
||||
@@ -16,21 +16,23 @@ enum just { right,
|
||||
std::string pad(std::string s, uint8_t len, just j = just::right);
|
||||
std::string center(std::string str, uint8_t len);
|
||||
std::string pBytes(double bytes, bool isKbytes = false);
|
||||
ssize_t readFile(std::string path, char* buffer, size_t maxlen);
|
||||
ssize_t readFile(const std::string& path, char* buffer, size_t maxlen);
|
||||
ssize_t readFile(const char* path, char* buffer, size_t maxlen);
|
||||
std::string getFirstDir(std::string_view path);
|
||||
std::string getFirstDir(const std::string_view& path);
|
||||
|
||||
template <size_t N>
|
||||
inline long long fastReadNum(const std::string& path, char (&buf)[N]) {
|
||||
inline int fastReadNum(const std::string& path, char (&buf)[N]) {
|
||||
readFile(path, buf, N);
|
||||
return std::strtoll(buf, nullptr, 10);
|
||||
int ret = 0;
|
||||
std::from_chars(buf, buf + N, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline std::string pNum(auto num, uint8_t decs = 0) {
|
||||
return std::format("{:.{}f}", num, decs);
|
||||
}
|
||||
|
||||
inline bool fileExists(std::string_view path) {
|
||||
inline bool fileExists(const std::string_view& path) {
|
||||
return std::filesystem::exists(path);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user