This commit is contained in:
2026-07-01 01:50:02 +02:00
parent 86da8434bd
commit 29c14dc56f
11 changed files with 48 additions and 52 deletions

View File

@@ -15,11 +15,11 @@
#include "sys.h"
#include "utils.h"
static const uint8_t lcd_contrast = 200;
static const uint16_t refresh_interval_ms = 1000;
static const char netif[] = "enp4s0f0";
static const char cpu_pcidev[] = "0000:00:18.3";
static const char gpu_pcidev[] = "0000:0a:00.0";
static constexpr uint8_t lcd_contrast = 200;
static constexpr uint16_t refresh_interval_ms = 1000;
static constexpr char netif[] = "enp4s0f0";
static constexpr char cpu_pcidev[] = "0000:00:18.3";
static constexpr char gpu_pcidev[] = "0000:0a:00.0";
struct control_t {
atomic_bool g_running;
@@ -78,7 +78,7 @@ static void *sensors_thread(void *arg) {
pthread_mutex_unlock(&control.sensors_mtx);
timespec_add_ms(&next, refresh_interval_ms);
clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &next, NULL);
clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &next, nullptr);
}
aio_close(&sensors->aio);
@@ -121,7 +121,7 @@ static void *display_thread(void *arg) {
{
// prepare some tricky sensors
const char modes[] = "QBP";
constexpr char modes[] = "QBP";
const uint16_t avg_fan_speed = (sensors->aio.fan_speed[0] + sensors->aio.fan_speed[1]) / 2;
char gpudelta[5];
@@ -194,13 +194,13 @@ int main(void) {
sigaddset(&sigset, SIGINT);
sigaddset(&sigset, SIGTERM);
sigaddset(&sigset, SIGQUIT);
pthread_sigmask(SIG_BLOCK, &sigset, NULL);
pthread_sigmask(SIG_BLOCK, &sigset, nullptr);
struct signalfd_siginfo info;
const int sfd = signalfd(-1, &sigset, SFD_CLOEXEC);
/* control vars setup */
pthread_mutex_init(&control.sensors_mtx, NULL);
pthread_cond_init(&control.sensors_ready, NULL);
pthread_mutex_init(&control.sensors_mtx, nullptr);
pthread_cond_init(&control.sensors_ready, nullptr);
control.g_running = true;
/* thread setup */
@@ -208,8 +208,8 @@ int main(void) {
pthread_t display_pthread;
/* actually start the threads */
pthread_create(&sensors_pthread, NULL, sensors_thread, sensors);
pthread_create(&display_pthread, NULL, display_thread, sensors);
pthread_create(&sensors_pthread, nullptr, sensors_thread, sensors);
pthread_create(&display_pthread, nullptr, display_thread, sensors);
/* halts here until signal to stop */
const ssize_t ret = read(sfd, &info, sizeof(info));
@@ -219,8 +219,8 @@ int main(void) {
applog(LOG_WRN, "got stop signal, shutting down...");
close(sfd);
control.g_running = false;
pthread_join(sensors_pthread, NULL);
pthread_join(display_pthread, NULL);
pthread_join(sensors_pthread, nullptr);
pthread_join(display_pthread, nullptr);
free(sensors);
return 0;
}