Merge pull request #1963 from NotaRobotexe/multiple_sheets

Multiple sheets
This commit is contained in:
DRracer 2019-07-04 15:45:46 +02:00 committed by GitHub
commit 8fa6785326
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 323 additions and 115 deletions

View File

@ -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];

View File

@ -1076,6 +1076,7 @@ void setup()
SERIAL_ECHO_START;
printf_P(PSTR(" " FW_VERSION_FULL "\n"));
//SERIAL_ECHOPAIR("Active sheet before:", static_cast<unsigned long int>(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet))));
#ifdef DEBUG_SEC_LANG
lang_table_header_t header;
@ -1424,20 +1425,7 @@ void setup()
printf_P(PSTR("Card NG!\n"));
#endif //DEBUG_SD_SPEED_TEST
if (eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_POWER_COUNT, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_Y, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_POWER_COUNT_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_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_LOAD_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0);
eeprom_init();
#ifdef SNMM
if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM
int _z = BOWDEN_LENGTH;
@ -1504,7 +1492,6 @@ void setup()
SilentModeMenu_MMU = 1;
eeprom_write_byte((uint8_t*)EEPROM_MMU_STEALTH, SilentModeMenu_MMU);
}
check_babystep(); //checking if Z babystep is in allowed range
#if !defined(DEBUG_DISABLE_FANCHECK) && defined(FANCHECK) && defined(TACH_1) && TACH_1 >-1
setup_fan_interrupt();
@ -1650,7 +1637,6 @@ void setup()
#ifdef WATCHDOG
wdt_enable(WDTO_4S);
#endif //WATCHDOG
}
@ -8159,12 +8145,15 @@ static void wait_for_heater(long codenum, uint8_t extruder) {
void check_babystep()
{
int babystep_z;
EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystep_z);
int babystep_z = eeprom_read_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)));
if ((babystep_z < Z_BABYSTEP_MIN) || (babystep_z > Z_BABYSTEP_MAX)) {
babystep_z = 0; //if babystep value is out of min max range, set it to 0
SERIAL_ECHOLNPGM("Z live adjust out of range. Setting to 0");
EEPROM_save_B(EEPROM_BABYSTEP_Z, &babystep_z);
eeprom_write_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)),
babystep_z);
lcd_show_fullscreen_message_and_wait_P(PSTR("Z live adjust out of range. Setting to 0. Click to continue."));
lcd_update_enable(true);
}

83
Firmware/eeprom.cpp Normal file
View File

@ -0,0 +1,83 @@
//! @file
//! @date Jun 20, 2019
//! @author Marek Běl
#include "eeprom.h"
#include "Marlin.h"
#include <avr/eeprom.h>
#include <stdint.h>
#include "language.h"
#if 0
template <typename T>
static T eeprom_read(T *address);
template<>
char eeprom_read<char>(char *address)
{
return eeprom_read_byte(reinterpret_cast<uint8_t*>(address));
}
#endif
template <typename T>
static void eeprom_write(T *address, T value);
template<>
void eeprom_write<char>(char *addres, char value)
{
eeprom_write_byte(reinterpret_cast<uint8_t*>(addres), static_cast<uint8_t>(value));
}
template <typename T>
static bool eeprom_is_uninitialized(T *address);
template <>
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);
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_Y, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_POWER_COUNT_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_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_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;
for (uint_least8_t j = 0; j < (sizeof(Sheet::name)/sizeof(Sheet::name[0])); ++j)
{
if (!eeprom_is_uninitialized(&(EEPROM_Sheets_base->s[i].name[j]))) is_uninitialized = false;
}
if(is_uninitialized)
{
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();
}

View File

@ -1,6 +1,10 @@
#ifndef EEPROM_H
#define EEPROM_H
#include <stdint.h>
void eeprom_init();
// The total size of the EEPROM is
// 4096 for the Atmega2560
#define EEPROM_TOP 4096
@ -167,8 +171,32 @@
#define EEPROM_NOZZLE_DIAMETER (EEPROM_CHECK_MODE-1) // uint8
#define EEPROM_NOZZLE_DIAMETER_uM (EEPROM_NOZZLE_DIAMETER-2) // uint16
typedef struct
{
char name[7]; //!< Can be null terminated, doesn't need to be null terminated
int16_t z_offset; //!< Z_BABYSTEP_MIN .. Z_BABYSTEP_MAX = Z_BABYSTEP_MIN*2/1000 [mm] .. Z_BABYSTEP_MAX*2/1000 [mm]
uint8_t bed_temp; //!< 0 .. 254 [°C]
uint8_t pinda_temp; //!< 0 .. 254 [°C]
} Sheet;
typedef struct
{
Sheet s[3];
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
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
//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
#define EEPROM_LAST_ITEM EEPROM_NOZZLE_DIAMETER_uM
#define EEPROM_LAST_ITEM ((uint16_t)EEPROM_Sheets_base)
// !!!!!
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
@ -189,7 +217,7 @@
#ifdef __cplusplus
#include "ConfigurationStore.h"
static_assert(EEPROM_FIRMWARE_VERSION_END < 20, "Firmware version EEPROM address conflicts with EEPROM_M500_base");
static M500_conf * const EEPROM_M500_base = reinterpret_cast<M500_conf*>(20); //offset for storing settings using M500
static constexpr M500_conf * const EEPROM_M500_base = reinterpret_cast<M500_conf*>(20); //offset for storing settings using M500
static_assert(((sizeof(M500_conf) + 20) < EEPROM_LAST_ITEM), "M500_conf address space conflicts with previous items.");
#endif

View File

@ -168,16 +168,40 @@ 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
//!
//! @param[in] sheet_E Sheet in EEPROM
//! @param[out] buffer for formatted output
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 + 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"), 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);
@ -224,6 +248,21 @@ uint8_t menu_item_submenu_P(const char* str, menu_func_t submenu)
return 0;
}
uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu)
{
if (menu_item == menu_line)
{
if (lcd_draw_update) menu_draw_item_puts_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)
@ -399,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))
{

View File

@ -3,6 +3,7 @@
#define _MENU_H
#include <inttypes.h>
#include "eeprom.h"
#define MENU_DATA_SIZE 32
@ -99,6 +100,10 @@ extern uint8_t menu_item_text_P(const char* str);
#define MENU_ITEM_SUBMENU_P(str, submenu) do { if (menu_item_submenu_P(str, submenu)) return; } while (0)
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_BACK_P(str) do { if (menu_item_back_P(str)) return; } while (0)
extern uint8_t menu_item_back_P(const char* str);
@ -125,6 +130,13 @@ extern void menu_draw_float31(const char* str, float val);
extern void menu_draw_float13(const char* str, float val);
struct SheetFormatBuffer
{
char c[19];
};
extern void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer);
#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) do { if (menu_item_edit_P(str, pval, minval, maxval)) return; } while (0)
//#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) MENU_ITEM_EDIT(int3, str, pval, minval, maxval)

View File

@ -3031,7 +3031,8 @@ void babystep_load()
check_babystep(); //checking if babystep is in allowed range, otherwise setting babystep to 0
// End of G80: Apply the baby stepping value.
EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystepLoadZ);
babystepLoadZ = eeprom_read_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)));
#if 0
SERIAL_ECHO("Z baby step: ");

View File

@ -10,7 +10,7 @@
//internationalized messages
const char MSG_AUTO_HOME[] PROGMEM_I1 = ISTR("Auto home"); ////
const char MSG_AUTO_MODE_ON[] PROGMEM_I1 = ISTR("Mode [auto power]"); ////
const char MSG_BABYSTEP_Z[] PROGMEM_I1 = ISTR("Live adjust Z"); ////
const char MSG_BABYSTEP_Z[] PROGMEM_I1 = ISTR("Live adjust Z"); //// c=18
const char MSG_BABYSTEP_Z_NOT_SET[] PROGMEM_I1 = ISTR("Distance between tip of the nozzle and the bed surface has not been set yet. Please follow the manual, chapter First steps, section First layer calibration."); ////c=20 r=12
const char MSG_BED[] PROGMEM_I1 = ISTR("Bed"); ////
const char MSG_BED_DONE[] PROGMEM_I1 = ISTR("Bed done"); ////
@ -55,6 +55,7 @@ const char MSG_CUT_FILAMENT[] PROGMEM_I1 = ISTR("Cut filament"); //// Number 1 t
const char MSG_M117_V2_CALIBRATION[] PROGMEM_I1 = ISTR("M117 First layer cal."); ////c=25 r=1
const char MSG_MAIN[] PROGMEM_I1 = ISTR("Main"); ////
const char MSG_BACK[] PROGMEM_I1 = ISTR("Back"); ////
const char MSG_SHEET[] PROGMEM_I1 = ISTR("Sheet"); ////c=10
const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1[] PROGMEM_I1 = ISTR("Measuring reference height of calibration point"); ////c=60
const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2[] PROGMEM_I1 = ISTR(" of 9"); ////c=14
const char MSG_MENU_CALIBRATION[] PROGMEM_I1 = ISTR("Calibration"); ////
@ -126,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"; ////

View File

@ -54,6 +54,7 @@ extern const char MSG_LOADING_FILAMENT[];
extern const char MSG_M117_V2_CALIBRATION[];
extern const char MSG_MAIN[];
extern const char MSG_BACK[];
extern const char MSG_SHEET[];
extern const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1[];
extern const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2[];
extern const char MSG_MENU_CALIBRATION[];
@ -127,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)
}

View File

@ -3068,13 +3068,13 @@ static void lcd_move_z() {
* other value leads to storing Z_AXIS
* @param msg text to be displayed
*/
static void _lcd_babystep(int axis, const char *msg)
static void lcd_babystep_z()
{
typedef struct
{ // 19bytes total
int8_t status; // 1byte
int babystepMem[3]; // 6bytes
float babystepMemMM[3]; // 12bytes
{
int8_t status;
int16_t babystepMemZ;
float babystepMemMMZ;
} _menu_data_t;
static_assert(sizeof(menu_data)>= sizeof(_menu_data_t),"_menu_data_t doesn't fit into menu_data");
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
@ -3085,17 +3085,19 @@ static void _lcd_babystep(int axis, const char *msg)
_md->status = 1;
check_babystep();
EEPROM_read_B(EEPROM_BABYSTEP_X, &_md->babystepMem[0]);
EEPROM_read_B(EEPROM_BABYSTEP_Y, &_md->babystepMem[1]);
EEPROM_read_B(EEPROM_BABYSTEP_Z, &_md->babystepMem[2]);
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)
_md->babystepMem[2] = 0;
_md->babystepMemZ = 0;
_md->babystepMemMM[0] = _md->babystepMem[0]/cs.axis_steps_per_unit[X_AXIS];
_md->babystepMemMM[1] = _md->babystepMem[1]/cs.axis_steps_per_unit[Y_AXIS];
_md->babystepMemMM[2] = _md->babystepMem[2]/cs.axis_steps_per_unit[Z_AXIS];
_md->babystepMemMMZ = _md->babystepMemZ/cs.axis_steps_per_unit[Z_AXIS];
lcd_draw_update = 1;
//SERIAL_ECHO("Z baby step: ");
//SERIAL_ECHO(_md->babystepMem[2]);
@ -3106,46 +3108,49 @@ static void _lcd_babystep(int axis, const char *msg)
if (lcd_encoder != 0)
{
if (homing_flag) lcd_encoder = 0;
_md->babystepMem[axis] += (int)lcd_encoder;
if (axis == 2)
{
if (_md->babystepMem[axis] < Z_BABYSTEP_MIN) _md->babystepMem[axis] = Z_BABYSTEP_MIN; //-3999 -> -9.99 mm
else if (_md->babystepMem[axis] > Z_BABYSTEP_MAX) _md->babystepMem[axis] = Z_BABYSTEP_MAX; //0
_md->babystepMemZ += (int)lcd_encoder;
if (_md->babystepMemZ < Z_BABYSTEP_MIN) _md->babystepMemZ = Z_BABYSTEP_MIN; //-3999 -> -9.99 mm
else if (_md->babystepMemZ > Z_BABYSTEP_MAX) _md->babystepMemZ = Z_BABYSTEP_MAX; //0
else
{
CRITICAL_SECTION_START
babystepsTodo[axis] += (int)lcd_encoder;
babystepsTodo[Z_AXIS] += (int)lcd_encoder;
CRITICAL_SECTION_END
}
}
_md->babystepMemMM[axis] = _md->babystepMem[axis]/cs.axis_steps_per_unit[axis];
_md->babystepMemMMZ = _md->babystepMemZ/cs.axis_steps_per_unit[Z_AXIS];
_delay(50);
lcd_encoder = 0;
lcd_draw_update = 1;
}
if (lcd_draw_update)
{
SheetFormatBuffer buffer;
menu_format_sheet_E(EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))], buffer);
lcd_set_cursor(0, 0);
lcd_print(buffer.c);
lcd_set_cursor(0, 1);
menu_draw_float13(msg, _md->babystepMemMM[axis]);
menu_draw_float13(_i("Adjusting Z:"), _md->babystepMemMMZ); ////MSG_BABYSTEPPING_Z c=15 Beware: must include the ':' as its last character
}
if (LCD_CLICKED || menu_leaving)
{
// Only update the EEPROM when leaving the menu.
EEPROM_save_B(
(axis == X_AXIS) ? EEPROM_BABYSTEP_X : ((axis == Y_AXIS) ? EEPROM_BABYSTEP_Y : EEPROM_BABYSTEP_Z),
&_md->babystepMem[axis]);
if(Z_AXIS == axis) calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
eeprom_update_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)),
_md->babystepMemZ);
eeprom_update_byte(&(EEPROM_Sheets_base->s[(eeprom_read_byte(
&(EEPROM_Sheets_base->active_sheet)))].bed_temp),
target_temperature_bed);
eeprom_update_byte(&(EEPROM_Sheets_base->s[(eeprom_read_byte(
&(EEPROM_Sheets_base->active_sheet)))].pinda_temp),
current_temperature_pinda);
calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
}
if (LCD_CLICKED) menu_back();
}
static void lcd_babystep_z()
{
_lcd_babystep(Z_AXIS, (_i("Adjusting Z:")));////MSG_BABYSTEPPING_Z c=15 Beware: must include the ':' as its last character
}
typedef struct
{ // 12bytes + 9bytes = 21bytes total
menu_data_edit_t reserved; //12 bytes reserved for number editing functions
@ -6300,6 +6305,95 @@ void lcd_resume_print()
isPrintPaused = false;
}
static void change_sheet(uint8_t sheet_num)
{
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()
{
change_sheet(1);
}
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();
}
static void lcd_rename_sheet_menu()
{
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]);
if (!menuData->initialized)
{
eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, sizeof(Sheet::name));
lcd_encoder = menuData->name[0];
menuData->initialized = true;
}
if (lcd_encoder < '\x20') lcd_encoder = '\x20';
if (lcd_encoder > '\x7F') lcd_encoder = '\x7F';
menuData->name[menuData->selected] = lcd_encoder;
lcd_set_cursor(0,0);
for (uint_least8_t i = 0; i < sizeof(Sheet::name); ++i)
{
lcd_putc(menuData->name[i]);
}
lcd_set_cursor(menuData->selected, 1);
lcd_putc('^');
if (lcd_clicked())
{
if ((menuData->selected + 1u) < sizeof(Sheet::name))
{
lcd_encoder = menuData->name[++(menuData->selected)];
}
else
{
eeprom_update_block(menuData->name,
EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name,
sizeof(Sheet::name));
menu_back();
}
}
}
static void lcd_sheet_menu()
{
MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_MAIN));
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();
}
static void lcd_main_menu()
{
@ -6322,55 +6416,6 @@ static void lcd_main_menu()
MENU_ITEM_FUNCTION_P(PSTR("power panic"), uvlo_);
#endif //TMC2130_DEBUG
/* if (farm_mode && !IS_SD_PRINTING )
{
int tempScrool = 0;
if (lcd_draw_update == 0 && LCD_CLICKED == 0)
//_delay(100);
return; // nothing to do (so don't thrash the SD card)
uint16_t fileCnt = card.getnrfilenames();
card.getWorkDirName();
if (card.filename[0] == '/')
{
#if SDCARDDETECT == -1
MENU_ITEM_FUNCTION_P(_T(MSG_REFRESH), lcd_sd_refresh);
#endif
} else {
MENU_ITEM_FUNCTION_P(PSTR(LCD_STR_FOLDER ".."), lcd_sd_updir);
}
for (uint16_t i = 0; i < fileCnt; i++)
{
if (menu_item == menu_line)
{
#ifndef SDCARD_RATHERRECENTFIRST
card.getfilename(i);
#else
card.getfilename(fileCnt - 1 - i);
#endif
if (card.filenameIsDir)
{
MENU_ITEM_SDDIR(_T(MSG_CARD_MENU), card.filename, card.longFilename);
} else {
MENU_ITEM_SDFILE(_T(MSG_CARD_MENU), card.filename, card.longFilename);
}
} else {
MENU_ITEM_DUMMY();
}
}
MENU_ITEM_BACK_P(PSTR("- - - - - - - - -"));
}*/
if ( ( IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal)) && (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU) && !homing_flag && !mesh_bed_leveling_flag)
{
MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z);//8
@ -6385,6 +6430,8 @@ static void lcd_main_menu()
MENU_ITEM_SUBMENU_P(_i("Preheat"), lcd_preheat_menu);////MSG_PREHEAT
}
#ifdef SDSUPPORT
if (card.cardOK || lcd_commands_type == LcdCommands::Layer1Cal)
{
@ -6475,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

View File

@ -82,7 +82,7 @@ generate_binary()
rm -f lang_$1.dat
LNG=$1
#check lang dictionary
/usr/bin/env python lang-check.py $1
/usr/bin/env python lang-check.py $1 --no-warning
#create lang_xx.tmp - different processing for 'en' language
if [ "$1" = "en" ]; then
#remove comments and empty lines