@@ -101,6 +101,9 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
101101 ffPercentAppendBar (& capacityBar , result -> capacity , options -> percent , & options -> moduleArgs );
102102 FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate ();
103103 ffTempsAppendNum (result -> temperature , & tempStr , options -> tempConfig , & options -> moduleArgs );
104+ FF_STRBUF_AUTO_DESTROY timeStr = ffStrbufCreate ();
105+ if (result -> timeRemaining > 0 )
106+ ffDurationAppendNum ((uint32_t ) result -> timeRemaining , & timeStr );
104107
105108 FF_PRINT_FORMAT_CHECKED (key .chars , 0 , & options -> moduleArgs , FF_PRINT_TYPE_NO_CUSTOM_KEY , ((FFformatarg []) {
106109 FF_FORMAT_ARG (result -> manufacturer , "manufacturer" ),
@@ -117,6 +120,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
117120 FF_FORMAT_ARG (hours , "time-hours" ),
118121 FF_FORMAT_ARG (minutes , "time-minutes" ),
119122 FF_FORMAT_ARG (seconds , "time-seconds" ),
123+ FF_FORMAT_ARG (result -> timeRemaining , "time-formatted" ),
120124 }));
121125 }
122126}
@@ -254,6 +258,8 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc,
254258 yyjson_mut_obj_add_uint (doc , obj , "cycleCount" , battery -> cycleCount );
255259 if (battery -> timeRemaining > 0 )
256260 yyjson_mut_obj_add_int (doc , obj , "timeRemaining" , battery -> timeRemaining );
261+ else
262+ yyjson_mut_obj_add_null (doc , obj , "timeRemaining" );
257263 }
258264
259265 FF_LIST_FOR_EACH (FFBatteryResult , battery , results )
0 commit comments