New ML support - menu tunning, startup

+config headers (bool - true/false replaced with 0/1)
+fixed include hierarchy
+removed comments
This commit is contained in:
Robert Pelnar 2018-06-10 16:04:32 +02:00
parent f098707021
commit fcfb4cdcae
9 changed files with 113 additions and 95 deletions

View File

@ -402,9 +402,9 @@ your extruder heater takes 2 minutes to hit the target on heating.
// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of the endstop.
#define X_MAX_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_INVERTING 1 // set to 1 to invert the logic of the endstop.
//#define DISABLE_MAX_ENDSTOPS
//#define DISABLE_MIN_ENDSTOPS
@ -420,11 +420,11 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
#define E_ENABLE_ON 0 // For all extruders
// Disables axis when it's not being used.
#define DISABLE_X false
#define DISABLE_Y false
#define DISABLE_Z false
#define DISABLE_E false // For all extruders
#define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled
#define DISABLE_X 0
#define DISABLE_Y 0
#define DISABLE_Z 0
#define DISABLE_E 0// For all extruders
#define DISABLE_INACTIVE_EXTRUDER 1 //disable only inactive extruders and keep active extruder enabled
// ENDSTOP SETTINGS:
@ -434,11 +434,11 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
#define Z_HOME_DIR -1
#ifdef DEBUG_DISABLE_SWLIMITS
#define min_software_endstops false
#define max_software_endstops false
#define min_software_endstops 0
#define max_software_endstops 0
#else
#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops true // If true, axis won't move to coordinates greater than the defined lengths below.
#define min_software_endstops 1 // If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops 1 // If true, axis won't move to coordinates greater than the defined lengths below.
#endif //DEBUG_DISABLE_SWLIMITS

View File

@ -143,7 +143,7 @@
//#define Y_DUAL_STEPPER_DRIVERS
// Define if the two Y drives need to rotate in opposite directions
#define INVERT_Y2_VS_Y_DIR true
#define INVERT_Y2_VS_Y_DIR 1
#ifdef Y_DUAL_STEPPER_DRIVERS
#undef EXTRUDERS
@ -160,13 +160,13 @@
#define Z_HOME_RETRACT_MM 2
//#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
#define AXIS_RELATIVE_MODES {false, false, false, false}
#define AXIS_RELATIVE_MODES {0, 0, 0, 0}
#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step). Toshiba steppers are 4x slower, but Prusa3D does not use those.
//By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step.
#define INVERT_X_STEP_PIN false
#define INVERT_Y_STEP_PIN false
#define INVERT_Z_STEP_PIN false
#define INVERT_E_STEP_PIN false
#define INVERT_X_STEP_PIN 0
#define INVERT_Y_STEP_PIN 0
#define INVERT_Z_STEP_PIN 0
#define INVERT_E_STEP_PIN 0
//default stepper release if idle
#define DEFAULT_STEPPER_DEACTIVE_TIME 60
@ -206,7 +206,7 @@
//#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
#define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
#define SD_FINISHED_STEPPERRELEASE true //if sd support and the file is finished: disable steppers?
#define SD_FINISHED_STEPPERRELEASE 1 //if sd support and the file is finished: disable steppers?
#define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
#define SDCARD_RATHERRECENTFIRST //reverse file order of sd card menu display. Its sorted practically after the file system block order.
@ -241,7 +241,7 @@
// SD Card Sorting options
// In current firmware Prusa Firmware version,
// SDSORT_CACHE_NAMES and SDSORT_DYNAMIC_RAM is not supported and must be set to false.
// SDSORT_CACHE_NAMES and SDSORT_DYNAMIC_RAM is not supported and must be set to 0.
#ifdef SDCARD_SORT_ALPHA
#define SD_SORT_TIME 0
#define SD_SORT_ALPHA 1
@ -249,11 +249,11 @@
#define SDSORT_LIMIT 100 // Maximum number of sorted items (10-256).
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
#define SDSORT_GCODE 0 // Allow turning sorting on/off with LCD and M34 g-code.
#define SDSORT_USES_RAM 0 // Pre-allocate a static array for faster pre-sorting.
#define SDSORT_USES_STACK 0 // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
#define SDSORT_CACHE_NAMES 0 // Keep sorted items in RAM longer for speedy performance. Most expensive option.
#define SDSORT_DYNAMIC_RAM 0 // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
#endif
#if defined(SDCARD_SORT_ALPHA)
@ -283,7 +283,7 @@
#define BABYSTEPPING
#ifdef BABYSTEPPING
#define BABYSTEP_XY //not only z, but also XY in the menu. more clutter, more functions
#define BABYSTEP_INVERT_Z false //true for inverse movements in Z
#define BABYSTEP_INVERT_Z 0 //1 for inverse movements in Z
#define BABYSTEP_Z_MULTIPLICATOR 2 //faster z movements
#ifdef COREXY

