get rid of macro, use inline func

This commit is contained in:
2025-12-28 19:06:23 +01:00
parent 12d7ab9b0f
commit 2d3a481638
5 changed files with 44 additions and 38 deletions

View File

@@ -55,8 +55,8 @@ void sys::getNetwork(Network* net, const std::string& device) {
_net current;
current.ts = std::chrono::steady_clock::now();
fastReadNum("/sys/class/net/" + device + "/statistics/rx_bytes", current.rx);
fastReadNum("/sys/class/net/" + device + "/statistics/tx_bytes", current.tx);
current.rx = fastReadNum("/sys/class/net/" + device + "/statistics/rx_bytes", buf);
current.tx = fastReadNum("/sys/class/net/" + device + "/statistics/tx_bytes", buf);
float ts_diff = std::chrono::duration_cast<std::chrono::microseconds>(current.ts - prev.ts).count() / 1000000.0f;
net->download = (current.rx - prev.rx) / ts_diff;
net->upload = (current.tx - prev.tx) / ts_diff;
@@ -77,7 +77,7 @@ void sys::updateSensors(sysSensors* s) {
if (s->hwmon.length() < 1)
return;
static char buf[8];
fastReadNum(s->hwmon + "/fan2_input", s->fan_speed[0]);
fastReadNum(s->hwmon + "/fan7_input", s->fan_speed[1]);
fastReadNum(s->hwmon + "/temp5_input", s->t_sensor) / 1000;
s->fan_speed[0] = fastReadNum(s->hwmon + "/fan2_input", buf);
s->fan_speed[1] = fastReadNum(s->hwmon + "/fan7_input", buf);
s->t_sensor = fastReadNum(s->hwmon + "/temp5_input", buf) / 1000;
}