Merge pull request #1030 from XPila/MK3-new_lang

3.4.0 RC1 finalization
This commit is contained in:
XPila 2018-08-10 19:57:08 +02:00 committed by GitHub
commit e6c80eaa0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 188 additions and 234 deletions

View File

@ -972,42 +972,9 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
case 2: _delay_ms(0); break; case 2: _delay_ms(0); break;
case 3: _delay_ms(0); break; case 3: _delay_ms(0); break;
} }
// _delay_ms(100);
/*
#ifdef MESH_BED_LEVELING
_delay_ms(2000);
if (!READ(BTN_ENC))
{
WRITE(BEEPER, HIGH);
_delay_ms(100);
WRITE(BEEPER, LOW);
_delay_ms(200);
WRITE(BEEPER, HIGH);
_delay_ms(100);
WRITE(BEEPER, LOW);
int _z = 0;
calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
EEPROM_save_B(EEPROM_BABYSTEP_X, &_z);
EEPROM_save_B(EEPROM_BABYSTEP_Y, &_z);
EEPROM_save_B(EEPROM_BABYSTEP_Z, &_z);
}
else
{
WRITE(BEEPER, HIGH);
_delay_ms(100);
WRITE(BEEPER, LOW);
}
#endif // mesh */
} }
} }
else
{
//_delay_ms(1000); // wait 1sec to display the splash screen // what's this and why do we need it?? - andre
}
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
} }
@ -7732,7 +7699,8 @@ void wait_for_heater(long codenum) {
} }
} }
void check_babystep() { void check_babystep()
{
int babystep_z; int babystep_z;
EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystep_z); EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystep_z);
if ((babystep_z < Z_BABYSTEP_MIN) || (babystep_z > Z_BABYSTEP_MAX)) { if ((babystep_z < Z_BABYSTEP_MIN) || (babystep_z > Z_BABYSTEP_MAX)) {

View File

@ -10,7 +10,7 @@
* @brief construct Timer * @brief construct Timer
* *
* It is guaranteed, that construction is equivalent with zeroing all members. * It is guaranteed, that construction is equivalent with zeroing all members.
* This property can be exploited in MenuData union. * This property can be exploited in menu_data.
*/ */
template<typename T> template<typename T>
Timer<T>::Timer() : m_isRunning(false), m_started() Timer<T>::Timer() : m_isRunning(false), m_started()

View File

@ -273,25 +273,35 @@ void menu_draw_float13(char chr, const char* str, float val)
lcd_printf_P(menu_fmt_float13, chr, str, spaces, val); lcd_printf_P(menu_fmt_float13, chr, str, spaces, val);
} }
#define _menu_data menuData.edit_menu typedef struct
{
//Variables used when editing values.
const char* editLabel;
void* editValue;
int32_t minEditValue;
int32_t maxEditValue;
} menu_data_edit_t;
void _menu_edit_int3(void) void _menu_edit_int3(void)
{ {
menu_data_edit_t* _md = (menu_data_edit_t*)&(menu_data[0]);
if (lcd_draw_update) if (lcd_draw_update)
{ {
if (lcd_encoder < _menu_data.minEditValue) lcd_encoder = _menu_data.minEditValue; if (lcd_encoder < _md->minEditValue) lcd_encoder = _md->minEditValue;
if (lcd_encoder > _menu_data.maxEditValue) lcd_encoder = _menu_data.maxEditValue; if (lcd_encoder > _md->maxEditValue) lcd_encoder = _md->maxEditValue;
lcd_set_cursor(0, 1); lcd_set_cursor(0, 1);
menu_draw_int3(' ', _menu_data.editLabel, (int)lcd_encoder); menu_draw_int3(' ', _md->editLabel, (int)lcd_encoder);
} }
if (LCD_CLICKED) if (LCD_CLICKED)
{ {
*((int*)(_menu_data.editValue)) = (int)lcd_encoder; *((int*)(_md->editValue)) = (int)lcd_encoder;
menu_back(); menu_back();
} }
} }
uint8_t menu_item_edit_int3(const char* str, int16_t* pval, int16_t min_val, int16_t max_val) uint8_t menu_item_edit_int3(const char* str, int16_t* pval, int16_t min_val, int16_t max_val)
{ {
menu_data_edit_t* _md = (menu_data_edit_t*)&(menu_data[0]);
if (menu_item == menu_line) if (menu_item == menu_line)
{ {
if (lcd_draw_update) if (lcd_draw_update)
@ -302,10 +312,10 @@ uint8_t menu_item_edit_int3(const char* str, int16_t* pval, int16_t min_val, int
if (menu_clicked && (lcd_encoder == menu_item)) if (menu_clicked && (lcd_encoder == menu_item))
{ {
menu_submenu(_menu_edit_int3); menu_submenu(_menu_edit_int3);
_menu_data.editLabel = str; _md->editLabel = str;
_menu_data.editValue = pval; _md->editValue = pval;
_menu_data.minEditValue = min_val; _md->minEditValue = min_val;
_menu_data.maxEditValue = max_val; _md->maxEditValue = max_val;
lcd_encoder = *pval; lcd_encoder = *pval;
return menu_item_ret(); return menu_item_ret();
} }

View File

@ -16,15 +16,6 @@ typedef struct
uint8_t position; uint8_t position;
} menu_record_t; } menu_record_t;
typedef struct
{
//Variables used when editing values.
const char* editLabel;
void* editValue;
int32_t minEditValue;
int32_t maxEditValue;
} menu_data_edit_t;
extern menu_record_t menu_stack[MENU_DEPTH_MAX]; extern menu_record_t menu_stack[MENU_DEPTH_MAX];
extern uint8_t menu_data[MENU_DATA_SIZE]; extern uint8_t menu_data[MENU_DATA_SIZE];

View File

@ -2984,13 +2984,14 @@ static int babystepLoadZ = 0;
void babystep_load() void babystep_load()
{ {
babystepLoadZ = 0;
// Apply Z height correction aka baby stepping before mesh bed leveling gets activated. // Apply Z height correction aka baby stepping before mesh bed leveling gets activated.
if(calibration_status() < CALIBRATION_STATUS_LIVE_ADJUST) if (calibration_status() < CALIBRATION_STATUS_LIVE_ADJUST)
{ {
check_babystep(); //checking if babystep is in allowed range, otherwise setting babystep to 0 check_babystep(); //checking if babystep is in allowed range, otherwise setting babystep to 0
// End of G80: Apply the baby stepping value. // End of G80: Apply the baby stepping value.
EEPROM_read_B(EEPROM_BABYSTEP_Z,&babystepLoadZ); EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystepLoadZ);
#if 0 #if 0
SERIAL_ECHO("Z baby step: "); SERIAL_ECHO("Z baby step: ");

View File

@ -176,6 +176,7 @@ extern void babystep_undo();
// Reset the current babystep counter without moving the axes. // Reset the current babystep counter without moving the axes.
extern void babystep_reset(); extern void babystep_reset();
extern void count_xyz_details(float (&distanceMin)[2]); extern void count_xyz_details(float (&distanceMin)[2]);
extern bool sample_z(); extern bool sample_z();

View File

@ -26,7 +26,7 @@ extern char choose_extruder_menu();
bool mmu_enabled = false; bool mmu_enabled = false;
int8_t mmu_state = -1; int8_t mmu_state = 0;
uint8_t mmu_extruder = 0; uint8_t mmu_extruder = 0;

View File

@ -77,7 +77,8 @@ bool tmc2130_sg_change = false;
bool skip_debug_msg = false; bool skip_debug_msg = false;
#define DBG(args...) printf_P(args) #define DBG(args...)
//printf_P(args)
#ifndef _n #ifndef _n
#define _n PSTR #define _n PSTR
#endif //_n #endif //_n

View File

@ -34,6 +34,8 @@ int uart2_getchar(FILE *stream)
//uart init (io + FILE stream) //uart init (io + FILE stream)
void uart2_init(void) void uart2_init(void)
{ {
DDRH &= ~0x01;
PORTH |= 0x01;
rbuf_ini(uart2_ibuf, sizeof(uart2_ibuf) - 4); rbuf_ini(uart2_ibuf, sizeof(uart2_ibuf) - 4);
UCSR2A |= (1 << U2X2); // baudrate multiplier UCSR2A |= (1 << U2X2); // baudrate multiplier
UBRR2L = UART_BAUD_SELECT(UART2_BAUD, F_CPU); // select baudrate UBRR2L = UART_BAUD_SELECT(UART2_BAUD, F_CPU); // select baudrate

View File

@ -46,10 +46,6 @@ char longFilenameOLD[LONG_FILENAME_LENGTH];
static void lcd_sd_updir(); static void lcd_sd_updir();
// State of the currently active menu.
// C Union manages sharing of the static memory by all the menus.
union MenuData menuData = { 0 };
int8_t ReInitLCD = 0; int8_t ReInitLCD = 0;
@ -124,7 +120,7 @@ static void lcd_control_temperature_preheat_pla_settings_menu();
static void lcd_control_temperature_preheat_abs_settings_menu(); static void lcd_control_temperature_preheat_abs_settings_menu();
static void lcd_control_motion_menu(); static void lcd_control_motion_menu();
static void lcd_control_volumetric_menu(); static void lcd_control_volumetric_menu();
static void lcd_settings_menu_back(); //static void lcd_settings_menu_back();
static void prusa_stat_printerstatus(int _status); static void prusa_stat_printerstatus(int _status);
static void prusa_stat_farm_number(); static void prusa_stat_farm_number();
@ -2175,23 +2171,34 @@ static void lcd_preheat_menu()
static void lcd_support_menu() static void lcd_support_menu()
{ {
if (menuData.supportMenu.status == 0 || lcd_draw_update == 2) typedef struct
{ // 22bytes total
int8_t status; // 1byte
bool is_flash_air; // 1byte
uint8_t ip[4]; // 4bytes
char ip_str[3*4+3+1]; // 16bytes
} _menu_data_t;
#if (22 > MENU_DATA_SIZE)
#error "check MENU_DATA_SIZE definition!"
#endif
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
if (_md->status == 0 || lcd_draw_update == 2)
{ {
// Menu was entered or SD card status has changed (plugged in or removed). // Menu was entered or SD card status has changed (plugged in or removed).
// Initialize its status. // Initialize its status.
menuData.supportMenu.status = 1; _md->status = 1;
menuData.supportMenu.is_flash_air = card.ToshibaFlashAir_isEnabled() && card.ToshibaFlashAir_GetIP(menuData.supportMenu.ip); _md->is_flash_air = card.ToshibaFlashAir_isEnabled() && card.ToshibaFlashAir_GetIP(_md->ip);
if (menuData.supportMenu.is_flash_air) if (_md->is_flash_air)
sprintf_P(menuData.supportMenu.ip_str, PSTR("%d.%d.%d.%d"), sprintf_P(_md->ip_str, PSTR("%d.%d.%d.%d"),
menuData.supportMenu.ip[0], menuData.supportMenu.ip[1], _md->ip[0], _md->ip[1],
menuData.supportMenu.ip[2], menuData.supportMenu.ip[3]); _md->ip[2], _md->ip[3]);
} else if (menuData.supportMenu.is_flash_air && } else if (_md->is_flash_air &&
menuData.supportMenu.ip[0] == 0 && menuData.supportMenu.ip[1] == 0 && _md->ip[0] == 0 && _md->ip[1] == 0 &&
menuData.supportMenu.ip[2] == 0 && menuData.supportMenu.ip[3] == 0 && _md->ip[2] == 0 && _md->ip[3] == 0 &&
++ menuData.supportMenu.status == 16) ++ _md->status == 16)
{ {
// Waiting for the FlashAir card to get an IP address from a router. Force an update. // Waiting for the FlashAir card to get an IP address from a router. Force an update.
menuData.supportMenu.status = 0; _md->status = 0;
} }
MENU_BEGIN(); MENU_BEGIN();
@ -2241,10 +2248,10 @@ static void lcd_support_menu()
// Show the FlashAir IP address, if the card is available. // Show the FlashAir IP address, if the card is available.
if (menuData.supportMenu.is_flash_air) { if (_md->is_flash_air) {
MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_BACK_P(STR_SEPARATOR);
MENU_ITEM_BACK_P(PSTR("FlashAir IP Addr:")); MENU_ITEM_BACK_P(PSTR("FlashAir IP Addr:"));
///! MENU_ITEM(back_RAM, menuData.supportMenu.ip_str, 0); ///! MENU_ITEM(back_RAM, _md->ip_str, 0);
} }
#ifndef MK1BP #ifndef MK1BP
@ -2502,7 +2509,7 @@ static void lcd_menu_AutoLoadFilament()
} }
else else
{ {
ShortTimer* ptimer = (ShortTimer*)&(menuData.autoLoadFilamentMenu.dummy); ShortTimer* ptimer = (ShortTimer*)&(menu_data[0]);
if (!ptimer->running()) ptimer->start(); if (!ptimer->running()) ptimer->start();
lcd_set_cursor(0, 0); lcd_set_cursor(0, 0);
lcd_puts_P(_T(MSG_ERROR)); lcd_puts_P(_T(MSG_ERROR));
@ -2613,10 +2620,19 @@ void lcd_menu_statistics()
static void _lcd_move(const char *name, int axis, int min, int max) static void _lcd_move(const char *name, int axis, int min, int max)
{ {
if (!menuData._lcd_moveMenu.initialized) typedef struct
{ // 2bytes total
bool initialized; // 1byte
bool endstopsEnabledPrevious; // 1byte
} _menu_data_t;
#if (2 > MENU_DATA_SIZE)
#error "check MENU_DATA_SIZE definition!"
#endif
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
if (!_md->initialized)
{ {
menuData._lcd_moveMenu.endstopsEnabledPrevious = enable_endstops(false); _md->endstopsEnabledPrevious = enable_endstops(false);
menuData._lcd_moveMenu.initialized = true; _md->initialized = true;
} }
if (lcd_encoder != 0) if (lcd_encoder != 0)
{ {
@ -2637,7 +2653,7 @@ static void _lcd_move(const char *name, int axis, int min, int max)
lcd_set_cursor(0, 1); lcd_set_cursor(0, 1);
menu_draw_float31(' ', name, current_position[axis]); menu_draw_float31(' ', name, current_position[axis]);
} }
if (menuExiting || LCD_CLICKED) (void)enable_endstops(menuData._lcd_moveMenu.endstopsEnabledPrevious); if (menuExiting || LCD_CLICKED) (void)enable_endstops(_md->endstopsEnabledPrevious);
if (LCD_CLICKED) menu_back(); if (LCD_CLICKED) menu_back();
} }
@ -2809,23 +2825,37 @@ static void lcd_move_z() {
*/ */
static void _lcd_babystep(int axis, const char *msg) static void _lcd_babystep(int axis, const char *msg)
{ {
if (menuData.babyStep.status == 0) typedef struct
{ // 19bytes total
int8_t status; // 1byte
int babystepMem[3]; // 6bytes
float babystepMemMM[3]; // 12bytes
} _menu_data_t;
#if (19 > MENU_DATA_SIZE)
#error "check MENU_DATA_SIZE definition!"
#endif
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
if (_md->status == 0)
{ {
// Menu was entered. // Menu was entered.
// Initialize its status. // Initialize its status.
menuData.babyStep.status = 1; _md->status = 1;
check_babystep(); check_babystep();
EEPROM_read_B(EEPROM_BABYSTEP_X, &menuData.babyStep.babystepMem[0]); EEPROM_read_B(EEPROM_BABYSTEP_X, &_md->babystepMem[0]);
EEPROM_read_B(EEPROM_BABYSTEP_Y, &menuData.babyStep.babystepMem[1]); EEPROM_read_B(EEPROM_BABYSTEP_Y, &_md->babystepMem[1]);
EEPROM_read_B(EEPROM_BABYSTEP_Z, &menuData.babyStep.babystepMem[2]); EEPROM_read_B(EEPROM_BABYSTEP_Z, &_md->babystepMem[2]);
menuData.babyStep.babystepMemMM[0] = menuData.babyStep.babystepMem[0]/axis_steps_per_unit[X_AXIS]; // same logic as in babystep_load
menuData.babyStep.babystepMemMM[1] = menuData.babyStep.babystepMem[1]/axis_steps_per_unit[Y_AXIS]; if (calibration_status() >= CALIBRATION_STATUS_LIVE_ADJUST)
menuData.babyStep.babystepMemMM[2] = menuData.babyStep.babystepMem[2]/axis_steps_per_unit[Z_AXIS]; _md->babystepMem[2] = 0;
_md->babystepMemMM[0] = _md->babystepMem[0]/axis_steps_per_unit[X_AXIS];
_md->babystepMemMM[1] = _md->babystepMem[1]/axis_steps_per_unit[Y_AXIS];
_md->babystepMemMM[2] = _md->babystepMem[2]/axis_steps_per_unit[Z_AXIS];
lcd_draw_update = 1; lcd_draw_update = 1;
//SERIAL_ECHO("Z baby step: "); //SERIAL_ECHO("Z baby step: ");
//SERIAL_ECHO(menuData.babyStep.babystepMem[2]); //SERIAL_ECHO(_md->babystepMem[2]);
// Wait 90 seconds before closing the live adjust dialog. // Wait 90 seconds before closing the live adjust dialog.
lcd_timeoutToStatus.start(); lcd_timeoutToStatus.start();
} }
@ -2833,11 +2863,11 @@ static void _lcd_babystep(int axis, const char *msg)
if (lcd_encoder != 0) if (lcd_encoder != 0)
{ {
if (homing_flag) lcd_encoder = 0; if (homing_flag) lcd_encoder = 0;
menuData.babyStep.babystepMem[axis] += (int)lcd_encoder; _md->babystepMem[axis] += (int)lcd_encoder;
if (axis == 2) if (axis == 2)
{ {
if (menuData.babyStep.babystepMem[axis] < Z_BABYSTEP_MIN) menuData.babyStep.babystepMem[axis] = Z_BABYSTEP_MIN; //-3999 -> -9.99 mm if (_md->babystepMem[axis] < Z_BABYSTEP_MIN) _md->babystepMem[axis] = Z_BABYSTEP_MIN; //-3999 -> -9.99 mm
else if (menuData.babyStep.babystepMem[axis] > Z_BABYSTEP_MAX) menuData.babyStep.babystepMem[axis] = Z_BABYSTEP_MAX; //0 else if (_md->babystepMem[axis] > Z_BABYSTEP_MAX) _md->babystepMem[axis] = Z_BABYSTEP_MAX; //0
else else
{ {
CRITICAL_SECTION_START CRITICAL_SECTION_START
@ -2845,7 +2875,7 @@ static void _lcd_babystep(int axis, const char *msg)
CRITICAL_SECTION_END CRITICAL_SECTION_END
} }
} }
menuData.babyStep.babystepMemMM[axis] = menuData.babyStep.babystepMem[axis]/axis_steps_per_unit[axis]; _md->babystepMemMM[axis] = _md->babystepMem[axis]/axis_steps_per_unit[axis];
delay(50); delay(50);
lcd_encoder = 0; lcd_encoder = 0;
lcd_draw_update = 1; lcd_draw_update = 1;
@ -2853,14 +2883,14 @@ static void _lcd_babystep(int axis, const char *msg)
if (lcd_draw_update) if (lcd_draw_update)
{ {
lcd_set_cursor(0, 1); lcd_set_cursor(0, 1);
menu_draw_float13(' ', msg, menuData.babyStep.babystepMemMM[axis]); menu_draw_float13(' ', msg, _md->babystepMemMM[axis]);
} }
if (LCD_CLICKED || menuExiting) if (LCD_CLICKED || menuExiting)
{ {
// Only update the EEPROM when leaving the menu. // Only update the EEPROM when leaving the menu.
EEPROM_save_B( EEPROM_save_B(
(axis == X_AXIS) ? EEPROM_BABYSTEP_X : ((axis == Y_AXIS) ? EEPROM_BABYSTEP_Y : EEPROM_BABYSTEP_Z), (axis == X_AXIS) ? EEPROM_BABYSTEP_X : ((axis == Y_AXIS) ? EEPROM_BABYSTEP_Y : EEPROM_BABYSTEP_Z),
&menuData.babyStep.babystepMem[axis]); &_md->babystepMem[axis]);
if(Z_AXIS == axis) calibration_status_store(CALIBRATION_STATUS_CALIBRATED); if(Z_AXIS == axis) calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
} }
if (LCD_CLICKED) menu_back(); if (LCD_CLICKED) menu_back();
@ -2878,6 +2908,22 @@ static void lcd_babystep_z() {
static void lcd_adjust_bed(); static void lcd_adjust_bed();
typedef struct
{ // 13bytes total
int8_t status; // 1byte
int8_t left; // 1byte
int8_t right; // 1byte
int8_t front; // 1byte
int8_t rear; // 1byte
int left2; // 2byte
int right2; // 2byte
int front2; // 2byte
int rear2; // 2byte
} _menu_data_adjust_bed_t;
#if (13 > MENU_DATA_SIZE)
#error "check MENU_DATA_SIZE definition!"
#endif
static void lcd_adjust_bed_reset() static void lcd_adjust_bed_reset()
{ {
eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID, 1); eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID, 1);
@ -2885,65 +2931,71 @@ static void lcd_adjust_bed_reset()
eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_RIGHT, 0); eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_RIGHT, 0);
eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_FRONT, 0); eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_FRONT, 0);
eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_REAR , 0); eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_REAR , 0);
menuData.adjustBed.status = 0; _menu_data_adjust_bed_t* _md = (_menu_data_adjust_bed_t*)&(menu_data[0]);
_md->status = 0;
} }
void adjust_bed_reset() { void adjust_bed_reset()
{
_menu_data_adjust_bed_t* _md = (_menu_data_adjust_bed_t*)&(menu_data[0]);
eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID, 1); eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID, 1);
eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_LEFT, 0); eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_LEFT, 0);
eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_RIGHT, 0); eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_RIGHT, 0);
eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_FRONT, 0); eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_FRONT, 0);
eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_REAR, 0); eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_REAR, 0);
menuData.adjustBed.left = menuData.adjustBed.left2 = 0; _md->left = _md->left2 = 0;
menuData.adjustBed.right = menuData.adjustBed.right2 = 0; _md->right = _md->right2 = 0;
menuData.adjustBed.front = menuData.adjustBed.front2 = 0; _md->front = _md->front2 = 0;
menuData.adjustBed.rear = menuData.adjustBed.rear2 = 0; _md->rear = _md->rear2 = 0;
} }
#define BED_ADJUSTMENT_UM_MAX 50 #define BED_ADJUSTMENT_UM_MAX 50
static void lcd_adjust_bed() static void lcd_adjust_bed()
{ {
if (menuData.adjustBed.status == 0) { _menu_data_adjust_bed_t* _md = (_menu_data_adjust_bed_t*)&(menu_data[0]);
if (_md->status == 0)
{
// Menu was entered. // Menu was entered.
// Initialize its status. // Initialize its status.
menuData.adjustBed.status = 1; _md->status = 1;
bool valid = false; bool valid = false;
menuData.adjustBed.left = menuData.adjustBed.left2 = eeprom_read_int8((unsigned char*)EEPROM_BED_CORRECTION_LEFT); _md->left = _md->left2 = eeprom_read_int8((unsigned char*)EEPROM_BED_CORRECTION_LEFT);
menuData.adjustBed.right = menuData.adjustBed.right2 = eeprom_read_int8((unsigned char*)EEPROM_BED_CORRECTION_RIGHT); _md->right = _md->right2 = eeprom_read_int8((unsigned char*)EEPROM_BED_CORRECTION_RIGHT);
menuData.adjustBed.front = menuData.adjustBed.front2 = eeprom_read_int8((unsigned char*)EEPROM_BED_CORRECTION_FRONT); _md->front = _md->front2 = eeprom_read_int8((unsigned char*)EEPROM_BED_CORRECTION_FRONT);
menuData.adjustBed.rear = menuData.adjustBed.rear2 = eeprom_read_int8((unsigned char*)EEPROM_BED_CORRECTION_REAR); _md->rear = _md->rear2 = eeprom_read_int8((unsigned char*)EEPROM_BED_CORRECTION_REAR);
if (eeprom_read_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID) == 1 && if (eeprom_read_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID) == 1 &&
menuData.adjustBed.left >= -BED_ADJUSTMENT_UM_MAX && menuData.adjustBed.left <= BED_ADJUSTMENT_UM_MAX && _md->left >= -BED_ADJUSTMENT_UM_MAX && _md->left <= BED_ADJUSTMENT_UM_MAX &&
menuData.adjustBed.right >= -BED_ADJUSTMENT_UM_MAX && menuData.adjustBed.right <= BED_ADJUSTMENT_UM_MAX && _md->right >= -BED_ADJUSTMENT_UM_MAX && _md->right <= BED_ADJUSTMENT_UM_MAX &&
menuData.adjustBed.front >= -BED_ADJUSTMENT_UM_MAX && menuData.adjustBed.front <= BED_ADJUSTMENT_UM_MAX && _md->front >= -BED_ADJUSTMENT_UM_MAX && _md->front <= BED_ADJUSTMENT_UM_MAX &&
menuData.adjustBed.rear >= -BED_ADJUSTMENT_UM_MAX && menuData.adjustBed.rear <= BED_ADJUSTMENT_UM_MAX) _md->rear >= -BED_ADJUSTMENT_UM_MAX && _md->rear <= BED_ADJUSTMENT_UM_MAX)
valid = true; valid = true;
if (! valid) { if (! valid) {
// Reset the values: simulate an edit. // Reset the values: simulate an edit.
menuData.adjustBed.left2 = 0; _md->left2 = 0;
menuData.adjustBed.right2 = 0; _md->right2 = 0;
menuData.adjustBed.front2 = 0; _md->front2 = 0;
menuData.adjustBed.rear2 = 0; _md->rear2 = 0;
} }
lcd_draw_update = 1; lcd_draw_update = 1;
eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID, 1); eeprom_update_byte((unsigned char*)EEPROM_BED_CORRECTION_VALID, 1);
} }
if (menuData.adjustBed.left != menuData.adjustBed.left2) if (_md->left != _md->left2)
eeprom_update_int8((unsigned char*)EEPROM_BED_CORRECTION_LEFT, menuData.adjustBed.left = menuData.adjustBed.left2); eeprom_update_int8((unsigned char*)EEPROM_BED_CORRECTION_LEFT, _md->left = _md->left2);
if (menuData.adjustBed.right != menuData.adjustBed.right2) if (_md->right != _md->right2)
eeprom_update_int8((unsigned char*)EEPROM_BED_CORRECTION_RIGHT, menuData.adjustBed.right = menuData.adjustBed.right2); eeprom_update_int8((unsigned char*)EEPROM_BED_CORRECTION_RIGHT, _md->right = _md->right2);
if (menuData.adjustBed.front != menuData.adjustBed.front2) if (_md->front != _md->front2)
eeprom_update_int8((unsigned char*)EEPROM_BED_CORRECTION_FRONT, menuData.adjustBed.front = menuData.adjustBed.front2); eeprom_update_int8((unsigned char*)EEPROM_BED_CORRECTION_FRONT, _md->front = _md->front2);
if (menuData.adjustBed.rear != menuData.adjustBed.rear2) if (_md->rear != _md->rear2)
eeprom_update_int8((unsigned char*)EEPROM_BED_CORRECTION_REAR, menuData.adjustBed.rear = menuData.adjustBed.rear2); eeprom_update_int8((unsigned char*)EEPROM_BED_CORRECTION_REAR, _md->rear = _md->rear2);
MENU_BEGIN(); MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_SETTINGS)); MENU_ITEM_BACK_P(_T(MSG_SETTINGS));
MENU_ITEM_EDIT_int3_P(_i("Left side [um]"), &menuData.adjustBed.left2, -BED_ADJUSTMENT_UM_MAX, BED_ADJUSTMENT_UM_MAX);////MSG_BED_CORRECTION_LEFT c=14 r=1 MENU_ITEM_EDIT_int3_P(_i("Left side [um]"), &_md->left2, -BED_ADJUSTMENT_UM_MAX, BED_ADJUSTMENT_UM_MAX);////MSG_BED_CORRECTION_LEFT c=14 r=1
MENU_ITEM_EDIT_int3_P(_i("Right side[um]"), &menuData.adjustBed.right2, -BED_ADJUSTMENT_UM_MAX, BED_ADJUSTMENT_UM_MAX);////MSG_BED_CORRECTION_RIGHT c=14 r=1 MENU_ITEM_EDIT_int3_P(_i("Right side[um]"), &_md->right2, -BED_ADJUSTMENT_UM_MAX, BED_ADJUSTMENT_UM_MAX);////MSG_BED_CORRECTION_RIGHT c=14 r=1
MENU_ITEM_EDIT_int3_P(_i("Front side[um]"), &menuData.adjustBed.front2, -BED_ADJUSTMENT_UM_MAX, BED_ADJUSTMENT_UM_MAX);////MSG_BED_CORRECTION_FRONT c=14 r=1 MENU_ITEM_EDIT_int3_P(_i("Front side[um]"), &_md->front2, -BED_ADJUSTMENT_UM_MAX, BED_ADJUSTMENT_UM_MAX);////MSG_BED_CORRECTION_FRONT c=14 r=1
MENU_ITEM_EDIT_int3_P(_i("Rear side [um]"), &menuData.adjustBed.rear2, -BED_ADJUSTMENT_UM_MAX, BED_ADJUSTMENT_UM_MAX);////MSG_BED_CORRECTION_REAR c=14 r=1 MENU_ITEM_EDIT_int3_P(_i("Rear side [um]"), &_md->rear2, -BED_ADJUSTMENT_UM_MAX, BED_ADJUSTMENT_UM_MAX);////MSG_BED_CORRECTION_REAR c=14 r=1
MENU_ITEM_FUNCTION_P(_i("Reset"), lcd_adjust_bed_reset);////MSG_BED_CORRECTION_RESET c=0 r=0 MENU_ITEM_FUNCTION_P(_i("Reset"), lcd_adjust_bed_reset);////MSG_BED_CORRECTION_RESET c=0 r=0
MENU_END(); MENU_END();
} }
@ -2966,7 +3018,7 @@ void pid_extruder() {
} }
} }
/*
void lcd_adjust_z() { void lcd_adjust_z() {
int enc_dif = 0; int enc_dif = 0;
int cursor_pos = 1; int cursor_pos = 1;
@ -3049,7 +3101,7 @@ void lcd_adjust_z() {
lcd_clear(); lcd_clear();
lcd_return_to_status(); lcd_return_to_status();
} }*/
bool lcd_wait_for_pinda(float temp) { bool lcd_wait_for_pinda(float temp) {
lcd_set_custom_characters_degree(); lcd_set_custom_characters_degree();
@ -4733,6 +4785,7 @@ static void lcd_ustep_linearity_menu_save()
} }
#endif //TMC2130 #endif //TMC2130
/*
static void lcd_settings_menu_back() static void lcd_settings_menu_back()
{ {
#ifdef TMC2130 #ifdef TMC2130
@ -4751,7 +4804,7 @@ static void lcd_settings_menu_back()
menu_menu = lcd_main_menu; menu_menu = lcd_main_menu;
// lcd_main_menu(); // lcd_main_menu();
} }
*/
static void lcd_calibration_menu() static void lcd_calibration_menu()
{ {
@ -5733,13 +5786,28 @@ static void lcd_colorprint_change() {
static void lcd_tune_menu() static void lcd_tune_menu()
{ {
if (menuData.tuneMenu.status == 0) { typedef struct
{ // 3bytes total
// To recognize, whether the menu has been just initialized.
int8_t status; // 1byte
// Backup of extrudemultiply, to recognize, that the value has been changed and
// it needs to be applied.
int16_t extrudemultiply; // 2byte
} _menu_data_t;
#if (3 > MENU_DATA_SIZE)
#error "check MENU_DATA_SIZE definition!"
#endif
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
if (_md->status == 0)
{
// Menu was entered. Mark the menu as entered and save the current extrudemultiply value. // Menu was entered. Mark the menu as entered and save the current extrudemultiply value.
menuData.tuneMenu.status = 1; _md->status = 1;
menuData.tuneMenu.extrudemultiply = extrudemultiply; _md->extrudemultiply = extrudemultiply;
} else if (menuData.tuneMenu.extrudemultiply != extrudemultiply) { }
else if (_md->extrudemultiply != extrudemultiply)
{
// extrudemultiply has been changed from the child menu. Apply the new value. // extrudemultiply has been changed from the child menu. Apply the new value.
menuData.tuneMenu.extrudemultiply = extrudemultiply; _md->extrudemultiply = extrudemultiply;
calculate_extruder_multipliers(); calculate_extruder_multipliers();
} }

View File

@ -13,92 +13,6 @@ extern void menu_lcd_longpress_func(void);
extern void menu_lcd_charsetup_func(void); extern void menu_lcd_charsetup_func(void);
extern void menu_lcd_lcdupdate_func(void); extern void menu_lcd_lcdupdate_func(void);
struct EditMenuParentState
{
//prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
menu_func_t prevMenu;
uint16_t prevEncoderPosition;
//Variables used when editing values.
const char* editLabel;
void* editValue;
int32_t minEditValue, maxEditValue;
// menu_func_t callbackFunc;
};
union MenuData
{
struct BabyStep
{
// 29B total
int8_t status;
int babystepMem[3];
float babystepMemMM[3];
} babyStep;
struct SupportMenu
{
// 6B+16B=22B total
int8_t status;
bool is_flash_air;
uint8_t ip[4];
char ip_str[3*4+3+1];
} supportMenu;
struct AdjustBed
{
// 6+13+16=35B
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
int8_t status;
int8_t left;
int8_t right;
int8_t front;
int8_t rear;
int left2;
int right2;
int front2;
int rear2;
} adjustBed;
struct TuneMenu
{
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
// To recognize, whether the menu has been just initialized.
int8_t status;
// Backup of extrudemultiply, to recognize, that the value has been changed and
// it needs to be applied.
int16_t extrudemultiply;
} tuneMenu;
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
struct AutoLoadFilamentMenu
{
//ShortTimer timer;
char dummy;
} autoLoadFilamentMenu;
struct _Lcd_moveMenu
{
bool initialized;
bool endstopsEnabledPrevious;
} _lcd_moveMenu;
struct sdcard_menu_t
{
uint8_t viewState;
} sdcard_menu;
menu_data_edit_t edit_menu;
};
// State of the currently active menu.
// C Union manages sharing of the static memory by all the menus.
extern union MenuData menuData;
// Call with a false parameter to suppress the LCD update from various places like the planner or the temp control. // Call with a false parameter to suppress the LCD update from various places like the planner or the temp control.
void ultralcd_init(); void ultralcd_init();
void lcd_setstatus(const char* message); void lcd_setstatus(const char* message);
@ -225,8 +139,6 @@ void lcd_temp_cal_show_result(bool result);
bool lcd_wait_for_pinda(float temp); bool lcd_wait_for_pinda(float temp);
union MenuData;
void bowden_menu(); void bowden_menu();
char reset_menu(); char reset_menu();
char choose_extruder_menu(); char choose_extruder_menu();