Skip to content

Commit

Permalink
Fixup after rebase + discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
D.R.racer committed Jul 28, 2022
1 parent e855e87 commit c53d081
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 79 deletions.
8 changes: 4 additions & 4 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,12 +646,12 @@ void crashdet_detected(uint8_t mask)
lcd_set_cursor(0, 1);
lcd_puts_P(_T(MSG_RESUME_PRINT));
lcd_putc('?');
bool yesno = lcd_show_yes_no_and_wait(false);
int8_t yesno = lcd_show_yes_no_and_wait(false);
if (yesno == LCD_LEFT_BUTTON_CHOICE)
{
enquecommand_P(PSTR("CRASH_RECOVER"));
}
else // MIDDLE_BUTTON_CHOICE
else // LCD_MIDDLE_BUTTON_CHOICE
{
enquecommand_P(PSTR("CRASH_CANCEL"));
}
Expand Down Expand Up @@ -3465,7 +3465,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
{
KEEPALIVE_STATE(PAUSED_FOR_USER);
#ifdef STEEL_SHEET
bool result = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_STEEL_SHEET_CHECK), false);
int8_t result = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_STEEL_SHEET_CHECK), false);
if(result == LCD_LEFT_BUTTON_CHOICE) {
lcd_show_fullscreen_message_and_wait_P(_T(MSG_REMOVE_STEEL_SHEET));
}
Expand Down Expand Up @@ -5150,7 +5150,7 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF);
break;
}
lcd_show_fullscreen_message_and_wait_P(_i("Stable ambient temperature 21-26C is needed a rigid stand is required."));////MSG_TEMP_CAL_WARNING c=20 r=4
bool result = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_STEEL_SHEET_CHECK), false);
int8_t result = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_STEEL_SHEET_CHECK), false);

