Merge branch 'MK3' of https://github.com/prusa3d/Prusa-Firmware into MK3-2093-sheet-display

This commit is contained in:
vintagepc 2019-08-30 19:17:27 -04:00
commit d347a36509
9 changed files with 181 additions and 145 deletions

View File

@ -308,11 +308,6 @@ extern bool axis_known_position[3];
extern int fanSpeed; extern int fanSpeed;
extern int8_t lcd_change_fil_state; 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 #ifdef TMC2130
void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0); void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0);
#else #else

View File

@ -3815,10 +3815,14 @@ eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,0xFFFF);
// lcd_calibration(); // lcd_calibration();
// } // }
} }
else if (code_seen('^')) { // This prevents reading files with "^" in their names.
// nothing, this is a version line // Since it is unclear, if there is some usage of this construct,
} else if(code_seen('G')) // it will be deprecated in 3.9 alpha a possibly completely removed in the future:
// else if (code_seen('^')) {
// // nothing, this is a version line
// }
else if(code_seen('G'))
{ {
gcode_in_progress = (int)code_value(); gcode_in_progress = (int)code_value();
// printf_P(_N("BEGIN G-CODE=%u\n"), gcode_in_progress); // printf_P(_N("BEGIN G-CODE=%u\n"), gcode_in_progress);
@ -5319,7 +5323,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
// ----------------------------------- // -----------------------------------
case 23: case 23:
starpos = (strchr(strchr_pointer + 4,'*')); starpos = (strchr(strchr_pointer + 4,'*'));
if(starpos!=NULL) if(starpos!=NULL)
*(starpos)='\0'; *(starpos)='\0';
card.openFile(strchr_pointer + 4,true); card.openFile(strchr_pointer + 4,true);
break; break;

View File

@ -394,7 +394,10 @@ bool SdBaseFile::make83Name(const char* str, uint8_t* name, const char** ptr) {
i = 8; // place for extension i = 8; // place for extension
} else { } else {
// illegal FAT characters // illegal FAT characters
PGM_P p = PSTR("|<>^+=?/[];,*\"\\"); //PGM_P p = PSTR("|<>^+=?/[];,*\"\\");
// 2019-08-27 really?
// Microsoft defines, that only a subset of these characters is not allowed.
PGM_P p = PSTR("|<>?/*\"\\");
uint8_t b; uint8_t b;
while ((b = pgm_read_byte(p++))) if (b == c) goto fail; while ((b = pgm_read_byte(p++))) if (b == c) goto fail;
// check size and only allow ASCII printable characters // check size and only allow ASCII printable characters

View File

@ -41,7 +41,8 @@ bool eeprom_is_uninitialized<char>(char *address)
return (0xff == eeprom_read_byte(reinterpret_cast<uint8_t*>(address))); return (0xff == eeprom_read_byte(reinterpret_cast<uint8_t*>(address)));
} }
bool is_sheet_initialized(uint8_t sheet_num){ bool eeprom_is_sheet_initialized(uint8_t sheet_num)
{
return (0xffff != eeprom_read_word(reinterpret_cast<uint16_t*>(&(EEPROM_Sheets_base-> return (0xffff != eeprom_read_word(reinterpret_cast<uint16_t*>(&(EEPROM_Sheets_base->
s[sheet_num].z_offset)))); s[sheet_num].z_offset))));
} }
@ -61,7 +62,14 @@ void eeprom_init()
if (eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0); if (eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0);
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_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((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); if (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == 0xff)
{
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0);
// 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)
int last_babystep = eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z);
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[0].z_offset)), last_babystep);
}
for (uint_least8_t i = 0; i < (sizeof(Sheets::s)/sizeof(Sheets::s[0])); ++i) for (uint_least8_t i = 0; i < (sizeof(Sheets::s)/sizeof(Sheets::s[0])); ++i)
{ {
@ -72,24 +80,56 @@ void eeprom_init()
} }
if(is_uninitialized) if(is_uninitialized)
{ {
SheetName sheetName;
eeprom_default_sheet_name(i,sheetName);
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){ for (uint_least8_t a = 0; a < sizeof(Sheet::name); ++a){
eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), sheet_PROGMEM_buffer[a]); eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), sheetName.c[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);
} }
} }
} }
if(!eeprom_is_sheet_initialized(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))))
{
eeprom_switch_to_next_sheet();
}
check_babystep(); check_babystep();
} }
//! @brief Get default sheet name for index
//!
//! @param[in] index
//! @param[out] sheetName
void eeprom_default_sheet_name(uint8_t index, SheetName &sheetName)
{
static_assert(8 == sizeof(SheetName),"Default sheet name needs to be adjusted.");
sprintf_P(sheetName.c, PSTR("%-6.6S"), _T(MSG_SHEET));
sheetName.c[6] = '1' + index;
sheetName.c[7] = '\0';
}
//! @brief Get next initialized sheet
//!
//! If current sheet is the only sheet initialized, current sheet is returned.
//!
//! @param sheet Current sheet
//! @return next initialized sheet
//! @retval -1 no sheet is initialized
int8_t eeprom_next_initialized_sheet(int8_t sheet)
{
for (int8_t i = 0; i < static_cast<int8_t>(sizeof(Sheets::s)/sizeof(Sheet)); ++i)
{
++sheet;
if (sheet >= static_cast<int8_t>(sizeof(Sheets::s)/sizeof(Sheet))) sheet = 0;
if (eeprom_is_sheet_initialized(sheet)) return sheet;
}
return -1;
}
void eeprom_switch_to_next_sheet()
{
int8_t sheet = eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet));
sheet = eeprom_next_initialized_sheet(sheet);
if (sheet >= 0) eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), sheet);
}

