put ts in structs

This commit is contained in:
2026-01-07 08:57:16 +01:00
parent 5359663c88
commit 49f883bf13
3 changed files with 26 additions and 20 deletions

View File

@@ -19,9 +19,9 @@
void Application::hassThread(const std::stop_token& st) {
applog(LOG::START, "Thread started");
HomeAssistant::Config config;
config.address = m_config.hass_url;
config.entity = m_config.hass_entity;
config.token = m_config.hass_token;
config.address = m_config.hass.url;
config.entity = m_config.hass.entity;
config.token = m_config.hass.token;
HomeAssistant pc_power(config);
pc_power.connect();
@@ -36,7 +36,7 @@ void Application::hassThread(const std::stop_token& st) {
}
void Application::sensorsThread(const std::stop_token& st) {
applog(LOG::START, "Thread started, poll interval {} ms", m_config.lcd_interval_ms);
applog(LOG::START, "Thread started, poll interval {} ms", m_config.lcd.refresh_interval_ms);
cpu::detectHwmon(&m_sensors.cpu, m_config.cpu_pciaddr);
gpu::detectHwmon(&m_sensors.gpu, m_config.gpu_pciaddr);
sys::detectHwmon(&m_sensors.sys, m_config.sys_sensor);
@@ -59,7 +59,7 @@ void Application::sensorsThread(const std::stop_token& st) {
// log(LOG::DBG, "took {} microseconds", std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - start).count());
m_control.display.release(); // unlocks display loop
std::this_thread::sleep_until(start + std::chrono::milliseconds(m_config.lcd_interval_ms));
std::this_thread::sleep_until(start + std::chrono::milliseconds(m_config.lcd.refresh_interval_ms));
}
applog(LOG::INF, "Thread stopped");
}
@@ -68,10 +68,10 @@ void Application::displayThread(const std::stop_token& st) {
std::stop_callback cb(st, [&] { m_control.display.release(); });
applog(LOG::START, "Thread started");
// init internal variables of LCDDisplay class
LCDDisplay lcd(m_config.lcd_port);
LCDDisplay lcd(m_config.lcd.port);
// basic lcd setup
lcd.setContrast(m_config.lcd_contrast);
lcd.setContrast(m_config.lcd.contrast);
lcd.setBacklight(true);
lcd.setCustomChar(0, {16, 6, 9, 8, 8, 9, 6, 0}); // celcius
lcd.setCustomChar(1, {0, 0, 4, 10, 10, 17, 31, 0}); // delta
@@ -86,7 +86,7 @@ void Application::displayThread(const std::stop_token& st) {
// actual main display loop
while (!st.stop_requested()) {
m_control.display.try_acquire_for(std::chrono::milliseconds(static_cast<int>(m_config.lcd_interval_ms * 1.25))); // holds the loop until sensor data is ready, max 1.25x of the loop time
m_control.display.try_acquire_for(std::chrono::milliseconds(static_cast<int>(m_config.lcd.refresh_interval_ms * 1.25))); // holds the loop until sensor data is ready, max 1.25x of the loop time
if (st.stop_requested()) break; // needed, otherwise it wont quit correctly
{
std::lock_guard lock(m_control.sensors);