if (result == LCD_LEFT_BUTTON_CHOICE)
{
Expand Down
6 changes: 3 additions & 3 deletions Firmware/Tcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ struct SChooseFromMenu {

SChooseFromMenu TCodeChooseFromMenu() {
if (MMU2::mmu2.Enabled()) {
return SChooseFromMenu( choose_menu_P(_T(MSG_CHOOSE_FILAMENT), _T(MSG_FILAMENT)), true );
return SChooseFromMenu( choose_menu_P(_T(MSG_SELECT_FILAMENT), _T(MSG_FILAMENT)), true );
} else {
return SChooseFromMenu( choose_menu_P(_T(MSG_CHOOSE_EXTRUDER), _T(MSG_EXTRUDER)), false );
return SChooseFromMenu( choose_menu_P(_T(MSG_SELECT_EXTRUDER), _T(MSG_EXTRUDER)), false );
}
}

Expand All @@ -48,7 +48,7 @@ void TCodes(char *const strchr_pointer, uint8_t codeValue) {
} else if (strchr_pointer[index] == 'x'){
// load to bondtech gears; if mmu is not present do nothing
if (MMU2::mmu2.Enabled()) {
MMU2::mmu2.tool_change(strchr_pointer[index], choose_menu_P(_T(MSG_CHOOSE_EXTRUDER), _T(MSG_EXTRUDER)));
MMU2::mmu2.tool_change(strchr_pointer[index], choose_menu_P(_T(MSG_SELECT_EXTRUDER), _T(MSG_EXTRUDER)));
}
} else if (strchr_pointer[index] == 'c'){
// load from bondtech gears to nozzle (nozzle should be preheated)
Expand Down
1 change: 0 additions & 1 deletion Firmware/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
| ^ | ^ | ^ | 03h 3 | ^ | bad_isr | ^ | ^
| ^ | ^ | ^ | 04h 4 | ^ | bad_pullup_temp_isr | ^ | ^
| ^ | ^ | ^ | 05h 5 | ^ | bad_pullup_step_isr | ^ | ^
| 0x0D03 3321 | uint8_t | EEPROM_FW_CRASH_FLAG | 01h 1 | ff/00 | Last FW crash reason (dump_crash_reason) | D21/D22 | D3 Ax0d03 C1
| 0x0D02 3320 | uint8_t | EEPROM_FSENSOR_JAM_DETECTION | 01h 1 | ff/01 | fsensor pat9125 jam detection feature | LCD menu | D3 Ax0d02 C1
| 0x0D01 3319 | uint8_t | EEPROM_MMU_ENABLED | 01h 1 | ff/01 | MMU enabled | LCD menu | D3 Ax0d01 C1
Expand Down
24 changes: 24 additions & 0 deletions Firmware/lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,30 @@ extern void lcd_update_enable(uint8_t enabled);

extern void lcd_buttons_update(void);

//! @brief Helper class to temporarily disable LCD updates
//!
//! When constructed (on stack), original state state of lcd_update_enabled is stored
//! and LCD updates are disabled.
//! When destroyed (gone out of scope), original state of LCD update is restored.
//! It has zero overhead compared to storing bool saved = lcd_update_enabled
//! and calling lcd_update_enable(false) and lcd_update_enable(saved).
class LcdUpdateDisabler
{
public:
LcdUpdateDisabler(): m_updateEnabled(lcd_update_enabled)
{
lcd_update_enable(false);
}
~LcdUpdateDisabler()
{
lcd_update_enable(m_updateEnabled);
}

private:
bool m_updateEnabled;
};


////////////////////////////////////
// Setup button and encode mappings for each panel (into 'lcd_buttons' variable
//
Expand Down
2 changes: 2 additions & 0 deletions Firmware/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ uint8_t menu_item_function_P(const char* str, char number, void (*func)(uint8_t)
{
menu_clicked = false;
lcd_consume_click();
lcd_update_enabled = 0;
if (func) func(fn_par);
lcd_update_enabled = 1;
return menu_item_ret();
}
}
Expand Down
12 changes: 6 additions & 6 deletions Firmware/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const char MSG_FIND_BED_OFFSET_AND_SKEW_LINE1[] PROGMEM_I1 = ISTR("Searching bed
const char MSG_FINISHING_MOVEMENTS[] PROGMEM_I1 = ISTR("Finishing movements"); ////MSG_FINISHING_MOVEMENTS c=20
const char MSG_FOLLOW_CALIBRATION_FLOW[] PROGMEM_I1 = ISTR("Printer has not been calibrated yet. Please follow the manual, chapter First steps, section Calibration flow."); ////MSG_FOLLOW_CALIBRATION_FLOW c=20 r=8
const char MSG_FOLLOW_Z_CALIBRATION_FLOW[] PROGMEM_I1 = ISTR("There is still a need to make Z calibration. Please follow the manual, chapter First steps, section Calibration flow."); ////MSG_FOLLOW_Z_CALIBRATION_FLOW c=20 r=9
const char MSG_FSENSOR_RUNOUT[] PROGMEM_I1 = ISTR("F. runout"); ////c=13
const char MSG_FSENSOR_RUNOUT[] PROGMEM_I1 = ISTR("F. runout"); ////MSG_FSENSOR_RUNOUT c=13
const char MSG_FSENSOR_AUTOLOAD[] PROGMEM_I1 = ISTR("F. autoload"); ////MSG_FSENSOR_AUTOLOAD c=13
const char MSG_FSENSOR_JAM_DETECTION[] PROGMEM_I1 = ISTR("F. jam detect"); ////c=13
const char MSG_FSENSOR_JAM_DETECTION[] PROGMEM_I1 = ISTR("F. jam detect"); ////MSG_FSENSOR_JAM_DETECTION c=13
const char MSG_FSENSOR[] PROGMEM_I1 = ISTR("Fil. sensor"); ////MSG_FSENSOR c=12
const char MSG_HEATING[] PROGMEM_I1 = ISTR("Heating"); ////MSG_HEATING c=20
const char MSG_HEATING_COMPLETE[] PROGMEM_I1 = ISTR("Heating done."); ////MSG_HEATING_COMPLETE c=20
Expand All @@ -53,9 +53,9 @@ const char MSG_SELECT_FILAMENT[] PROGMEM_I1 = ISTR("Select filament:"); ////MSG_
const char MSG_LAST_PRINT[] PROGMEM_I1 = ISTR("Last print"); ////MSG_LAST_PRINT c=18
const char MSG_LAST_PRINT_FAILURES[] PROGMEM_I1 = ISTR("Last print failures"); ////MSG_LAST_PRINT_FAILURES c=20
const char MSG_LOAD_FILAMENT[] PROGMEM_I1 = ISTR("Load filament"); ////MSG_LOAD_FILAMENT c=17
const char MSG_LOAD_TO_BONDTECH[] PROGMEM_I1 = ISTR("Load to Bondtech"); ////c=18
const char MSG_LOAD_TO_BONDTECH[] PROGMEM_I1 = ISTR("Load to Bondtech"); ////MSG_LOAD_TO_BONDTECH c=18
const char MSG_LOADING_FILAMENT[] PROGMEM_I1 = ISTR("Loading filament"); ////MSG_LOADING_FILAMENT c=20
const char MSG_TESTING_FILAMENT[] PROGMEM_I1 = ISTR("Testing filament"); ////c=20
const char MSG_TESTING_FILAMENT[] PROGMEM_I1 = ISTR("Testing filament"); ////MSG_TESTING_FILAMENT c=20
const char MSG_EJECT_FILAMENT[] PROGMEM_I1 = ISTR("Eject filament"); ////MSG_EJECT_FILAMENT c=17
const char MSG_CUT_FILAMENT[] PROGMEM_I1 = ISTR("Cut filament"); ////MSG_CUT_FILAMENT c=17
const char MSG_M117_V2_CALIBRATION[] PROGMEM_I1 = ISTR("M117 First layer cal."); ////MSG_M117_V2_CALIBRATION c=25
Expand Down Expand Up @@ -157,8 +157,8 @@ const char MSG_TIMEOUT[] PROGMEM_I1 = ISTR("Timeout"); ////MSG_TIMEOUT c=12
const char MSG_BRIGHT[] PROGMEM_I1 = ISTR("Bright"); ////MSG_BRIGHT c=6
const char MSG_DIM[] PROGMEM_I1 = ISTR("Dim"); ////MSG_DIM c=6
const char MSG_AUTO[] PROGMEM_I1 = ISTR("Auto"); ////MSG_AUTO c=6
const char MSG_FS_V_03_OR_OLDER[] PROGMEM_I1 = ISTR("FS v0.3 or older"); ////c=18
const char MSG_FS_V_04_OR_NEWER[] PROGMEM_I1 = ISTR("FS v0.4 or newer"); ////c=18
const char MSG_FS_V_03_OR_OLDER[] PROGMEM_I1 = ISTR("FS v0.3 or older"); ////MSG_FS_V_03_OR_OLDER c=18
const char MSG_FS_V_04_OR_NEWER[] PROGMEM_I1 = ISTR("FS v0.4 or newer"); ////MSG_FS_V_04_OR_NEWER c=18
// Beware - the space at the beginning is necessary since it is reused in LCD menu items which are to be with a space
const char MSG_IR_04_OR_NEWER[] PROGMEM_I1 = ISTR(" 0.4 or newer");////c=18
const char MSG_IR_03_OR_OLDER[] PROGMEM_I1 = ISTR(" 0.3 or older");////c=18
Expand Down
124 changes: 62 additions & 62 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,7 @@ static void lcd_menu_fails_stats_total()
//! @endcode

//! @todo Positioning of the messages and values on LCD aren't fixed to their exact place. This causes issues with translations.
//! @todo leptun refactor this piece of code please
static void lcd_menu_fails_stats_print()
{
lcd_timeoutToStatus.stop(); //infinite timeout
Expand Down Expand Up @@ -1852,6 +1853,7 @@ switch(eFilamentAction)
}
if(lcd_clicked()
#ifdef FILAMENT_SENSOR
/// @todo leptun - add this as a specific retest item
|| (((eFilamentAction == FilamentAction::Load) || (eFilamentAction == FilamentAction::AutoLoad)) && fsensor.getFilamentLoadEvent())
#endif //FILAMENT_SENSOR
) {
Expand Down Expand Up @@ -2322,7 +2324,7 @@ void show_preheat_nozzle_warning()

void lcd_load_filament_color_check()
{
bool clean = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_CLEAN), false, LCD_LEFT_BUTTON_CHOICE);
int8_t clean = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_FILAMENT_CLEAN), false, LCD_LEFT_BUTTON_CHOICE);
while (clean == LCD_MIDDLE_BUTTON_CHOICE) {
load_filament_final_feed();
st_synchronize();
Expand All @@ -2338,15 +2340,13 @@ static void lcd_menu_AutoLoadFilament()
}
#endif //FILAMENT_SENSOR

static void preheat_or_continue()
{
bFilamentFirstRun = false;
if (target_temperature[0] >= extrude_min_temp)
{
static void preheat_or_continue() {
if (target_temperature[0] >= extrude_min_temp) {
bFilamentPreheatState = true;
mFilamentItem(target_temperature[0], target_temperature_bed);
} else {
lcd_generic_preheat_menu();
}
else lcd_generic_preheat_menu();
}

static void lcd_LoadFilament()
Expand Down Expand Up @@ -3132,7 +3132,7 @@ const char* lcd_display_message_fullscreen_P(const char *msg)
*/
void lcd_show_fullscreen_message_and_wait_P(const char *msg)
{
lcd_update_enable(false);
LcdUpdateDisabler lcdUpdateDisabler;
const char *msg_next = lcd_display_message_fullscreen_P(msg);
bool multi_screen = msg_next != NULL;
lcd_set_custom_characters_nextpage();
Expand All @@ -3152,7 +3152,6 @@ void lcd_show_fullscreen_message_and_wait_P(const char *msg)
if (msg_next == NULL) {
KEEPALIVE_STATE(IN_HANDLER);
lcd_set_custom_characters();
lcd_update_enable(true);
return;
}
else {
Expand Down Expand Up @@ -3276,60 +3275,60 @@ int8_t lcd_show_multiscreen_message_with_choices_and_wait_P(const char * const m
manage_heater();
manage_inactivity(true);

if (multiscreen_cb)
{
multiscreen_cb();
}

if (multiscreen_cb) {
multiscreen_cb();
}

if (abs(enc_dif - lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP) {
if (msg_next == NULL) {


if (abs(enc_dif - lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP) {
if (msg_next == NULL) {
if (third_choice) { // third_choice is not nullptr, safe to dereference
if (enc_dif > lcd_encoder_diff && current_selection != LCD_LEFT_BUTTON_CHOICE) {
// Rotating knob counter clockwise
current_selection--;
} else if (enc_dif < lcd_encoder_diff && current_selection != LCD_RIGHT_BUTTON_CHOICE) {
// Rotating knob clockwise
current_selection++;
}
} else {
if (enc_dif > lcd_encoder_diff && current_selection != LCD_LEFT_BUTTON_CHOICE) {
// Rotating knob counter clockwise
current_selection = LCD_LEFT_BUTTON_CHOICE;
} else if (enc_dif < lcd_encoder_diff && current_selection != LCD_MIDDLE_BUTTON_CHOICE) {
// Rotating knob clockwise
current_selection = LCD_MIDDLE_BUTTON_CHOICE;
}
}
lcd_show_choices_prompt_P(current_selection, first_choice, second_choice, second_col, third_choice);
enc_dif = lcd_encoder_diff;
Sound_MakeSound(e_SOUND_TYPE_EncoderMove);
if (enc_dif > lcd_encoder_diff && current_selection != LCD_LEFT_BUTTON_CHOICE) {
// Rotating knob counter clockwise
current_selection--;
} else if (enc_dif < lcd_encoder_diff && current_selection != LCD_RIGHT_BUTTON_CHOICE) {
// Rotating knob clockwise
current_selection++;
}
} else {
if (enc_dif > lcd_encoder_diff && current_selection != LCD_LEFT_BUTTON_CHOICE) {
// Rotating knob counter clockwise
current_selection = LCD_LEFT_BUTTON_CHOICE;
} else if (enc_dif < lcd_encoder_diff && current_selection != LCD_MIDDLE_BUTTON_CHOICE) {
// Rotating knob clockwise
current_selection = LCD_MIDDLE_BUTTON_CHOICE;
}
}
lcd_show_choices_prompt_P(current_selection, first_choice, second_choice, second_col, third_choice);
enc_dif = lcd_encoder_diff;
Sound_MakeSound(e_SOUND_TYPE_EncoderMove);
} else {
Sound_MakeSound(e_SOUND_TYPE_BlindAlert);
break; //turning knob skips waiting loop
}
}
if (lcd_clicked()) {
Sound_MakeSound(e_SOUND_TYPE_ButtonEcho);
if (msg_next == NULL) {
KEEPALIVE_STATE(IN_HANDLER);
lcd_set_custom_characters();
lcd_update_enable(true);
return current_selection;
Sound_MakeSound(e_SOUND_TYPE_BlindAlert);
break; // turning knob skips waiting loop
}
}
if (lcd_clicked()) {
Sound_MakeSound(e_SOUND_TYPE_ButtonEcho);
if (msg_next == NULL) {
KEEPALIVE_STATE(IN_HANDLER);
lcd_set_custom_characters();
lcd_update_enable(true);
return current_selection;
} else
break;
}
}
if (multi_screen) {
if (msg_next == NULL) {
msg_next = msg;
}
msg_next = lcd_display_message_fullscreen_P(msg_next);
}
if (msg_next == NULL) {
lcd_show_choices_prompt_P(current_selection, first_choice, second_choice, second_col, third_choice);
}
}
}
}
if (multi_screen) {
if (msg_next == NULL) {
msg_next = msg;
}
msg_next = lcd_display_message_fullscreen_P(msg_next);
}
if (msg_next == NULL) {
lcd_show_choices_prompt_P(current_selection, first_choice, second_choice, second_col, third_choice);
}
}
}

//! @brief Display and wait for a Yes/No choice using the last line of the LCD
Expand Down Expand Up @@ -4290,7 +4289,7 @@ static void lcd_wizard_load() {
bool lcd_autoDepleteEnabled()
{
return (lcd_autoDeplete
#ifdef FILAMENT_SENSOR ///should be removed during mmu2 refactoring
#ifdef FILAMENT_SENSOR // @todo leptun: should be removed during mmu2 refactoring - needs checking
&& fsensor.isReady()
#endif
);
Expand Down Expand Up @@ -4616,10 +4615,10 @@ static void lcd_fsensor_settings_menu() {

switch(fsensor.getActionOnError()) {
case Filament_sensor::SensorActionOnError::_Continue:
MENU_ITEM_TOGGLE_P(_T(MSG_FS_ACTION), _T(MSG_FS_CONTINUE), lcd_fsensor_actionNA_set);
MENU_ITEM_TOGGLE_P(_T(MSG_FS_ACTION), _T(MSG_CONTINUE_SHORT), lcd_fsensor_actionNA_set);
break;
case Filament_sensor::SensorActionOnError::_Pause:
MENU_ITEM_TOGGLE_P(_T(MSG_FS_ACTION), _T(MSG_FS_PAUSE), lcd_fsensor_actionNA_set);
MENU_ITEM_TOGGLE_P(_T(MSG_FS_ACTION), _T(MSG_PAUSE), lcd_fsensor_actionNA_set);
break;
default:
lcd_fsensor_actionNA_set();
Expand Down Expand Up @@ -7814,6 +7813,7 @@ static void menu_action_sdfile(const char* filename)
//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)) {
result = !lcd_show_fullscreen_message_yes_no_and_wait_P(_i("File incomplete. Continue anyway?"), false);////MSG_FILE_INCOMPLETE c=20 r=3
lcd_update_enable(true);
}
if (result) {
enquecommand(cmd);
Expand Down Expand Up @@ -8121,7 +8121,7 @@ void menu_lcd_lcdupdate_func(void)
}
#endif//CARDINSERTED
backlight_update();
if (lcd_next_update_millis < _millis() || lcd_draw_update)
if (lcd_next_update_millis < _millis())
{
if (abs(lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP)
{
Expand Down
6 changes: 3 additions & 3 deletions Firmware/ultralcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ extern void lcd_show_fullscreen_message_and_wait_P(const char *msg);
// 1: no, 0: yes, -1: timeouted
extern int8_t lcd_show_yes_no_and_wait(bool allow_timeouting = true, uint8_t default_selection = LCD_MIDDLE_BUTTON_CHOICE);
// 1: no, 0: yes, -1: timeouted
extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, uint8_t default_selection = MIDDLE_BUTTON_CHOICE);
extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, uint8_t default_selection = LCD_MIDDLE_BUTTON_CHOICE);
extern int8_t lcd_show_multiscreen_message_with_choices_and_wait_P(const char * const msg, bool allow_timeouting, uint8_t default_selection,
const char * const first_choice, const char * const second_choice, const char * const third_choice = nullptr, uint8_t second_col = 7,
void (*multiscreen_cb)(void) = nullptr);
extern int8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, uint8_t default_selection = MIDDLE_BUTTON_CHOICE);
extern int8_t lcd_show_multiscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, uint8_t default_selection = LCD_MIDDLE_BUTTON_CHOICE);
// Ask the user to move the Z axis up to the end stoppers and let
// the user confirm that it has been done.

Expand Down Expand Up @@ -129,7 +129,7 @@ enum class CustomMsg : uint_least8_t
TempCompPreheat, //!< Temperature compensation preheat
M0Wait, //!< M0/M1 Wait command working even from SD
M117, //!< M117 Set the status line message on the LCD
Resuming, //!< Resuming message
Resuming, //!< Resuming message
MMUProgress, ///< MMU progress message
};

Expand Down

0 comments on commit c53d081

Please sign in to comment.