Merge pull request #4053 from vintagepc/2477-redux

#2477 Improved M-code control for stealth mode/normal mode
This commit is contained in:
3d-gussner 2023-07-27 15:44:22 +02:00 committed by GitHub
commit 07d7bfa8a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 202 additions and 140 deletions

View File

@ -173,6 +173,7 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#define enable_z() poweron_z()
#define disable_z() poweroff_z()
#else
extern bool bEnableForce_z; // Used by ultralcd stealth toggle
void init_force_z();
void check_force_z();
void enable_force_z();
@ -440,6 +441,7 @@ extern int8_t busy_state;
#define FORCE_HIGH_POWER_END force_high_power_mode(false)
void force_high_power_mode(bool start_high_power_section);
void change_power_mode_live(uint8_t mode);
#endif //TMC2130

View File

@ -2409,25 +2409,30 @@ void retract(bool retracting, bool swapretract = false) {
#ifdef TMC2130
void force_high_power_mode(bool start_high_power_section) {
#ifdef PSU_Delta
if (start_high_power_section == true) enable_force_z();
#endif //PSU_Delta
uint8_t silent;
silent = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
if (silent == 1) {
//we are in silent mode, set to normal mode to enable crash detection
// Wait for the planner queue to drain and for the stepper timer routine to reach an idle state.
void change_power_mode_live(uint8_t mode)
{
// Wait for the planner queue to drain and for the stepper timer routine to reach an idle state.
st_synchronize();
cli();
tmc2130_mode = (start_high_power_section == true) ? TMC2130_MODE_NORMAL : TMC2130_MODE_SILENT;
tmc2130_mode = mode;
update_mode_profile();
tmc2130_init(TMCInitParams(FarmOrUserECool()));
// We may have missed a stepper timer interrupt due to the time spent in the tmc2130_init() routine.
// Be safe than sorry, reset the stepper timer before re-enabling interrupts.
st_reset_timer();
sei();
}
void force_high_power_mode(bool start_high_power_section) {
#ifdef PSU_Delta
if (start_high_power_section == true) enable_force_z();
#endif //PSU_Delta
uint8_t silent;
silent = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
if (silent == 1 || tmc2130_mode == TMC2130_MODE_SILENT) {
//we are in silent mode, set to normal mode to enable crash detection
change_power_mode_live((start_high_power_section == true) ? TMC2130_MODE_NORMAL : TMC2130_MODE_SILENT);
}
}
#endif //TMC2130
@ -8172,30 +8177,64 @@ Sigma_Exit:
}
break;
/*!
#endif // TMC2130_SERVICE_CODES_M910_M918
/*!
### M914 - Set TMC2130 normal mode <a href="https://reprap.org/wiki/G-code#M914:_Set_TMC2130_normal_mode">M914: Set TMC2130 normal mode</a>
Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code.
Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)
#### Usage
M914 [ P | R ]
#### Parameters
- `P` - Make the mode change permanent (write to EEPROM)
- `R` - Revert to EEPROM value
*/
case 914:
{
tmc2130_mode = TMC2130_MODE_NORMAL;
update_mode_profile();
tmc2130_init(TMCInitParams(false, FarmOrUserECool()));
}
break;
/*!
### M915 - Set TMC2130 silent mode <a href="https://reprap.org/wiki/G-code#M915:_Set_TMC2130_silent_mode">M915: Set TMC2130 silent mode</a>
Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code.
Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)
#### Usage
M915 [ P | R ]
#### Parameters
- `P` - Make the mode change permanent (write to EEPROM)
- `R` - Revert to EEPROM value
*/
#ifdef TMC2130
case 914:
case 915:
{
tmc2130_mode = TMC2130_MODE_SILENT;
update_mode_profile();
tmc2130_init(TMCInitParams(false, FarmOrUserECool()));
uint8_t newMode = (mcode_in_progress==914) ? TMC2130_MODE_NORMAL : TMC2130_MODE_SILENT;
//printf_P(_n("tmc2130mode/smm/eep: %d %d %d %d"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT), bEnableForce_z);
if (code_seen('R'))
{
newMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
}
else if (code_seen('P'))
{
uint8_t newMenuMode = (mcode_in_progress==914) ? SILENT_MODE_NORMAL : SILENT_MODE_STEALTH;
eeprom_update_byte((unsigned char *)EEPROM_SILENT, newMenuMode);
SilentModeMenu = newMenuMode;
//printf_P(_n("tmc2130mode/smm/eep: %d %d %d %d"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT), bEnableForce_z);
}
if (tmc2130_mode != newMode
#ifdef PSU_Delta
|| !bEnableForce_z
#endif
)
{
#ifdef PSU_Delta
enable_force_z();
#endif
change_power_mode_live(newMode);
}
}
break;
#endif // TMC2130
#ifdef TMC2130_SERVICE_CODES_M910_M918
/*!
### M916 - Set TMC2130 Stallguard sensitivity threshold <a href="https://reprap.org/wiki/G-code#M916:_Set_TMC2130_Stallguard_sensitivity_threshold">M916: Set TMC2130 Stallguard sensitivity threshold</a>
Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code.

View File

@ -953,7 +953,12 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
bool high_deviation_occured = false;
bedPWMDisabled = 1;
#ifdef TMC2130
FORCE_HIGH_POWER_START;
bool bHighPowerForced = false;
if (tmc2130_mode == TMC2130_MODE_SILENT)
{
FORCE_HIGH_POWER_START;
bHighPowerForced = true;
}
#endif
//printf_P(PSTR("Min. Z: %f\n"), minimum_z);
#ifdef SUPPORT_VERBOSITY
@ -1047,7 +1052,7 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
enable_z_endstop(endstop_z_enabled);
// SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 3");
#ifdef TMC2130
FORCE_HIGH_POWER_END;
if (bHighPowerForced) FORCE_HIGH_POWER_END;
#endif
bedPWMDisabled = 0;
return true;
@ -1057,7 +1062,7 @@ error:
enable_endstops(endstops_enabled);
enable_z_endstop(endstop_z_enabled);
#ifdef TMC2130
FORCE_HIGH_POWER_END;
if (bHighPowerForced) FORCE_HIGH_POWER_END;
#endif
bedPWMDisabled = 0;
return false;

View File

@ -477,11 +477,11 @@ void lcdui_print_time(void)
print_t = print_tc;
suff = 'C';
} else
//#endif //CLOCK_INTERVAL_TIME
//#endif //CLOCK_INTERVAL_TIME
if (print_tr != PRINT_TIME_REMAINING_INIT) {
print_t = print_tr;
suff = 'R';
} else
} else
print_t = (_millis() - starttime) / 60000;
if (feedmultiply != 100 && (print_t == print_tr || print_t == print_tc)) {
@ -555,7 +555,7 @@ void lcdui_print_status_line(void) {
{
return; // Nothing to do, waiting for delay to expire
}
switch (custom_message_type) {
case CustomMsg::M117: // M117 Set the status line message on the LCD
case CustomMsg::Status: // Nothing special, print status message normally
@ -1064,7 +1064,7 @@ void lcd_menu_extruder_info() // NOT static due to using ins
lcd_timeoutToStatus.stop(); //infinite timeout
lcd_home();
lcd_printf_P(PSTR("%-15.15S%-5d\n" "%-15.15S%-5d\n"), _T(MSG_HOTEND_FAN_SPEED), 60*fan_speed[0], _T(MSG_PRINT_FAN_SPEED), 60*fan_speed[1] );
lcd_printf_P(PSTR("%-15.15S%-5d\n" "%-15.15S%-5d\n"), _T(MSG_HOTEND_FAN_SPEED), 60*fan_speed[0], _T(MSG_PRINT_FAN_SPEED), 60*fan_speed[1] );
menu_back_if_clicked();
}
@ -1188,12 +1188,12 @@ static void lcd_menu_fails_stats_total()
{
lcd_timeoutToStatus.stop(); //infinite timeout
lcd_home();
lcd_printf_P(failStatsFmt,
lcd_printf_P(failStatsFmt,
_T(MSG_TOTAL_FAILURES),
_T(MSG_POWER_FAILURES), clamp999( eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) ),
_T(MSG_FIL_RUNOUTS), clamp999( eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) ),
_T(MSG_CRASH),
clamp999( eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) ),
clamp999( eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) ),
clamp999( eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) ));
menu_back_if_clicked();
}
@ -1226,11 +1226,11 @@ static void lcd_menu_fails_stats_print()
}
//! @brief Open fail statistics menu
//!
//!
//! This version of function is used, when there is filament sensor,
//! power failure and crash detection.
//! There are Last print and Total menu items.
//!
//!
//! @code{.unparsed}
//! |01234567890123456789|
//! | Main | MSG_MAIN c=18
@ -1251,12 +1251,12 @@ static void lcd_menu_fails_stats()
#elif defined(FILAMENT_SENSOR)
static const char failStatsFmt[] PROGMEM = "%S\n" " %-16.16S%-3d\n" "%S\n" " %-16.16S%-3d\n";
//!
//!
//! @brief Print last print and total filament run outs
//!
//!
//! This version of function is used, when there is filament sensor,
//! but no other sensors (e.g. power failure, crash detection).
//!
//!
//! Example screen:
//! @code{.unparsed}
//! |01234567890123456789|
@ -1272,7 +1272,7 @@ static void lcd_menu_fails_stats()
uint8_t filamentLast = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT);
uint16_t filamentTotal = clamp999( eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) );
lcd_home();
lcd_printf_P(failStatsFmt,
lcd_printf_P(failStatsFmt,
_T(MSG_LAST_PRINT_FAILURES),
_T(MSG_FIL_RUNOUTS), filamentLast,
_T(MSG_TOTAL_FAILURES),
@ -1327,7 +1327,7 @@ static void lcd_menu_debug()
//! @param [in] ipgmLabel pointer to string in PROGMEM
//! @param [in] value to be printed behind the label
static void lcd_menu_temperatures_line(const char *ipgmLabel, int value){
static const size_t maxChars = 15;
static const size_t maxChars = 15;
char tmp[maxChars];
pgmtext_with_colon(ipgmLabel, tmp, maxChars);
lcd_printf_P(PSTR(" %s%3d\x01 \n"), tmp, value); // no need to add -14.14 to string alignment
@ -1407,7 +1407,7 @@ static void lcd_menu_belt_status()
}
#endif //TMC2130
#ifdef RESUME_DEBUG
#ifdef RESUME_DEBUG
extern void stop_and_save_print_to_ram(float z_move, float e_move);
extern void restore_print_from_ram_and_continue(float e_move);
@ -1420,7 +1420,7 @@ static void lcd_menu_test_restore()
{
restore_print_from_ram_and_continue(0.8);
}
#endif //RESUME_DEBUG
#endif //RESUME_DEBUG
//! @brief Show Preheat Menu
static void lcd_preheat_menu()
@ -1508,54 +1508,54 @@ void TestPullupCrash() {
//! | MMM DD YYYY | __DATE__
//! | ------------------ | STR_SEPARATOR
//! @endcode
//!
//!
//! If MMU is connected
//!
//!
//! @code{.unparsed}
//! | MMU connected | c=18
//! | FW: 1.0.6-7064523 |
//! @endcode
//!
//!
//! If MMU is not connected
//!
//!
//! @code{.unparsed}
//! | MMU N/A | c=18
//! @endcode
//!
//!
//! If Flash Air is connected
//!
//!
//! @code{.unparsed}
//! | ------------------ | STR_SEPARATOR
//! | FlashAir IP Addr: | c=18
//! | 192.168.1.100 |
//! @endcode
//!
//!
//! @code{.unparsed}
//! | ------------------ | STR_SEPARATOR
//! | XYZ cal. details | MSG_XYZ_DETAILS c=18
//! | Extruder info | MSG_INFO_EXTRUDER
//! | XYZ cal. details | MSG_INFO_SENSORS
//! @endcode
//!
//!
//! If TMC2130 defined
//!
//!
//! @code{.unparsed}
//! | Belt status | MSG_BELT_STATUS
//! @endcode
//!
//!
//! @code{.unparsed}
//! | Temperatures | MSG_MENU_TEMPERATURES
//! @endcode
//!
//!
//! If Voltage Bed and PWR Pin are defined
//!
//!
//! @code{.unparsed}
//! | Voltages | MSG_MENU_VOLTAGES
//! @endcode
//!
//!
//!
//!
//! If DEBUG_BUILD is defined
//!
//!
//! @code{.unparsed}
//! | Debug | c=18
//! @endcode
@ -1596,7 +1596,7 @@ static void lcd_support_menu()
#if (FW_DEV_VERSION != FW_VERSION_GOLD) && (FW_DEV_VERSION != FW_VERSION_RC)
MENU_ITEM_BACK_P(PSTR(" repo " FW_REPOSITORY));
#endif
MENU_ITEM_BACK_P(_n("prusa3d.com"));////MSG_PRUSA3D c=18
MENU_ITEM_BACK_P(_n("forum.prusa3d.com"));////MSG_PRUSA3D_FORUM c=18
MENU_ITEM_BACK_P(_n("help.prusa3d.com"));////MSG_PRUSA3D_HELP c=18
@ -1644,10 +1644,10 @@ static void lcd_support_menu()
lcd_print(_md->ip_str);
}
}
// Show the printer IP address, if it is available.
if (IP_address) {
MENU_ITEM_BACK_P(STR_SEPARATOR);
MENU_ITEM_BACK_P(_i("Printer IP Addr:")); ////MSG_PRINTER_IP c=18
MENU_ITEM_BACK_P(PSTR(" "));
@ -1666,7 +1666,7 @@ static void lcd_support_menu()
#ifdef TMC2130
MENU_ITEM_SUBMENU_P(_T(MSG_BELT_STATUS), lcd_menu_belt_status);
#endif //TMC2130
MENU_ITEM_SUBMENU_P(_i("Temperatures"), lcd_menu_temperatures);////MSG_MENU_TEMPERATURES c=18
#if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN)
@ -1936,7 +1936,7 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed)
lcd_draw_update = 1;
lcd_clear();
lcd_puts_at_P(0, 3, _T(MSG_CANCEL));
lcd_puts_at_P(0, 3, _T(MSG_CANCEL));
lcd_set_cursor(0, 1);
switch (eFilamentAction)
@ -2118,7 +2118,7 @@ void lcd_change_success() {
}
static void lcd_loading_progress_bar(uint16_t loading_time_ms) {
static void lcd_loading_progress_bar(uint16_t loading_time_ms) {
for (uint_least8_t i = 0; i < LCD_WIDTH; i++) {
lcd_putc_at(i, 3, '.');
@ -2209,7 +2209,7 @@ uint8_t lcd_alright() {
}
void show_preheat_nozzle_warning()
{
{
lcd_clear();
lcd_puts_at_P(0, 0, _T(MSG_ERROR));
lcd_puts_at_P(0, 2, _T(MSG_PREHEAT_NOZZLE));
@ -2454,7 +2454,7 @@ float _deg(float rad)
}
//! @brief Show Measured XYZ Skew
//!
//!
//! @code{.unparsed}
//! |01234567890123456789|
//! |Measured skew :0.00D| MSG_MEASURED_SKEW c=14
@ -2490,7 +2490,7 @@ static void lcd_menu_xyz_skew()
menu_goto(lcd_menu_xyz_offset, 0, true);
}
//! @brief Show measured bed offset from expected position
//!
//!
//! @code{.unparsed}
//! |01234567890123456789|
//! |[0;0] point offset | MSG_MEASURED_OFFSET c=20
@ -2552,7 +2552,7 @@ static void lcd_babystep_z()
// Initialize its status.
_md->status = 1;
check_babystep();
if(!eeprom_is_sheet_initialized(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))){
_md->babystepMemZ = 0;
}
@ -2601,7 +2601,7 @@ static void lcd_babystep_z()
// NOTE: bed_temp and pinda_temp are not currently read/used anywhere.
eeprom_update_byte(&(EEPROM_Sheets_base->s[active_sheet].bed_temp),target_temperature_bed);
#ifdef PINDA_THERMISTOR
#ifdef PINDA_THERMISTOR
eeprom_update_byte(&(EEPROM_Sheets_base->s[active_sheet].pinda_temp),current_temperature_pinda);
#endif //PINDA_THERMISTOR
calibration_status_set(CALIBRATION_STATUS_LIVE_ADJUST);
@ -2629,7 +2629,7 @@ void lcd_adjust_bed_reset(void)
}
//! @brief Show Bed level correct
//!
//!
//! @code{.unparsed}
//! |01234567890123456789|
//! |Settings: | MSG_SETTINGS
@ -2674,7 +2674,7 @@ void lcd_adjust_bed(void)
}
//! @brief Show PID Extruder
//!
//!
//! @code{.unparsed}
//! |01234567890123456789|
//! |Set temperature: |
@ -3176,7 +3176,7 @@ void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, ui
}
void lcd_temp_cal_show_result(bool result) {
custom_message_type = CustomMsg::Status;
disable_x();
disable_y();
@ -3238,7 +3238,7 @@ static void lcd_print_state(uint8_t state)
case STATE_OFF:
lcd_puts_P(_N(" 0"));
break;
default:
default:
lcd_puts_P(_T(MSG_NA));
break;
}
@ -3264,7 +3264,7 @@ static void lcd_show_sensors_state()
lcd_puts_at_P(0, 0, MSG_PINDA);
lcd_set_cursor(LCD_WIDTH - 14, 0);
lcd_print_state(pinda_state);
if (MMU2::mmu2.Enabled()) {
const uint8_t finda_state = MMU2::mmu2.FindaDetectsFilament();
lcd_puts_at_P(10, 0, _n("FINDA"));////MSG_FINDA c=5
@ -3402,7 +3402,7 @@ static void lcd_silent_mode_set() {
#else
st_current_init();
#endif //TMC2130
#ifdef TMC2130
if (lcd_crash_detect_enabled() && (SilentModeMenu != SILENT_MODE_NORMAL))
menu_submenu(lcd_crash_mode_info2);
@ -3459,7 +3459,7 @@ static void lcd_language_menu()
}
uint8_t cnt = lang_get_count();
#ifdef XFLASH
if (cnt == 2) //display secondary language in case of clear xflash
if (cnt == 2) //display secondary language in case of clear xflash
{
if (menu_item_text_P(lang_get_name_by_code(lang_get_code(1))))
{
@ -3480,7 +3480,7 @@ static void lcd_language_menu()
#ifdef COMMUNITY_LANGUAGE_SUPPORT
#ifdef XFLASH
MENU_ITEM_SUBMENU_P(_T(MSG_COMMUNITY_MADE), lcd_community_language_menu);
MENU_ITEM_SUBMENU_P(_T(MSG_COMMUNITY_MADE), lcd_community_language_menu);
#endif //XFLASH
#endif //COMMUNITY_LANGUAGE_SUPPORT && W52X20CL
@ -3577,7 +3577,7 @@ void lcd_first_layer_calibration_reset()
lcd_set_cursor(0, 0);
float offset = static_cast<int16_t>(eeprom_read_word(reinterpret_cast<uint16_t*>(&EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)))/cs.axis_steps_per_mm[Z_AXIS];
lcd_printf_P(_i("Sheet %.7s\nZ offset: %+1.3fmm\n%cContinue\n%cReset"),////MSG_SHEET_OFFSET c=20 r=4
sheet_name, offset, menuData->reset ? ' ' : '>', menuData->reset ? '>' : ' ');// \n denotes line break, %.7s is replaced by 7 character long sheet name, %+1.3f is replaced by 6 character long floating point number, %c is replaced by > or white space (one character) based on whether first or second option is selected. % denoted place holders can not be reordered.
sheet_name, offset, menuData->reset ? ' ' : '>', menuData->reset ? '>' : ' ');// \n denotes line break, %.7s is replaced by 7 character long sheet name, %+1.3f is replaced by 6 character long floating point number, %c is replaced by > or white space (one character) based on whether first or second option is selected. % denoted place holders can not be reordered.
}
@ -3671,7 +3671,7 @@ static void wait_preheat()
lcdui_print_temp(LCD_STR_THERMOMETER[0], (int)(degHotend(0) + 0.5), (int)(degTargetHotend(0) + 0.5));
delay_keep_alive(1000);
}
}
static void lcd_wizard_load() {
@ -3757,14 +3757,14 @@ void lcd_wizard(WizState state)
// Make sure EEPROM_WIZARD_ACTIVE is true if entering using different entry point
// other than WizState::Run - it is useful for debugging wizard.
if (state != S::Run) eeprom_update_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1);
FORCE_BL_ON_START;
while (!end) {
printf_P(PSTR("Wizard state: %d\n"), (uint8_t)state);
switch (state) {
case S::Run: //Run wizard?
// 2019-08-07 brutal hack - solving the "viper" situation.
// It is caused by the fact, that tmc2130_st_isr makes a crash detection before the printers really starts.
// And thus it calles stop_and_save_print_to_ram which sets the saved_printing flag.
@ -3773,9 +3773,9 @@ void lcd_wizard(WizState state)
// This primarily happens when the printer is new and parked in 0,0
// So any new printer will fail the first layer calibration unless being reset or the Stop function gets called.
// We really must find a way to prevent the crash from happening before the printer is started - that would be the correct solution.
// Btw. the flag may even trigger the viper situation on normal start this way and the user won't be able to find out why.
// Btw. the flag may even trigger the viper situation on normal start this way and the user won't be able to find out why.
saved_printing = false;
if( eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)==2){
// printer pre-assembled: finish remaining steps
lcd_show_fullscreen_message_and_wait_P(_T(MSG_WIZARD_WELCOME_SHIPPING));
@ -3914,9 +3914,9 @@ void lcd_wizard(WizState state)
break;
}
}
FORCE_BL_ON_END;
const char *msg = NULL;
printf_P(_N("Wizard end state: %d\n"), (uint8_t)state);
switch (state) {
@ -4010,9 +4010,9 @@ static void lcd_fsensor_actionNA_set(void)
static void lcd_fsensor_settings_menu() {
MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_BACK));
MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR), fsensor.isEnabled() ? _T(MSG_ON) : _T(MSG_OFF), lcd_fsensor_enabled_set);
if (fsensor.isEnabled()) {
if (fsensor.isError()) {
MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR_RUNOUT), _T(MSG_NA), fsensor_reinit);
@ -4028,7 +4028,7 @@ static void lcd_fsensor_settings_menu() {
MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR_JAM_DETECTION), fsensor.getJamDetectionEnabled() ? _T(MSG_ON) : _T(MSG_OFF), lcd_fsensor_jam_detection_set);
#endif //defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
}
switch(fsensor.getActionOnError()) {
case Filament_sensor::SensorActionOnError::_Continue:
MENU_ITEM_TOGGLE_P(_T(MSG_FS_ACTION), _T(MSG_CONTINUE_SHORT), lcd_fsensor_actionNA_set);
@ -4040,7 +4040,7 @@ static void lcd_fsensor_settings_menu() {
lcd_fsensor_actionNA_set();
}
}
MENU_END();
}
@ -4091,15 +4091,31 @@ static void SETTINGS_SILENT_MODE()
if (!farm_mode)
{ // dont show in menu if we are in farm mode
#ifdef TMC2130
if (eeprom_read_byte((uint8_t *)EEPROM_SILENT) == SILENT_MODE_NORMAL)
uint8_t eeprom_mode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
bool bDesync = tmc2130_mode ^ eeprom_mode;
if (eeprom_mode == SILENT_MODE_NORMAL)
{
if (bDesync)
{
MENU_ITEM_TOGGLE_P(_T(MSG_MODE), PSTR("M915"), lcd_silent_mode_set);
}
else
{
MENU_ITEM_TOGGLE_P(_T(MSG_MODE), _T(MSG_NORMAL), lcd_silent_mode_set);
MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), lcd_crash_detect_enabled() ? _T(MSG_ON) : _T(MSG_OFF), crash_mode_switch);
}
MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), lcd_crash_detect_enabled() ? _T(MSG_ON) : _T(MSG_OFF), crash_mode_switch);
}
else
{
if (bDesync)
{
MENU_ITEM_TOGGLE_P(_T(MSG_MODE), PSTR("M914") , lcd_silent_mode_set);
}
else
{
MENU_ITEM_TOGGLE_P(_T(MSG_MODE), _T(MSG_STEALTH), lcd_silent_mode_set);
MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), NULL, lcd_crash_mode_info);
}
MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), NULL, lcd_crash_mode_info);
}
#else // TMC2130
switch (eeprom_read_byte((uint8_t *)EEPROM_SILENT))
@ -4394,7 +4410,7 @@ void lcd_hw_setup_menu(void) // can not be "static"
//! The SuperPINDA is detected when the PINDA temp is below its defined limit.
//! This works well on the EINSY board but not on the miniRAMBo board as
//! as a disconnected SuperPINDA will show higher temps compared to an EINSY board.
//!
//!
//! This menu allows the user to en-/disable the SuperPINDA manualy
MENU_ITEM_TOGGLE_P(_N("SuperPINDA"), eeprom_read_byte((uint8_t *)EEPROM_PINDA_TEMP_COMPENSATION) ? _T(MSG_YES) : _T(MSG_NO), lcd_pinda_temp_compensation_toggle);
#endif //PINDA_TEMP_COMP
@ -4581,7 +4597,7 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite
const uint8_t item_len = item?strlen_P(item):0;
int8_t first = 0;
int8_t cursor_pos = 1;
lcd_clear();
KEEPALIVE_STATE(PAUSED_FOR_USER);
@ -4605,7 +4621,7 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite
}
if (cursor_pos > 3)
{
{
cursor_pos = 3;
if (first < items_no - 3)
{
@ -4733,7 +4749,7 @@ static void lcd_disable_farm_mode()
}
lcd_update_enable(true);
lcd_draw_update = 2;
}
static inline void load_all_wrapper(){
@ -5090,8 +5106,8 @@ static void lcd_sheet_menu()
//!
//! | recover print | ifdef TMC2130_DEBUG
//! | power panic | ifdef TMC2130_DEBUG
//!
//! | Live adjust Z | printing + Z low
//!
//! | Live adjust Z | printing + Z low
//!
//! | Change filament | farm mode
//!
@ -5111,7 +5127,7 @@ static void lcd_sheet_menu()
//! | Eject from MMU | not printing + mmu or paused
//! | Cut filament | not printing + mmu or paused + cut atctive
//! | Settings | not printing or paused
//! | Calibration | not printing
//! | Calibration | not printing
//! | Statistics | not printing
//! | Fail stats | allways
//! | Fail stats MMU | mmu
@ -5127,12 +5143,12 @@ static void lcd_main_menu()
MENU_ITEM_BACK_P(_T(MSG_INFO_SCREEN));
#ifdef RESUME_DEBUG
if (!saved_printing)
#ifdef RESUME_DEBUG
if (!saved_printing)
MENU_ITEM_FUNCTION_P(PSTR("tst - Save"), lcd_menu_test_save);
else
MENU_ITEM_FUNCTION_P(PSTR("tst - Restore"), lcd_menu_test_restore);
#endif //RESUME_DEBUG
#endif //RESUME_DEBUG
#ifdef TMC2130_DEBUG
MENU_ITEM_FUNCTION_P(PSTR("recover print"), recover_print);
@ -5282,7 +5298,7 @@ void stepper_timer_overflow() {
static void lcd_colorprint_change() {
enquecommand_P(MSG_M600);
custom_message_type = CustomMsg::FilamentLoading; //just print status message
@ -5434,7 +5450,7 @@ static void mbl_probe_nr_toggle() {
static void lcd_mesh_bed_leveling_settings()
{
bool magnet_elimination = (eeprom_read_byte((uint8_t*)EEPROM_MBL_MAGNET_ELIMINATION) > 0);
uint8_t points_nr = eeprom_read_byte((uint8_t*)EEPROM_MBL_POINTS_NR);
char sToggle[4]; //enough for nxn format
@ -5472,13 +5488,13 @@ static void lcd_backlight_menu()
ON_MENU_LEAVE(
backlight_save();
);
MENU_ITEM_BACK_P(_T(MSG_BACK));
MENU_ITEM_EDIT_int3_P(_T(MSG_BL_HIGH), &backlightLevel_HIGH, backlightLevel_LOW, 255);
MENU_ITEM_EDIT_int3_P(_T(MSG_BL_LOW), &backlightLevel_LOW, 0, backlightLevel_HIGH);
MENU_ITEM_TOGGLE_P(_T(MSG_MODE), ((backlightMode==BACKLIGHT_MODE_BRIGHT) ? _T(MSG_BRIGHT) : ((backlightMode==BACKLIGHT_MODE_DIM) ? _T(MSG_DIM) : _T(MSG_AUTO))), backlight_mode_toggle);
MENU_ITEM_EDIT_int3_P(_T(MSG_TIMEOUT), &backlightTimer_period, 1, 999);
MENU_END();
}
#endif //LCD_BL_PIN
@ -5636,7 +5652,7 @@ void lcd_sdcard_menu()
} _menu_data_sdcard_t;
static_assert(sizeof(menu_data)>= sizeof(_menu_data_sdcard_t),"_menu_data_sdcard_t doesn't fit into menu_data");
_menu_data_sdcard_t* _md = (_menu_data_sdcard_t*)&(menu_data[0]);
switch(_md->menuState)
{
case _uninitialized: //Initialize menu data
@ -5671,12 +5687,12 @@ void lcd_sdcard_menu()
}
if (lcd_draw_update == 0 && !lcd_clicked())
return; // nothing to do (so don't thrash the SD card)
_md->row = -1; // assume that no SD file/dir is currently selected. Once they are rendered, it will be changed to the correct row for the _scrolling state.
//if we reached this point it means that the encoder moved or clicked or the state is being switched. Reset the scrollTimer.
_md->lcd_scrollTimer.start();
MENU_BEGIN();
MENU_ITEM_BACK_P(_T(bMain?MSG_MAIN:MSG_BACK)); // i.e. default menu-item / menu-item after card insertion
card.getWorkDirName();
@ -5704,7 +5720,7 @@ void lcd_sdcard_menu()
#endif
if (lcd_encoder == menu_item) //If the file is selected.
{
_md->selectedFileID = i;
_md->isDir = card.filenameIsDir;
_md->row = menu_row;
@ -5722,7 +5738,7 @@ void lcd_sdcard_menu()
{
// LCD_CLICKED is used so that the click event is later consumed by the _standard state.
const bool rewindFlag = LCD_CLICKED || lcd_draw_update; //flag that says whether the menu should return to _standard state.
if (_md->scrollPointer == NULL)
{
//load filename to memory.
@ -5733,7 +5749,7 @@ void lcd_sdcard_menu()
#endif
_md->scrollPointer = (card.longFilename[0] == '\0') ? card.filename : card.longFilename;
}
if (rewindFlag)
_md->offset = 0; //redraw once again from the beginning.
if (_md->lcd_scrollTimer.expired(300) || rewindFlag)
@ -5773,13 +5789,13 @@ void lcd_belttest()
lcd_clear();
// Belttest requires high power mode. Enable it.
FORCE_HIGH_POWER_START;
uint16_t X = eeprom_read_word((uint16_t*)(EEPROM_BELTSTATUS_X));
uint16_t Y = eeprom_read_word((uint16_t*)(EEPROM_BELTSTATUS_Y));
lcd_puts_P(_T(MSG_CHECKING_X));
lcd_set_cursor(0,1), lcd_printf_P(PSTR("X: %u -> ..."),X);
KEEPALIVE_STATE(IN_HANDLER);
// N.B: it doesn't make sense to handle !lcd_selfcheck...() because selftest_sg throws its own error screen
// that clobbers ours, with more info than we could provide. So on fail we just fall through to take us back to status.
if (lcd_selfcheck_axis_sg(X_AXIS)){
@ -5797,7 +5813,7 @@ void lcd_belttest()
lcd_wait_for_click_delay(10);
}
}
FORCE_HIGH_POWER_END;
KEEPALIVE_STATE(NOT_BUSY);
}
@ -5815,7 +5831,7 @@ static bool lcd_selftest_IRsensor(bool bStandalone)
IR_sensor_analog::SensorRevision oldSensorRevision = fsensor.getSensorRevision();
IR_sensor_analog::SensorRevision newSensorRevision;
uint16_t volt_IR_int = fsensor.getVoltRaw();
newSensorRevision = (volt_IR_int < fsensor.IRsensor_Hopen_TRESHOLD) ? IR_sensor_analog::SensorRevision::_Rev04 : IR_sensor_analog::SensorRevision::_Old;
printf_P(PSTR("Measured filament sensor high level: %4.2fV\n"), Raw2Voltage(volt_IR_int) );
if(volt_IR_int < fsensor.IRsensor_Hmin_TRESHOLD){
@ -6063,7 +6079,7 @@ bool lcd_selftest()
{
#if (FILAMENT_SENSOR_TYPE == FSENSOR_IR) || (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
if (MMU2::mmu2.Enabled())
{
{
_progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filaments sensor
_result = selftest_irsensor();
if (_result)
@ -6095,7 +6111,7 @@ bool lcd_selftest()
lcd_reset_alert_level();
enquecommand_P(MSG_M84);
lcd_update_enable(true);
if (_result)
{
calibration_status_set(CALIBRATION_STATUS_SELFTEST);
@ -6109,9 +6125,9 @@ bool lcd_selftest()
#ifdef TMC2130
FORCE_HIGH_POWER_END;
#endif // TMC2130
FORCE_BL_ON_END;
KEEPALIVE_STATE(NOT_BUSY);
return(_result);
}
@ -6126,7 +6142,7 @@ static void reset_crash_det(uint8_t axis) {
}
static bool lcd_selfcheck_axis_sg(uint8_t axis) {
// each axis length is measured twice
// each axis length is measured twice
float axis_length, current_position_init, current_position_final;
float measured_axis_length[2];
float margin = 60;
@ -6145,12 +6161,12 @@ static bool lcd_selfcheck_axis_sg(uint8_t axis) {
raise_z_above(MESH_HOME_Z_SEARCH);
tmc2130_home_enter(1 << axis);
// first axis length measurement begin
// first axis length measurement begin
current_position[axis] -= (axis_length + margin);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60);
st_synchronize();
tmc2130_sg_measure_start(axis);
@ -6174,16 +6190,16 @@ static bool lcd_selfcheck_axis_sg(uint8_t axis) {
measured_axis_length[0] = fabs(current_position_final - current_position_init);
// first measurement end and second measurement begin
// first measurement end and second measurement begin
current_position[axis] -= margin;
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60);
st_synchronize();
st_synchronize();
current_position[axis] -= (axis_length + margin);
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60);
st_synchronize();
current_position_init = st_get_position_mm(axis);
@ -6216,7 +6232,7 @@ static bool lcd_selfcheck_axis_sg(uint8_t axis) {
}
printf_P(_N("Axis length difference:%.3f\n"), fabs(measured_axis_length[0] - measured_axis_length[1]));
if (fabs(measured_axis_length[0] - measured_axis_length[1]) > 1) { //check if difference between first and second measurement is low
//loose pulleys
const char *_error_1;
@ -6344,7 +6360,7 @@ static bool lcd_selfcheck_pulleys(int axis)
refresh_cmd_timeout();
manage_inactivity(true);
if (axis == 0) move = 50; //X_AXIS
if (axis == 0) move = 50; //X_AXIS
else move = 50; //Y_AXIS
current_position_init = current_position[axis];
@ -6358,7 +6374,7 @@ static bool lcd_selfcheck_pulleys(int axis)
plan_buffer_line_curposXYZE(200);
st_synchronize();
if (SilentModeMenu != SILENT_MODE_OFF) st_current_set(0, tmp_motor[0]); //set back to normal operation currents
else st_current_set(0, tmp_motor_loud[0]); //set motor current back
else st_current_set(0, tmp_motor_loud[0]); //set motor current back
current_position[axis] = current_position[axis] - move;
plan_buffer_line_curposXYZE(50);
st_synchronize();
@ -6514,9 +6530,9 @@ static bool lcd_selfcheck_check_heater(bool _isbed)
static void lcd_selftest_error(TestError testError, const char *_error_1, const char *_error_2)
{
lcd_beeper_quick_feedback();
FORCE_BL_ON_END;
target_temperature[0] = 0;
target_temperature_bed = 0;
manage_heater();
@ -6905,9 +6921,9 @@ static bool check_file(const char* filename) {
manage_heater();
#endif // CMDBUFFER_DEBUG
}
menu_progressbar_finish();
cmdqueue_serial_disabled = false;
card.printingHasFinished();
@ -6948,7 +6964,7 @@ static void menu_action_sdfile(const char* filename)
eeprom_write_byte((uint8_t*)EEPROM_DIRS + j + 8 * i, card.dir_names[i][j]);
}
}
//filename is just a pointer to card.filename, which changes everytime you try to open a file by filename. So you can't use filename directly
//to open a file. Instead, the cached filename in cmd is used as that one is static for the whole lifetime of this function.
if (!check_file(cmd + 4)) {
@ -7174,7 +7190,7 @@ void menu_lcd_lcdupdate_func(void)
// and instead show the submenu title 'No SD card'.
//
// 2. 'No SD card': When the user inserts the SD card we want
// to back out of this submenu. Not only to show
// to back out of this submenu. Not only to show
// 'Print from SD' submenu title but also because the user
// will be prompted with another menu with the sorted list of files.
// Without backing out of the menu, the list will appear empty and
@ -7282,7 +7298,7 @@ void UserECool_toggle(){
bool UserECoolEnabled(){
// We enable E-cool mode for non-farm prints IFF the experimental menu is visible AND the EEPROM_ECOOL variable has
// a value of the universal answer to all problems of the universe
return ( eeprom_read_byte((uint8_t *)EEPROM_ECOOL_ENABLE) == EEPROM_ECOOL_MAGIC_NUMBER )
return ( eeprom_read_byte((uint8_t *)EEPROM_ECOOL_ENABLE) == EEPROM_ECOOL_MAGIC_NUMBER )
&& ( eeprom_read_byte((uint8_t *)EEPROM_EXPERIMENTAL_VISIBILITY) == 1 );
}
@ -7307,15 +7323,15 @@ void lcd_experimental_menu()
#ifdef EXTRUDER_ALTFAN_DETECT
MENU_ITEM_TOGGLE_P(_N("ALTFAN det."), altfanOverride_get()?_T(MSG_OFF):_T(MSG_ON), altfanOverride_toggle);////MSG_MENU_ALTFAN c=18
#endif //EXTRUDER_ALTFAN_DETECT
#ifdef TMC2130
MENU_ITEM_TOGGLE_P(_N("E-cool mode"), UserECoolEnabled()?_T(MSG_ON):_T(MSG_OFF), UserECool_toggle);////MSG_MENU_ECOOL c=18
#endif
#ifdef DEBUG_PULLUP_CRASH
MENU_ITEM_FUNCTION_P(_N("Test Pullup Crash"), TestPullupCrash);
#endif // DEBUG_PULLUP_CRASH
#ifdef PRUSA_SN_SUPPORT
MENU_ITEM_FUNCTION_P(_N("Fake serial number"), WorkaroundPrusaSN);////MSG_WORKAROUND_PRUSA_SN c=18
#endif //PRUSA_SN_SUPPORT