Increase number of configurable steel sheets to 8. Move sheets into sub menu of HW setup.
This commit is contained in:
parent
f3bb72be64
commit
32f435d1a0
@ -308,11 +308,6 @@ extern bool axis_known_position[3];
|
||||
extern int fanSpeed;
|
||||
extern int8_t lcd_change_fil_state;
|
||||
|
||||
const char sheet1[] PROGMEM = "1";
|
||||
const char sheet2[] PROGMEM = "2";
|
||||
const char sheet3[] PROGMEM = "3";
|
||||
const char *const defaultSheetNames[] PROGMEM = {sheet1,sheet2,sheet3};
|
||||
|
||||
#ifdef TMC2130
|
||||
void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0);
|
||||
#else
|
||||
|
@ -72,11 +72,11 @@ void eeprom_init()
|
||||
}
|
||||
if(is_uninitialized)
|
||||
{
|
||||
SheetName sheetName;
|
||||
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){
|
||||
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)
|
||||
@ -90,6 +90,15 @@ void eeprom_init()
|
||||
check_babystep();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//! @brief Get default sheet name for index
|
||||
//!
|
||||
//! @param[in] index
|
||||
//! @param[out] sheetName
|
||||
void default_sheet_name(uint8_t index, SheetName &sheetName)
|
||||
{
|
||||
sheetName.c[0] = '1' + index;
|
||||
for (uint8_t i = 1; i < (sizeof(sheetName.c)/sizeof(sheetName.c[0])); ++i)
|
||||
{
|
||||
sheetName.c[i] = '\0';
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
void eeprom_init();
|
||||
extern bool is_sheet_initialized(uint8_t sheet_num);
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[7]; //!< Can be null terminated, doesn't need to be null terminated
|
||||
@ -19,12 +13,12 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Sheet s[3];
|
||||
Sheet s[8];
|
||||
uint8_t active_sheet;
|
||||
} Sheets;
|
||||
// sizeof(Sheets). Do not change it unless EEPROM_Sheets_base is last item in EEPROM.
|
||||
// Otherwise it would move following items.
|
||||
#define EEPROM_SHEETS_SIZEOF 34
|
||||
#define EEPROM_SHEETS_SIZEOF 89
|
||||
|
||||
#ifdef __cplusplus
|
||||
static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEPROM_SHEETS_SIZEOF.");
|
||||
@ -235,5 +229,14 @@ enum
|
||||
EEPROM_MMU_CUTTER_ENABLED_always = 2,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
void eeprom_init();
|
||||
bool is_sheet_initialized(uint8_t sheet_num);
|
||||
struct SheetName
|
||||
{
|
||||
char c[sizeof(Sheet::name) + 1];
|
||||
};
|
||||
void default_sheet_name(uint8_t index, SheetName &sheetName);
|
||||
#endif
|
||||
|
||||
#endif // EEPROM_H
|
||||
|
@ -244,10 +244,6 @@ 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();
|
||||
#endif // DELTA_CALIBRATION_MENU
|
||||
@ -5526,37 +5522,38 @@ SETTINGS_VERSION;
|
||||
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"
|
||||
{
|
||||
MENU_BEGIN();
|
||||
MENU_ITEM_BACK_P(_T(bSettings?MSG_SETTINGS:MSG_BACK)); // i.e. default menu-item / menu-item after checking mismatch
|
||||
MENU_BEGIN();
|
||||
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));
|
||||
//strncpy(buffer,_i(" "),sizeof(buffer));
|
||||
//strncpy(buffer,EEPROM_Sheets_base->s[0].name,sizeof(buffer));
|
||||
MENU_ITEM_SUBMENU_P(_i("Steel sheets"), sheets_menu);
|
||||
SETTINGS_NOZZLE;
|
||||
MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu);
|
||||
|
||||
//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);
|
||||
|
||||
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();
|
||||
MENU_END();
|
||||
}
|
||||
|
||||
static void lcd_settings_menu()
|
||||
@ -6543,22 +6540,6 @@ static void change_sheet_from_menu()
|
||||
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()
|
||||
{
|
||||
struct MenuData
|
||||
@ -6605,11 +6586,10 @@ static void lcd_rename_sheet_menu()
|
||||
|
||||
static void lcd_reset_sheet()
|
||||
{
|
||||
char name[sizeof(Sheet::name)];
|
||||
|
||||
strcpy_P(name, (char *)pgm_read_word(&(defaultSheetNames[selected_sheet])));
|
||||
SheetName sheetName;
|
||||
default_sheet_name(selected_sheet, sheetName);
|
||||
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[selected_sheet].z_offset)),0xffff);
|
||||
eeprom_update_block(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));
|
||||
if (selected_sheet == eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))
|
||||
{
|
||||
change_sheet_from_menu();
|
||||
|
Loading…
Reference in New Issue
Block a user