diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 36291de0d..d593ed095 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 75edc0e6f..5b0f56c3e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -5746,9 +5746,9 @@ inline void gcode_M17() { static bool sd_print_paused = false; #endif - static void filament_change_beep(const int max_beep_count, const bool init=false) { + static void filament_change_beep(const int8_t max_beep_count, const bool init=false) { static millis_t next_buzz = 0; - static uint16_t runout_beep = 0; + static int8_t runout_beep = 0; if (init) next_buzz = runout_beep = 0; @@ -5762,8 +5762,9 @@ inline void gcode_M17() { } } - static bool pause_print(const float& retract, const float& z_lift, const float& x_pos, const float& y_pos, - const float& unload_length = 0 , int max_beep_count = 0, bool show_lcd = false) { + static bool pause_print(const float &retract, const float &z_lift, const float &x_pos, const float &y_pos, + const float &unload_length = 0 , int8_t max_beep_count = 0, bool show_lcd = false + ) { if (move_away_flag) return false; // already paused if (!DEBUGGING(DRYRUN) && thermalManager.tooColdToExtrude(active_extruder) && unload_length > 0) { @@ -5772,8 +5773,6 @@ inline void gcode_M17() { return false; } - const bool job_running = print_job_timer.isRunning(); - // Indicate that the printer is paused move_away_flag = true; @@ -5857,7 +5856,7 @@ inline void gcode_M17() { return true; } - static void wait_for_filament_reload(int max_beep_count = 0) { + static void wait_for_filament_reload(int8_t max_beep_count = 0) { bool nozzle_timed_out = false; // Wait for filament insert by user and press button @@ -5882,7 +5881,7 @@ inline void gcode_M17() { KEEPALIVE_STATE(IN_HANDLER); } - static void resume_print(const float& load_length = 0, const float& initial_extrude_length = 0, int max_beep_count = 0) { + static void resume_print(const float &load_length = 0, const float &initial_extrude_length = 0, int8_t max_beep_count = 0) { bool nozzle_timed_out = false; if (!move_away_flag) return; diff --git a/Marlin/SdBaseFile.cpp b/Marlin/SdBaseFile.cpp index 298cdd114..97b4fa00f 100644 --- a/Marlin/SdBaseFile.cpp +++ b/Marlin/SdBaseFile.cpp @@ -1819,7 +1819,7 @@ fail: //------------------------------------------------------------------------------ // suppress cpplint warnings with NOLINT comment #if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN) - void (*SdBaseFile::oldDateTime_)(uint16_t& date, uint16_t& time) = 0; // NOLINT + void (*SdBaseFile::oldDateTime_)(uint16_t &date, uint16_t &time) = 0; // NOLINT #endif // ALLOW_DEPRECATED_FUNCTIONS diff --git a/Marlin/SdBaseFile.h b/Marlin/SdBaseFile.h index 2b912d2ed..02ab70543 100644 --- a/Marlin/SdBaseFile.h +++ b/Marlin/SdBaseFile.h @@ -402,7 +402,7 @@ class SdBaseFile { * \param[in] dateTime The user's call back function. */ static void dateTimeCallback( - void (*dateTime)(uint16_t& date, uint16_t& time)) { // NOLINT + void (*dateTime)(uint16_t &date, uint16_t &time)) { // NOLINT oldDateTime_ = dateTime; dateTime_ = dateTime ? oldToNew : 0; } @@ -477,7 +477,7 @@ class SdBaseFile { //------------------------------------------------------------------------------ // rest are private private: - static void (*oldDateTime_)(uint16_t& date, uint16_t& time); // NOLINT + static void (*oldDateTime_)(uint16_t &date, uint16_t &time); // NOLINT static void oldToNew(uint16_t* date, uint16_t* time) { uint16_t d; uint16_t t; diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index 5a1184c93..a8f4c3166 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index a0daae4e6..3132bf9ff 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h b/Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h index 14488300c..142cd1d24 100644 --- a/Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h +++ b/Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index e165a7fc3..171ab3e4d 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h index 7fe59aa6d..fb7869435 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h @@ -443,6 +443,9 @@ // Include a page of printer information in the LCD Main Menu #define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible #define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index 2311850eb..44aae82fa 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -455,6 +455,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/K8400/Configuration_adv.h b/Marlin/example_configurations/K8400/Configuration_adv.h index 538c121d8..a04d83baf 100644 --- a/Marlin/example_configurations/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/K8400/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index 0df6dfc18..3605da6a7 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 60b47073c..6bfee737d 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h index 7bc66c6d4..05caf958e 100644 --- a/Marlin/example_configurations/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/TinyBoy2/Configuration_adv.h b/Marlin/example_configurations/TinyBoy2/Configuration_adv.h index 36623187d..488da0e2b 100644 --- a/Marlin/example_configurations/TinyBoy2/Configuration_adv.h +++ b/Marlin/example_configurations/TinyBoy2/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu #define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index e165a7fc3..171ab3e4d 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h index 62eaf358b..eb44f9e09 100644 --- a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h +++ b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h @@ -444,6 +444,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h index 6ad9e985f..6eed64c6f 100644 --- a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h @@ -444,6 +444,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 2664b31be..6f45736b6 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -444,6 +444,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 2664b31be..6f45736b6 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -444,6 +444,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index e7142cf16..8f7ae5496 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -449,6 +449,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index e1fe86a0e..779dbe9a9 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -444,6 +444,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/gCreate_gMax1.5+/Configuration_adv.h b/Marlin/example_configurations/gCreate_gMax1.5+/Configuration_adv.h index 59b43ccb6..71a3d90e0 100644 --- a/Marlin/example_configurations/gCreate_gMax1.5+/Configuration_adv.h +++ b/Marlin/example_configurations/gCreate_gMax1.5+/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 5483576d9..9aa560794 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 8dcc348ab..660d479b5 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/wt150/Configuration_adv.h b/Marlin/example_configurations/wt150/Configuration_adv.h index 700c5227f..bf586bdba 100644 --- a/Marlin/example_configurations/wt150/Configuration_adv.h +++ b/Marlin/example_configurations/wt150/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu #define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/gcode.h b/Marlin/gcode.h index 26154a6bc..d7f76cbcd 100644 --- a/Marlin/gcode.h +++ b/Marlin/gcode.h @@ -133,7 +133,7 @@ public: // Code is found in the string. If not found, value_ptr is unchanged. // This allows "if (seen('A')||seen('B'))" to use the last-found value. static bool seen(const char c) { - char *p = strchr(command_args, c); + const char *p = strchr(command_args, c); const bool b = !!p; if (b) value_ptr = DECIMAL_SIGNED(p[1]) ? &p[1] : NULL; return b; diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 44b1a36f4..4deeb83e8 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -1510,7 +1510,7 @@ void Planner::sync_from_steppers() { /** * Setters for planner position (also setting stepper position). */ -void Planner::set_position_mm(const AxisEnum axis, const float& v) { +void Planner::set_position_mm(const AxisEnum axis, const float &v) { #if ENABLED(DISTINCT_E_FACTORS) const uint8_t axis_index = axis + (axis == E_AXIS ? active_extruder : 0); last_extruder = active_extruder; diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 3cac779d3..376740b9f 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -67,8 +67,11 @@ float Temperature::current_temperature[HOTENDS] = { 0.0 }, Temperature::current_temperature_bed = 0.0; int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 }, Temperature::target_temperature[HOTENDS] = { 0 }, - Temperature::current_temperature_bed_raw = 0, - Temperature::target_temperature_bed = 0; + Temperature::current_temperature_bed_raw = 0; + +#if HAS_HEATER_BED + int16_t Temperature::target_temperature_bed = 0; +#endif #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) float Temperature::redundant_temperature = 0.0; diff --git a/Marlin/temperature.h b/Marlin/temperature.h index 0e911a70c..c75349681 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -92,6 +92,10 @@ enum ADCSensorState { #define ACTUAL_ADC_SAMPLES max(int(MIN_ADC_ISR_LOOPS), int(SensorsReady)) +#if !HAS_HEATER_BED + constexpr int16_t target_temperature_bed = 0; +#endif + class Temperature { public: @@ -100,8 +104,11 @@ class Temperature { current_temperature_bed; static int16_t current_temperature_raw[HOTENDS], target_temperature[HOTENDS], - current_temperature_bed_raw, - target_temperature_bed; + current_temperature_bed_raw; + + #if HAS_HEATER_BED + static int16_t target_temperature_bed; + #endif static volatile bool in_temp_isr; @@ -382,9 +389,17 @@ class Temperature { } static void setTargetBed(const int16_t celsius) { - target_temperature_bed = celsius; - #if WATCH_THE_BED - start_watching_bed(); + #if HAS_HEATER_BED + target_temperature_bed = + #ifdef BED_MAXTEMP + min(celsius, BED_MAXTEMP) + #else + celsius + #endif + ; + #if WATCH_THE_BED + start_watching_bed(); + #endif #endif } diff --git a/Marlin/ubl_motion.cpp b/Marlin/ubl_motion.cpp index e733d75ca..5131315e1 100644 --- a/Marlin/ubl_motion.cpp +++ b/Marlin/ubl_motion.cpp @@ -585,8 +585,8 @@ float seg_dest[XYZE]; // per-segment destination, initialize to first segment LOOP_XYZE(i) seg_dest[i] = current_position[i] + segment_distance[i]; - const float& dx_seg = segment_distance[X_AXIS]; // alias for clarity - const float& dy_seg = segment_distance[Y_AXIS]; + const float &dx_seg = segment_distance[X_AXIS]; // alias for clarity + const float &dy_seg = segment_distance[Y_AXIS]; float rx = RAW_X_POSITION(seg_dest[X_AXIS]), // assume raw vs logical coordinates shifted but not scaled. ry = RAW_Y_POSITION(seg_dest[Y_AXIS]); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 32d47419d..6cacb3ae6 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -60,6 +60,9 @@ int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2 uint8_t lcd_status_message_level; char lcd_status_message[3 * (LCD_WIDTH) + 1] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1 +#if ENABLED(STATUS_MESSAGE_SCROLLING) + uint8_t status_scroll_pos = 0; +#endif #if ENABLED(DOGLCD) #include "ultralcd_impl_DOGM.h" @@ -3961,22 +3964,29 @@ void lcd_update() { } // ELAPSED(ms, next_lcd_update_ms) } -void set_utf_strlen(char* s, uint8_t n) { - uint8_t i = 0, j = 0; - while (s[i] && (j < n)) { - #if ENABLED(MAPPER_NON) - j++; - #else - if ((s[i] & 0xC0u) != 0x80u) j++; - #endif - i++; +#if DISABLED(STATUS_MESSAGE_SCROLLING) + + void set_utf_strlen(char* s, uint8_t n) { + uint8_t i = 0, j = 0; + while (s[i] && (j < n)) { + #if ENABLED(MAPPER_NON) + j++; + #else + if ((s[i] & 0xC0u) != 0x80u) j++; + #endif + i++; + } + while (j++ < n) s[i++] = ' '; + s[i] = '\0'; } - while (j++ < n) s[i++] = ' '; - s[i] = '\0'; -} + +#endif // !STATUS_MESSAGE_SCROLLING void lcd_finishstatus(bool persist=false) { - set_utf_strlen(lcd_status_message, LCD_WIDTH); + #if DISABLED(STATUS_MESSAGE_SCROLLING) + set_utf_strlen(lcd_status_message, LCD_WIDTH); + #endif + #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0)) UNUSED(persist); #endif @@ -3992,6 +4002,10 @@ void lcd_finishstatus(bool persist=false) { #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT) previous_lcd_status_ms = millis(); //get status message to show up for a while #endif + + #if ENABLED(STATUS_MESSAGE_SCROLLING) + status_scroll_pos = 0; + #endif } #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0 diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index c0049a4c7..ac6fedabb 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -234,13 +234,24 @@ char lcd_print_and_count(const char c) { else return charset_mapper(c); } -void lcd_print(const char* const str) { - for (uint8_t i = 0; char c = str[i]; ++i) lcd_print(c); +/** + * Core LCD printing functions + * On DOGM all strings go through a filter for utf + * But only use lcd_print_utf and lcd_printPGM_utf for translated text + */ +void lcd_print(const char* const str) { for (uint8_t i = 0; char c = str[i]; ++i) lcd_print(c); } +void lcd_printPGM(const char* str) { for (; char c = pgm_read_byte(str); ++str) lcd_print(c); } + +void lcd_print_utf(const char* const str, const uint8_t maxLength=LCD_WIDTH) { + char c; + for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) + n -= charset_mapper(c); } -/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */ -void lcd_printPGM(const char* str) { - for (; char c = pgm_read_byte(str); ++str) lcd_print(c); +void lcd_printPGM_utf(const char* str, const uint8_t maxLength=LCD_WIDTH) { + char c; + for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) + n -= charset_mapper(c); } // Initialize or re-initialize the LCD @@ -320,7 +331,7 @@ static void lcd_implementation_init() { void lcd_kill_screen() { lcd_setFont(FONT_MENU); u8g.setPrintPos(0, u8g.getHeight()/4*1); - lcd_print(lcd_status_message); + lcd_print_utf(lcd_status_message); u8g.setPrintPos(0, u8g.getHeight()/4*2); lcd_printPGM(PSTR(MSG_HALTED)); u8g.setPrintPos(0, u8g.getHeight()/4*3); @@ -395,6 +406,20 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr, } } +inline void lcd_implementation_status_message() { + #if ENABLED(STATUS_MESSAGE_SCROLLING) + lcd_print_utf(lcd_status_message + status_scroll_pos); + const uint8_t slen = lcd_strlen(lcd_status_message); + if (slen > LCD_WIDTH) { + // Skip any non-printing bytes + while (!charset_mapper(lcd_status_message[status_scroll_pos])) ++status_scroll_pos; + if (++status_scroll_pos > slen - LCD_WIDTH) status_scroll_pos = 0; + } + #else + lcd_print_utf(lcd_status_message); + #endif +} + //#define DOGM_SD_PERCENT static void lcd_implementation_status_screen() { @@ -645,10 +670,7 @@ static void lcd_implementation_status_screen() { #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT) if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) { //Display both Status message line and Filament display on the last line - const char *str = lcd_status_message; - uint8_t i = LCD_WIDTH; - char c; - while (i-- && (c = *str++)) lcd_print(c); + lcd_implementation_status_message(); } else { lcd_printPGM(PSTR(LCD_STR_FILAM_DIA)); @@ -660,10 +682,7 @@ static void lcd_implementation_status_screen() { u8g.print('%'); } #else - const char *str = lcd_status_message; - uint8_t i = LCD_WIDTH; - char c; - while (i-- && (c = *str++)) lcd_print(c); + lcd_implementation_status_message(); #endif } } diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h index 1f7683387..b735baa8f 100644 --- a/Marlin/ultralcd_impl_HD44780.h +++ b/Marlin/ultralcd_impl_HD44780.h @@ -380,16 +380,22 @@ static void lcd_implementation_init( void lcd_implementation_clear() { lcd.clear(); } -/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */ -void lcd_printPGM(const char *str) { - for (; char c = pgm_read_byte(str); ++str) charset_mapper(c); -} +void lcd_print(const char c) { charset_mapper(c); } + +void lcd_print(const char * const str) { for (uint8_t i = 0; char c = str[i]; ++i) lcd.print(c); } +void lcd_printPGM(const char* str) { for (; char c = pgm_read_byte(str); ++str) lcd.print(c); } -void lcd_print(const char* const str) { - for (uint8_t i = 0; const char c = str[i]; ++i) charset_mapper(c); +void lcd_print_utf(const char * const str, const uint8_t maxLength=LCD_WIDTH) { + char c; + for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) + n -= charset_mapper(c); } -void lcd_print(const char c) { charset_mapper(c); } +void lcd_printPGM_utf(const char* str, const uint8_t maxLength=LCD_WIDTH) { + char c; + for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) + n -= charset_mapper(c); +} #if ENABLED(SHOW_BOOTSCREEN) @@ -545,7 +551,7 @@ void lcd_print(const char c) { charset_mapper(c); } void lcd_kill_screen() { lcd.setCursor(0, 0); - lcd_print(lcd_status_message); + lcd_print_utf(lcd_status_message); #if LCD_HEIGHT < 4 lcd.setCursor(0, 2); #else @@ -818,10 +824,17 @@ static void lcd_implementation_status_screen() { #endif // FILAMENT_LCD_DISPLAY && SDSUPPORT - const char *str = lcd_status_message; - uint8_t i = LCD_WIDTH; - char c; - while (i-- && (c = *str++)) lcd_print(c); + #if ENABLED(STATUS_MESSAGE_SCROLLING) + lcd_print_utf(lcd_status_message + status_scroll_pos); + const uint8_t slen = lcd_strlen(lcd_status_message); + if (slen > LCD_WIDTH) { + // Skip any non-printing bytes + while (!charset_mapper(lcd_status_message[status_scroll_pos])) ++status_scroll_pos; + if (++status_scroll_pos > slen - LCD_WIDTH) status_scroll_pos = 0; + } + #else + lcd_print_utf(lcd_status_message); + #endif } #if ENABLED(ULTIPANEL) diff --git a/Marlin/utility.cpp b/Marlin/utility.cpp index 15378fb62..ee1bef1c9 100644 --- a/Marlin/utility.cpp +++ b/Marlin/utility.cpp @@ -57,14 +57,14 @@ void safe_delay(millis_t ms) { #define MINUSOR(n, alt) (n >= 0 ? (alt) : (n = -n, '-')) // Convert unsigned int to string with 12 format - char* itostr2(const uint8_t& xx) { + char* itostr2(const uint8_t &xx) { conv[5] = DIGIMOD(xx, 10); conv[6] = DIGIMOD(xx, 1); return &conv[5]; } // Convert signed int to rj string with 123 or -12 format - char* itostr3(const int& x) { + char* itostr3(const int &x) { int xx = x; conv[4] = MINUSOR(xx, RJDIGIT(xx, 100)); conv[5] = RJDIGIT(xx, 10); @@ -73,7 +73,7 @@ void safe_delay(millis_t ms) { } // Convert unsigned int to lj string with 123 format - char* itostr3left(const int& xx) { + char* itostr3left(const int &xx) { char *str = &conv[6]; *str = DIGIMOD(xx, 1); if (xx >= 10) { @@ -85,7 +85,7 @@ void safe_delay(millis_t ms) { } // Convert signed int to rj string with 1234, _123, -123, _-12, or __-1 format - char *itostr4sign(const int& x) { + char *itostr4sign(const int &x) { const bool neg = x < 0; const int xx = neg ? -x : x; if (x >= 1000) { @@ -116,7 +116,7 @@ void safe_delay(millis_t ms) { } // Convert unsigned float to string with 1.23 format - char* ftostr12ns(const float& x) { + char* ftostr12ns(const float &x) { const long xx = (x < 0 ? -x : x) * 100; conv[3] = DIGIMOD(xx, 100); conv[4] = '.'; @@ -126,7 +126,7 @@ void safe_delay(millis_t ms) { } // Convert signed float to fixed-length string with 023.45 / -23.45 format - char *ftostr32(const float& x) { + char *ftostr32(const float &x) { long xx = x * 100; conv[1] = MINUSOR(xx, DIGIMOD(xx, 10000)); conv[2] = DIGIMOD(xx, 1000); @@ -140,7 +140,7 @@ void safe_delay(millis_t ms) { #if ENABLED(LCD_DECIMAL_SMALL_XY) // Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format - char *ftostr4sign(const float& fx) { + char *ftostr4sign(const float &fx) { const int x = fx * 10; if (!WITHIN(x, -99, 999)) return itostr4sign((int)fx); const bool neg = x < 0; @@ -155,7 +155,7 @@ void safe_delay(millis_t ms) { #endif // LCD_DECIMAL_SMALL_XY // Convert float to fixed-length string with +123.4 / -123.4 format - char* ftostr41sign(const float& x) { + char* ftostr41sign(const float &x) { int xx = x * 10; conv[1] = MINUSOR(xx, '+'); conv[2] = DIGIMOD(xx, 1000); @@ -167,7 +167,7 @@ void safe_delay(millis_t ms) { } // Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format - char* ftostr43sign(const float& x, char plus/*=' '*/) { + char* ftostr43sign(const float &x, char plus/*=' '*/) { long xx = x * 1000; conv[1] = xx ? MINUSOR(xx, plus) : ' '; conv[2] = DIGIMOD(xx, 1000); @@ -179,7 +179,7 @@ void safe_delay(millis_t ms) { } // Convert unsigned float to rj string with 12345 format - char* ftostr5rj(const float& x) { + char* ftostr5rj(const float &x) { const long xx = x < 0 ? -x : x; conv[2] = RJDIGIT(xx, 10000); conv[3] = RJDIGIT(xx, 1000); @@ -190,7 +190,7 @@ void safe_delay(millis_t ms) { } // Convert signed float to string with +1234.5 format - char* ftostr51sign(const float& x) { + char* ftostr51sign(const float &x) { long xx = x * 10; conv[0] = MINUSOR(xx, '+'); conv[1] = DIGIMOD(xx, 10000); @@ -203,7 +203,7 @@ void safe_delay(millis_t ms) { } // Convert signed float to string with +123.45 format - char* ftostr52sign(const float& x) { + char* ftostr52sign(const float &x) { long xx = x * 100; conv[0] = MINUSOR(xx, '+'); conv[1] = DIGIMOD(xx, 10000); @@ -216,7 +216,7 @@ void safe_delay(millis_t ms) { } // Convert unsigned float to string with 1234.56 format omitting trailing zeros - char* ftostr62rj(const float& x) { + char* ftostr62rj(const float &x) { const long xx = (x < 0 ? -x : x) * 100; conv[0] = RJDIGIT(xx, 100000); conv[1] = RJDIGIT(xx, 10000); @@ -229,7 +229,7 @@ void safe_delay(millis_t ms) { } // Convert signed float to space-padded string with -_23.4_ format - char* ftostr52sp(const float& x) { + char* ftostr52sp(const float &x) { long xx = x * 100; uint8_t dig; conv[1] = MINUSOR(xx, RJDIGIT(xx, 10000)); diff --git a/Marlin/utility.h b/Marlin/utility.h index f14b272fb..779b788c7 100644 --- a/Marlin/utility.h +++ b/Marlin/utility.h @@ -32,53 +32,53 @@ void safe_delay(millis_t ms); #if ENABLED(ULTRA_LCD) // Convert unsigned int to string with 12 format - char* itostr2(const uint8_t& x); + char* itostr2(const uint8_t &x); // Convert signed int to rj string with 123 or -12 format - char* itostr3(const int& x); + char* itostr3(const int &x); // Convert unsigned int to lj string with 123 format - char* itostr3left(const int& xx); + char* itostr3left(const int &xx); // Convert signed int to rj string with _123, -123, _-12, or __-1 format - char *itostr4sign(const int& x); + char *itostr4sign(const int &x); // Convert unsigned float to string with 1.23 format - char* ftostr12ns(const float& x); + char* ftostr12ns(const float &x); // Convert signed float to fixed-length string with 023.45 / -23.45 format - char *ftostr32(const float& x); + char *ftostr32(const float &x); // Convert float to fixed-length string with +123.4 / -123.4 format - char* ftostr41sign(const float& x); + char* ftostr41sign(const float &x); // Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format - char* ftostr43sign(const float& x, char plus=' '); + char* ftostr43sign(const float &x, char plus=' '); // Convert unsigned float to rj string with 12345 format - char* ftostr5rj(const float& x); + char* ftostr5rj(const float &x); // Convert signed float to string with +1234.5 format - char* ftostr51sign(const float& x); + char* ftostr51sign(const float &x); // Convert signed float to space-padded string with -_23.4_ format - char* ftostr52sp(const float& x); + char* ftostr52sp(const float &x); // Convert signed float to string with +123.45 format - char* ftostr52sign(const float& x); + char* ftostr52sign(const float &x); // Convert unsigned float to string with 1234.56 format omitting trailing zeros - char* ftostr62rj(const float& x); + char* ftostr62rj(const float &x); // Convert float to rj string with 123 or -12 format - FORCE_INLINE char *ftostr3(const float& x) { return itostr3((int)x); } + FORCE_INLINE char *ftostr3(const float &x) { return itostr3((int)x); } #if ENABLED(LCD_DECIMAL_SMALL_XY) // Convert float to rj string with 1234, _123, 12.3, _1.2, -123, _-12, or -1.2 format - char *ftostr4sign(const float& fx); + char *ftostr4sign(const float &fx); #else // Convert float to rj string with 1234, _123, -123, __12, _-12, ___1, or __-1 format - FORCE_INLINE char *ftostr4sign(const float& x) { return itostr4sign((int)x); } + FORCE_INLINE char *ftostr4sign(const float &x) { return itostr4sign((int)x); } #endif #endif // ULTRA_LCD diff --git a/Marlin/vector_3.h b/Marlin/vector_3.h index 23ef745a1..19f6e3a3a 100644 --- a/Marlin/vector_3.h +++ b/Marlin/vector_3.h @@ -77,7 +77,7 @@ struct matrix_3x3 { }; -void apply_rotation_xyz(matrix_3x3 rotationMatrix, float& x, float& y, float& z); +void apply_rotation_xyz(matrix_3x3 rotationMatrix, float &x, float &y, float &z); #endif // HAS_ABL #endif // VECTOR_3_H