Merge pull request #662 from mkbel/fix_return_autoload
Return from Autoload filament and Load filament menu item to parent m…
This commit is contained in:
commit
d2736fdacf
|
|
@ -6,6 +6,12 @@
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief construct Timer
|
||||||
|
*
|
||||||
|
* It is guaranteed, that construction is equivalent with zeroing all members.
|
||||||
|
* This property can be exploited in MenuData union.
|
||||||
|
*/
|
||||||
Timer::Timer() : m_isRunning(false), m_started()
|
Timer::Timer() : m_isRunning(false), m_started()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,11 @@ union MenuData
|
||||||
// editMenuParentState is used when an edit menu is entered, so it knows
|
// editMenuParentState is used when an edit menu is entered, so it knows
|
||||||
// the return menu and encoder state.
|
// the return menu and encoder state.
|
||||||
struct EditMenuParentState editMenuParentState;
|
struct EditMenuParentState editMenuParentState;
|
||||||
|
|
||||||
|
struct AutoLoadFilamentMenu
|
||||||
|
{
|
||||||
|
Timer timer;
|
||||||
|
} autoLoadFilamentMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
// State of the currently active menu.
|
// State of the currently active menu.
|
||||||
|
|
@ -188,6 +193,7 @@ unsigned char firstrun = 1;
|
||||||
|
|
||||||
/** forward declarations **/
|
/** forward declarations **/
|
||||||
|
|
||||||
|
static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg, uint8_t &nlines);
|
||||||
// void copy_and_scalePID_i();
|
// void copy_and_scalePID_i();
|
||||||
// void copy_and_scalePID_d();
|
// void copy_and_scalePID_d();
|
||||||
|
|
||||||
|
|
@ -2069,23 +2075,36 @@ void lcd_alright() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PAT9125
|
||||||
|
static void lcd_menu_AutoLoadFilament()
|
||||||
|
{
|
||||||
|
if (degHotend0() > EXTRUDE_MINTEMP)
|
||||||
|
{
|
||||||
|
uint8_t nlines;
|
||||||
|
lcd_display_message_fullscreen_nonBlocking_P(MSG_AUTOLOADING_ENABLED,nlines);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!menuData.autoLoadFilamentMenu.timer.running()) menuData.autoLoadFilamentMenu.timer.start();
|
||||||
|
lcd.setCursor(0, 0);
|
||||||
|
lcd_printPGM(MSG_ERROR);
|
||||||
|
lcd.setCursor(0, 2);
|
||||||
|
lcd_printPGM(MSG_PREHEAT_NOZZLE);
|
||||||
|
if (menuData.autoLoadFilamentMenu.timer.expired(2000ul)) menu_action_back();
|
||||||
|
}
|
||||||
|
if (lcd_clicked()) menu_action_back();
|
||||||
|
}
|
||||||
|
#endif //PAT9125
|
||||||
|
|
||||||
|
static void lcd_LoadFilament()
|
||||||
void lcd_LoadFilament()
|
|
||||||
{
|
{
|
||||||
if (degHotend0() > EXTRUDE_MINTEMP)
|
if (degHotend0() > EXTRUDE_MINTEMP)
|
||||||
{
|
{
|
||||||
#ifdef PAT9125
|
custom_message = true;
|
||||||
if (filament_autoload_enabled && fsensor_enabled)
|
loading_flag = true;
|
||||||
{
|
enquecommand_P(PSTR("M701")); //load filament
|
||||||
lcd_show_fullscreen_message_and_wait_P(MSG_AUTOLOADING_ENABLED);
|
SERIAL_ECHOLN("Loading filament");
|
||||||
return;
|
lcd_return_to_status();
|
||||||
}
|
|
||||||
#endif //PAT9125
|
|
||||||
custom_message = true;
|
|
||||||
loading_flag = true;
|
|
||||||
enquecommand_P(PSTR("M701")); //load filament
|
|
||||||
SERIAL_ECHOLN("Loading filament");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -2094,14 +2113,12 @@ void lcd_LoadFilament()
|
||||||
lcd.setCursor(0, 0);
|
lcd.setCursor(0, 0);
|
||||||
lcd_printPGM(MSG_ERROR);
|
lcd_printPGM(MSG_ERROR);
|
||||||
lcd.setCursor(0, 2);
|
lcd.setCursor(0, 2);
|
||||||
lcd_printPGM(MSG_PREHEAT_NOZZLE);
|
lcd_printPGM(MSG_PREHEAT_NOZZLE);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
lcd_implementation_clear();
|
lcd_implementation_clear();
|
||||||
}
|
}
|
||||||
lcd_return_to_status();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void lcd_menu_statistics()
|
void lcd_menu_statistics()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -2777,11 +2794,16 @@ static inline bool pgm_is_interpunction(const char *c_addr)
|
||||||
return c == '.' || c == ',' || c == ':'|| c == ';' || c == '?' || c == '!' || c == '/';
|
return c == '.' || c == ',' || c == ':'|| c == ';' || c == '?' || c == '!' || c == '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines)
|
/**
|
||||||
|
* @brief show full screen message
|
||||||
|
*
|
||||||
|
* This function is non-blocking
|
||||||
|
* @param msg message to be displayed from PROGMEM
|
||||||
|
* @param nlines
|
||||||
|
* @return rest of the text (to be displayed on next page)
|
||||||
|
*/
|
||||||
|
static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg, uint8_t &nlines)
|
||||||
{
|
{
|
||||||
// Disable update of the screen by the usual lcd_update() routine.
|
|
||||||
lcd_update_enable(false);
|
|
||||||
lcd_implementation_clear();
|
|
||||||
lcd.setCursor(0, 0);
|
lcd.setCursor(0, 0);
|
||||||
const char *msgend = msg;
|
const char *msgend = msg;
|
||||||
uint8_t row = 0;
|
uint8_t row = 0;
|
||||||
|
|
@ -2834,6 +2856,21 @@ const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines)
|
||||||
return multi_screen ? msgend : NULL;
|
return multi_screen ? msgend : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines)
|
||||||
|
{
|
||||||
|
// Disable update of the screen by the usual lcd_update() routine.
|
||||||
|
lcd_update_enable(false);
|
||||||
|
lcd_implementation_clear();
|
||||||
|
return lcd_display_message_fullscreen_nonBlocking_P(msg, nlines);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief show full screen message and wait
|
||||||
|
*
|
||||||
|
* This function is blocking.
|
||||||
|
* @param msg message to be displayed from PROGMEM
|
||||||
|
*/
|
||||||
void lcd_show_fullscreen_message_and_wait_P(const char *msg)
|
void lcd_show_fullscreen_message_and_wait_P(const char *msg)
|
||||||
{
|
{
|
||||||
const char *msg_next = lcd_display_message_fullscreen_P(msg);
|
const char *msg_next = lcd_display_message_fullscreen_P(msg);
|
||||||
|
|
@ -5689,7 +5726,7 @@ static void lcd_main_menu()
|
||||||
#ifndef SNMM
|
#ifndef SNMM
|
||||||
#ifdef PAT9125
|
#ifdef PAT9125
|
||||||
if ( ((filament_autoload_enabled == true) && (fsensor_enabled == true)))
|
if ( ((filament_autoload_enabled == true) && (fsensor_enabled == true)))
|
||||||
MENU_ITEM(function, MSG_AUTOLOAD_FILAMENT, lcd_LoadFilament);
|
MENU_ITEM(submenu, MSG_AUTOLOAD_FILAMENT, lcd_menu_AutoLoadFilament);
|
||||||
else
|
else
|
||||||
#endif //PAT9125
|
#endif //PAT9125
|
||||||
MENU_ITEM(function, MSG_LOAD_FILAMENT, lcd_LoadFilament);
|
MENU_ITEM(function, MSG_LOAD_FILAMENT, lcd_LoadFilament);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue