Browse Source

Status bar, lcd optimization, compile warning fix

Alex Voinea 5 years ago
parent
commit
960f4a88ed
5 changed files with 21 additions and 39 deletions
  1. 20 10
      Firmware/cardreader.cpp
  2. 0 15
      Firmware/lcd.cpp
  3. 0 1
      Firmware/lcd.h
  4. 1 10
      Firmware/ultralcd.cpp
  5. 0 3
      Firmware/ultralcd.h

+ 20 - 10
Firmware/cardreader.cpp

@@ -741,9 +741,6 @@ void CardReader::presort() {
 			fileCnt = SDSORT_LIMIT;
 		}
 		lcd_clear();
-		#if !SDSORT_USES_RAM
-			lcd_set_progress();
-		#endif
 		lcd_puts_at_P(0, 1, _i("Sorting files"));////MSG_SORTING c=20 r=1
 
 		// Sort order is always needed. May be static or dynamic.
@@ -837,11 +834,26 @@ void CardReader::presort() {
 #define _SORT_CMP_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_NODIR() : (fs > 0 ? dir1 : !dir1))
 #define _SORT_CMP_TIME_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_TIME_NODIR() : (fs < 0 ? dir1 : !dir1))
 
-			for (int16_t gap = fileCnt/2; gap > 0; gap /= 2)
+			uint16_t counter = 0;
+			uint16_t total = 0;
+			for (uint16_t i = fileCnt/2; i > 0; i /= 2) total += fileCnt - i; //total runs for progress bar
+			
+			for (uint16_t gap = fileCnt/2; gap > 0; gap /= 2)
 			{
-				for (int16_t i = gap; i < fileCnt; i++)
+				for (uint16_t i = gap; i < fileCnt; i++)
 				{
 					if (!IS_SD_INSERTED) return;
+					
+					int8_t percent = (counter * 100) / total;
+					for (int column = 0; column < 20; column++) {
+						if (column < (percent / 5))
+						{
+							lcd_set_cursor(column, 2);
+							lcd_print('\xFF'); //simple progress bar
+						}
+					}
+					counter++;
+					
 					manage_heater();
 					uint8_t orderBckp = sort_order[i];
 					getfilename_simple(positions[orderBckp]);
@@ -852,7 +864,7 @@ void CardReader::presort() {
 					bool dir1 = filenameIsDir;
 					#endif
 					
-					int16_t j = i;
+					uint16_t j = i;
 					getfilename_simple(positions[sort_order[j - gap]]);
 					char *name2 = LONGEST_FILENAME; // use the string in-place
 					#if HAS_FOLDER_SORTING
@@ -878,7 +890,6 @@ void CardReader::presort() {
 				}
 			}
 
-
 #else //Bubble Sort
 			uint32_t counter = 0;
 			uint16_t total = 0.5*(fileCnt - 1)*(fileCnt);
@@ -924,7 +935,7 @@ void CardReader::presort() {
 					if (column < (percent / 5))
 					{
 						lcd_set_cursor(column, 2);
-						lcd_print('\x01'); //simple progress bar
+						lcd_print('\xFF'); //simple progress bar
 					}
 				}
 				counter++;
@@ -1010,10 +1021,9 @@ void CardReader::presort() {
 	for (int column = 0; column <= 19; column++)
 	{
 		lcd_set_cursor(column, 2);
-		lcd_print('\x01'); //simple progress bar
+		lcd_print('\xFF'); //simple progress bar
 	}
 	_delay(300);
-	lcd_set_degree();
 	lcd_clear();
 #endif
 	lcd_update(2);

+ 0 - 15
Firmware/lcd.cpp

@@ -957,21 +957,6 @@ void lcd_set_custom_characters_arrows(void)
 	lcd_createChar_P(1, lcd_chardata_arrdown);
 }
 
-const uint8_t lcd_chardata_progress[8] PROGMEM = {
-	B11111,
-	B11111,
-	B11111,
-	B11111,
-	B11111,
-	B11111,
-	B11111,
-	B11111};
-
-void lcd_set_custom_characters_progress(void)
-{
-	lcd_createChar_P(1, lcd_chardata_progress);
-}
-
 const uint8_t lcd_chardata_arr2down[8] PROGMEM = {
 	B00000,
 	B00000,

+ 0 - 1
Firmware/lcd.h

@@ -201,7 +201,6 @@ private:
 
 extern void lcd_set_custom_characters(void);
 extern void lcd_set_custom_characters_arrows(void);
-extern void lcd_set_custom_characters_progress(void);
 extern void lcd_set_custom_characters_nextpage(void);
 extern void lcd_set_custom_characters_degree(void);
 

+ 1 - 10
Firmware/ultralcd.cpp

@@ -4590,17 +4590,10 @@ static void lcd_fsensor_state_set()
 }
 #endif //FILAMENT_SENSOR
 
-
-#if !SDSORT_USES_RAM
 void lcd_set_degree() {
 	lcd_set_custom_characters_degree();
 }
 
-void lcd_set_progress() {
-	lcd_set_custom_characters_progress();
-}
-#endif
-
 #if (LANG_MODE != 0)
 
 void menu_setlang(unsigned char lang)
@@ -8665,7 +8658,6 @@ static void lcd_connect_printer() {
 	
 	int i = 0;
 	int t = 0;
-	lcd_set_custom_characters_progress();
 	lcd_puts_at_P(0, 0, _i("Connect printer to")); 
 	lcd_puts_at_P(0, 1, _i("monitoring or hold"));
 	lcd_puts_at_P(0, 2, _i("the knob to continue"));
@@ -8682,12 +8674,11 @@ static void lcd_connect_printer() {
 			i = 0; 
 			lcd_puts_at_P(0, 3, PSTR("                    "));
 		}
-		if (i!=0) lcd_puts_at_P((i * 20) / (NC_BUTTON_LONG_PRESS * 10), 3, "\x01");
+		if (i!=0) lcd_puts_at_P((i * 20) / (NC_BUTTON_LONG_PRESS * 10), 3, "\xFF");
 		if (i == NC_BUTTON_LONG_PRESS * 10) {
 			no_response = false;
 		}
 	}
-	lcd_set_custom_characters_degree();
 	lcd_update_enable(true);
 	lcd_update(2);
 }

+ 0 - 3
Firmware/ultralcd.h

@@ -213,10 +213,7 @@ void lcd_temp_calibration_set();
 
 void display_loading();
 
-#if !SDSORT_USES_RAM
 void lcd_set_degree();
-void lcd_set_progress();
-#endif
 
 void lcd_language();