it closes properly and EASY now

This commit is contained in:
2026-01-03 15:34:58 +01:00
parent 4b00625470
commit 4720239ebd
2 changed files with 31 additions and 39 deletions

View File

@@ -8,29 +8,27 @@
#include <semaphore>
#include <stop_token>
#include <sys.hpp>
#include <vector>
#include <thread>
class Application {
public:
public:
struct Config {
uint16_t lcd_interval_ms = 500;
uint8_t lcd_contrast = 215;
uint16_t lcd_interval_ms;
uint8_t lcd_contrast;
std::string lcd_port;
std::string cpu_pciaddr = "0000:00:18.3";
std::string gpu_pciaddr = "0000:0b:00.0";
std::string sys_sensor = "nct6775.656";
std::string sys_ifname = "enp4s0f0";
std::string home_dir = "/home/drath";
std::string cpu_pciaddr;
std::string gpu_pciaddr;
std::string sys_sensor;
std::string sys_ifname;
std::string home_dir;
};
explicit Application(const Config& config);
explicit Application(Config config);
~Application();
void Run();
private:
private:
struct Sensors {
sys::TimeDate td;
double avg[3] = {0.0f};
@@ -46,17 +44,13 @@ private:
struct Control {
std::binary_semaphore display{0};
std::binary_semaphore main{0};
std::atomic_bool quit{false};
std::stop_source stop;
sigset_t sigset;
};
Config m_config; // m_ is member variable
Config m_config; // m_ is prefix for member variable
Control m_control;
static Application* s_instance;
static void signalHandler(int);
static void hassThread(const std::stop_token& st, Sensors& s);
void hassThread(const std::stop_token& st, Sensors& s);
void sensorsThread(const std::stop_token& st, Sensors& s);
void displayThread(const std::stop_token& st, Sensors& s);
};