Merge remote-tracking branch 'upstream/MK3' into MK3_PF-build_106
This commit is contained in:
commit
93c098c8f0
@ -308,6 +308,11 @@ extern bool axis_known_position[3];
|
||||
extern int fanSpeed;
|
||||
extern int8_t lcd_change_fil_state;
|
||||
|
||||
const char smooth1[] PROGMEM = "Smooth1";
|
||||
const char smooth2[] PROGMEM = "Smooth2";
|
||||
const char textured[] PROGMEM = "Textur1";
|
||||
const char *const defaultSheetNames[] PROGMEM = {smooth1,smooth2,textured};
|
||||
|
||||
#ifdef TMC2130
|
||||
void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0);
|
||||
#else
|
||||
|
@ -41,9 +41,9 @@ bool eeprom_is_uninitialized<char>(char *address)
|
||||
return (0xff == eeprom_read_byte(reinterpret_cast<uint8_t*>(address)));
|
||||
}
|
||||
|
||||
bool is_sheet_initialized(){
|
||||
bool is_sheet_initialized(uint8_t sheet_num){
|
||||
return (0xffff != eeprom_read_word(reinterpret_cast<uint16_t*>(&(EEPROM_Sheets_base->
|
||||
s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))].z_offset))));
|
||||
s[sheet_num].z_offset))));
|
||||
}
|
||||
|
||||
void eeprom_init()
|
||||
@ -62,6 +62,7 @@ void eeprom_init()
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0);
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0);
|
||||
if (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == 0xff) eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0);
|
||||
|
||||
for (uint_least8_t i = 0; i < (sizeof(Sheets::s)/sizeof(Sheets::s[0])); ++i)
|
||||
{
|
||||
bool is_uninitialized = true;
|
||||
@ -71,14 +72,19 @@ void eeprom_init()
|
||||
}
|
||||
if(is_uninitialized)
|
||||
{
|
||||
|
||||
char sheet_PROGMEM_buffer[8];
|
||||
strcpy_P(sheet_PROGMEM_buffer, (char *)pgm_read_word(&(defaultSheetNames[i])));
|
||||
for (uint_least8_t a = 0; a < sizeof(Sheet::name); ++a){
|
||||
eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), sheet_PROGMEM_buffer[a]);
|
||||
}
|
||||
|
||||
// When upgrading from version older version (before multiple sheets were implemented in v3.8.0)
|
||||
// Sheet 1 uses the previous Live adjust Z (@EEPROM_BABYSTEP_Z)
|
||||
if(i == 0){
|
||||
int last_babystep = eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z);
|
||||
eeprom_write_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[i].z_offset)), last_babystep);
|
||||
}
|
||||
eeprom_write(&(EEPROM_Sheets_base->s[i].name[0]), static_cast<char>(i + '1'));
|
||||
eeprom_write(&(EEPROM_Sheets_base->s[i].name[1]), '\0');
|
||||
}
|
||||
}
|
||||
check_babystep();
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
void eeprom_init();
|
||||
extern bool is_sheet_initialized();
|
||||
extern bool is_sheet_initialized(uint8_t sheet_num);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -196,6 +196,27 @@ void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer)
|
||||
buffer.c[index + 7] = '\0';
|
||||
}
|
||||
|
||||
//! @brief Format sheet name in select menu
|
||||
//!
|
||||
//! @param[in] sheet_E Sheet in EEPROM
|
||||
//! @param[out] buffer for formatted output
|
||||
void menu_format_sheet_select_E(const Sheet &sheet_E, SheetFormatBuffer &buffer)
|
||||
{
|
||||
uint_least8_t index = sprintf_P(buffer.c,PSTR("%-9.9S["), _T(MSG_SHEET));
|
||||
eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7);
|
||||
buffer.c[index + 7] = ']';
|
||||
buffer.c[index + 8] = '\0';
|
||||
}
|
||||
|
||||
static void menu_draw_item_select_sheet_E(char type_char, const Sheet &sheet)
|
||||
{
|
||||
lcd_set_cursor(0, menu_row);
|
||||
SheetFormatBuffer buffer;
|
||||
menu_format_sheet_select_E(sheet, buffer);
|
||||
lcd_printf_P(PSTR("%c%-18.18s%c"), menu_selection_mark(), buffer.c, type_char);
|
||||
}
|
||||
|
||||
|
||||
static void menu_draw_item_puts_E(char type_char, const Sheet &sheet)
|
||||
{
|
||||
lcd_set_cursor(0, menu_row);
|
||||
@ -269,6 +290,21 @@ uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t menu_item_submenu_select_sheet_E(const Sheet &sheet, menu_func_t submenu)
|
||||
{
|
||||
if (menu_item == menu_line)
|
||||
{
|
||||
if (lcd_draw_update) menu_draw_item_select_sheet_E(LCD_STR_ARROW_RIGHT[0], sheet);
|
||||
if (menu_clicked && (lcd_encoder == menu_item))
|
||||
{
|
||||
menu_submenu(submenu);
|
||||
return menu_item_ret();
|
||||
}
|
||||
}
|
||||
menu_item++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t menu_item_back_P(const char* str)
|
||||
{
|
||||
if (menu_item == menu_line)
|
||||
|
@ -103,6 +103,8 @@ extern uint8_t menu_item_submenu_P(const char* str, menu_func_t submenu);
|
||||
#define MENU_ITEM_SUBMENU_E(sheet, submenu) do { if (menu_item_submenu_E(sheet, submenu)) return; } while (0)
|
||||
extern uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu);
|
||||
|
||||
#define MENU_ITEM_SUBMENU_SELECT_SHEET_E(sheet, submenu) do { if (menu_item_submenu_select_sheet_E(sheet, submenu)) return; } while (0)
|
||||
extern uint8_t menu_item_submenu_select_sheet_E(const Sheet &sheet, menu_func_t submenu);
|
||||
|
||||
#define MENU_ITEM_BACK_P(str) do { if (menu_item_back_P(str)) return; } while (0)
|
||||
extern uint8_t menu_item_back_P(const char* str);
|
||||
|
@ -257,6 +257,11 @@ static void lcd_connect_printer();
|
||||
void lcd_finishstatus();
|
||||
|
||||
static void lcd_sdcard_menu();
|
||||
static void lcd_sheet_menu();
|
||||
|
||||
static void lcd_select_sheet_0_menu();
|
||||
static void lcd_select_sheet_1_menu();
|
||||
static void lcd_select_sheet_2_menu();
|
||||
|
||||
#ifdef DELTA_CALIBRATION_MENU
|
||||
static void lcd_delta_calibrate_menu();
|
||||
@ -298,6 +303,8 @@ static void menu_action_sddirectory(const char* filename);
|
||||
bool lcd_oldcardstatus;
|
||||
#endif
|
||||
|
||||
uint8_t selected_sheet = 0;
|
||||
|
||||
bool ignore_click = false;
|
||||
bool wait_for_unclick;
|
||||
|
||||
@ -3088,7 +3095,7 @@ static void lcd_babystep_z()
|
||||
_md->status = 1;
|
||||
check_babystep();
|
||||
|
||||
if(!is_sheet_initialized()){
|
||||
if(!is_sheet_initialized(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))){
|
||||
_md->babystepMemZ = 0;
|
||||
}
|
||||
else{
|
||||
@ -4679,6 +4686,7 @@ void lcd_toshiba_flash_air_compatibility_toggle()
|
||||
|
||||
void lcd_v2_calibration()
|
||||
{
|
||||
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), selected_sheet);
|
||||
if (mmu_enabled)
|
||||
{
|
||||
const uint8_t filament = choose_menu_P(_i("Select PLA filament:"),_T(MSG_FILAMENT),_i("Cancel")); ////c=20 r=1 ////c=19 r=1
|
||||
@ -5501,11 +5509,33 @@ void lcd_hw_setup_menu(void) // can not be "static"
|
||||
{
|
||||
MENU_BEGIN();
|
||||
MENU_ITEM_BACK_P(_T(bSettings?MSG_SETTINGS:MSG_BACK)); // i.e. default menu-item / menu-item after checking mismatch
|
||||
if(!farm_mode)
|
||||
|
||||
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[0], lcd_select_sheet_0_menu);
|
||||
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[1], lcd_select_sheet_1_menu);
|
||||
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[2], lcd_select_sheet_2_menu);
|
||||
|
||||
//strncpy(buffer,_i("Sheet"),sizeof(buffer));
|
||||
//strncpy(buffer,_i(" "),sizeof(buffer));
|
||||
//strncpy(buffer,EEPROM_Sheets_base->s[0].name,sizeof(buffer));
|
||||
|
||||
//const char* menu = EEPROM_Sheets_base->s[0].name.c_str();
|
||||
|
||||
//const char *b = new char(buffer);
|
||||
//const char *b = const char *b = new char(buffer);(buffer);
|
||||
//printf_P(_N("UVLO - end %d\n"), _millis() - time_start);
|
||||
//SERIAL_ECHOPGM(buffer);
|
||||
//SERIAL_ECHOPGM(reinterpret_cast<const char*>(buffer));
|
||||
//SERIAL_ECHOPGM("lakdjushasdjaljsdakjsdn");
|
||||
//char* p = &buffer[0];
|
||||
|
||||
//MENU_ITEM_SUBMENU_P(reinterpret_cast<const char*>(p),lcd_sheet_menu);
|
||||
|
||||
//delete(b);
|
||||
|
||||
if(!farm_mode){
|
||||
SETTINGS_NOZZLE;
|
||||
// ... a sem prijdou 'plechy'
|
||||
if(!farm_mode)
|
||||
MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu);
|
||||
}
|
||||
MENU_END();
|
||||
}
|
||||
|
||||
@ -6456,38 +6486,36 @@ void lcd_resume_print()
|
||||
isPrintPaused = false;
|
||||
}
|
||||
|
||||
static void change_sheet(uint8_t sheet_num)
|
||||
static void change_sheet()
|
||||
{
|
||||
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), sheet_num);
|
||||
if(is_sheet_initialized())
|
||||
calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
|
||||
else
|
||||
calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
|
||||
|
||||
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), selected_sheet);
|
||||
menu_back(3);
|
||||
}
|
||||
|
||||
static void change_sheet_from_menu(){
|
||||
uint8_t next_sheet = selected_sheet+1;
|
||||
if(next_sheet > 2) next_sheet = 0;
|
||||
if(is_sheet_initialized(next_sheet)){
|
||||
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), next_sheet);
|
||||
selected_sheet = next_sheet;
|
||||
}
|
||||
menu_back();
|
||||
}
|
||||
|
||||
static void lcd_select_sheet_0_menu()
|
||||
{
|
||||
change_sheet(0);
|
||||
selected_sheet = 0;
|
||||
lcd_sheet_menu();
|
||||
}
|
||||
static void lcd_select_sheet_1_menu()
|
||||
{
|
||||
change_sheet(1);
|
||||
selected_sheet = 1;
|
||||
lcd_sheet_menu();
|
||||
}
|
||||
static void lcd_select_sheet_2_menu()
|
||||
{
|
||||
change_sheet(2);
|
||||
}
|
||||
|
||||
static void lcd_select_sheet_menu()
|
||||
{
|
||||
MENU_BEGIN();
|
||||
MENU_ITEM_BACK_P(_T(MSG_BACK));
|
||||
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[0], lcd_select_sheet_0_menu);
|
||||
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[1], lcd_select_sheet_1_menu);
|
||||
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[2], lcd_select_sheet_2_menu);
|
||||
MENU_END();
|
||||
selected_sheet = 2;
|
||||
lcd_sheet_menu();
|
||||
}
|
||||
|
||||
static void lcd_rename_sheet_menu()
|
||||
@ -6503,7 +6531,7 @@ static void lcd_rename_sheet_menu()
|
||||
|
||||
if (!menuData->initialized)
|
||||
{
|
||||
eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, sizeof(Sheet::name));
|
||||
eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[selected_sheet].name, sizeof(Sheet::name));
|
||||
lcd_encoder = menuData->name[0];
|
||||
menuData->initialized = true;
|
||||
}
|
||||
@ -6527,20 +6555,46 @@ static void lcd_rename_sheet_menu()
|
||||
else
|
||||
{
|
||||
eeprom_update_block(menuData->name,
|
||||
EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name,
|
||||
EEPROM_Sheets_base->s[selected_sheet].name,
|
||||
sizeof(Sheet::name));
|
||||
menu_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void lcd_reset_sheet()
|
||||
{
|
||||
struct MenuData
|
||||
{
|
||||
bool initialized;
|
||||
uint8_t selected;
|
||||
char name[sizeof(Sheet::name)];
|
||||
};
|
||||
static_assert(sizeof(menu_data)>= sizeof(MenuData),"MenuData doesn't fit into menu_data");
|
||||
MenuData* menuData = (MenuData*)&(menu_data[0]);
|
||||
eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[selected_sheet].name, sizeof(Sheet::name));
|
||||
|
||||
menuData->initialized = false;
|
||||
strcpy_P(menuData->name, (char *)pgm_read_word(&(defaultSheetNames[selected_sheet])));
|
||||
|
||||
|
||||
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[selected_sheet].z_offset)),0xffff);
|
||||
eeprom_update_block(menuData->name,EEPROM_Sheets_base->s[selected_sheet].name,sizeof(Sheet::name));
|
||||
menu_back(2);
|
||||
}
|
||||
|
||||
static void lcd_sheet_menu()
|
||||
{
|
||||
MENU_BEGIN();
|
||||
MENU_ITEM_BACK_P(_T(MSG_MAIN));
|
||||
MENU_ITEM_SUBMENU_P(_i("Select"), lcd_select_sheet_menu); //// c=18
|
||||
MENU_ITEM_SUBMENU_P(_i("Rename"), lcd_rename_sheet_menu); //// c=18
|
||||
MENU_ITEM_BACK_P(_T(MSG_HW_SETUP));
|
||||
|
||||
if(is_sheet_initialized(selected_sheet)){
|
||||
MENU_ITEM_SUBMENU_P(_i("Select"), change_sheet); //// c=18
|
||||
}
|
||||
|
||||
MENU_ITEM_SUBMENU_P(_T(MSG_V2_CALIBRATION), lcd_v2_calibration);
|
||||
MENU_ITEM_SUBMENU_P(_i("Rename"), lcd_rename_sheet_menu); //// c=18
|
||||
MENU_ITEM_SUBMENU_P(_i("Reset"), lcd_reset_sheet); //// c=18
|
||||
|
||||
MENU_END();
|
||||
}
|
||||
@ -6680,7 +6734,10 @@ static void lcd_main_menu()
|
||||
|
||||
}
|
||||
|
||||
if(!isPrintPaused)MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], lcd_sheet_menu);
|
||||
if(!isPrintPaused && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal))
|
||||
{
|
||||
MENU_ITEM_SUBMENU_SELECT_SHEET_E(EEPROM_Sheets_base->s[selected_sheet], change_sheet_from_menu);
|
||||
}
|
||||
|
||||
if (!is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user