View File

@ -3,12 +3,6 @@
#include <stdint.h> #include <stdint.h>
#ifdef __cplusplus
void eeprom_init();
extern bool is_sheet_initialized(uint8_t sheet_num);
#endif
typedef struct typedef struct
{ {
char name[7]; //!< Can be null terminated, doesn't need to be null terminated char name[7]; //!< Can be null terminated, doesn't need to be null terminated
@ -19,12 +13,12 @@ typedef struct
typedef struct typedef struct
{ {
Sheet s[3]; Sheet s[8];
uint8_t active_sheet; uint8_t active_sheet;
} Sheets; } Sheets;
// sizeof(Sheets). Do not change it unless EEPROM_Sheets_base is last item in EEPROM. // sizeof(Sheets). Do not change it unless EEPROM_Sheets_base is last item in EEPROM.
// Otherwise it would move following items. // Otherwise it would move following items.
#define EEPROM_SHEETS_SIZEOF 34 #define EEPROM_SHEETS_SIZEOF 89
#ifdef __cplusplus #ifdef __cplusplus
static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEPROM_SHEETS_SIZEOF."); static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEPROM_SHEETS_SIZEOF.");
@ -36,9 +30,9 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP
#define EEPROM_TOP 4096 #define EEPROM_TOP 4096
#define EEPROM_SILENT 4095 #define EEPROM_SILENT 4095
#define EEPROM_LANG 4094 #define EEPROM_LANG 4094
#define EEPROM_BABYSTEP_X 4092 #define EEPROM_BABYSTEP_X 4092 //unused
#define EEPROM_BABYSTEP_Y 4090 #define EEPROM_BABYSTEP_Y 4090 //unused
#define EEPROM_BABYSTEP_Z 4088 #define EEPROM_BABYSTEP_Z 4088 //legacy, multiple values stored now in EEPROM_Sheets_base
#define EEPROM_CALIBRATION_STATUS 4087 #define EEPROM_CALIBRATION_STATUS 4087
#define EEPROM_BABYSTEP_Z0 4085 #define EEPROM_BABYSTEP_Z0 4085
#define EEPROM_FILAMENTUSED 4081 #define EEPROM_FILAMENTUSED 4081
@ -235,5 +229,16 @@ enum
EEPROM_MMU_CUTTER_ENABLED_always = 2, EEPROM_MMU_CUTTER_ENABLED_always = 2,
}; };
#ifdef __cplusplus
void eeprom_init();
bool eeprom_is_sheet_initialized(uint8_t sheet_num);
struct SheetName
{
char c[sizeof(Sheet::name) + 1];
};
void eeprom_default_sheet_name(uint8_t index, SheetName &sheetName);
int8_t eeprom_next_initialized_sheet(int8_t sheet);
void eeprom_switch_to_next_sheet();
#endif
#endif // EEPROM_H #endif // EEPROM_H

