add some return values to some shit so it shuts down elegantly on crash

This commit is contained in:
2026-01-15 00:19:53 +01:00
parent 6297317f93
commit 7929a687e8
11 changed files with 105 additions and 64 deletions

View File

@@ -11,11 +11,12 @@
class LCDDisplay {
private:
int _lcd = -1;
uint32_t _baud = 0;
std::string _dev;
std::array<char, LCD_LINES * LCD_COLS + 8> writebuf{}; // 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);
int open(bool reopen = false);
void write(const uint8_t* cmdbuf, uint8_t len);
void close();
@@ -27,6 +28,7 @@ class LCDDisplay {
explicit LCDDisplay(const std::string& dev, uint32_t baud = 0010002); // from termios-baud.h, B115200
~LCDDisplay();
int Init();
void clear();
void setContrast(uint8_t contrast);
void setBacklight(bool enabled);

View File

@@ -34,7 +34,7 @@ class Application {
explicit Application(Config config);
~Application();
void Run();
int Run();
private:
struct Sensors {
@@ -55,6 +55,8 @@ class Application {
sigset_t sigset;
};
pid_t m_mainPid{};
int m_ret = 0;
Config m_config{}; // m_ is prefix for member variable
Control m_control{};
Sensors m_sensors{};
@@ -62,6 +64,8 @@ class Application {
void hassThread(const std::stop_token& st);
void sensorsThread(const std::stop_token& st);
void displayThread(const std::stop_token& st);
void Crash(int ret);
};
#endif

View File

@@ -25,7 +25,7 @@ struct cpuSensors {
std::string hwmon;
};
void detectHwmon(cpuSensors* target, const std::string& pci);
int detect(cpuSensors* target, const std::string& pci);
void update(cpuSensors* c);
} // namespace cpu

View File

@@ -40,7 +40,7 @@ struct gpuSensors {
std::string hwmon;
};
void detectHwmon(gpuSensors* target, const std::string& pci);
int detect(gpuSensors* target, const std::string& pci);
void update(gpuSensors* g);
} // namespace gpu

View File

@@ -41,7 +41,7 @@ void getTimeDate(TimeDate* td);
void getDisk(Disk* disk);
void getRam(Memory* mem);
void getNetwork(Network* net, const std::string& device);
void detectHwmon(sysSensors* s, const std::string& platform);
int detect(sysSensors* s, const std::string& platform);
void updateSensors(sysSensors* s);
} // namespace sys