clang format all of this

This commit is contained in:
2026-01-02 18:23:09 +01:00
parent 8c83bf9df1
commit 3a9b2647d1
9 changed files with 26 additions and 24 deletions

View File

@@ -13,7 +13,7 @@
/* lcd size hardcoded to 4x40 idgaf */
LCDDisplay::LCDDisplay(const std::string& dev, const uint32_t baud) {
_dev = dev;
this->open(); // calls this (LCDDisplay) open() function, LCDDisplay::open()
this->open(); // calls this (LCDDisplay) open() function, LCDDisplay::open()
struct termios term{};
// Setup the serial port 8 data bits, no parity, 1 stopbit, no flow control
@@ -42,7 +42,7 @@ LCDDisplay::~LCDDisplay() {
void LCDDisplay::open(const bool reopen) {
applog(LOG::INF, "Opening serial port at \"{}\"", _dev);
if (_lcd < 0 || reopen)
_lcd = ::open(_dev.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK); // ::open calls the global open() instead of LCDDisplay::open()
_lcd = ::open(_dev.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK); // ::open calls the global open() instead of LCDDisplay::open()
if (_lcd < 0) {
applog(LOG::ERR, "Error opening serial port \"{}\"", _dev); // err
exit(_lcd);

View File

@@ -18,7 +18,7 @@ void detectHwmon(cpuSensors* target, const std::string& pci) {
return;
}
if (utils::fileExists(target->hwmon+ "/in1_input")) // idk if this is reliable, we're trying to avoid just reading the name
if (utils::fileExists(target->hwmon + "/in1_input")) // idk if this is reliable, we're trying to avoid just reading the name
target->module = k10temp;
applog(LOG::INF, "Detected module no. {} in path \"{}\"", target->module ? "zenpower" : "k10temp", target->hwmon);
}
@@ -51,11 +51,11 @@ void update(cpuSensors* c) {
// commented out unused values so its faster
if (c->module == zenpower) {
utils::fastReadNum<1000>(c->hwmon + "/temp1_input", buf, c->tdie);
utils::fastReadNum<1000>(c->hwmon + "/temp2_input", buf, c->tctl);
utils::fastReadNum<1000>(c->hwmon + "/temp3_input", buf, c->tccd1);
// utils::fastReadNum<1000>(c->hwmon + "/in1_input", buf, c->vcore);
// utils::fastReadNum<1000>(c->hwmon + "/in2_input", buf, c->vsoc);
utils::fastReadNum<1000>(c->hwmon + "/temp1_input", buf, c->tdie);
utils::fastReadNum<1000>(c->hwmon + "/temp2_input", buf, c->tctl);
utils::fastReadNum<1000>(c->hwmon + "/temp3_input", buf, c->tccd1);
// utils::fastReadNum<1000>(c->hwmon + "/in1_input", buf, c->vcore);
// utils::fastReadNum<1000>(c->hwmon + "/in2_input", buf, c->vsoc);
}
if (c->module == k10temp) {

View File

@@ -11,21 +11,21 @@
namespace gpu {
const std::string rel_metrics_path = "/../../gpu_metrics"; // gpu_metrics path relative to hwmon path
constexpr uint16_t max_metrics_length = 512; // length of the metrics buffer
constexpr uint16_t max_metrics_length = 512; // length of the metrics buffer
/* takes pointer to a target gpu::sensors struct and updates its hwmon path and detects gpu_metrics */
void detectHwmon(gpuSensors* target, const std::string& pci) {
target->hwmon = utils::getFirstDir("/sys/bus/pci/devices/" + pci + "/hwmon");
applog(LOG::INF, "Detected path \"{}\"", target->hwmon);
if(utils::fileExists(target->hwmon + rel_metrics_path)) {
if (utils::fileExists(target->hwmon + rel_metrics_path)) {
applog(LOG::INF, "found gpu_metrics");
target->hasGpuMetrics = true;
}
}
/* some metrics are missing in gpu_metrics, we always fill them from fs, unused metrics are commented out */
void fillMissingMetrics(gpuSensors* g) {;
void fillMissingMetrics(gpuSensors* g) {
static std::array<char, 32> buf;
utils::fastReadNum<1000>(g->hwmon + "/in0_input", buf, g->vcore);
// g->fan_pwm = std::stoi(readFile(g->hwmon + "/pwm1", 4)) * 100 / 256;

View File

@@ -52,9 +52,9 @@ void HomeAssistant::event_handler(struct lws* wsi, const enum lws_callback_reaso
if (ha_type == "event") {
json = json["event"];
if(json.contains("a"))
if (json.contains("a"))
state = std::stof(json["a"][entity]["s"].get<std::string>());
if(json.contains("c"))
if (json.contains("c"))
state = std::stof(json["c"][entity]["+"]["s"].get<std::string>());
break;
}
@@ -75,7 +75,7 @@ void HomeAssistant::event_handler(struct lws* wsi, const enum lws_callback_reaso
case LWS_CALLBACK_CLIENT_WRITEABLE: {
/* skip whole callback if there's no tx to send */
if (! tx.empty()) {
if (!tx.empty()) {
const size_t msgLen = LWS_PRE + tx.size();
auto* buf = static_cast<unsigned char*>(malloc(msgLen));
if (buf) {

View File

@@ -30,10 +30,10 @@ void sys::getTimeDate(TimeDate* td) {
}
void sys::getRam(Memory* mem) {
static std::array<char, 128> buf; // file is longer but we only need first 128 chars
static std::array<char, 128> buf; // file is longer but we only need first 128 chars
utils::readFile("/proc/meminfo", buf);
mem->free = getVal("MemAvailable:", std::string_view(buf));
mem->total = getVal("MemTotal:", std::string_view(buf)); // shouldn't really update this on each loop
mem->total = getVal("MemTotal:", std::string_view(buf)); // shouldn't really update this on each loop
mem->used = mem->total - mem->free;
}