@@ -101,6 +101,9 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
101
101
ffPercentAppendBar (& capacityBar , result -> capacity , options -> percent , & options -> moduleArgs );
102
102
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate ();
103
103
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 );
104
107
105
108
FF_PRINT_FORMAT_CHECKED (key .chars , 0 , & options -> moduleArgs , FF_PRINT_TYPE_NO_CUSTOM_KEY , ((FFformatarg []) {
106
109
FF_FORMAT_ARG (result -> manufacturer , "manufacturer" ),
@@ -117,6 +120,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
117
120
FF_FORMAT_ARG (hours , "time-hours" ),
118
121
FF_FORMAT_ARG (minutes , "time-minutes" ),
119
122
FF_FORMAT_ARG (seconds , "time-seconds" ),
123
+ FF_FORMAT_ARG (result -> timeRemaining , "time-formatted" ),
120
124
}));
121
125
}
122
126
}
@@ -254,6 +258,8 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc,
254
258
yyjson_mut_obj_add_uint (doc , obj , "cycleCount" , battery -> cycleCount );
255
259
if (battery -> timeRemaining > 0 )
256
260
yyjson_mut_obj_add_int (doc , obj , "timeRemaining" , battery -> timeRemaining );
261
+ else
262
+ yyjson_mut_obj_add_null (doc , obj , "timeRemaining" );
257
263
}
258
264
259
265
FF_LIST_FOR_EACH (FFBatteryResult , battery , results )
0 commit comments