58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
#ifndef APP_HPP
|
|
#define APP_HPP
|
|
|
|
#include <atomic>
|
|
#include <cpu.hpp>
|
|
#include <gpu.hpp>
|
|
#include <mutex>
|
|
#include <semaphore>
|
|
#include <stop_token>
|
|
#include <sys.hpp>
|
|
#include <thread>
|
|
|
|
class Application {
|
|
public:
|
|
struct Config {
|
|
uint16_t lcd_interval_ms;
|
|
uint8_t lcd_contrast;
|
|
std::string lcd_port;
|
|
std::string cpu_pciaddr;
|
|
std::string gpu_pciaddr;
|
|
std::string sys_sensor;
|
|
std::string sys_ifname;
|
|
std::string home_dir;
|
|
};
|
|
|
|
explicit Application(Config config);
|
|
~Application();
|
|
void Run();
|
|
|
|
private:
|
|
struct Sensors {
|
|
sys::TimeDate td;
|
|
double avg[3] = {0.0f};
|
|
sys::Memory ram;
|
|
sys::Disk home;
|
|
sys::Network net;
|
|
sys::sysSensors sys;
|
|
cpu::cpuSensors cpu;
|
|
gpu::gpuSensors gpu;
|
|
double hass_state = 0.0f;
|
|
std::mutex mtx; // making sure the struct isnt accessed by multiple threads at once
|
|
};
|
|
|
|
struct Control {
|
|
std::binary_semaphore display{0};
|
|
sigset_t sigset;
|
|
};
|
|
|
|
Config m_config; // m_ is prefix for member variable
|
|
Control m_control{};
|
|
Sensors m_sensors{};
|
|
|
|
void hassThread(const std::stop_token& st);
|
|
void sensorsThread(const std::stop_token& st);
|
|
void displayThread(const std::stop_token& st);
|
|
};
|
|
|
|
#endif |