formatting shit
This commit is contained in:
@@ -24,7 +24,7 @@ struct cpu_sensors_t {
|
||||
char hwmon[128];
|
||||
};
|
||||
|
||||
void cpu_detect(struct cpu_sensors_t* t, const char* pci_dev);
|
||||
void cpu_detect(struct cpu_sensors_t *t, const char *pci_dev);
|
||||
void cpu_update(struct cpu_sensors_t *c);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef GPU_H
|
||||
#define GPU_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct gpu_sensors_t {
|
||||
uint64_t vram_used;
|
||||
@@ -36,7 +36,7 @@ struct gpu_sensors_t {
|
||||
char hwmon[128];
|
||||
};
|
||||
|
||||
void gpu_detect(struct gpu_sensors_t* t, const char* pci);
|
||||
void gpu_update(struct gpu_sensors_t* g);
|
||||
void gpu_detect(struct gpu_sensors_t *t, const char *pci);
|
||||
void gpu_update(struct gpu_sensors_t *g);
|
||||
|
||||
#endif
|
||||
@@ -16,19 +16,19 @@ struct lcd_t {
|
||||
|
||||
typedef uint8_t lcd_glyph_t[8];
|
||||
|
||||
void lcd_close(struct lcd_t* lcd);
|
||||
void lcd_clear(struct lcd_t* lcd);
|
||||
void lcd_set_contrast(struct lcd_t* lcd, uint8_t contrast);
|
||||
void lcd_set_backlight(struct lcd_t* lcd, bool enabled);
|
||||
void lcd_set_cursor(struct lcd_t* lcd, uint8_t row, uint8_t col);
|
||||
void lcd_set_custom_char(struct lcd_t* lcd, uint8_t index, const lcd_glyph_t* glyph);
|
||||
void lcd_write_str(struct lcd_t* lcd, const char* str, uint8_t len);
|
||||
void lcd_write_str_pos(struct lcd_t* lcd, const char* str, uint8_t len, uint8_t posX, uint8_t posY);
|
||||
void lcd_write_buf(struct lcd_t* lcd, uint8_t row, uint8_t col, const char* str);
|
||||
void lcd_writef(struct lcd_t *lcd, uint8_t x, uint8_t y, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
|
||||
void lcd_clear_buf(struct lcd_t* lcd);
|
||||
void lcd_flush_buf(struct lcd_t* lcd);
|
||||
char lcd_bar(struct lcd_t* lcd, uint8_t char_id, double value);
|
||||
int lcd_init(struct lcd_t* lcd);
|
||||
void lcd_close(struct lcd_t *lcd);
|
||||
void lcd_clear(struct lcd_t *lcd);
|
||||
void lcd_set_contrast(struct lcd_t *lcd, uint8_t contrast);
|
||||
void lcd_set_backlight(struct lcd_t *lcd, bool enabled);
|
||||
void lcd_set_cursor(struct lcd_t *lcd, uint8_t row, uint8_t col);
|
||||
void lcd_set_custom_char(struct lcd_t *lcd, uint8_t index, const lcd_glyph_t *glyph);
|
||||
void lcd_write_str(struct lcd_t *lcd, const char *str, uint8_t len);
|
||||
void lcd_write_str_pos(struct lcd_t *lcd, const char *str, uint8_t len, uint8_t posX, uint8_t posY);
|
||||
void lcd_write_buf(struct lcd_t *lcd, uint8_t row, uint8_t col, const char *str);
|
||||
void lcd_writef(struct lcd_t *lcd, uint8_t x, uint8_t y, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
|
||||
void lcd_clear_buf(struct lcd_t *lcd);
|
||||
void lcd_flush_buf(struct lcd_t *lcd);
|
||||
char lcd_bar(struct lcd_t *lcd, uint8_t char_id, double value);
|
||||
int lcd_init(struct lcd_t *lcd);
|
||||
|
||||
#endif
|
||||
@@ -15,25 +15,25 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef enum {
|
||||
LOG_INF,
|
||||
LOG_WRN,
|
||||
LOG_ERR,
|
||||
LOG_DBG,
|
||||
LOG_START,
|
||||
LOG_INF,
|
||||
LOG_WRN,
|
||||
LOG_ERR,
|
||||
LOG_DBG,
|
||||
LOG_START,
|
||||
} log_level_t;
|
||||
|
||||
/* __PRETTY_FUNCTION__ is a GCC/Clang extension that gives the full
|
||||
s ignature: "voi*d foo(int x)" — same thing source_location gave you.
|
||||
Falls back to plain __func__ (C99) if somehow unavailable. */
|
||||
#define applog(level, fmt, ...) \
|
||||
log_write(level, __PRETTY_FUNCTION__, fmt, ##__VA_ARGS__)
|
||||
log_write(level, __PRETTY_FUNCTION__, fmt, ##__VA_ARGS__)
|
||||
|
||||
/* format attribute gives compile-time printf format checking —
|
||||
better than wha*t std::format gave you at runtime */
|
||||
void log_write(log_level_t level, const char *func, const char *fmt, ...)
|
||||
__attribute__((format(printf, 3, 4)));
|
||||
__attribute__((format(printf, 3, 4)));
|
||||
|
||||
#else /* APPLOG_ENABLED not defined */
|
||||
#else /* APPLOG_ENABLED not defined */
|
||||
|
||||
#define applog(...) ((void)0)
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ struct network_t {
|
||||
};
|
||||
|
||||
struct syssensors_t {
|
||||
uint16_t fan_speed[2]; // left and right cpu fans
|
||||
int16_t t_sensor; // ntc temp sensor
|
||||
uint16_t fan_speed[2]; // left and right cpu fans
|
||||
int16_t t_sensor; // ntc temp sensor
|
||||
char hwmon[128];
|
||||
};
|
||||
|
||||
@@ -37,11 +37,11 @@ void sys_get_load_avg(double *load_avg);
|
||||
|
||||
void sys_get_ram(struct memory_t *ram);
|
||||
|
||||
void sys_get_disk(struct disk_t* disk);
|
||||
void sys_get_disk(struct disk_t *disk);
|
||||
|
||||
void sys_get_network(struct network_t* network);
|
||||
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);
|
||||
void sys_detect(struct syssensors_t *s, const char *platform);
|
||||
void sys_update_sensors(struct syssensors_t *s);
|
||||
|
||||
#endif //LINUXSMARTIE_SYS_H
|
||||
#endif // LINUXSMARTIE_SYS_H
|
||||
@@ -1,28 +1,48 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <time.h>
|
||||
#include <stdbool.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);
|
||||
char *pretty_num(double num, char *buf, size_t bufsz);
|
||||
|
||||
void fast_read_num_u64(const char* dir, const char* file, char* buf, uint64_t* result, uint32_t divider);
|
||||
void fast_read_num_u16(const char* dir, const char* file, char* buf, uint16_t* result, uint32_t divider);
|
||||
void fast_read_num_u8(const char* dir, const char* file, char* buf, uint8_t* result, uint32_t divider);
|
||||
void fast_read_num_i16(const char* dir, const char* file, char* buf, int16_t* result, uint32_t divider);
|
||||
void fast_read_num_f(const char* dir, const char* file, char* buf, float* result, uint32_t divider);
|
||||
|
||||
bool file_exists(const char *path);
|
||||
size_t read_file(const char* path, char* buffer, size_t n);
|
||||
|
||||
int get_hwmon_dir(char *path);
|
||||
#if __STDC_VERSION__ >= 202311L
|
||||
#define C_STD "C23"
|
||||
#elif __STDC_VERSION__ >= 201710L
|
||||
#define C_STD "C17"
|
||||
#elif __STDC_VERSION__ >= 201112L
|
||||
#define C_STD "C11"
|
||||
#elif __STDC_VERSION__ >= 199901L
|
||||
#define C_STD "C99"
|
||||
#else
|
||||
#define C_STD "C89"
|
||||
#endif
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define P_BYTES(bytes, start) pretty_bytes((bytes), (start), (char[16]){0}, 16)
|
||||
#define P_NUM(num) pretty_num((num), (char[8]){0}, 8)
|
||||
|
||||
void timespec_add_ms(struct timespec *ts, uint16_t ms);
|
||||
|
||||
uint64_t timespec_diff_us(const struct timespec *a, const struct timespec *b);
|
||||
|
||||
char *pretty_num(double num, char *buf, size_t bufsz);
|
||||
|
||||
char *pretty_bytes(uint64_t bytes, int8_t start_suffix, char *buf, size_t bufsz);
|
||||
|
||||
bool file_exists(const char *path);
|
||||
|
||||
int get_hwmon_dir(char *path);
|
||||
|
||||
size_t read_file(const char *path, char *buffer, size_t n);
|
||||
|
||||
void fast_read_num_u64(const char *dir, const char *file, char *buf, uint64_t *result, uint32_t divider);
|
||||
|
||||
void fast_read_num_u16(const char *dir, const char *file, char *buf, uint16_t *result, uint32_t divider);
|
||||
|
||||
void fast_read_num_u8(const char *dir, const char *file, char *buf, uint8_t *result, uint32_t divider);
|
||||
|
||||
void fast_read_num_i16(const char *dir, const char *file, char *buf, int16_t *result, uint32_t divider);
|
||||
|
||||
void fast_read_num_f(const char *dir, const char *file, char *buf, float *result, uint32_t divider);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user