Merge pull request #151 from PavelSindler/MK2
improved scrolling in SD card menu, storing to eeprom via M500 improved and uses different eeprom version for multi material
This commit is contained in:
commit
b5039351be
|
|
@ -5,7 +5,7 @@
|
||||||
#include "Configuration_prusa.h"
|
#include "Configuration_prusa.h"
|
||||||
|
|
||||||
// Firmware version
|
// Firmware version
|
||||||
#define FW_version "3.0.12"
|
#define FW_version "3.0.12-1"
|
||||||
|
|
||||||
#define FW_PRUSA3D_MAGIC "PRUSA3DFW"
|
#define FW_PRUSA3D_MAGIC "PRUSA3DFW"
|
||||||
#define FW_PRUSA3D_MAGIC_LEN 10
|
#define FW_PRUSA3D_MAGIC_LEN 10
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,13 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
|
||||||
// wrong data being written to the variables.
|
// wrong data being written to the variables.
|
||||||
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
|
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
|
||||||
|
|
||||||
#define EEPROM_VERSION "V1"
|
#ifdef SNMM
|
||||||
|
#define EEPROM_VERSION "M1"
|
||||||
|
#else
|
||||||
|
#define EEPROM_VERSION "V1"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef EEPROM_SETTINGS
|
#ifdef EEPROM_SETTINGS
|
||||||
void Config_StoreSettings()
|
void Config_StoreSettings()
|
||||||
|
|
@ -264,13 +270,15 @@ void Config_PrintSettings()
|
||||||
|
|
||||||
|
|
||||||
#ifdef EEPROM_SETTINGS
|
#ifdef EEPROM_SETTINGS
|
||||||
void Config_RetrieveSettings()
|
bool Config_RetrieveSettings()
|
||||||
{
|
{
|
||||||
int i=EEPROM_OFFSET;
|
int i=EEPROM_OFFSET;
|
||||||
|
bool previous_settings_retrieved = true;
|
||||||
char stored_ver[4];
|
char stored_ver[4];
|
||||||
char ver[4]=EEPROM_VERSION;
|
char ver[4]=EEPROM_VERSION;
|
||||||
EEPROM_READ_VAR(i,stored_ver); //read stored version
|
EEPROM_READ_VAR(i,stored_ver); //read stored version
|
||||||
// SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
|
|
||||||
|
// SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
|
||||||
if (strncmp(ver,stored_ver,3) == 0)
|
if (strncmp(ver,stored_ver,3) == 0)
|
||||||
{
|
{
|
||||||
// version number match
|
// version number match
|
||||||
|
|
@ -350,19 +358,26 @@ void Config_RetrieveSettings()
|
||||||
calculate_volumetric_multipliers();
|
calculate_volumetric_multipliers();
|
||||||
// Call updatePID (similar to when we have processed M301)
|
// Call updatePID (similar to when we have processed M301)
|
||||||
updatePID();
|
updatePID();
|
||||||
float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
|
|
||||||
axis_steps_per_unit[3] = tmp1[3];
|
|
||||||
|
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
SERIAL_ECHOLNPGM("Stored settings retrieved");
|
SERIAL_ECHOLNPGM("Stored settings retrieved");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Config_ResetDefault();
|
Config_ResetDefault();
|
||||||
|
|
||||||
|
//Return false to inform user that eeprom version was changed and firmware is using default hardcoded settings now.
|
||||||
|
//In case that storing to eeprom was not used yet, do not inform user that hardcoded settings are used.
|
||||||
|
if (eeprom_read_byte((uint8_t *)EEPROM_OFFSET) != 0xFF ||
|
||||||
|
eeprom_read_byte((uint8_t *)EEPROM_OFFSET + 1) != 0xFF ||
|
||||||
|
eeprom_read_byte((uint8_t *)EEPROM_OFFSET + 2) != 0xFF) {
|
||||||
|
previous_settings_retrieved = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef EEPROM_CHITCHAT
|
#ifdef EEPROM_CHITCHAT
|
||||||
Config_PrintSettings();
|
Config_PrintSettings();
|
||||||
#endif
|
#endif
|
||||||
|
return previous_settings_retrieved;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ FORCE_INLINE void Config_PrintSettings() {}
|
||||||
|
|
||||||
#ifdef EEPROM_SETTINGS
|
#ifdef EEPROM_SETTINGS
|
||||||
void Config_StoreSettings();
|
void Config_StoreSettings();
|
||||||
void Config_RetrieveSettings();
|
bool Config_RetrieveSettings();
|
||||||
#else
|
#else
|
||||||
FORCE_INLINE void Config_StoreSettings() {}
|
FORCE_INLINE void Config_StoreSettings() {}
|
||||||
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
|
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
|
||||||
|
|
|
||||||
|
|
@ -1045,7 +1045,7 @@ void setup()
|
||||||
SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
|
SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
|
||||||
lcd_update_enable(false);
|
lcd_update_enable(false);
|
||||||
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
|
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
|
||||||
Config_RetrieveSettings();
|
bool previous_settings_retrieved = Config_RetrieveSettings();
|
||||||
SdFatUtil::set_stack_guard(); //writes magic number at the end of static variables to protect against overwriting static memory by stack
|
SdFatUtil::set_stack_guard(); //writes magic number at the end of static variables to protect against overwriting static memory by stack
|
||||||
tp_init(); // Initialize temperature loop
|
tp_init(); // Initialize temperature loop
|
||||||
plan_init(); // Initialize planner;
|
plan_init(); // Initialize planner;
|
||||||
|
|
@ -1209,6 +1209,12 @@ void setup()
|
||||||
lcd_show_fullscreen_message_and_wait_P(MSG_FOLLOW_CALIBRATION_FLOW);
|
lcd_show_fullscreen_message_and_wait_P(MSG_FOLLOW_CALIBRATION_FLOW);
|
||||||
}
|
}
|
||||||
for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]);
|
for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]);
|
||||||
|
|
||||||
|
//If eeprom version for storing parameters to eeprom using M500 changed, default settings are used. Inform user in this case
|
||||||
|
if (!previous_settings_retrieved) {
|
||||||
|
lcd_show_fullscreen_message_and_wait_P(MSG_DEFAULT_SETTINGS_LOADED);
|
||||||
|
}
|
||||||
|
|
||||||
lcd_update_enable(true);
|
lcd_update_enable(true);
|
||||||
|
|
||||||
// Store the currently running firmware into an eeprom,
|
// Store the currently running firmware into an eeprom,
|
||||||
|
|
@ -4950,10 +4956,6 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 500: // M500 Store settings in EEPROM
|
case 500: // M500 Store settings in EEPROM
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -775,6 +775,11 @@ const char * const MSG_DATE_LANG_TABLE[LANG_NUM] PROGMEM = {
|
||||||
MSG_DATE_DE
|
MSG_DATE_DE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char MSG_DEFAULT_SETTINGS_LOADED_EN[] PROGMEM = "Default settings loaded";
|
||||||
|
const char * const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[1] PROGMEM = {
|
||||||
|
MSG_DEFAULT_SETTINGS_LOADED_EN
|
||||||
|
};
|
||||||
|
|
||||||
const char MSG_DISABLE_STEPPERS_EN[] PROGMEM = "Disable steppers";
|
const char MSG_DISABLE_STEPPERS_EN[] PROGMEM = "Disable steppers";
|
||||||
const char MSG_DISABLE_STEPPERS_CZ[] PROGMEM = "Vypnout motory";
|
const char MSG_DISABLE_STEPPERS_CZ[] PROGMEM = "Vypnout motory";
|
||||||
const char MSG_DISABLE_STEPPERS_IT[] PROGMEM = "Disabilit motori";
|
const char MSG_DISABLE_STEPPERS_IT[] PROGMEM = "Disabilit motori";
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,8 @@ extern const char* const MSG_CURRENT_LANG_TABLE[LANG_NUM];
|
||||||
#define MSG_CURRENT LANG_TABLE_SELECT(MSG_CURRENT_LANG_TABLE)
|
#define MSG_CURRENT LANG_TABLE_SELECT(MSG_CURRENT_LANG_TABLE)
|
||||||
extern const char* const MSG_DATE_LANG_TABLE[LANG_NUM];
|
extern const char* const MSG_DATE_LANG_TABLE[LANG_NUM];
|
||||||
#define MSG_DATE LANG_TABLE_SELECT(MSG_DATE_LANG_TABLE)
|
#define MSG_DATE LANG_TABLE_SELECT(MSG_DATE_LANG_TABLE)
|
||||||
|
extern const char* const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[1];
|
||||||
|
#define MSG_DEFAULT_SETTINGS_LOADED LANG_TABLE_SELECT_EXPLICIT(MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE, 0)
|
||||||
extern const char* const MSG_DISABLE_STEPPERS_LANG_TABLE[LANG_NUM];
|
extern const char* const MSG_DISABLE_STEPPERS_LANG_TABLE[LANG_NUM];
|
||||||
#define MSG_DISABLE_STEPPERS LANG_TABLE_SELECT(MSG_DISABLE_STEPPERS_LANG_TABLE)
|
#define MSG_DISABLE_STEPPERS LANG_TABLE_SELECT(MSG_DISABLE_STEPPERS_LANG_TABLE)
|
||||||
extern const char* const MSG_DWELL_LANG_TABLE[LANG_NUM];
|
extern const char* const MSG_DWELL_LANG_TABLE[LANG_NUM];
|
||||||
|
|
|
||||||
|
|
@ -310,4 +310,5 @@
|
||||||
#define(length=12, lines=1) MSG_RIGHT "Right:"
|
#define(length=12, lines=1) MSG_RIGHT "Right:"
|
||||||
#define(length=15, lines=1) MSG_MEASURED_SKEW "Measured skew:"
|
#define(length=15, lines=1) MSG_MEASURED_SKEW "Measured skew:"
|
||||||
#define(length=15, lines=1) MSG_SLIGHT_SKEW "Slight skew:"
|
#define(length=15, lines=1) MSG_SLIGHT_SKEW "Slight skew:"
|
||||||
#define(length=15, lines=1) MSG_SEVERE_SKEW "Severe skew:"
|
#define(length=15, lines=1) MSG_SEVERE_SKEW "Severe skew:"
|
||||||
|
#define(length=20, lines=4) MSG_DEFAULT_SETTINGS_LOADED "Default settings loaded"
|
||||||
|
|
@ -1182,33 +1182,34 @@ static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char*
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int inter = 0;
|
|
||||||
char* longFilenameTMP = longFilename;
|
char* longFilenameTMP = longFilename;
|
||||||
|
|
||||||
while( ((c = *longFilenameTMP) != '\0') && (inter == 0) )
|
while((c = *longFilenameTMP) != '\0')
|
||||||
{
|
{
|
||||||
|
|
||||||
lcd.setCursor(i, row);
|
lcd.setCursor(i, row);
|
||||||
lcd.print(c);
|
lcd.print(c);
|
||||||
i++;
|
i++;
|
||||||
longFilenameTMP++;
|
longFilenameTMP++;
|
||||||
if(i==LCD_WIDTH){
|
if(i==LCD_WIDTH) {
|
||||||
i=1;
|
i=1;
|
||||||
j++;
|
j++;
|
||||||
longFilenameTMP = longFilename;
|
longFilenameTMP = longFilename + j;
|
||||||
longFilenameTMP = longFilenameTMP+j;
|
|
||||||
n = LCD_WIDTH - 1;
|
n = LCD_WIDTH - 1;
|
||||||
for(int g = 0; ((g<300)&&(inter == 0)) ;g++){
|
for(int g = 0; g<300 ;g++){
|
||||||
if(LCD_CLICKED || ( enc_dif != encoderDiff )){
|
if(LCD_CLICKED || ( enc_dif != encoderDiff )){
|
||||||
|
longFilenameTMP = longFilename;
|
||||||
// inter = 1;
|
*(longFilenameTMP + LCD_WIDTH - 2) = '\0';
|
||||||
|
int i = 1;
|
||||||
|
int j = 0;
|
||||||
|
break;
|
||||||
}else{
|
}else{
|
||||||
delay(1);
|
if (j == 1) delay(3); //wait around 1.2 s to start scrolling text
|
||||||
|
delay(1); //then scroll with redrawing every 300 ms
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(c!='\0'){
|
if(c!='\0'){
|
||||||
lcd.setCursor(i, row);
|
lcd.setCursor(i, row);
|
||||||
|
|
@ -1217,7 +1218,7 @@ static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char*
|
||||||
}
|
}
|
||||||
n=n-i+1;
|
n=n-i+1;
|
||||||
while(n--)
|
while(n--)
|
||||||
lcd.print(' ');
|
lcd.print(' ');
|
||||||
}
|
}
|
||||||
static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename)
|
static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue