Browse Source

Fix PROGMEM read in ProgressCode message

This could cause the printer to crash. The Serial Stream would show
a garbled string and the same corruption would appear on the Status
Screen's status line.
Guðni Már Gilbert 3 years ago
parent
commit
4b71466526
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Firmware/mmu2_progress_converter.cpp

+ 2 - 1
Firmware/mmu2_progress_converter.cpp

@@ -62,7 +62,8 @@ static const char * const progressTexts[] PROGMEM = {
 };
 };
 
 
 const char * const ProgressCodeToText(uint16_t pc){
 const char * const ProgressCodeToText(uint16_t pc){
-    return ( pc <= 26 ) ? progressTexts[pc] : progressTexts[0]; // @@TODO ?? a better fallback option?
+    // @@TODO ?? a better fallback option?
+    return ( pc <= 26 ) ? static_cast<const char * const>(pgm_read_ptr(&progressTexts[pc])) : static_cast<const char * const>(pgm_read_ptr(&progressTexts[0]));
 }
 }
 
 
 void TranslateProgress(uint16_t pc, char *dst, size_t dstSize) { 
 void TranslateProgress(uint16_t pc, char *dst, size_t dstSize) {