clangify includes

This commit is contained in:
Drath
2025-10-29 01:26:47 +01:00
parent 33f343fa0a
commit 68cd4b0bfe
12 changed files with 63 additions and 53 deletions

View File

@@ -1,5 +1,15 @@
#include "LCDDisplay.hpp"
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include <array>
#include <cstdint>
#include <cstring>
#include <log.hpp>
#include <string>
/* lcd size hardcoded to 4x40 idgaf */
LCDDisplay::LCDDisplay(std::string dev, uint32_t baud) {
_dev = dev;

View File

@@ -1,5 +1,10 @@
#include <chrono>
#include <cpu.hpp>
#include <print>
#include <cstdint>
#include <filesystem>
#include <log.hpp>
#include <string>
#include <utils.hpp>
namespace cpu {

View File

@@ -1,4 +1,8 @@
#include <gpu.hpp>
#include <gpu_metrics.hpp>
#include <log.hpp>
#include <string>
#include <utils.hpp>
/* maybe have a read pp_table function */
/* would be neat to wrap it in a class but eh namespace is good enough */

View File

@@ -1,4 +1,10 @@
#include <libwebsockets.h>
#include <ArduinoJson.hpp>
#include <hass.hpp>
#include <log.hpp>
#include <string>
HomeAssistant::HomeAssistant(std::string addr, std::string ent) {
address = addr;
@@ -9,7 +15,7 @@ HomeAssistant::~HomeAssistant() {
disconnect();
}
void HomeAssistant::event_handler(struct lws *wsi, enum lws_callback_reasons reason, char *in) {
void HomeAssistant::event_handler(struct lws* wsi, enum lws_callback_reasons reason, char* in) {
ArduinoJson::JsonDocument json;
switch (reason) {
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: {
@@ -50,7 +56,7 @@ void HomeAssistant::event_handler(struct lws *wsi, enum lws_callback_reasons rea
break;
}
log(LOG::WRN, "HomeAssistant::event_handler", "unhandled event: {}", (char *)in);
log(LOG::WRN, "HomeAssistant::event_handler", "unhandled event: {}", (char*)in);
break;
}
@@ -68,7 +74,7 @@ void HomeAssistant::event_handler(struct lws *wsi, enum lws_callback_reasons rea
/* skip whole callback if there's no tx to send */
if (tx.size() > 0) {
size_t msgLen = LWS_PRE + tx.size();
unsigned char *buf = (unsigned char *)malloc(msgLen);
unsigned char* buf = (unsigned char*)malloc(msgLen);
if (buf) {
memcpy(&buf[LWS_PRE], tx.c_str(), tx.size());
if (!lws_write(wsi, &buf[LWS_PRE], tx.size(), LWS_WRITE_TEXT))
@@ -85,9 +91,9 @@ void HomeAssistant::event_handler(struct lws *wsi, enum lws_callback_reasons rea
}
}
int HomeAssistant::callback(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len) {
HomeAssistant *self = static_cast<HomeAssistant *>(user);
self->event_handler(wsi, reason, (char *)in);
int HomeAssistant::callback(struct lws* wsi, enum lws_callback_reasons reason, void* user, void* in, size_t len) {
HomeAssistant* self = static_cast<HomeAssistant*>(user);
self->event_handler(wsi, reason, (char*)in);
return 0;
}
@@ -101,7 +107,7 @@ int HomeAssistant::connect() {
memset(&info, 0, sizeof info);
static const struct lws_protocols protocols[] = {
{"lws-minimal-client", callback, sizeof(void *), 0, 0, NULL, 0},
{"lws-minimal-client", callback, sizeof(void*), 0, 0, NULL, 0},
LWS_PROTOCOL_LIST_TERM};
static const struct lws_extension extensions[] = {

View File

@@ -1,4 +1,5 @@
#include <sys/statvfs.h>
#include <chrono>
#include <format>
#include <string>
@@ -35,11 +36,11 @@ void sys::getNetwork(Network* net, std::string device) {
uint64_t rx = 0;
uint64_t tx = 0;
};
static _net prev;
_net current;
current.ts = std::chrono::steady_clock::now();
current.ts = std::chrono::steady_clock::now();
current.rx = std::stoull(readFile("/sys/class/net/" + device + "/statistics/rx_bytes", 32));
current.tx = std::stoull(readFile("/sys/class/net/" + device + "/statistics/tx_bytes", 32));
float ts_diff = std::chrono::duration_cast<std::chrono::microseconds>(current.ts - prev.ts).count() / 1000000.0f;
@@ -48,13 +49,13 @@ void sys::getNetwork(Network* net, std::string device) {
prev = current;
}
void sys::detectHwmon(sysSensors* s, std::string platform) {
s->hwmon = getFirstDir("/sys/devices/platform/" + platform + "/hwmon");
}
void sys::updateSensors(sysSensors* s) {
s->fan_speed[0] = std::stol(readFile(s->hwmon + "/fan2_input", 4));
s->fan_speed[1] = std::stol(readFile(s->hwmon + "/fan7_input", 4));;
s->fan_speed[1] = std::stol(readFile(s->hwmon + "/fan7_input", 4));
;
s->t_sensor = std::stol(readFile(s->hwmon + "/temp5_input", 2));
}

View File

@@ -1,5 +1,15 @@
#include <utils.hpp>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <cstdint>
#include <cstdlib>
#include <filesystem>
#include <format>
#include <log.hpp>
#include <string>
#include <string_view>
#include <utils.hpp>
// pads given string to length
std::string pad(std::string s, uint8_t len, bool ljust) {
@@ -23,8 +33,8 @@ std::string pBytes(double bytes, bool isKbytes) {
if (suffix == 'K' && isKbytes) continue; // skip first loop if already in Kbytes
bytes /= 1024.0;
if (bytes < 1024) {
if(bytes > 100) return pNum(bytes) + suffix;
if(bytes > 10) return pNum(bytes, 1) + suffix;
if (bytes > 100) return pNum(bytes) + suffix;
if (bytes > 10) return pNum(bytes, 1) + suffix;
return pNum(bytes, 2) + suffix;
}
}