yuge overhaul, threads, hass, rewrote display, hwmons, bunc of shit
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
#ifndef LCDDISPLAY_HPP
|
||||
#define LCDDISPLAY_HPP
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <sstream>
|
||||
@@ -6,10 +9,12 @@
|
||||
class LCDDisplay {
|
||||
private:
|
||||
uint8_t _lcd;
|
||||
void writeStr(std::string str);
|
||||
char linebuf[4][41]{};
|
||||
void writeStr(std::string str); // do not use
|
||||
void writeLines(std::array<std::string, 4> lines); // do not use
|
||||
|
||||
public:
|
||||
LCDDisplay(std::string dev, uint32_t baud = 0010002); // from termios-baud.h, B115200
|
||||
LCDDisplay(std::string dev, uint32_t baud = 0010002); // from termios-baud.h, B115200
|
||||
~LCDDisplay();
|
||||
|
||||
// custom char array
|
||||
@@ -19,8 +24,11 @@ class LCDDisplay {
|
||||
void setContrast(uint8_t contrast);
|
||||
void setBacklight(bool enabled);
|
||||
void setCursor(uint8_t row, uint8_t col);
|
||||
void writeLines(std::array<std::string, 4> lines);
|
||||
void writeBuf(uint8_t row, uint8_t col, std::string str);
|
||||
void flushBuffer();
|
||||
void writeSStream(std::stringstream& ss);
|
||||
void setCustomChar(uint8_t index, std::array<uint8_t, 8> cchar);
|
||||
char bar(uint8_t char_id, double value);
|
||||
};
|
||||
|
||||
#endif
|
||||
33
include/cpu.hpp
Normal file
33
include/cpu.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef CPU_HPP
|
||||
#define CPU_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <print>
|
||||
#include <string>
|
||||
|
||||
#include <utils.hpp>
|
||||
|
||||
#define N_CPU 16
|
||||
|
||||
struct cpu_hwmon_t {
|
||||
std::string path = "";
|
||||
bool zenpower = false;
|
||||
};
|
||||
|
||||
struct cpu_t {
|
||||
int tdie = 0;
|
||||
int tctl = 0;
|
||||
int tccd1 = 0;
|
||||
double pcore = 0.0;
|
||||
double psoc = 0.0;
|
||||
double ptotal = 0.0;
|
||||
double vcore = 0.0;
|
||||
double vsoc = 0.0;
|
||||
uint32_t avg_freq = 0;
|
||||
};
|
||||
|
||||
cpu_t getCpu(cpu_hwmon_t hw);
|
||||
cpu_hwmon_t detectCpuHwmon(std::string pci);
|
||||
|
||||
#endif
|
||||
@@ -1,25 +1,32 @@
|
||||
#ifndef GPU_HPP
|
||||
#define GPU_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <print>
|
||||
#include <string>
|
||||
#include <utils.hpp>
|
||||
|
||||
struct gpu_t {
|
||||
uint16_t fan_speed;
|
||||
uint16_t core_clock;
|
||||
uint16_t mem_clock;
|
||||
double vcore;
|
||||
uint16_t power_avg;
|
||||
uint16_t power_cap;
|
||||
uint16_t power_max;
|
||||
uint8_t fan_pwm;
|
||||
uint8_t edge_temp;
|
||||
uint8_t hotspot_temp;
|
||||
uint8_t mem_temp;
|
||||
uint8_t gfx_vrm_temp;
|
||||
uint8_t soc_vrm_temp;
|
||||
uint8_t mem_vrm_temp;
|
||||
uint64_t vram_used;
|
||||
uint64_t vram_total;
|
||||
uint8_t core_usage;
|
||||
uint8_t media_usage;
|
||||
uint8_t umc_usage;
|
||||
uint16_t fan_speed = 0;
|
||||
uint16_t core_clock = 0;
|
||||
uint16_t mem_clock = 0;
|
||||
double vcore = 0;
|
||||
uint16_t power_avg = 0;
|
||||
uint16_t power_cap = 0;
|
||||
uint16_t power_max = 0;
|
||||
uint8_t fan_pwm = 0;
|
||||
uint8_t edge_temp = 0;
|
||||
uint8_t hotspot_temp = 0;
|
||||
uint8_t mem_temp = 0;
|
||||
uint8_t gfx_vrm_temp = 0;
|
||||
uint8_t soc_vrm_temp = 0;
|
||||
uint8_t mem_vrm_temp = 0;
|
||||
uint64_t vram_used = 0;
|
||||
uint64_t vram_total = 0;
|
||||
uint8_t core_usage = 0;
|
||||
uint8_t media_usage = 0;
|
||||
uint8_t umc_usage = 0;
|
||||
};
|
||||
|
||||
struct GpuMetricsHeader_t {
|
||||
@@ -28,6 +35,9 @@ struct GpuMetricsHeader_t {
|
||||
uint8_t content_revision = 0;
|
||||
};
|
||||
|
||||
std::string detectGpuHwmon(std::string pci);
|
||||
gpu_t getGpu(GpuMetricsHeader_t header, std::string hw);
|
||||
gpu_t getGpu(std::string hw);
|
||||
GpuMetricsHeader_t getGpuMetricsHeader(std::string path);
|
||||
GpuMetricsHeader_t getGpuMetricsHeader(std::string path);
|
||||
|
||||
#endif
|
||||
12
include/sys.hpp
Normal file
12
include/sys.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef SYS_HPP
|
||||
#define SYS_HPP
|
||||
|
||||
#include <ctime>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <utils.hpp>
|
||||
|
||||
std::string getAvgs();
|
||||
std::array<std::string, 2> getTimeDate();
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,27 @@
|
||||
#ifndef UTILS_HPP
|
||||
#define UTILS_HPP
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <print>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
std::string readFile(std::string path, uint8_t trim = 0);
|
||||
std::string pNum(double num, uint8_t decs = 0);
|
||||
std::string pNum(float num, uint8_t decs = 0);
|
||||
std::string pBytes(double bytes, bool isKbytes = false);
|
||||
std::string readFile(std::string path, size_t trim = 4096);
|
||||
ssize_t readFile2(std::string path, char *buffer, size_t maxlen);
|
||||
ssize_t readFile2(const char *path, char *buffer, size_t maxlen);
|
||||
int get_val(const std::string &target, const std::string &content);
|
||||
std::string findHwmonPath(std::string module);
|
||||
std::string getFirstDir(std::string path);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user