diff --git a/src/LCDDisplay.cpp b/src/LCDDisplay.cpp index 54e63fd..d0da302 100644 --- a/src/LCDDisplay.cpp +++ b/src/LCDDisplay.cpp @@ -4,18 +4,18 @@ #include #include -#include +#include #include /* lcd size hardcoded to 4x40 idgaf */ LCDDisplay::LCDDisplay(std::string dev, uint32_t baud) { - std::cout << "[LCDDisplay] Opening LCD at " << dev << std::endl; + std::println("[LCDDisplay] Opening LCD at {}", dev); struct termios term; int lcd = open(dev.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK); // handle errors if (lcd < 0) { - std::cerr << "[LCDDisplay] Error opening serial port " << dev << std::endl; + std::println("[LCDDisplay] Error opening serial port {}", dev); // err exit(lcd); } @@ -30,7 +30,7 @@ LCDDisplay::LCDDisplay(std::string dev, uint32_t baud) { } LCDDisplay::~LCDDisplay() { - std::cout << "[LCDDisplay] Closing LCD port" << std::endl; + std::println("[LCDDisplay] Closing LCD port"); close(_lcd); } @@ -40,13 +40,13 @@ void LCDDisplay::clear() { } void LCDDisplay::setContrast(uint8_t contrast) { - std::cout << "[LCDDisplay] Set contrast to " << std::to_string(contrast) << std::endl; + std::println("[LCDDisplay] Set contrast to {}", contrast); uint8_t cmdbuf[] = {254, 80, contrast}; write(_lcd, &cmdbuf, 3); } void LCDDisplay::setBacklight(bool enabled) { - std::cout << "[LCDDisplay] Backlight set to " << std::to_string(enabled) << std::endl; + std::println("[LCDDisplay] Set brightness to {}", enabled); uint8_t cmdbuf[] = {254, (uint8_t)(enabled ? 66 : 70), 255}; write(_lcd, &cmdbuf, enabled ? 3 : 2); } @@ -63,7 +63,7 @@ void LCDDisplay::writeStr(std::string str) { void LCDDisplay::writeLines(std::array lines) { for (auto& line : lines) { if (line.size() > 40) { - std::cerr << "Line " << line << " too long! (" << line.size() << " chars)" << std::endl; + std::println("Line {} too long! ({} chars)", line, line.size()); continue; } line.insert(line.end(), 40 - line.size(), ' '); @@ -78,14 +78,13 @@ void LCDDisplay::writeLines(std::array lines) { void LCDDisplay::writeSStream(std::stringstream& ss) { std::string s = ss.str(); if (s.size() != 160) - std::cerr << "[LCDDisplay] stringstream wrong (" + std::to_string((int)(160 - s.size())) + " chars too short)" << std::endl; + std::println("[LCDDisplay] stringstream wrong ({} chars too short)", 160 - s.size()); // err setCursor(0, 0); writeStr(s.substr(0, 80)); setCursor(2, 0); writeStr(s.substr(80, 159)); } - void LCDDisplay::setCustomChar(uint8_t index, std::array cchar) { uint8_t cmdbuf[11]; cmdbuf[0] = 254; @@ -99,7 +98,7 @@ void LCDDisplay::setCustomChar(uint8_t index, std::array cchar) { char LCDDisplay::bar(uint8_t char_id, double value) { std::array b; b.fill(0b01110); - for(uint8_t i = 0; i < (1.0 - value) * 8; i++) + for (uint8_t i = 0; i < (1.0 - value) * 8; i++) b[i] = 0; setCustomChar(char_id, b); return cc[char_id]; diff --git a/src/gpu.cpp b/src/gpu.cpp index 48c68e6..9c4b715 100644 --- a/src/gpu.cpp +++ b/src/gpu.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -89,11 +89,10 @@ GpuMetricsHeader_t getGpuMetricsHeader(std::string path) { std::ifstream f(path, std::ios::binary); if (f.good()) { f.read(reinterpret_cast(&header), sizeof(header)); - std::cout << "[GpuMetrics] header at path " + path + " read, GpuMetrics_v" << std::to_string(header.format_revision) << "_" << std::to_string(header.content_revision); - std::cout << ", size " << std::to_string(header.structure_size) << std::endl; + std::println("[GpuMetrics] header at path {} read, GpuMetrics_v{}_{}, size {}", path, header.format_revision, header.content_revision, header.structure_size); f.close(); } else { - std::cerr << "[GpuMetrics] error reading header at path " + path + " (wrong card # ?)" << std::endl; + std::println("[GpuMetrics] error reading header at path {} (wrong card # ?)", path); // should be err } return header; @@ -109,7 +108,7 @@ auto getGpuMetrics(GpuMetricsHeader_t h, std::string path) { f.close(); } } else { - std::cout << "[GpuMetrics] read failed, unsupported format" << std::endl; + std::println("[GpuMetrics] read failed, unsupported format"); } return metrics; diff --git a/src/utils.cpp b/src/utils.cpp index df35bbc..2d10473 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -11,7 +11,7 @@ std::string readFile(std::string path, uint8_t trim) { std::stringstream ss; std::ifstream fs(path); if (!fs.good()) { - std::cerr << "[readFile] Error reading " << path << std::endl; + std::println("[readFile] Error reading {}", path); return ""; } ss << fs.rdbuf(); @@ -38,7 +38,7 @@ std::string findHwmonPath(std::string module) { auto f = readFile("/sys/class/hwmon/hwmon" + std::to_string(id) + "/name"); if (f.size() == 0) break; if (f == module) { - std::cout << ("[Hwmon] Detected " + module + " path is " + "/sys/class/hwmon/hwmon" + std::to_string(id)) << std::endl; + std::println("[Hwmon] Detected {} path is /sys/class/hwmon/hwmon{}", module, id); return "/sys/class/hwmon/hwmon" + std::to_string(id); } }