View File

@ -616,7 +616,6 @@ void servo_init()
#endif
}
static void lcd_language_menu();
void stop_and_save_print_to_ram(float z_move, float e_move);
void restore_print_from_ram_and_continue(float e_move);
@ -760,7 +759,7 @@ void factory_reset(char level, bool quiet)
WRITE(BEEPER, HIGH);
_delay_ms(100);
WRITE(BEEPER, LOW);
eeprom_update_byte((unsigned char*)EEPROM_LANG, LANG_ID_FORCE_SELECTION);
lang_reset();
break;
//Level 1: Reset statistics
@ -791,12 +790,11 @@ void factory_reset(char level, bool quiet)
//lcd_print_at_PGM(1,2,PSTR("Shipping prep"));
// Force language selection at the next boot up.
eeprom_update_byte((unsigned char*)EEPROM_LANG, LANG_ID_FORCE_SELECTION);
lang_reset();
// Force the "Follow calibration flow" message at the next boot up.
calibration_status_store(CALIBRATION_STATUS_Z_CALIBRATION);
eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 1); //run wizard
farm_no = 0;
//*** MaR::180501_01
farm_mode = false;
eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode);
EEPROM_save_B(EEPROM_FARM_NUMBER, &farm_no);
@ -992,12 +990,12 @@ void erase_eeprom_section(uint16_t offset, uint16_t bytes)
for (int i = offset; i < (offset+bytes); i++) eeprom_write_byte((uint8_t*)i, 0xFF);
}
#include "bootapp.h"
#ifdef W25X20CL
// language upgrade from external flash
#include "bootapp.h" //bootloader support
// language update from external flash
#define LANGBOOT_BLOCKSIZE 0x1000
#define LANGBOOT_RAMBUFFER 0x0800
@ -1095,15 +1093,16 @@ void setup()
lcd_splash();
#ifdef W25X20CL
if (w25x20cl_init())
update_sec_lang_from_external_flash();
else
kill(_i("External SPI flash W25X20CL not responding."));
#endif //W25X20CL
setup_killpin();
setup_powerhold();
//*** MaR::180501_02b
farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE);
EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no);
if ((farm_mode == 0xFF && farm_no == 0) || ((uint16_t)farm_no == 0xFFFF))
@ -1389,7 +1388,6 @@ void setup()
#if defined(Z_AXIS_ALWAYS_ON)
enable_z();
#endif
//*** MaR::180501_02
farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE);
EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no);
if ((farm_mode == 0xFF && farm_no == 0) || (farm_no == 0xFFFF)) farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode
@ -1495,7 +1493,9 @@ void setup()
list_sec_lang_from_external_flash();
#endif //DEBUG_W25X20CL
lang_select(eeprom_read_byte((uint8_t*)EEPROM_LANG));
// lang_reset();
if (!lang_select(eeprom_read_byte((uint8_t*)EEPROM_LANG)))
lcd_language();
#ifdef DEBUG_SEC_LANG
@ -3229,7 +3229,7 @@ void process_commands()
SERIAL_PROTOCOLLN(FILAMENT_SIZE "-" ELECTRONICS "-" NOZZLE_TYPE );
} else if(code_seen("Lang")) {
eeprom_update_byte((unsigned char*)EEPROM_LANG, LANG_ID_FORCE_SELECTION);
lang_reset();
} else if(code_seen("Lz")) {
EEPROM_save_B(EEPROM_BABYSTEP_Z,0);
@ -6017,7 +6017,7 @@ Sigma_Exit:
break;
case 509: //M509 Force language selection
{
eeprom_update_byte((unsigned char*)EEPROM_LANG, LANG_ID_FORCE_SELECTION);
lang_reset();
SERIAL_ECHO_START;
SERIAL_PROTOCOLPGM(("LANG SEL FORCED"));
}

View File

@ -1,8 +1,10 @@
//language.c
#include "language.h"
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include "bootapp.h"
#include "Configuration.h"
#ifdef W25X20CL
#include "w25x20cl.h"
@ -44,34 +46,32 @@ uint8_t lang_select(uint8_t lang)
if (lang == LANG_ID_PRI) //primary language
{
lang_table = 0;
lang_selected = 0;
return 1;
lang_selected = lang;
}
#ifdef W25X20CL
if (lang_get_code(lang) == lang_get_code(LANG_ID_SEC)) lang = LANG_ID_SEC;
if (lang == LANG_ID_SEC) //current secondary language
{
uint16_t ui = _SEC_LANG_TABLE; //table pointer
if (pgm_read_dword(((uint32_t*)(ui + 0))) != LANG_MAGIC) return 0; //magic not valid
lang_table = ui; // set table pointer
lang_selected = 1; // set language id
return 1;
if (pgm_read_dword(((uint32_t*)_SEC_LANG_TABLE)) == LANG_MAGIC) //magic valid
{
lang_table = _SEC_LANG_TABLE; // set table pointer
lang_selected = lang; // set language id
}
}
#else //W25X20CL
#endif //W25X20CL
/*
uint16_t ui = (uint16_t)&_SEC_LANG; //pointer to _SEC_LANG reserved space
ui += 0x00ff; //add 1 page
ui &= 0xff00; //align to page
lang_table = ui; //set table pointer
ui = pgm_read_word(((uint16_t*)(((char*)lang_table + 16)))); //read relative offset of first string (language name)
return (const char*)((char*)lang_table + ui); //return calculated pointer
*/
if (lang_selected == lang)
{
eeprom_update_byte((unsigned char*)EEPROM_LANG, lang_selected);
return 1;
}
return 0;
}
uint8_t lang_get_count()
{
#ifdef W25X20CL
W25X20CL_SPI_ENTER();
uint8_t count = 2; //count = 1+n (primary + secondary + all in xflash)
uint32_t addr = 0x00000; //start of xflash
lang_table_header_t header; //table header structure
@ -98,11 +98,11 @@ uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* off
if (offset) *offset = ui;
return (header == LANG_MAGIC)?1:0; //return 1 if magic valid
}
W25X20CL_SPI_ENTER();
uint32_t addr = 0x00000; //start of xflash
lang--;
while (1)
{
W25X20CL_SPI_ENTER();
w25x20cl_rd_data(addr, header, sizeof(lang_table_header_t)); //read table header from xflash
if (header->magic != LANG_MAGIC) break; //break if not valid
if (offset) *offset = addr;
@ -124,6 +124,7 @@ uint16_t lang_get_code(uint8_t lang)
if (pgm_read_dword(((uint32_t*)(ui + 0))) != LANG_MAGIC) return LANG_CODE_XX; //magic not valid
return pgm_read_word(((uint32_t*)(ui + 10))); //return lang code from progmem
}
W25X20CL_SPI_ENTER();
uint32_t addr = 0x00000; //start of xflash
lang_table_header_t header; //table header structure
lang--;
@ -160,6 +161,18 @@ const char* lang_get_name_by_code(uint16_t code)
return _n("??");
}
void lang_reset(void)
{
lang_selected = 0;
eeprom_update_byte((unsigned char*)EEPROM_LANG, LANG_ID_FORCE_SELECTION);
}
uint8_t lang_is_selected(void)
{
uint8_t lang_eeprom = eeprom_read_byte((unsigned char*)EEPROM_LANG);
return (lang_eeprom != LANG_ID_FORCE_SELECTION) && (lang_eeprom == lang_selected);
}
#ifdef DEBUG_SEC_LANG
const char* lang_get_sec_lang_str_by_id(uint16_t id)
{

View File

@ -100,14 +100,20 @@ extern const char* lang_get_translation(const char* s);
#define _SEC_LANG_TABLE ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00)
#endif //(LANG_MODE != 0)
//selects
//selects language, eeprom is updated in case of success
extern uint8_t lang_select(uint8_t lang);
//get total number of languages (primary + all in xflash)
extern uint8_t lang_get_count();
//returns total number of languages (primary + all in xflash)
extern uint8_t lang_get_count(void);
//reads lang table header and offset in xflash or progmem
extern uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* offset);
//reads lang code from xflash or progmem
extern uint16_t lang_get_code(uint8_t lang);
//returns localized language name (text for menu item)
extern const char* lang_get_name_by_code(uint16_t code);
//reset language to "LANG_ID_FORCE_SELECTION", epprom is updated
extern void lang_reset(void);
//returns 1 if language is selected
extern uint8_t lang_is_selected(void);
#ifdef DEBUG_SEC_LANG
extern const char* lang_get_sec_lang_str_by_id(uint16_t id);

