Commit d3046f1a authored by MagoKimbra's avatar MagoKimbra

Add LCD menu Configuration + BAUDRATE

Add LCD menu Configuration
Add LCD configuration Baudrate
parent 27cbf4f3
......@@ -13,7 +13,7 @@
#define SERIAL_PORT 0
// This determines the communication speed of the printer
#define BAUDRATE 115000
#define BAUDRATE 115200
//#define BAUDRATE 250000
// This enables the serial port associated to the Bluetooth interface
......
......@@ -52,6 +52,7 @@ void Config_StoreSettings()
char ver[4]= "000";
int i=EEPROM_OFFSET;
EEPROM_WRITE_VAR(i,ver); // invalidate data first
EEPROM_WRITE_VAR(i,baudrate);
EEPROM_WRITE_VAR(i,axis_steps_per_unit);
EEPROM_WRITE_VAR(i,max_feedrate);
EEPROM_WRITE_VAR(i,max_retraction_feedrate);
......@@ -121,6 +122,8 @@ void Config_StoreSettings()
void Config_PrintSettings()
{ // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
SERIAL_ECHO_START;
SERIAL_ECHOPAIR("Baudrate: ", baudrate);
SERIAL_ECHOLN("");
SERIAL_ECHOLNPGM("Steps per unit:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[0]);
......@@ -262,6 +265,7 @@ void Config_RetrieveSettings()
if (strncmp(ver,stored_ver,3) == 0)
{
// version number match
EEPROM_READ_VAR(i,baudrate);
EEPROM_READ_VAR(i,axis_steps_per_unit);
EEPROM_READ_VAR(i,max_feedrate);
EEPROM_READ_VAR(i,max_retraction_feedrate);
......@@ -338,6 +342,9 @@ void Config_RetrieveSettings()
void Config_ResetDefault()
{
//Setting default baudrate for serial
baudrate=BAUDRATE;
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
float tmp2[]=DEFAULT_MAX_FEEDRATE;
float tmp3[]=DEFAULT_RETRACTION_MAX_FEEDRATE;
......
......@@ -142,13 +142,13 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
// these are the offsets to the probe relative to the extruder tip (Hotend - Probe)
#define X_PROBE_OFFSET_FROM_EXTRUDER 0
#define Y_PROBE_OFFSET_FROM_EXTRUDER 20
#define Z_PROBE_OFFSET_FROM_EXTRUDER -3.35
#define Z_PROBE_OFFSET_FROM_EXTRUDER -2.95
#define Z_RAISE_BEFORE_HOMING 10 // (in mm) Raise Z before homing (G28) for Probe Clearance.
// Be sure you have this distance over your Z_MAX_POS in case
#define Z_RAISE_BEFORE_PROBING 10 //How much the extruder will be raised before traveling to the first probing point.
#define Z_RAISE_BETWEEN_PROBINGS 4 //How much the extruder will be raised when traveling from between next probing points
#define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when traveling from between next probing points
//#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
//#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.
......
......@@ -231,6 +231,7 @@ void setPwmFrequency(uint8_t pin, int val);
#define CRITICAL_SECTION_END SREG = _sreg;
#endif //CRITICAL_SECTION_START
extern unsigned long baudrate;
extern float homing_feedrate[];
extern bool axis_relative_modes[];
extern int feedmultiply;
......
......@@ -206,6 +206,8 @@
//===========================================================================
//=============================public variables=============================
//===========================================================================
unsigned long baudrate;
#ifdef SDSUPPORT
CardReader card;
#endif
......@@ -619,8 +621,11 @@ void setup()
setup_pausepin();
#endif
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
Config_RetrieveSettings();
setup_powerhold();
MYSERIAL.begin(BAUDRATE);
MYSERIAL.begin(baudrate);
SERIAL_PROTOCOLLNPGM("start");
SERIAL_ECHO_START;
......@@ -656,9 +661,6 @@ void setup()
fromsd[i] = false;
}
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
Config_RetrieveSettings();
tp_init(); // Initialize temperature loop
plan_init(); // Initialize planner;
watchdog_init();
......
......@@ -283,6 +283,8 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -413,6 +415,8 @@
#define MSG_ENDSTOP_ABORT "Blad wyl. kranc."
#define MSG_CONTRAST "Kontrast"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -543,6 +547,8 @@
#define MSG_ENDSTOP_ABORT "Butee abandon"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -674,6 +680,8 @@
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -810,6 +818,8 @@
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -938,6 +948,8 @@
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -1078,6 +1090,8 @@
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -1211,6 +1225,8 @@
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -1338,6 +1354,8 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -1472,6 +1490,8 @@
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_CONTRAST "Contrast"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -1597,6 +1617,8 @@
#define MSG_BABYSTEP_Z "Babystap Z"
#define MSG_ENDSTOP_ABORT "Endstop afbr."
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -1723,6 +1745,8 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......@@ -1848,6 +1872,8 @@
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop deuseztat"
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#endif
......
......@@ -23,6 +23,9 @@ int gumPreheatHotendTemp;
int gumPreheatHPBTemp;
int gumPreheatFanSpeed;
const long baudrates[] = {9600,14400,19200,28800,38400,56000,115200,250000};
int baudrate_position = -1;
#ifdef ULTIPANEL
static float manual_feedrate[] = MANUAL_FEEDRATE;
#endif // ULTIPANEL
......@@ -55,6 +58,7 @@ static void lcd_tune_menu();
static void lcd_prepare_menu();
static void lcd_move_menu();
static void lcd_control_menu();
static void lcd_config_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();
......@@ -299,6 +303,7 @@ static void lcd_main_menu()
#endif
}
#endif
MENU_ITEM(submenu, MSG_CONFIG, lcd_config_menu);
END_MENU();
}
......@@ -922,6 +927,43 @@ static void lcd_control_menu()
#ifdef FWRETRACT
MENU_ITEM(submenu, MSG_RETRACT, lcd_control_retract_menu);
#endif
END_MENU();
}
static void config_baudrate()
{
if(baudrate_position<0){
for (int8_t p = 0; p < 8; p++){
if (baudrates[p]==baudrate) baudrate_position = p;
}
}
if (encoderPosition != 0)
{
refresh_cmd_timeout();
baudrate_position += int(encoderPosition /2);
if(baudrate_position>7) baudrate_position=7;
if(baudrate_position<0) baudrate_position=0;
encoderPosition = 0;
lcdDrawUpdate = 1;
}
if (lcdDrawUpdate)
{
lcd_implementation_drawedit(PSTR("Baudrate"), ltostr7(baudrates[baudrate_position]));
baudrate=baudrates[baudrate_position];
}
if (LCD_CLICKED)
{
lcd_quick_feedback();
currentMenu = lcd_config_menu;
encoderPosition = 0;
}
}
static void lcd_config_menu()
{
START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM(submenu, MSG_BAUDRATE, config_baudrate);
#ifdef EEPROM_SETTINGS
MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
MENU_ITEM(function, MSG_LOAD_EPROM, Config_RetrieveSettings);
......@@ -1751,6 +1793,37 @@ char *itostr4(const int &xx)
return conv;
}
char *ltostr7(const long &xx)
{
if (xx >= 1000000)
conv[0]=(xx/1000000)%10+'0';
else
conv[0]=' ';
if (xx >= 100000)
conv[1]=(xx/100000)%10+'0';
else
conv[1]=' ';
if (xx >= 10000)
conv[2]=(xx/10000)%10+'0';
else
conv[2]=' ';
if (xx >= 1000)
conv[3]=(xx/1000)%10+'0';
else
conv[3]=' ';
if (xx >= 100)
conv[4]=(xx/100)%10+'0';
else
conv[4]=' ';
if (xx >= 10)
conv[5]=(xx/10)%10+'0';
else
conv[5]=' ';
conv[6]=(xx)%10+'0';
conv[7]=0;
return conv;
}
// convert float to string with +123 format
char *ftostr30(const float &x)
{
......
......@@ -109,6 +109,8 @@ char *itostr3(const int &xx);
char *itostr3left(const int &xx);
char *itostr4(const int &xx);
char *ltostr7(const long &xx);
char *ftostr3(const float &x);
char *ftostr30(const float &x);
char *ftostr31ns(const float &x); // float to string without sign character
......
......@@ -213,6 +213,19 @@ extern volatile uint16_t buttons; //an extended version of the last checked but
static void lcd_implementation_init()
{
#ifdef DELTA
byte bedTemp[8] =
{
B00000,
B01110,
B11111,
B11011,
B11111,
B01110,
B00000,
B00000
};
#else
byte bedTemp[8] =
{
B00000,
......@@ -224,12 +237,13 @@ static void lcd_implementation_init()
B00000,
B00000
}; //thanks Sonny Mounicou
#endif //DELTA
byte degree[8] =
{
B01100,
B10010,
B10010,
B01100,
B00100,
B01010,
B00100,
B00000,
B00000,
B00000,
B00000,
......@@ -242,18 +256,18 @@ static void lcd_implementation_init()
B01010,
B01010,
B01010,
B10001,
B10001,
B11111,
B11111,
B01110
};
byte uplevel[8]={
B00100,
B01110,
B11111,
B10101,
B00100,
B00100,
B11100,
B00000,
B00000,
B00000
}; //thanks joris
byte refresh[8]={
......@@ -459,17 +473,17 @@ static void lcd_implementation_status_screen()
lcd.print(' ');
# else
lcd.setCursor(0,1);
#ifdef DELTA
# ifdef DELTA
lcd.print('X');
lcd.print(ftostr30(current_position[X_AXIS]));
lcd_printPGM(PSTR(" Y"));
lcd.print(ftostr30(current_position[Y_AXIS]));
#else
# else
lcd.print('X');
lcd.print(ftostr3(current_position[X_AXIS]));
lcd_printPGM(PSTR(" Y"));
lcd.print(ftostr3(current_position[Y_AXIS]));
#endif
# endif // DELTA
# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
# endif//LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - 8, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment