Merge pull request #219 from Justblair/Marlin_v1

Added new function to the LCD menu.  Preheat settings now adjustable and can be stored
hackerspace-green
ErikZalm 2012-08-21 23:21:11 -07:00
commit 8c94ad0d26
4 changed files with 353 additions and 19 deletions

View File

@ -6,7 +6,13 @@
#include "temperature.h"
//#include <EEPROM.h>
int plaPreheatHotendTemp;
int plaPreheatHPBTemp;
int plaPreheatFanSpeed;
int absPreheatHotendTemp;
int absPreheatHPBTemp;
int absPreheatFanSpeed;
template <class T> int EEPROM_writeAnything(int &ee, const T& value)
{
@ -38,7 +44,7 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
// the default values are used whenever there is a change to the data, to prevent
// wrong data being written to the variables.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V06"
#define EEPROM_VERSION "V07"
inline void EEPROM_StoreSettings()
{
@ -58,6 +64,12 @@ inline void EEPROM_StoreSettings()
EEPROM_writeAnything(i,max_z_jerk);
EEPROM_writeAnything(i,max_e_jerk);
EEPROM_writeAnything(i,add_homeing);
EEPROM_writeAnything(i,plaPreheatHotendTemp);
EEPROM_writeAnything(i,plaPreheatHPBTemp);
EEPROM_writeAnything(i,plaPreheatFanSpeed);
EEPROM_writeAnything(i,absPreheatHotendTemp);
EEPROM_writeAnything(i,absPreheatHPBTemp);
EEPROM_writeAnything(i,absPreheatFanSpeed);
#ifdef PIDTEMP
EEPROM_writeAnything(i,Kp);
EEPROM_writeAnything(i,Ki);
@ -162,6 +174,12 @@ inline void EEPROM_RetrieveSettings(bool def=false)
EEPROM_readAnything(i,max_z_jerk);
EEPROM_readAnything(i,max_e_jerk);
EEPROM_readAnything(i,add_homeing);
EEPROM_readAnything(i,plaPreheatHotendTemp);
EEPROM_readAnything(i,plaPreheatHPBTemp);
EEPROM_readAnything(i,plaPreheatFanSpeed);
EEPROM_readAnything(i,absPreheatHotendTemp);
EEPROM_readAnything(i,absPreheatHPBTemp);
EEPROM_readAnything(i,absPreheatFanSpeed);
#ifndef PIDTEMP
float Kp,Ki,Kd;
#endif
@ -195,6 +213,14 @@ inline void EEPROM_RetrieveSettings(bool def=false)
add_homeing[0] = add_homeing[1] = add_homeing[2] = 0;
SERIAL_ECHO_START;
SERIAL_ECHOLN("Using Default settings:");
#ifdef ULTIPANEL
plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP;
absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
#endif
}
#ifdef EEPROM_CHITCHAT
EEPROM_printSettings();

View File

@ -77,6 +77,7 @@
#define MSG_MAIN_WIDE " Main \003"
#define MSG_RECTRACT_WIDE " Rectract \x7E"
#define MSG_TEMPERATURE_WIDE " Temperature \x7E"
#define MSG_TEMPERATURE_RTN " Temperature \003"
#define MSG_MOTION_WIDE " Motion \x7E"
#define MSG_STORE_EPROM " Store memory"
#define MSG_LOAD_EPROM " Load memory"
@ -101,14 +102,16 @@
#define MSG_KILLED "KILLED. "
#define MSG_STOPPED "STOPPED. "
#define MSG_PREHEAT_PLA " Preheat PLA"
#define MSG_PREHEAT_PLA_SETTINGS " Preheat PLA Setting"
#define MSG_PREHEAT_ABS_SETTINGS " Preheat ABS Setting"
#define MSG_PREHEAT_ABS " Preheat ABS"
#define MSG_STEPPER_RELEASED "Released."
#define MSG_CONTROL_RETRACT " Retract mm:"
#define MSG_CONTROL_RETRACTF " Retract F:"
#define MSG_CONTROL_RETRACT_ZLIFT " Hop mm:"
#define MSG_CONTROL_RETRACT_RECOVER " UnRet +mm:"
#define MSG_CONTROL_RETRACT_RECOVERF " UnRet F:"
#define MSG_AUTORETRACT " AutoRetr.:"
#define MSG_CONTROL_RETRACT " Retract mm:"
#define MSG_CONTROL_RETRACTF " Retract F:"
#define MSG_CONTROL_RETRACT_ZLIFT " Hop mm:"
#define MSG_CONTROL_RETRACT_RECOVER " UnRet +mm:"
#define MSG_CONTROL_RETRACT_RECOVERF " UnRet F:"
#define MSG_AUTORETRACT " AutoRetr.:"
// Serial Console Messages

View File

@ -46,12 +46,14 @@
#define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
#endif
// blocking time for recognizing a new keypress of one key, ms
#define blocktime 500
#define lcdslow 5
enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl,Sub_RetractControl};
enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl,Sub_RetractControl, Sub_PreheatPLASettings, Sub_PreheatABSSettings};
class MainMenu{
public:
@ -71,6 +73,8 @@
void showControlRetract();
void showAxisMove();
void showSD();
void showPLAsettings();
void showABSsettings();
bool force_lcd_update;
long lastencoderpos;
int8_t lineoffset;

View File

@ -528,17 +528,17 @@ void MainMenu::showPrepare()
MENUITEM( lcdprintPGM(MSG_SET_ORIGIN) , BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
break;
case ItemP_preheat_pla:
MENUITEM( lcdprintPGM(MSG_PREHEAT_PLA) , BLOCK;setTargetHotend0(PLA_PREHEAT_HOTEND_TEMP);setTargetBed(PLA_PREHEAT_HPB_TEMP);
MENUITEM( lcdprintPGM(MSG_PREHEAT_PLA) , BLOCK;setTargetHotend0(plaPreheatHotendTemp);setTargetBed(plaPreheatHPBTemp);
#if FAN_PIN > -1
FanSpeed=PLA_PREHEAT_FAN_SPEED;
FanSpeed = plaPreheatFanSpeed;
analogWrite(FAN_PIN, FanSpeed);
#endif
beepshort(); );
break;
case ItemP_preheat_abs:
MENUITEM( lcdprintPGM(MSG_PREHEAT_ABS) , BLOCK;setTargetHotend0(ABS_PREHEAT_HOTEND_TEMP);setTargetBed(ABS_PREHEAT_HPB_TEMP);
MENUITEM( lcdprintPGM(MSG_PREHEAT_ABS) , BLOCK;setTargetHotend0(absPreheatHotendTemp);setTargetBed(absPreheatHPBTemp);
#if FAN_PIN > -1
FanSpeed=ABS_PREHEAT_FAN_SPEED;
FanSpeed = absPreheatFanSpeed;
analogWrite(FAN_PIN, FanSpeed);
#endif
beepshort(); );
@ -789,7 +789,7 @@ void MainMenu::showTune()
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
}
}
if((activeline!=line) )
break;
@ -967,7 +967,9 @@ enum {
ItemCT_bed,
#endif
ItemCT_fan,
ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C
ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C,
ItemCT_PLA_PreHeat_Setting,
ItemCT_ABS_PreHeat_Setting,
};
void MainMenu::showControlTemp()
@ -1434,16 +1436,19 @@ void MainMenu::showControlTemp()
#endif
#endif
break;
case ItemCT_PLA_PreHeat_Setting:
MENUITEM( lcdprintPGM(MSG_PREHEAT_PLA_SETTINGS) , BLOCK;status=Sub_PreheatPLASettings;beepshort(); ) ;
break;
case ItemCT_ABS_PreHeat_Setting:
MENUITEM( lcdprintPGM(MSG_PREHEAT_ABS_SETTINGS) , BLOCK;status=Sub_PreheatABSSettings;beepshort(); ) ;
break;
default:
break;
}
line++;
}
#ifdef PID_ADD_EXTRUSION_RATE
updateActiveLines(ItemCT_PID_C,encoderpos);
#else
updateActiveLines(ItemCT_PID_D,encoderpos);
#endif
updateActiveLines(ItemCT_ABS_PreHeat_Setting,encoderpos);
}
@ -2569,6 +2574,14 @@ void MainMenu::update()
{
showSD();
}break;
case Sub_PreheatPLASettings:
{
showPLAsettings();
}break;
case Sub_PreheatABSSettings:
{
showABSsettings();
}break;
}
if(timeoutToStatus<millis())
@ -2577,11 +2590,299 @@ void MainMenu::update()
lastencoderpos=encoderpos;
}
enum {
ItemPLAPreHeat_Exit,
ItemPLAPreHeat_set_PLA_FanSpeed,
ItemPLAPreHeat_set_nozzle,
ItemPLAPreHeat_set_HPB,
ItemPLAPreHeat_Store_Eprom
};
void MainMenu::showPLAsettings()
{
#ifdef ULTIPANEL
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case ItemPLAPreHeat_Exit:
MENUITEM( lcdprintPGM(MSG_TEMPERATURE_RTN) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
break;
case ItemPLAPreHeat_set_PLA_FanSpeed:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatFanSpeed));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=plaPreheatFanSpeed;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>255) encoderpos=255;
plaPreheatFanSpeed=encoderpos;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemPLAPreHeat_set_nozzle:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHotendTemp));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=plaPreheatHotendTemp;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
plaPreheatHotendTemp = encoderpos;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemPLAPreHeat_set_HPB:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHPBTemp));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=plaPreheatHPBTemp;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>250) encoderpos=150;
plaPreheatHPBTemp = encoderpos;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemPLAPreHeat_Store_Eprom:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_StoreSettings();
}
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemPLAPreHeat_Store_Eprom,encoderpos);
#endif
}
enum {
ItemABSPreHeat_Exit,
ItemABSPreHeat_set_FanSpeed,
ItemABSPreHeat_set_nozzle,
ItemABSPreHeat_set_HPB,
ItemABSPreHeat_Store_Eprom
};
void MainMenu::showABSsettings()
{
#ifdef ULTIPANEL
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case ItemABSPreHeat_Exit:
MENUITEM( lcdprintPGM(MSG_TEMPERATURE_RTN) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
break;
case ItemABSPreHeat_set_FanSpeed:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatFanSpeed));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=absPreheatFanSpeed;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>255) encoderpos=255;
absPreheatFanSpeed=encoderpos;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemABSPreHeat_set_nozzle:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHotendTemp));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=absPreheatHotendTemp;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
absPreheatHotendTemp = encoderpos;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemABSPreHeat_set_HPB:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHPBTemp));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=absPreheatHPBTemp;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>250) encoderpos=150;
absPreheatHPBTemp = encoderpos;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
case ItemABSPreHeat_Store_Eprom:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_StoreSettings();
}
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemABSPreHeat_Store_Eprom,encoderpos);
#endif
}
//**********************************************************************************************************
// convert float to string with +123.4 format
char *ftostr3(const float &x)
{