Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Firmware/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ extern float retract_recover_length_swap;

extern uint8_t host_keepalive_interval;


extern unsigned long starttime;
extern unsigned long stoptime;
extern int bowden_length[4];
Expand Down
8 changes: 8 additions & 0 deletions Firmware/eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <avr/eeprom.h>
#include <stdint.h>


#include "language.h"

#if 0
template <typename T>
static T eeprom_read(T *address);
Expand Down Expand Up @@ -38,6 +41,11 @@ bool eeprom_is_uninitialized<char>(char *address)
return (0xff == eeprom_read_byte(reinterpret_cast<uint8_t*>(address)));
}

bool is_sheet_initialized(){
return (0xffff != eeprom_read_word(reinterpret_cast<uint16_t*>(&(EEPROM_Sheets_base->
s[eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))].z_offset))));
}

void eeprom_init()
{
if (eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_POWER_COUNT, 0);
Expand Down
1 change: 1 addition & 0 deletions Firmware/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ typedef struct
static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_NOZZLE_DIAMETER - EEPROM_SHEETS_SIZEOF);

#ifdef __cplusplus
extern bool is_sheet_initialized();
static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEPROM_SHEETS_SIZEOF.");
#endif

Expand Down
16 changes: 10 additions & 6 deletions Firmware/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,14 @@ int menu_draw_item_printf_P(char type_char, const char* format, ...)
}
*/

static char menu_selection_mark(){
return (lcd_encoder == menu_item)?'>':' ';
}

static void menu_draw_item_puts_P(char type_char, const char* str)
{
lcd_set_cursor(0, menu_row);
lcd_printf_P(PSTR("%c%-18.18S%c"), (lcd_encoder == menu_item)?'>':' ', str, type_char);
lcd_printf_P(PSTR("%c%-18.18S%c"), menu_selection_mark(), str, type_char);
}

//! @brief Format sheet name
Expand All @@ -182,22 +186,22 @@ void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer)
{
uint_least8_t index = sprintf_P(buffer.c, PSTR("%.10S "), _T(MSG_SHEET));
eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7);
index += 7;
buffer.c[index] = '\0';
//index += 7;
buffer.c[index + 7] = '\0';
}

static void menu_draw_item_puts_E(char type_char, const Sheet &sheet)
{
lcd_set_cursor(0, menu_row);
SheetFormatBuffer buffer;
menu_format_sheet_E(sheet, buffer);
lcd_printf_P(PSTR("%c%-18.18s%c"), (lcd_encoder == menu_item)?'>':' ', buffer.c, type_char);
lcd_printf_P(PSTR("%c%-18.18s%c"), menu_selection_mark(), buffer.c, type_char);
}

static void menu_draw_item_puts_P(char type_char, const char* str, char num)
{
lcd_set_cursor(0, menu_row);
lcd_printf_P(PSTR("%c%-.16S "), (lcd_encoder == menu_item)?'>':' ', str);
lcd_printf_P(PSTR("%c%-.16S "), menu_selection_mark(), str);
lcd_putc(num);
lcd_set_cursor(19, menu_row);
lcd_putc(type_char);
Expand Down Expand Up @@ -434,7 +438,7 @@ uint8_t menu_item_edit_P(const char* str, T pval, int16_t min_val, int16_t max_v
if (lcd_draw_update)
{
lcd_set_cursor(0, menu_row);
menu_draw_P<T>((lcd_encoder == menu_item)?'>':' ', str, *pval);
menu_draw_P<T>(menu_selection_mark(), str, *pval);
}
if (menu_clicked && (lcd_encoder == menu_item))
{
Expand Down
3 changes: 3 additions & 0 deletions Firmware/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ const char MSG_ENDSTOP_OPEN[] PROGMEM_N1 = "open"; ////
const char MSG_POWERUP[] PROGMEM_N1 = "PowerUp"; ////
const char MSG_ERR_STOPPED[] PROGMEM_N1 = "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"; ////
const char MSG_ENDSTOP_HIT[] PROGMEM_N1 = "TRIGGERED"; ////
const char MSG_V2_CALIBRATION[] PROGMEM_N1 = "First layer cal."; ////c=17 r=1
const char MSG_SELECT[] PROGMEM_N1 = "Select"; ////
const char MSG_RENAME[] PROGMEM_N1 = "Rename"; ////
3 changes: 3 additions & 0 deletions Firmware/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ extern const char MSG_ERR_STOPPED[];
extern const char MSG_ENDSTOP_HIT[];
extern const char MSG_EJECT_FILAMENT[];
extern const char MSG_CUT_FILAMENT[];
extern const char MSG_V2_CALIBRATION[];
extern const char MSG_SELECT[];
extern const char MSG_RENAME[];

#if defined(__cplusplus)
}
Expand Down
42 changes: 28 additions & 14 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3084,9 +3084,14 @@ static void lcd_babystep_z()
// Initialize its status.
_md->status = 1;
check_babystep();

_md->babystepMemZ = eeprom_read_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)));

if(!is_sheet_initialized()){
_md->babystepMemZ = 0;
}
else{
_md->babystepMemZ = eeprom_read_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)));
}

// same logic as in babystep_load
if (calibration_status() >= CALIBRATION_STATUS_LIVE_ADJUST)
Expand Down Expand Up @@ -6300,26 +6305,34 @@ void lcd_resume_print()
isPrintPaused = false;
}

static void lcd_select_sheet_0_menu()
static void change_sheet(uint8_t sheet_num)
{
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0);
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);

menu_back(3);
}

static void lcd_select_sheet_0_menu()
{
change_sheet(0);
}
static void lcd_select_sheet_1_menu()
{
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 1);
menu_back(3);
change_sheet(1);
}
static void lcd_select_sheet_2_menu()
{
eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 2);
menu_back(3);
change_sheet(2);
}

static void lcd_select_sheet_menu()
{
MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_SHEET));
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);
Expand Down Expand Up @@ -6374,9 +6387,9 @@ 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_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z);
MENU_ITEM_SUBMENU_P(_T(MSG_SELECT), lcd_select_sheet_menu); //// c=18
MENU_ITEM_SUBMENU_P(_T(MSG_RENAME), lcd_rename_sheet_menu); //// c=18
MENU_ITEM_SUBMENU_P(_T(MSG_V2_CALIBRATION), lcd_v2_calibration); ////MSG_V2_CALIBRATION c=17 r=1

MENU_END();
}
Expand Down Expand Up @@ -6415,7 +6428,6 @@ static void lcd_main_menu()
} else
{
MENU_ITEM_SUBMENU_P(_i("Preheat"), lcd_preheat_menu);////MSG_PREHEAT
MENU_ITEM_SUBMENU_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], lcd_sheet_menu);
}


Expand Down Expand Up @@ -6510,6 +6522,8 @@ 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 (!is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal))
{
MENU_ITEM_SUBMENU_P(_i("Statistics "), lcd_menu_statistics);////MSG_STATISTICS
Expand Down