Skip to content

Commit f7b45e3

Browse files
authored
Improve output of ESP32 operations (#298)
***NO_CI***
1 parent 1ef9563 commit f7b45e3

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

nanoFirmwareFlasher.Library/Esp32Operations.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
520520
if (verbosity >= VerbosityLevel.Normal)
521521
{
522522
OutputWriter.ForegroundColor = ConsoleColor.White;
523-
OutputWriter.Write($"Backup configuration...");
523+
OutputWriter.WriteLine($"Backup configuration...");
524524
}
525525

526526
// can't do this without a partition table
@@ -550,6 +550,9 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
550550

551551
if (verbosity >= VerbosityLevel.Normal)
552552
{
553+
// move cursor up and clear line
554+
OutputWriter.Write("\u001b[A\r\u001b[K");
555+
553556
OutputWriter.ForegroundColor = ConsoleColor.White;
554557
OutputWriter.Write($"Backup configuration...");
555558
OutputWriter.ForegroundColor = ConsoleColor.Green;
@@ -562,28 +565,26 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(
562565

563566
OutputWriter.ForegroundColor = ConsoleColor.White;
564567

565-
if (verbosity < VerbosityLevel.Normal)
568+
if (verbosity >= VerbosityLevel.Normal)
566569
{
567-
// output the start of operation message for verbosity lower than normal
570+
// output the start of operation message for verbosity normal and above
568571
// otherwise the progress from esptool is shown
569572
OutputWriter.ForegroundColor = ConsoleColor.White;
570-
OutputWriter.Write($"Flashing firmware...");
573+
OutputWriter.WriteLine($"Flashing firmware...");
571574
}
572575

573576
// write to flash
574577
operationResult = espTool.WriteFlash(firmware.FlashPartitions);
575578

576579
if (operationResult == ExitCodes.OK)
577580
{
578-
if (verbosity < VerbosityLevel.Normal)
579-
{
580-
// operation completed output
581-
OutputWriter.ForegroundColor = ConsoleColor.Green;
582-
OutputWriter.WriteLine("OK".PadRight(110));
583-
}
584-
585581
if (verbosity >= VerbosityLevel.Normal)
586582
{
583+
// output the start of operation message for verbosity normal and above
584+
// move cursor up and clear line
585+
OutputWriter.Write("\u001b[A\r\u001b[K");
586+
587+
// operation completed output
587588
// output the full message as usual after the progress from esptool
588589
OutputWriter.ForegroundColor = ConsoleColor.White;
589590
OutputWriter.Write($"Flashing firmware...");

0 commit comments

Comments
 (0)