View File

@ -203,9 +203,13 @@ void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer)
void menu_format_sheet_select_E(const Sheet &sheet_E, SheetFormatBuffer &buffer) 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)); uint_least8_t index = sprintf_P(buffer.c,PSTR("%-9.9S["), _T(MSG_SHEET));
eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7); eeprom_read_block(&(buffer.c[index]), sheet_E.name, sizeof(sheet_E.name)/sizeof(sheet_E.name[0]));
buffer.c[index + 7] = ']'; for (const uint_least8_t start = index; static_cast<uint_least8_t>(index - start) < sizeof(sheet_E.name)/sizeof(sheet_E.name[0]); ++index)
buffer.c[index + 8] = '\0'; {
if (buffer.c[index] == '\0') break;
}
buffer.c[index] = ']';
buffer.c[index + 1] = '\0';
} }
static void menu_draw_item_select_sheet_E(char type_char, const Sheet &sheet) static void menu_draw_item_select_sheet_E(char type_char, const Sheet &sheet)
@ -290,14 +294,18 @@ uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu)
return 0; return 0;
} }
uint8_t menu_item_submenu_select_sheet_E(const Sheet &sheet, menu_func_t submenu) uint8_t menu_item_function_E(const Sheet &sheet, menu_func_t func)
{ {
if (menu_item == menu_line) if (menu_item == menu_line)
{ {
if (lcd_draw_update) menu_draw_item_select_sheet_E(LCD_STR_ARROW_RIGHT[0], sheet); if (lcd_draw_update) menu_draw_item_select_sheet_E(' ', sheet);
if (menu_clicked && (lcd_encoder == menu_item)) if (menu_clicked && (lcd_encoder == menu_item))
{ {
menu_submenu(submenu); menu_clicked = false;
lcd_consume_click();
lcd_update_enabled = 0;
if (func) func();
lcd_update_enabled = 1;
return menu_item_ret(); return menu_item_ret();
} }
} }

View File

@ -103,8 +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) #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); 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) #define MENU_ITEM_FUNCTION_E(sheet, submenu) do { if (menu_item_function_E(sheet, submenu)) return; } while (0)
extern uint8_t menu_item_submenu_select_sheet_E(const Sheet &sheet, menu_func_t submenu); extern uint8_t menu_item_function_E(const Sheet &sheet, menu_func_t func);
#define MENU_ITEM_BACK_P(str) do { if (menu_item_back_P(str)) return; } while (0) #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); extern uint8_t menu_item_back_P(const char* str);

View File

@ -3,10 +3,10 @@
#define SOUND_H #define SOUND_H
#define MSG_SOUND_MODE_LOUD "Sound [loud]" #define MSG_SOUND_MODE_LOUD "Sound [loud]"
#define MSG_SOUND_MODE_ONCE "Sound [once]" #define MSG_SOUND_MODE_ONCE "Sound [once]"
#define MSG_SOUND_MODE_SILENT "Sound [silent]" #define MSG_SOUND_MODE_SILENT "Sound [silent]"
#define MSG_SOUND_MODE_BLIND "Sound [blind]" #define MSG_SOUND_MODE_BLIND "Sound [assist]"
#define e_SOUND_MODE_NULL 0xFF #define e_SOUND_MODE_NULL 0xFF

View File

@ -244,10 +244,6 @@ void lcd_finishstatus();
static void lcd_sdcard_menu(); static void lcd_sdcard_menu();
static void lcd_sheet_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 #ifdef DELTA_CALIBRATION_MENU
static void lcd_delta_calibrate_menu(); static void lcd_delta_calibrate_menu();
#endif // DELTA_CALIBRATION_MENU #endif // DELTA_CALIBRATION_MENU
@ -2496,6 +2492,12 @@ bFilamentPreheatState=false;
mFilamentItem(PET_PREHEAT_HOTEND_TEMP,PET_PREHEAT_HPB_TEMP); mFilamentItem(PET_PREHEAT_HOTEND_TEMP,PET_PREHEAT_HPB_TEMP);
} }
static void mFilamentItem_ASA()
{
bFilamentPreheatState=false;
mFilamentItem(ASA_PREHEAT_HOTEND_TEMP,ASA_PREHEAT_HPB_TEMP);
}
static void mFilamentItem_ABS() static void mFilamentItem_ABS()
{ {
bFilamentPreheatState=false; bFilamentPreheatState=false;
@ -2530,15 +2532,16 @@ if(eFilamentAction==FilamentAction::AutoLoad)
void mFilamentMenu() void mFilamentMenu()
{ {
MENU_BEGIN(); MENU_BEGIN();
MENU_ITEM_FUNCTION_P(_T(MSG_MAIN),mFilamentBack); MENU_ITEM_FUNCTION_P(_T(MSG_MAIN),mFilamentBack);
MENU_ITEM_SUBMENU_P(PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)),mFilamentItem_PLA); MENU_ITEM_SUBMENU_P(PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)),mFilamentItem_PLA);
MENU_ITEM_SUBMENU_P(PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)),mFilamentItem_PET); MENU_ITEM_SUBMENU_P(PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)),mFilamentItem_PET);
MENU_ITEM_SUBMENU_P(PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)),mFilamentItem_ABS); MENU_ITEM_SUBMENU_P(PSTR("ASA - " STRINGIFY(ASA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ASA_PREHEAT_HPB_TEMP)),mFilamentItem_ASA);
MENU_ITEM_SUBMENU_P(PSTR("HIPS - " STRINGIFY(HIPS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(HIPS_PREHEAT_HPB_TEMP)),mFilamentItem_HIPS); MENU_ITEM_SUBMENU_P(PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)),mFilamentItem_ABS);
MENU_ITEM_SUBMENU_P(PSTR("PP - " STRINGIFY(PP_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PP_PREHEAT_HPB_TEMP)),mFilamentItem_PP); MENU_ITEM_SUBMENU_P(PSTR("HIPS - " STRINGIFY(HIPS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(HIPS_PREHEAT_HPB_TEMP)),mFilamentItem_HIPS);
MENU_ITEM_SUBMENU_P(PSTR("FLEX - " STRINGIFY(FLEX_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FLEX_PREHEAT_HPB_TEMP)),mFilamentItem_FLEX); MENU_ITEM_SUBMENU_P(PSTR("PP - " STRINGIFY(PP_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PP_PREHEAT_HPB_TEMP)),mFilamentItem_PP);
MENU_END(); MENU_ITEM_SUBMENU_P(PSTR("FLEX - " STRINGIFY(FLEX_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FLEX_PREHEAT_HPB_TEMP)),mFilamentItem_FLEX);
MENU_END();
} }
void mFilamentItemForce() void mFilamentItemForce()
@ -3105,7 +3108,7 @@ static void lcd_babystep_z()
_md->status = 1; _md->status = 1;
check_babystep(); check_babystep();
if(!is_sheet_initialized(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))){ if(!eeprom_is_sheet_initialized(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))){
_md->babystepMemZ = 0; _md->babystepMemZ = 0;
} }
else{ else{
@ -4697,7 +4700,6 @@ void lcd_toshiba_flash_air_compatibility_toggle()
void lcd_v2_calibration() void lcd_v2_calibration()
{ {
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), selected_sheet);
if (mmu_enabled) 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 const uint8_t filament = choose_menu_P(_i("Select PLA filament:"),_T(MSG_FILAMENT),_i("Cancel")); ////c=20 r=1 ////c=19 r=1
@ -5529,37 +5531,38 @@ SETTINGS_VERSION;
MENU_END(); MENU_END();
} }
template <uint8_t number>
static void select_sheet_menu()
{
selected_sheet = number;
lcd_sheet_menu();
}
static void sheets_menu()
{
MENU_BEGIN();
MENU_ITEM_BACK_P(_i("HW Setup"));
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[0], select_sheet_menu<0>);
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[1], select_sheet_menu<1>);
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[2], select_sheet_menu<2>);
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[3], select_sheet_menu<3>);
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[4], select_sheet_menu<4>);
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[5], select_sheet_menu<5>);
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[6], select_sheet_menu<6>);
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[7], select_sheet_menu<7>);
MENU_END();
}
void lcd_hw_setup_menu(void) // can not be "static" void lcd_hw_setup_menu(void) // can not be "static"
{ {
MENU_BEGIN(); MENU_BEGIN();
MENU_ITEM_BACK_P(_T(bSettings?MSG_SETTINGS:MSG_BACK)); // i.e. default menu-item / menu-item after checking mismatch MENU_ITEM_BACK_P(_T(bSettings?MSG_SETTINGS:MSG_BACK)); // i.e. default menu-item / menu-item after checking mismatch
//strncpy(buffer,_i("Sheet"),sizeof(buffer)); MENU_ITEM_SUBMENU_P(_i("Steel sheets"), sheets_menu);
//strncpy(buffer,_i(" "),sizeof(buffer)); SETTINGS_NOZZLE;
//strncpy(buffer,EEPROM_Sheets_base->s[0].name,sizeof(buffer)); MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu);
//const char* menu = EEPROM_Sheets_base->s[0].name.c_str(); MENU_END();
//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);
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);
SETTINGS_NOZZLE;
MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu);
MENU_END();
} }
static void lcd_settings_menu() static void lcd_settings_menu()
@ -5912,27 +5915,30 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite
cursor_pos++; cursor_pos++;
} }
enc_dif = lcd_encoder_diff; enc_dif = lcd_encoder_diff;
Sound_MakeSound(e_SOUND_TYPE_EncoderMove);
} }
if (cursor_pos > 3) if (cursor_pos > 3)
{ {
Sound_MakeSound(e_SOUND_TYPE_BlindAlert);
cursor_pos = 3; cursor_pos = 3;
if (first < items_no - 3) if (first < items_no - 3)
{ {
first++; first++;
lcd_clear(); lcd_clear();
} else { // here we are at the very end of the list
Sound_MakeSound(e_SOUND_TYPE_BlindAlert);
} }
} }
if (cursor_pos < 1) if (cursor_pos < 1)
{ {
Sound_MakeSound(e_SOUND_TYPE_BlindAlert);
cursor_pos = 1; cursor_pos = 1;
if (first > 0) if (first > 0)
{ {
first--; first--;
lcd_clear(); lcd_clear();
} else { // here we are at the very end of the list
Sound_MakeSound(e_SOUND_TYPE_BlindAlert);
} }
} }
@ -5962,7 +5968,6 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite
lcd_print(" "); lcd_print(" ");
lcd_set_cursor(0, cursor_pos); lcd_set_cursor(0, cursor_pos);
lcd_print(">"); lcd_print(">");
Sound_MakeSound(e_SOUND_TYPE_EncoderMove);
_delay(100); _delay(100);
if (lcd_clicked()) if (lcd_clicked())
@ -6518,40 +6523,7 @@ static void change_sheet()
menu_back(3); menu_back(3);
} }
static void change_sheet_from_menu(){
uint8_t next_sheet = eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))+1;
while(true){
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;
break;
}
else if (next_sheet == selected_sheet){
break;
}
else{
next_sheet++;
}
}
menu_back();
}
static void lcd_select_sheet_0_menu()
{
selected_sheet = 0;
lcd_sheet_menu();
}
static void lcd_select_sheet_1_menu()
{
selected_sheet = 1;
lcd_sheet_menu();
}
static void lcd_select_sheet_2_menu()
{
selected_sheet = 2;
lcd_sheet_menu();
}
static void lcd_rename_sheet_menu() static void lcd_rename_sheet_menu()
{ {
@ -6608,37 +6580,41 @@ static void lcd_rename_sheet_menu()
static void lcd_reset_sheet() static void lcd_reset_sheet()
{ {
struct MenuData SheetName sheetName;
{ eeprom_default_sheet_name(selected_sheet, sheetName);
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_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)); eeprom_update_block(sheetName.c,EEPROM_Sheets_base->s[selected_sheet].name,sizeof(Sheet::name));
menu_back(2); if (selected_sheet == eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))
{
eeprom_switch_to_next_sheet();
if((-1 == eeprom_next_initialized_sheet(0)) && (CALIBRATION_STATUS_CALIBRATED == calibration_status()))
{
calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
}
}
menu_back();
}
//! @brief Activate selected_sheet and run first layer calibration
static void activate_calibrate_sheet()
{
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), selected_sheet);
lcd_v2_calibration();
} }
static void lcd_sheet_menu() static void lcd_sheet_menu()
{ {
MENU_BEGIN(); MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_HW_SETUP)); MENU_ITEM_BACK_P(_i("Steel sheets"));
if(is_sheet_initialized(selected_sheet)){ if(eeprom_is_sheet_initialized(selected_sheet)){
MENU_ITEM_SUBMENU_P(_i("Select"), change_sheet); //// c=18 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(_T(MSG_V2_CALIBRATION), activate_calibrate_sheet);
MENU_ITEM_SUBMENU_P(_i("Rename"), lcd_rename_sheet_menu); //// c=18 MENU_ITEM_SUBMENU_P(_i("Rename"), lcd_rename_sheet_menu); //// c=18
MENU_ITEM_SUBMENU_P(_i("Reset"), lcd_reset_sheet); //// c=18 MENU_ITEM_FUNCTION_P(_i("Reset"), lcd_reset_sheet); //// c=18
MENU_END(); MENU_END();
} }
@ -6737,7 +6713,12 @@ static void lcd_main_menu()
{ {
if (!farm_mode) if (!farm_mode)
{ {
MENU_ITEM_SUBMENU_SELECT_SHEET_E(EEPROM_Sheets_base->s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))], change_sheet_from_menu); const int8_t sheet = eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet));
const int8_t nextSheet = eeprom_next_initialized_sheet(sheet);
if ((nextSheet >= 0) && (sheet != nextSheet)) // show menu only if we have 2 or more sheets initialized
{
MENU_ITEM_FUNCTION_E(EEPROM_Sheets_base->s[sheet], eeprom_switch_to_next_sheet);
}
} }
} }
@ -6785,7 +6766,7 @@ static void lcd_main_menu()
if(!isPrintPaused) MENU_ITEM_SUBMENU_P(_T(MSG_MENU_CALIBRATION), lcd_calibration_menu); if(!isPrintPaused) MENU_ITEM_SUBMENU_P(_T(MSG_MENU_CALIBRATION), lcd_calibration_menu);
} }
if (!is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal)) if (!is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal))
{ {
MENU_ITEM_SUBMENU_P(_i("Statistics "), lcd_menu_statistics);////MSG_STATISTICS MENU_ITEM_SUBMENU_P(_i("Statistics "), lcd_menu_statistics);////MSG_STATISTICS