View File

@ -1457,7 +1457,6 @@ void digitalPotWrite(int address, int value) // From Arduino DigitalPotControl e
#endif
}
//*** MaR::180416_03
void EEPROM_read_st(int pos, uint8_t* value, uint8_t size)
{
do

View File

@ -1,7 +1,8 @@
#ifndef THERMISTORTABLES_H_
#define THERMISTORTABLES_H_
#include "Marlin.h"
#include "Configuration_adv.h"
#include <avr/pgmspace.h>
#define OVERSAMPLENR 16

View File

@ -214,7 +214,6 @@ static void lcd_prepare_menu();
//static void lcd_move_menu();
static void lcd_settings_menu();
static void lcd_calibration_menu();
static void lcd_language_menu();
static void lcd_control_temperature_menu();
static void lcd_control_temperature_preheat_pla_settings_menu();
static void lcd_control_temperature_preheat_abs_settings_menu();
@ -3680,22 +3679,6 @@ static void lcd_crash_mode_set()
#endif //TMC2130
static void lcd_set_lang(unsigned char lang)
{
if (lang > LANG_ID_SEC)
{
if (!lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Copy selected language from XFLASH?"), false, true))
{
lcd_return_to_status();
lcd_update_enable(true);
return;
}
lang_boot_update_start(lang);
}
if (lang_select(lang))
eeprom_update_byte((unsigned char*)EEPROM_LANG, lang);
}
#ifdef PAT9125
static void lcd_fsensor_state_set()
{
@ -3727,13 +3710,10 @@ void lcd_set_progress() {
static void lcd_language_menu()
{
START_MENU();
// if (langsel == LANGSEL_OFF)
// MENU_ITEM(back, _T(MSG_SETTINGS), 0);
// else if (langsel == LANGSEL_ACTIVE)
MENU_ITEM(back, _T(MSG_WATCH), 0);
if (lang_is_selected()) MENU_ITEM(back, _T(MSG_SETTINGS), 0);
MENU_ITEM(setlang, lang_get_name_by_code(lang_get_code(0)), 0);
// MENU_ITEM(setlang, lang_get_name_by_code(lang_get_code(1)), 1);
for (int i = 2; i < lang_get_count(); i++) //skip seconday language - solved in menu_action_setlang
for (int i = 2; i < lang_get_count(); i++) //skip seconday language - solved in lang_select
MENU_ITEM(setlang, lang_get_name_by_code(lang_get_code(i)), i);
END_MENU();
}
@ -3929,6 +3909,26 @@ void lcd_wizard() {
}
}
void lcd_language()
{
lcd_update_enable(true);
lcd_implementation_clear();
lcd_goto_menu(lcd_language_menu);
lcd_timeoutToStatus = -1; //infinite timeout
lcdDrawUpdate = 2;
while ((currentMenu != lcd_status_screen) && (!lang_is_selected()))
{
delay(50);
lcd_update();
manage_heater();
manage_inactivity(true);
}
if (lang_is_selected())
lcd_return_to_status();
else
lang_select(LANG_ID_PRI);
}
void lcd_wizard(int state) {
bool end = false;
@ -4167,7 +4167,6 @@ static void lcd_settings_menu()
#ifdef TMC2130
if(!farm_mode)
{
//*** MaR::180416_01a
if (SilentModeMenu == SILENT_MODE_NORMAL) MENU_ITEM(function, _T(MSG_STEALTH_MODE_OFF), lcd_silent_mode_set);
else MENU_ITEM(function, _T(MSG_STEALTH_MODE_ON), lcd_silent_mode_set);
if (SilentModeMenu == SILENT_MODE_NORMAL)
@ -5725,7 +5724,6 @@ static void lcd_tune_menu()
#ifdef TMC2130
if(!farm_mode)
{
//*** MaR::180416_01b
if (SilentModeMenu == SILENT_MODE_NORMAL) MENU_ITEM(function, _T(MSG_STEALTH_MODE_OFF), lcd_silent_mode_set);
else MENU_ITEM(function, _T(MSG_STEALTH_MODE_ON), lcd_silent_mode_set);
@ -6551,7 +6549,6 @@ static bool lcd_selfcheck_pulleys(int axis)
st_current_set(0, 850); //set motor current higher
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], 200, active_extruder);
st_synchronize();
//*** MaR::180416_02
if (SilentModeMenu != SILENT_MODE_OFF) st_current_set(0, tmp_motor[0]); //set back to normal operation currents
else st_current_set(0, tmp_motor_loud[0]); //set motor current back
current_position[axis] = current_position[axis] - move;
@ -7118,18 +7115,16 @@ static void menu_action_gcode(const char* pgcode) {
static void menu_action_setlang(unsigned char lang)
{
if (lang <= LANG_ID_SEC)
if (!lang_select(lang))
{
lcd_set_lang(lang);
return;
if (lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Copy selected language from XFLASH?"), false, true))
lang_boot_update_start(lang);
lcd_update_enable(true);
lcd_implementation_clear();
lcd_goto_menu(lcd_language_menu);
lcd_timeoutToStatus = -1; //infinite timeout
lcdDrawUpdate = 2;
}
uint16_t code = lang_get_code(lang);
if (code == lang_get_code(1))
{
lcd_set_lang(1);
return;
}
lcd_set_lang(lang);
}
static void menu_action_function(menuFunc_t data) {

View File

@ -6,6 +6,8 @@
#ifdef ULTRA_LCD
static void lcd_language_menu();
void lcd_update(uint8_t lcdDrawUpdateOverride = 0);
// Call with a false parameter to suppress the LCD update from various places like the planner or the temp control.
void lcd_update_enable(bool enable);
@ -299,6 +301,8 @@ void display_loading();
void lcd_set_progress();
#endif
void lcd_language();
void lcd_wizard();
void lcd_wizard(int state);