This commit is contained in:
2026-05-10 21:17:36 +02:00
parent f28cd4c31a
commit 9bd2357b96
7 changed files with 118 additions and 33 deletions

View File

@@ -25,6 +25,11 @@ struct network_t {
char device[32];
};
struct syssensors_t {
uint16_t fan_speed[2]; // left and right cpu fans
int16_t t_sensor; // ntc temp sensor
char hwmon[128];
};
void sys_get_time(struct time_date_t *td);
@@ -36,4 +41,7 @@ void sys_get_disk(struct disk_t* disk);
void sys_get_network(struct network_t* network);
void sys_detect(struct syssensors_t* s, const char* platform);
void sys_update_sensors(struct syssensors_t* s);
#endif //LINUXSMARTIE_SYS_H

View File

@@ -1,11 +1,22 @@
#ifndef UTILS_H
#define UTILS_H
#include <time.h>
uint64_t timespec_diff_us(const struct timespec *a, const struct timespec *b);
void timespec_add_ms(struct timespec *ts, uint16_t ms);
char *pretty_bytes(uint64_t bytes, int8_t start_suffix, char *buf, size_t bufsz);
void fast_read_num_u64(const char* dir, const char* file, char* buf, uint64_t* result, uint16_t divider);
void fast_read_num_u16(const char* dir, const char* file, char* buf, uint16_t* result, uint16_t divider);
void fast_read_num_i16(const char* dir, const char* file, char* buf, int16_t* result, uint16_t divider);
bool file_exists(const char *path);
int get_hwmon_dir(char *path);
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define P_BYTES(kb, start) pretty_bytes((kb), (start), (char[16]){0}, 16)
#endif