77#include "modules/battery/battery.h"
88#include "util/stringUtils.h"
99
10- #define FF_BATTERY_NUM_FORMAT_ARGS 14
11-
1210static void printBattery (FFBatteryOptions * options , FFBatteryResult * result , uint8_t index )
1311{
1412 FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate ();
@@ -22,7 +20,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
2220 else
2321 {
2422 ffStrbufClear (& key );
25- FF_PARSE_FORMAT_STRING_CHECKED (& key , & options -> moduleArgs .key , 2 , ((FFformatarg []){
23+ FF_PARSE_FORMAT_STRING_CHECKED (& key , & options -> moduleArgs .key , ((FFformatarg []) {
2624 FF_FORMAT_ARG (index , "index" ),
2725 FF_FORMAT_ARG (result -> modelName , "name" ),
2826 }));
@@ -105,7 +103,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
105103 FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate ();
106104 ffTempsAppendNum (result -> temperature , & tempStr , options -> tempConfig , & options -> moduleArgs );
107105
108- FF_PRINT_FORMAT_CHECKED (key .chars , 0 , & options -> moduleArgs , FF_PRINT_TYPE_NO_CUSTOM_KEY , FF_BATTERY_NUM_FORMAT_ARGS , ((FFformatarg []) {
106+ FF_PRINT_FORMAT_CHECKED (key .chars , 0 , & options -> moduleArgs , FF_PRINT_TYPE_NO_CUSTOM_KEY , ((FFformatarg []) {
109107 FF_FORMAT_ARG (result -> manufacturer , "manufacturer" ),
110108 FF_FORMAT_ARG (result -> modelName , "model-name" ),
111109 FF_FORMAT_ARG (result -> technology , "technology" ),
@@ -270,39 +268,35 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc,
270268 }
271269}
272270
273- void ffPrintBatteryHelpFormat (void )
274- {
275- FF_PRINT_MODULE_FORMAT_HELP_CHECKED (FF_BATTERY_MODULE_NAME , "{4} ({12} hours {13} mins) [{5}]" , FF_BATTERY_NUM_FORMAT_ARGS , ((const char * []) {
276- "Battery manufacturer - manufacturer" ,
277- "Battery model name - model-name" ,
278- "Battery technology - technology" ,
279- "Battery capacity (percentage num) - capacity" ,
280- "Battery status - status" ,
281- "Battery temperature (formatted) - temperature" ,
282- "Battery cycle count - cycle-count" ,
283- "Battery serial number - serial" ,
284- "Battery manufactor date - manufacture-date" ,
285- "Battery capacity (percentage bar) - capacity-bar" ,
286- "Battery time remaining days - time-days" ,
287- "Battery time remaining hours - time-hours" ,
288- "Battery time remaining minutes - time-minutes" ,
289- "Battery time remaining seconds - time-seconds" ,
290- }));
291- }
271+ static FFModuleBaseInfo ffModuleInfo = {
272+ .name = FF_BATTERY_MODULE_NAME ,
273+ .description = "Print battery capacity, status, etc" ,
274+ .parseCommandOptions = (void * ) ffParseBatteryCommandOptions ,
275+ .parseJsonObject = (void * ) ffParseBatteryJsonObject ,
276+ .printModule = (void * ) ffPrintBattery ,
277+ .generateJsonResult = (void * ) ffGenerateBatteryJsonResult ,
278+ .generateJsonConfig = (void * ) ffGenerateBatteryJsonConfig ,
279+ .formatArgs = FF_FORMAT_ARG_LIST (((FFModuleFormatArg []) {
280+ {"Battery manufacturer" , "manufacturer" },
281+ {"Battery model name" , "model-name" },
282+ {"Battery technology" , "technology" },
283+ {"Battery capacity (percentage num)" , "capacity" },
284+ {"Battery status" , "status" },
285+ {"Battery temperature (formatted)" , "temperature" },
286+ {"Battery cycle count" , "cycle-count" },
287+ {"Battery serial number" , "serial" },
288+ {"Battery manufactor date" , "manufacture-date" },
289+ {"Battery capacity (percentage bar)" , "capacity-bar" },
290+ {"Battery time remaining days" , "time-days" },
291+ {"Battery time remaining hours" , "time-hours" },
292+ {"Battery time remaining minutes" , "time-minutes" },
293+ {"Battery time remaining seconds" , "time-seconds" },
294+ }))
295+ };
292296
293297void ffInitBatteryOptions (FFBatteryOptions * options )
294298{
295- ffOptionInitModuleBaseInfo (
296- & options -> moduleInfo ,
297- FF_BATTERY_MODULE_NAME ,
298- "Print battery capacity, status, etc" ,
299- ffParseBatteryCommandOptions ,
300- ffParseBatteryJsonObject ,
301- ffPrintBattery ,
302- ffGenerateBatteryJsonResult ,
303- ffPrintBatteryHelpFormat ,
304- ffGenerateBatteryJsonConfig
305- );
299+ options -> moduleInfo = ffModuleInfo ;
306300 ffOptionInitModuleArg (& options -> moduleArgs , "" );
307301 options -> temp = false;
308302 options -> tempConfig = (FFColorRangeConfig ) { 60 , 80 };
0 commit comments