bunch of shit clang-tidy and clion made me do
This commit is contained in:
18
src/app.cpp
18
src/app.cpp
@@ -19,14 +19,14 @@
|
||||
namespace app {
|
||||
|
||||
const std::string lcd_port = "/dev/serial/by-id/usb-Raspberry_Pi_Pico_E6616407E37AA12F-if00"; // tis a symlink, can also be just /dev/ttyACM0
|
||||
const uint16_t lcd_interval_ms = 500;
|
||||
const uint8_t lcd_contrast = 215;
|
||||
constexpr uint16_t lcd_interval_ms = 500;
|
||||
constexpr uint8_t lcd_contrast = 215;
|
||||
|
||||
const std::string cpu_pciaddr = "0000:00:18.3";
|
||||
const std::string gpu_pciaddr = "0000:0b:00.0";
|
||||
const std::string sys_sensor = "nct6775.656";
|
||||
const std::string sys_ifname = "enp4s0f0";
|
||||
const std::string home_dir = "/home/drath";
|
||||
constexpr std::string home_dir = "/home/drath";
|
||||
|
||||
namespace semaphores {
|
||||
std::binary_semaphore display{0};
|
||||
@@ -39,7 +39,7 @@ void signalHandler(int) {
|
||||
app::semaphores::display.release();
|
||||
}
|
||||
|
||||
void hassThread(std::stop_token st, app::sensors& s) {
|
||||
void hassThread(const std::stop_token& st, app::sensors& s) {
|
||||
applog(LOG::START, "Thread started");
|
||||
HomeAssistant pc_power("home.drath.win", "sensor.gniazdko_komputer_moc");
|
||||
|
||||
@@ -54,7 +54,7 @@ void hassThread(std::stop_token st, app::sensors& s) {
|
||||
}
|
||||
}
|
||||
|
||||
void sensorsThread(std::stop_token st, app::sensors& s) {
|
||||
void sensorsThread(const std::stop_token& st, app::sensors& s) {
|
||||
applog(LOG::START, "Thread started, poll interval {} ms", lcd_interval_ms);
|
||||
cpu::detectHwmon(&s.cpu, cpu_pciaddr);
|
||||
gpu::detectHwmon(&s.gpu, gpu_pciaddr);
|
||||
@@ -82,7 +82,7 @@ void sensorsThread(std::stop_token st, app::sensors& s) {
|
||||
}
|
||||
}
|
||||
|
||||
void displayThread(std::stop_token st, app::sensors& s) {
|
||||
void displayThread(const std::stop_token& st, app::sensors& s) {
|
||||
applog(LOG::START, "Thread started");
|
||||
// init internal variables of LCDDisplay class
|
||||
LCDDisplay lcd(lcd_port);
|
||||
@@ -113,7 +113,7 @@ void displayThread(std::stop_token st, app::sensors& s) {
|
||||
gpu_temps = utils::pad(lcd.cc(1) + std::to_string(s.gpu.temp_hotspot - s.gpu.temp_edge) + lcd.cc(0), 4) + " " + utils::pad(gpu_temps + "/" + std::to_string(s.gpu.temp_hotspot), 5);
|
||||
|
||||
uint16_t cpu_fan = 0;
|
||||
for (auto& fan : s.sys.fan_speed)
|
||||
for (const auto& fan : s.sys.fan_speed)
|
||||
cpu_fan += fan;
|
||||
cpu_fan /= 2;
|
||||
|
||||
@@ -130,7 +130,7 @@ void displayThread(std::stop_token st, app::sensors& s) {
|
||||
lcd.writeBuf(1, 32 - gpu_temps.size(), utils::pad(utils::pBytes(s.gpu.vram_used), 6));
|
||||
lcd.writeBuf(1, 39 - gpu_temps.size(), gpu_temps + lcd.cc(0));
|
||||
|
||||
lcd.writeBuf(2, 0, utils::pad(std::to_string((int)s.cpu.ptotal) + "W", 8, utils::just::left));
|
||||
lcd.writeBuf(2, 0, utils::pad(std::to_string(static_cast<int>(s.cpu.ptotal)) + "W", 8, utils::just::left));
|
||||
lcd.writeBuf(2, s.cpu.ptotal < 100 ? 4 : 5, std::to_string(cpu_fan) + "R"); // avg fan speed
|
||||
lcd.writeBuf(2, 12, lcd.cc(3) + utils::pBytes(s.net.upload));
|
||||
lcd.writeBuf(2, 19, lcd.cc(4) + utils::pBytes(s.net.download));
|
||||
@@ -152,7 +152,7 @@ void displayThread(std::stop_token st, app::sensors& s) {
|
||||
lcd.flushBuf();
|
||||
}
|
||||
|
||||
void start(void) {
|
||||
void start() {
|
||||
applog(LOG::START, "Application started");
|
||||
std::signal(SIGINT, app::signalHandler);
|
||||
std::signal(SIGTERM, app::signalHandler);
|
||||
|
||||
Reference in New Issue
Block a user