Percent: in custom format, only set num and bar string if enabled in percent config

Also fix `percentage-bar` printing in Brightness module
This commit is contained in:
李通洲
2024-11-14 15:33:43 +08:00
parent 6801fe3d9c
commit 782af250ff
12 changed files with 82 additions and 40 deletions
+5 -3
View File
@@ -9,13 +9,13 @@
static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* device, uint8_t index)
{
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
if(options->moduleArgs.outputFormat.length == 0)
{
ffPrintLogoAndKey(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
bool showBatteryLevel = device->battery > 0 && device->battery <= 100;
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
if (showBatteryLevel && (percentType & FF_PERCENTAGE_TYPE_BAR_BIT))
{
@@ -41,9 +41,11 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
else
{
FF_STRBUF_AUTO_DESTROY percentageNum = ffStrbufCreate();
ffPercentAppendNum(&percentageNum, device->battery, options->percent, false, &options->moduleArgs);
if(percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
ffPercentAppendNum(&percentageNum, device->battery, options->percent, false, &options->moduleArgs);
FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate();
ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs);
if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs);
FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BLUETOOTH_NUM_FORMAT_ARGS, ((FFformatarg[]) {
FF_FORMAT_ARG(device->name, "name"),