File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,11 @@ void updateFromSD(char *firmwareFileName)
114114 byte dataArray[pageSize];
115115 int bytesWritten = 0 ;
116116
117+ // Indicate progress
118+ int barWidthInCharacters = 20 ; // Width of progress bar, ie [###### % complete
119+ long portionSize = updateSize / barWidthInCharacters;
120+ int barWidth = 0 ;
121+
117122 // Bulk write from the SD file to the EEPROM
118123 while (firmwareFile.available ())
119124 {
@@ -127,7 +132,17 @@ void updateFromSD(char *firmwareFileName)
127132 else
128133 bytesWritten += bytesToWrite;
129134
130- if (bytesWritten % (512 * 32 ) == 0 ) Serial.print (" ." ); // Indicate progress
135+ // Indicate progress
136+ if (bytesWritten > barWidth * portionSize)
137+ {
138+ // Advance the bar
139+ barWidth++;
140+ Serial.print (" \n [" );
141+ for (int x = 0 ; x < barWidth ; x++)
142+ Serial.print (" =" );
143+ Serial.printf (" %d%%" , bytesWritten * 100 / updateSize);
144+ if (bytesWritten == updateSize) Serial.println (" ]" );
145+ }
131146 }
132147 Serial.println (F (" \n File move complete" ));
133148
Original file line number Diff line number Diff line change @@ -115,6 +115,11 @@ void updateFromSD(char *firmwareFileName)
115115 byte dataArray[pageSize];
116116 int bytesWritten = 0 ;
117117
118+ // Indicate progress
119+ int barWidthInCharacters = 20 ; // Width of progress bar, ie [###### % complete
120+ long portionSize = updateSize / barWidthInCharacters;
121+ int barWidth = 0 ;
122+
118123 // Bulk write from the SD file to the EEPROM
119124 while (firmwareFile.available ())
120125 {
@@ -128,8 +133,19 @@ void updateFromSD(char *firmwareFileName)
128133 else
129134 bytesWritten += bytesToWrite;
130135
131- if (bytesWritten % (512 * 32 ) == 0 ) Serial.print (" ." ); // Indicate progress
136+ // Indicate progress
137+ if (bytesWritten > barWidth * portionSize)
138+ {
139+ // Advance the bar
140+ barWidth++;
141+ Serial.print (" \n [" );
142+ for (int x = 0 ; x < barWidth ; x++)
143+ Serial.print (" =" );
144+ Serial.printf (" %02d%%" , bytesWritten * 100 / updateSize);
145+ if (bytesWritten == updateSize) Serial.println (" ]" );
146+ }
132147 }
148+
133149 Serial.println (F (" \n File move complete" ));
134150
135151 if (Update.end ())
You can’t perform that action at this time.
0 commit comments