From 58a489f1ad7f80b5575137071ca73dafe2b06fec Mon Sep 17 00:00:00 2001 From: Edward Emelianov Date: Tue, 27 Oct 2026 23:39:45 +0300 Subject: [PATCH] convert `slippers` into volts --- Poweroff_daemon/serial.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Poweroff_daemon/serial.c b/Poweroff_daemon/serial.c index 17864f7..98ab9c8 100644 --- a/Poweroff_daemon/serial.c +++ b/Poweroff_daemon/serial.c @@ -124,6 +124,8 @@ bool check_buttons(){ return false; } +#define VOLTAGE(v) (((double)(v)) * 0.01432) + /* Check voltage: returns 1 if V12 < 970 */ bool check_voltage(){ int voltage = 0; @@ -131,16 +133,16 @@ bool check_voltage(){ if(!get_int(CMD_GETVOLTAGE, ANS_V12, &voltage)) return false; if(voltage < 0 || voltage > LOG_V12*2) return false; // trash in answer if(voltage < LOWEST_V12){ - LOGERR("V12 low: %d (%.2f V)", voltage, (double)voltage / 100.); + LOGERR("V12 low: %d (%.2f V)", voltage, VOLTAGE(voltage)); return true; }else if(voltage < LOG_V12){ // log once per minute double tnow = sl_dtime(); if(tnow - tlog > LOG_VOLTAGE_DT){ - LOGMSG("Voltage now: %d (%.2f V)", voltage, (double)voltage / 100.); + LOGMSG("Voltage now: %d (%.2f V)", voltage, VOLTAGE(voltage)); tlog = tnow; } }else if(tlog > 0.){ - LOGMSG("Power restored, now: %d (%.2f V)", voltage, (double)voltage / 100.); + LOGMSG("Power restored, now: %d (%.2f V)", voltage, VOLTAGE(voltage)); tlog = -1.; } return false;