2011-11-05 13:13:20 +00:00
|
|
|
#include "ultralcd.h"
|
2011-11-06 18:23:08 +00:00
|
|
|
#ifdef ULTRA_LCD
|
2011-11-05 15:49:29 +00:00
|
|
|
|
2011-11-06 22:34:40 +00:00
|
|
|
//===========================================================================
|
|
|
|
//=============================imported variables============================
|
|
|
|
//===========================================================================
|
2011-11-05 13:13:20 +00:00
|
|
|
|
|
|
|
extern volatile int feedmultiply;
|
2011-11-06 18:36:29 +00:00
|
|
|
extern volatile bool feedmultiplychanged;
|
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
extern long position[4];
|
2011-11-06 20:39:53 +00:00
|
|
|
extern CardReader card;
|
2011-11-05 13:13:20 +00:00
|
|
|
|
2011-11-06 22:34:40 +00:00
|
|
|
//===========================================================================
|
|
|
|
//=============================public variables============================
|
|
|
|
//===========================================================================
|
|
|
|
volatile char buttons=0; //the last checked buttons in a bit array.
|
|
|
|
int encoderpos=0;
|
|
|
|
short lastenc=0;
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//=============================private variables============================
|
|
|
|
//===========================================================================
|
2011-11-06 18:36:29 +00:00
|
|
|
static char messagetext[LCD_WIDTH]="";
|
2011-11-05 13:13:20 +00:00
|
|
|
|
2011-11-06 22:34:40 +00:00
|
|
|
//return for string conversion routines
|
|
|
|
static char conv[8];
|
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
#include <LiquidCrystal.h>
|
|
|
|
LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
|
|
|
|
|
2011-11-06 18:36:29 +00:00
|
|
|
static unsigned long previous_millis_lcd=0;
|
|
|
|
static long previous_millis_buttons=0;
|
2011-11-05 13:13:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef NEWPANEL
|
2011-11-06 18:36:29 +00:00
|
|
|
static long blocking=0;
|
2011-11-05 13:13:20 +00:00
|
|
|
#else
|
2011-11-06 18:36:29 +00:00
|
|
|
static long blocking[8]={0,0,0,0,0,0,0,0};
|
2011-11-05 13:13:20 +00:00
|
|
|
#endif
|
2011-11-06 22:34:40 +00:00
|
|
|
|
|
|
|
static MainMenu menu;
|
|
|
|
|
2011-11-07 21:33:13 +00:00
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
|
|
|
|
void lcdProgMemprint(const char *str)
|
|
|
|
{
|
|
|
|
char ch=pgm_read_byte(str);
|
|
|
|
while(ch)
|
|
|
|
{
|
|
|
|
lcd.print(ch);
|
|
|
|
ch=pgm_read_byte(++str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#define lcdprintPGM(x) lcdProgMemprint(PSTR(x))
|
|
|
|
|
2011-11-06 22:34:40 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//=============================functions ============================
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
inline int intround(const float &x){return int(0.5+x);}
|
2011-11-05 13:13:20 +00:00
|
|
|
|
|
|
|
void lcd_status(const char* message)
|
|
|
|
{
|
|
|
|
strncpy(messagetext,message,LCD_WIDTH);
|
2011-11-20 15:05:42 +00:00
|
|
|
messagetext[strlen(message)]=0;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
2011-11-09 19:27:15 +00:00
|
|
|
void lcd_statuspgm(const char* message)
|
|
|
|
{
|
|
|
|
char ch=pgm_read_byte(message);
|
|
|
|
char *target=messagetext;
|
2011-11-09 21:09:16 +00:00
|
|
|
uint8_t cnt=0;
|
|
|
|
while(ch &&cnt<LCD_WIDTH)
|
2011-11-09 19:27:15 +00:00
|
|
|
{
|
|
|
|
*target=ch;
|
|
|
|
target++;
|
2011-11-09 21:09:16 +00:00
|
|
|
cnt++;
|
2011-11-09 19:27:15 +00:00
|
|
|
ch=pgm_read_byte(++message);
|
|
|
|
}
|
2011-11-20 15:05:42 +00:00
|
|
|
*target=0;
|
2011-11-09 19:27:15 +00:00
|
|
|
}
|
|
|
|
|
2011-11-06 13:03:41 +00:00
|
|
|
inline void clear()
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
lcd.clear();
|
|
|
|
}
|
2011-11-06 18:36:29 +00:00
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
|
|
|
|
void lcd_init()
|
|
|
|
{
|
|
|
|
//beep();
|
|
|
|
byte Degree[8] =
|
|
|
|
{
|
|
|
|
B01100,
|
|
|
|
B10010,
|
|
|
|
B10010,
|
|
|
|
B01100,
|
|
|
|
B00000,
|
|
|
|
B00000,
|
|
|
|
B00000,
|
|
|
|
B00000
|
|
|
|
};
|
|
|
|
byte Thermometer[8] =
|
|
|
|
{
|
|
|
|
B00100,
|
|
|
|
B01010,
|
|
|
|
B01010,
|
|
|
|
B01010,
|
|
|
|
B01010,
|
|
|
|
B10001,
|
|
|
|
B10001,
|
|
|
|
B01110
|
|
|
|
};
|
|
|
|
byte uplevel[8]={0x04, 0x0e, 0x1f, 0x04, 0x1c, 0x00, 0x00, 0x00};//thanks joris
|
|
|
|
byte refresh[8]={0x00, 0x06, 0x19, 0x18, 0x03, 0x13, 0x0c, 0x00}; //thanks joris
|
2011-11-20 13:43:47 +00:00
|
|
|
byte folder [8]={0x00, 0x1c, 0x1f, 0x11, 0x11, 0x1f, 0x00, 0x00}; //thanks joris
|
2011-11-05 13:13:20 +00:00
|
|
|
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
|
|
|
lcd.createChar(1,Degree);
|
|
|
|
lcd.createChar(2,Thermometer);
|
|
|
|
lcd.createChar(3,uplevel);
|
|
|
|
lcd.createChar(4,refresh);
|
2011-11-20 13:43:47 +00:00
|
|
|
lcd.createChar(5,folder);
|
2011-11-09 19:27:15 +00:00
|
|
|
LCD_MESSAGEPGM("UltiMarlin ready.");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void beep()
|
|
|
|
{
|
|
|
|
//return;
|
2011-11-06 13:03:41 +00:00
|
|
|
#ifdef ULTIPANEL
|
|
|
|
pinMode(BEEPER,OUTPUT);
|
2011-11-06 22:21:12 +00:00
|
|
|
for(int8_t i=0;i<20;i++){
|
2011-11-06 13:03:41 +00:00
|
|
|
WRITE(BEEPER,HIGH);
|
|
|
|
delay(5);
|
|
|
|
WRITE(BEEPER,LOW);
|
|
|
|
delay(5);
|
|
|
|
}
|
|
|
|
#endif
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void beepshort()
|
|
|
|
{
|
|
|
|
//return;
|
2011-11-06 13:03:41 +00:00
|
|
|
#ifdef ULTIPANEL
|
|
|
|
pinMode(BEEPER,OUTPUT);
|
2011-11-06 22:21:12 +00:00
|
|
|
for(int8_t i=0;i<10;i++){
|
2011-11-06 13:03:41 +00:00
|
|
|
WRITE(BEEPER,HIGH);
|
|
|
|
delay(3);
|
|
|
|
WRITE(BEEPER,LOW);
|
|
|
|
delay(3);
|
|
|
|
}
|
|
|
|
#endif
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
2011-11-06 13:03:41 +00:00
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
void lcd_status()
|
|
|
|
{
|
2011-11-06 13:03:41 +00:00
|
|
|
#ifdef ULTIPANEL
|
|
|
|
static uint8_t oldbuttons=0;
|
|
|
|
static long previous_millis_buttons=0;
|
|
|
|
static long previous_lcdinit=0;
|
|
|
|
// buttons_check(); // Done in temperature interrupt
|
|
|
|
//previous_millis_buttons=millis();
|
|
|
|
|
|
|
|
if((buttons==oldbuttons) && ((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
|
|
|
|
return;
|
|
|
|
oldbuttons=buttons;
|
|
|
|
#else
|
2011-11-05 13:13:20 +00:00
|
|
|
|
2011-11-06 13:03:41 +00:00
|
|
|
if(((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
|
|
|
|
return;
|
|
|
|
#endif
|
2011-11-05 13:13:20 +00:00
|
|
|
|
|
|
|
previous_millis_lcd=millis();
|
|
|
|
menu.update();
|
|
|
|
}
|
|
|
|
#ifdef ULTIPANEL
|
2011-11-06 18:23:08 +00:00
|
|
|
|
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
void buttons_init()
|
|
|
|
{
|
2011-11-06 18:23:08 +00:00
|
|
|
#ifdef NEWPANEL
|
|
|
|
pinMode(BTN_EN1,INPUT);
|
|
|
|
pinMode(BTN_EN2,INPUT);
|
|
|
|
pinMode(BTN_ENC,INPUT);
|
|
|
|
pinMode(SDCARDDETECT,INPUT);
|
|
|
|
WRITE(BTN_EN1,HIGH);
|
|
|
|
WRITE(BTN_EN2,HIGH);
|
|
|
|
WRITE(BTN_ENC,HIGH);
|
|
|
|
WRITE(SDCARDDETECT,HIGH);
|
|
|
|
#else
|
|
|
|
pinMode(SHIFT_CLK,OUTPUT);
|
|
|
|
pinMode(SHIFT_LD,OUTPUT);
|
|
|
|
pinMode(SHIFT_EN,OUTPUT);
|
|
|
|
pinMode(SHIFT_OUT,INPUT);
|
|
|
|
WRITE(SHIFT_OUT,HIGH);
|
|
|
|
WRITE(SHIFT_LD,HIGH);
|
|
|
|
WRITE(SHIFT_EN,LOW);
|
|
|
|
#endif
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void buttons_check()
|
|
|
|
{
|
|
|
|
|
2011-11-06 18:23:08 +00:00
|
|
|
#ifdef NEWPANEL
|
|
|
|
uint8_t newbutton=0;
|
|
|
|
if(READ(BTN_EN1)==0) newbutton|=EN_A;
|
|
|
|
if(READ(BTN_EN2)==0) newbutton|=EN_B;
|
|
|
|
if((blocking<millis()) &&(READ(BTN_ENC)==0))
|
|
|
|
newbutton|=EN_C;
|
|
|
|
buttons=newbutton;
|
|
|
|
#else //read it from the shift register
|
|
|
|
uint8_t newbutton=0;
|
|
|
|
WRITE(SHIFT_LD,LOW);
|
|
|
|
WRITE(SHIFT_LD,HIGH);
|
|
|
|
unsigned char tmp_buttons=0;
|
2011-11-06 22:21:12 +00:00
|
|
|
for(int8_t i=0;i<8;i++)
|
2011-11-06 18:23:08 +00:00
|
|
|
{
|
|
|
|
newbutton = newbutton>>1;
|
|
|
|
if(READ(SHIFT_OUT))
|
|
|
|
newbutton|=(1<<7);
|
|
|
|
WRITE(SHIFT_CLK,HIGH);
|
|
|
|
WRITE(SHIFT_CLK,LOW);
|
|
|
|
}
|
|
|
|
buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
|
|
|
|
#endif
|
|
|
|
|
2011-11-20 13:43:47 +00:00
|
|
|
//manage encoder rotation
|
2011-11-05 13:13:20 +00:00
|
|
|
char enc=0;
|
|
|
|
if(buttons&EN_A)
|
|
|
|
enc|=(1<<0);
|
|
|
|
if(buttons&EN_B)
|
|
|
|
enc|=(1<<1);
|
|
|
|
if(enc!=lastenc)
|
|
|
|
{
|
|
|
|
switch(enc)
|
|
|
|
{
|
|
|
|
case encrot0:
|
|
|
|
if(lastenc==encrot3)
|
|
|
|
encoderpos++;
|
|
|
|
else if(lastenc==encrot1)
|
|
|
|
encoderpos--;
|
|
|
|
break;
|
|
|
|
case encrot1:
|
|
|
|
if(lastenc==encrot0)
|
|
|
|
encoderpos++;
|
|
|
|
else if(lastenc==encrot2)
|
|
|
|
encoderpos--;
|
|
|
|
break;
|
|
|
|
case encrot2:
|
|
|
|
if(lastenc==encrot1)
|
|
|
|
encoderpos++;
|
|
|
|
else if(lastenc==encrot3)
|
|
|
|
encoderpos--;
|
|
|
|
break;
|
|
|
|
case encrot3:
|
|
|
|
if(lastenc==encrot2)
|
|
|
|
encoderpos++;
|
|
|
|
else if(lastenc==encrot0)
|
|
|
|
encoderpos--;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lastenc=enc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
MainMenu::MainMenu()
|
|
|
|
{
|
|
|
|
status=Main_Status;
|
|
|
|
displayStartingRow=0;
|
|
|
|
activeline=0;
|
|
|
|
force_lcd_update=true;
|
2011-11-06 18:23:08 +00:00
|
|
|
#ifdef ULTIPANEL
|
|
|
|
buttons_init();
|
|
|
|
#endif
|
2011-11-05 13:13:20 +00:00
|
|
|
lcd_init();
|
|
|
|
linechanging=false;
|
2011-11-20 15:05:42 +00:00
|
|
|
tune=false;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainMenu::showStatus()
|
|
|
|
{
|
|
|
|
#if LCD_HEIGHT==4
|
2011-11-06 13:03:41 +00:00
|
|
|
static int olddegHotEnd0=-1;
|
|
|
|
static int oldtargetHotEnd0=-1;
|
2011-11-05 13:13:20 +00:00
|
|
|
//force_lcd_update=true;
|
|
|
|
if(force_lcd_update||feedmultiplychanged) //initial display of content
|
|
|
|
{
|
|
|
|
feedmultiplychanged=false;
|
|
|
|
encoderpos=feedmultiply;
|
|
|
|
clear();
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
|
2011-11-06 13:03:41 +00:00
|
|
|
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(10,0);lcdprintPGM("B123/567\001 ");
|
2011-11-06 13:03:41 +00:00
|
|
|
#endif
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
2011-11-06 13:03:41 +00:00
|
|
|
int tHotEnd0=intround(degHotend0());
|
|
|
|
if((abs(tHotEnd0-olddegHotEnd0)>1)||force_lcd_update) //>1 because otherwise the lcd is refreshed to often.
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
lcd.setCursor(1,0);
|
2011-11-06 13:03:41 +00:00
|
|
|
lcd.print(ftostr3(tHotEnd0));
|
|
|
|
olddegHotEnd0=tHotEnd0;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
2011-11-06 13:03:41 +00:00
|
|
|
int ttHotEnd0=intround(degTargetHotend0());
|
|
|
|
if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
lcd.setCursor(5,0);
|
2011-11-06 13:03:41 +00:00
|
|
|
lcd.print(ftostr3(ttHotEnd0));
|
|
|
|
oldtargetHotEnd0=ttHotEnd0;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
|
2011-11-20 13:43:47 +00:00
|
|
|
static int oldtBed=-1;
|
|
|
|
static int oldtargetBed=-1;
|
|
|
|
int tBed=intround(degBed());
|
|
|
|
if((tBed!=oldtBed)||force_lcd_update)
|
|
|
|
{
|
|
|
|
lcd.setCursor(1,0);
|
|
|
|
lcd.print(ftostr3(tBed));
|
|
|
|
oldtBed=tBed;
|
|
|
|
}
|
|
|
|
int targetBed=intround(degTargetBed());
|
|
|
|
if((targetBed!=oldtargetBed)||force_lcd_update)
|
|
|
|
{
|
|
|
|
lcd.setCursor(5,0);
|
|
|
|
lcd.print(ftostr3(targetBed));
|
|
|
|
oldtargetBed=targetBed;
|
|
|
|
}
|
2011-11-05 13:13:20 +00:00
|
|
|
#endif
|
|
|
|
//starttime=2;
|
|
|
|
static uint16_t oldtime=0;
|
|
|
|
if(starttime!=0)
|
|
|
|
{
|
|
|
|
lcd.setCursor(0,1);
|
|
|
|
uint16_t time=millis()/60000-starttime/60000;
|
|
|
|
|
|
|
|
if(starttime!=oldtime)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.print(itostr2(time/60));lcdprintPGM("h ");lcd.print(itostr2(time%60));lcdprintPGM("m");
|
2011-11-05 13:13:20 +00:00
|
|
|
oldtime=time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static int oldzpos=0;
|
|
|
|
int currentz=current_position[2]*10;
|
|
|
|
if((currentz!=oldzpos)||force_lcd_update)
|
|
|
|
{
|
|
|
|
lcd.setCursor(10,1);
|
2011-11-07 21:33:13 +00:00
|
|
|
lcdprintPGM("Z:");lcd.print(itostr31(currentz));
|
2011-11-05 13:13:20 +00:00
|
|
|
oldzpos=currentz;
|
|
|
|
}
|
|
|
|
static int oldfeedmultiply=0;
|
|
|
|
int curfeedmultiply=feedmultiply;
|
|
|
|
if(encoderpos!=curfeedmultiply||force_lcd_update)
|
|
|
|
{
|
|
|
|
curfeedmultiply=encoderpos;
|
|
|
|
if(curfeedmultiply<10)
|
|
|
|
curfeedmultiply=10;
|
|
|
|
if(curfeedmultiply>999)
|
|
|
|
curfeedmultiply=999;
|
|
|
|
feedmultiply=curfeedmultiply;
|
|
|
|
encoderpos=curfeedmultiply;
|
|
|
|
}
|
|
|
|
if((curfeedmultiply!=oldfeedmultiply)||force_lcd_update)
|
|
|
|
{
|
|
|
|
oldfeedmultiply=curfeedmultiply;
|
|
|
|
lcd.setCursor(0,2);
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.print(itostr3(curfeedmultiply));lcdprintPGM("% ");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
if(messagetext[0]!='\0')
|
|
|
|
{
|
|
|
|
lcd.setCursor(0,LCD_HEIGHT-1);
|
2011-11-20 15:05:42 +00:00
|
|
|
lcd.print(messagetext);
|
|
|
|
uint8_t n=strlen(messagetext);
|
|
|
|
for(int8_t i=0;i<LCD_WIDTH-n;i++)
|
|
|
|
lcd.print(" ");
|
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
messagetext[0]='\0';
|
|
|
|
}
|
2011-11-15 19:54:40 +00:00
|
|
|
|
|
|
|
static uint8_t oldpercent=101;
|
|
|
|
uint8_t percent=card.percentDone();
|
2011-11-15 19:55:00 +00:00
|
|
|
if(oldpercent!=percent ||force_lcd_update)
|
2011-11-15 19:54:40 +00:00
|
|
|
{
|
2011-11-15 19:55:00 +00:00
|
|
|
lcd.setCursor(7,2);
|
|
|
|
lcd.print(itostr3((int)percent));
|
|
|
|
lcdprintPGM("%SD");
|
|
|
|
|
2011-11-15 19:54:40 +00:00
|
|
|
}
|
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
#else //smaller LCDS----------------------------------
|
2011-11-06 13:03:41 +00:00
|
|
|
static int olddegHotEnd0=-1;
|
|
|
|
static int oldtargetHotEnd0=-1;
|
2011-11-05 13:13:20 +00:00
|
|
|
if(force_lcd_update) //initial display of content
|
|
|
|
{
|
|
|
|
encoderpos=feedmultiply;
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
|
2011-11-05 13:13:20 +00:00
|
|
|
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(10,0);lcdprintPGM("B123/567\001 ");
|
2011-11-05 13:13:20 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-11-06 13:03:41 +00:00
|
|
|
int tHotEnd0=intround(degHotend0());
|
|
|
|
int ttHotEnd0=intround(degTargetHotend0());
|
2011-11-05 15:49:29 +00:00
|
|
|
|
2011-11-06 13:03:41 +00:00
|
|
|
|
|
|
|
if((abs(tHotEnd0-olddegHotEnd0)>1)||force_lcd_update)
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
lcd.setCursor(1,0);
|
2011-11-06 13:03:41 +00:00
|
|
|
lcd.print(ftostr3(tHotEnd0));
|
|
|
|
olddegHotEnd0=tHotEnd0;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
2011-11-06 13:03:41 +00:00
|
|
|
if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
lcd.setCursor(5,0);
|
2011-11-06 13:03:41 +00:00
|
|
|
lcd.print(ftostr3(ttHotEnd0));
|
|
|
|
oldtargetHotEnd0=ttHotEnd0;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(messagetext[0]!='\0')
|
|
|
|
{
|
|
|
|
lcd.setCursor(0,LCD_HEIGHT-1);
|
2011-11-20 15:05:42 +00:00
|
|
|
lcd.print(messagetext);
|
|
|
|
uint8_t n=strlen(messagetext);
|
|
|
|
for(int8_t i=0;i<LCD_WIDTH-n;i++)
|
|
|
|
lcd.print(" ");
|
2011-11-05 13:13:20 +00:00
|
|
|
messagetext[0]='\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2011-11-20 13:43:47 +00:00
|
|
|
force_lcd_update=false;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum {ItemP_exit, ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude, ItemP_disstep};
|
|
|
|
|
2011-11-20 10:55:33 +00:00
|
|
|
//any action must not contain a ',' character anywhere, or this breaks:
|
|
|
|
#define MENUITEM(repaint_action, click_action) \
|
|
|
|
{\
|
|
|
|
if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
|
|
|
|
if((activeline==line) && CLICKED) {click_action} \
|
|
|
|
}
|
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
void MainMenu::showPrepare()
|
|
|
|
{
|
|
|
|
uint8_t line=0;
|
2011-11-20 10:55:33 +00:00
|
|
|
clearIfNecessary();
|
2011-11-06 22:21:12 +00:00
|
|
|
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
//Serial.println((int)(line-lineoffset));
|
|
|
|
switch(i)
|
|
|
|
{
|
|
|
|
case ItemP_exit:
|
2011-11-20 10:55:33 +00:00
|
|
|
MENUITEM( lcdprintPGM(" Prepare") , BLOCK;status=Main_Menu;beepshort(); ) ;
|
|
|
|
break;
|
2011-11-05 13:13:20 +00:00
|
|
|
case ItemP_home:
|
2011-11-20 10:55:33 +00:00
|
|
|
MENUITEM( lcdprintPGM(" Auto Home") , BLOCK;enquecommand("G28 X-105 Y-105 Z0");beepshort(); ) ;
|
|
|
|
break;
|
2011-11-05 13:13:20 +00:00
|
|
|
case ItemP_origin:
|
2011-11-20 10:55:33 +00:00
|
|
|
MENUITEM( lcdprintPGM(" Set Origin") , BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
|
|
|
|
break;
|
2011-11-05 13:13:20 +00:00
|
|
|
case ItemP_preheat:
|
2011-11-20 10:55:33 +00:00
|
|
|
MENUITEM( lcdprintPGM(" Preheat") , BLOCK;setTargetHotend0(170);beepshort(); ) ;
|
|
|
|
break;
|
2011-11-05 13:13:20 +00:00
|
|
|
case ItemP_extrude:
|
2011-11-20 10:55:33 +00:00
|
|
|
MENUITEM( lcdprintPGM(" Extrude") , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
|
|
|
|
break;
|
2011-11-05 13:13:20 +00:00
|
|
|
case ItemP_disstep:
|
2011-11-20 10:55:33 +00:00
|
|
|
MENUITEM( lcdprintPGM(" Disable Steppers") , BLOCK;enquecommand("M84");beepshort(); ) ;
|
|
|
|
break;
|
2011-11-05 13:13:20 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
line++;
|
|
|
|
}
|
2011-11-20 10:55:33 +00:00
|
|
|
updateActiveLines(ItemP_disstep,encoderpos);
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
2011-11-20 13:43:47 +00:00
|
|
|
|
2011-11-20 15:05:42 +00:00
|
|
|
enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,ItemT_fan};
|
|
|
|
|
|
|
|
void MainMenu::showTune()
|
|
|
|
{
|
|
|
|
uint8_t line=0;
|
|
|
|
clearIfNecessary();
|
|
|
|
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
|
|
|
|
{
|
|
|
|
//Serial.println((int)(line-lineoffset));
|
|
|
|
switch(i)
|
|
|
|
{
|
|
|
|
case ItemT_exit:
|
|
|
|
MENUITEM( lcdprintPGM(" Tune") , BLOCK;status=Main_Menu;beepshort(); ) ;
|
|
|
|
break;
|
|
|
|
case ItemT_speed:
|
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Speed:");
|
|
|
|
lcd.setCursor(13,line);lcd.print(ftostr3(feedmultiply));
|
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
encoderpos=feedmultiply;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<1) encoderpos=1;
|
|
|
|
if(encoderpos>400) encoderpos=400;
|
|
|
|
feedmultiply = encoderpos;
|
|
|
|
feedmultiplychanged=true;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
case ItemT_nozzle:
|
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
|
|
|
|
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
|
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
encoderpos=intround(degTargetHotend0());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setTargetHotend0(encoderpos);
|
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<0) encoderpos=0;
|
|
|
|
if(encoderpos>260) encoderpos=260;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case ItemT_fan:
|
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Fan speed:");
|
|
|
|
lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
|
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
encoderpos=fanpwm;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<0) encoderpos=0;
|
|
|
|
if(encoderpos>255) encoderpos=255;
|
|
|
|
fanpwm=encoderpos;
|
|
|
|
analogWrite(FAN_PIN, fanpwm);
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
case ItemT_flow://axis_steps_per_unit[i] = code_value();
|
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Flow:");
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
|
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
encoderpos=(int)axis_steps_per_unit[3];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
|
|
|
|
position[E_AXIS]=lround(position[E_AXIS]*factor);
|
|
|
|
//current_position[3]*=factor;
|
|
|
|
axis_steps_per_unit[E_AXIS]= encoderpos;
|
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<5) encoderpos=5;
|
|
|
|
if(encoderpos>9999) encoderpos=9999;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
line++;
|
|
|
|
}
|
|
|
|
updateActiveLines(ItemT_fan,encoderpos);
|
|
|
|
}
|
2011-11-05 13:13:20 +00:00
|
|
|
|
2011-11-20 10:55:33 +00:00
|
|
|
//does not work
|
|
|
|
// #define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \
|
|
|
|
// {\
|
|
|
|
// if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
|
|
|
|
// if(activeline==line) \
|
|
|
|
// { \
|
|
|
|
// if(CLICKED) \
|
|
|
|
// { \
|
|
|
|
// linechanging=!linechanging; \
|
|
|
|
// if(linechanging) {enter_action;} \
|
|
|
|
// else {accept_action;} \
|
|
|
|
// } \
|
|
|
|
// else \
|
|
|
|
// if(linechanging) {change_action};}\
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
|
2011-11-20 13:43:47 +00:00
|
|
|
enum {
|
|
|
|
ItemCT_exit, ItemCT_nozzle, ItemCT_fan,
|
|
|
|
ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C
|
|
|
|
};
|
|
|
|
|
|
|
|
void MainMenu::showControlTemp()
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
uint8_t line=0;
|
2011-11-20 10:55:33 +00:00
|
|
|
clearIfNecessary();
|
2011-11-06 22:21:12 +00:00
|
|
|
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
switch(i)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCT_exit:
|
|
|
|
MENUITEM( lcdprintPGM(" Temperature") , BLOCK;status=Main_Control;beepshort(); ) ;
|
2011-11-20 10:55:33 +00:00
|
|
|
break;
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCT_nozzle:
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
|
2011-11-20 15:05:42 +00:00
|
|
|
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 15:05:42 +00:00
|
|
|
encoderpos=intround(degTargetHotend0());
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-06 13:03:41 +00:00
|
|
|
setTargetHotend0(encoderpos);
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<0) encoderpos=0;
|
|
|
|
if(encoderpos>260) encoderpos=260;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCT_fan:
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Fan speed:");
|
2011-11-05 13:13:20 +00:00
|
|
|
lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
|
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
encoderpos=fanpwm;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-20 15:05:42 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
2011-11-05 13:13:20 +00:00
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<0) encoderpos=0;
|
|
|
|
if(encoderpos>255) encoderpos=255;
|
|
|
|
fanpwm=encoderpos;
|
|
|
|
analogWrite(FAN_PIN, fanpwm);
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCT_PID_P:
|
|
|
|
{
|
2011-11-05 13:13:20 +00:00
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" PID-P: ");
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr4(Kp));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
encoderpos=(int)Kp/5;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
Kp= encoderpos*5;
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
2011-11-20 13:43:47 +00:00
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
if(encoderpos<1) encoderpos=1;
|
|
|
|
if(encoderpos>9990/5) encoderpos=9990/5;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCT_PID_I:
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" PID-I: ");
|
|
|
|
lcd.setCursor(13,line);lcd.print(ftostr51(Ki));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
encoderpos=(int)(Ki*10);
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
Ki= encoderpos/10.;
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
if(encoderpos<0) encoderpos=0;
|
|
|
|
if(encoderpos>9990) encoderpos=9990;
|
|
|
|
lcd.setCursor(13,line);lcd.print(ftostr51(encoderpos/10.));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCT_PID_D:
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" PID-D: ");
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr4(Kd));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
encoderpos=(int)Kd/5;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
Kd= encoderpos*5;
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
if(encoderpos<0) encoderpos=0;
|
2011-11-05 13:13:20 +00:00
|
|
|
if(encoderpos>9990/5) encoderpos=9990/5;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
|
|
|
|
}
|
|
|
|
}
|
2011-11-20 13:43:47 +00:00
|
|
|
}break;
|
|
|
|
case ItemCT_PID_C:
|
|
|
|
#ifdef PID_ADD_EXTRUSION_RATE
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" PID-C: ");
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(Kc));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
encoderpos=(int)Kc;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
Kc= encoderpos;
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<0) encoderpos=0;
|
2011-11-20 13:43:47 +00:00
|
|
|
if(encoderpos>990) encoderpos=990;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-20 13:43:47 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
line++;
|
|
|
|
}
|
|
|
|
#ifdef PID_ADD_EXTRUSION_RATE
|
|
|
|
updateActiveLines(ItemCT_PID_C,encoderpos);
|
|
|
|
#else
|
|
|
|
updateActiveLines(ItemCT_PID_D,encoderpos);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ItemCM_exit,
|
|
|
|
ItemCM_acc, ItemCM_xyjerk,
|
|
|
|
ItemCM_vmaxx, ItemCM_vmaxy, ItemCM_vmaxz, ItemCM_vmaxe,
|
|
|
|
ItemCM_vtravmin,ItemCM_vmin,
|
|
|
|
ItemCM_amaxx, ItemCM_amaxy, ItemCM_amaxz, ItemCM_amaxe,
|
|
|
|
ItemCM_aret,ItemCM_esteps
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainMenu::showControlMotion()
|
|
|
|
{
|
|
|
|
uint8_t line=0;
|
|
|
|
clearIfNecessary();
|
|
|
|
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
|
|
|
|
{
|
|
|
|
switch(i)
|
|
|
|
{
|
|
|
|
case ItemCM_exit:
|
|
|
|
MENUITEM( lcdprintPGM(" Motion") , BLOCK;status=Main_Control;beepshort(); ) ;
|
|
|
|
break;
|
|
|
|
case ItemCM_acc:
|
|
|
|
{
|
2011-11-05 13:13:20 +00:00
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Acc:");
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
encoderpos=(int)acceleration/100;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
acceleration= encoderpos*100;
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
if(encoderpos<5) encoderpos=5;
|
|
|
|
if(encoderpos>990) encoderpos=990;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCM_xyjerk: //max_xy_jerk
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Vxy-jerk: ");
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
encoderpos=(int)max_xy_jerk;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
max_xy_jerk= encoderpos;
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
if(encoderpos<1) encoderpos=1;
|
2011-11-05 13:13:20 +00:00
|
|
|
if(encoderpos>990) encoderpos=990;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
2011-11-20 13:43:47 +00:00
|
|
|
|
|
|
|
case ItemCM_vmaxx:
|
|
|
|
case ItemCM_vmaxy:
|
|
|
|
case ItemCM_vmaxz:
|
|
|
|
case ItemCM_vmaxe:
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Vmax ");
|
2011-11-20 13:43:47 +00:00
|
|
|
if(i==ItemCM_vmaxx)lcdprintPGM("x:");
|
|
|
|
if(i==ItemCM_vmaxy)lcdprintPGM("y:");
|
|
|
|
if(i==ItemCM_vmaxz)lcdprintPGM("z:");
|
|
|
|
if(i==ItemCM_vmaxe)lcdprintPGM("e:");
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemCM_vmaxx]));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
encoderpos=(int)max_feedrate[i-ItemCM_vmaxx];
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
max_feedrate[i-ItemCM_vmaxx]= encoderpos;
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<1) encoderpos=1;
|
|
|
|
if(encoderpos>990) encoderpos=990;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCM_vmin:
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Vmin:");
|
2011-11-15 21:50:43 +00:00
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(minimumfeedrate));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-15 21:50:43 +00:00
|
|
|
encoderpos=(int)(minimumfeedrate);
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-15 21:50:43 +00:00
|
|
|
minimumfeedrate= encoderpos;
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<0) encoderpos=0;
|
|
|
|
if(encoderpos>990) encoderpos=990;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCM_vtravmin:
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" VTrav min:");
|
2011-11-15 21:50:43 +00:00
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate));
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-15 21:50:43 +00:00
|
|
|
encoderpos=(int)mintravelfeedrate;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-15 21:50:43 +00:00
|
|
|
mintravelfeedrate= encoderpos;
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<0) encoderpos=0;
|
|
|
|
if(encoderpos>990) encoderpos=990;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCM_amaxx:
|
|
|
|
case ItemCM_amaxy:
|
|
|
|
case ItemCM_amaxz:
|
|
|
|
case ItemCM_amaxe:
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Amax ");
|
2011-11-20 13:43:47 +00:00
|
|
|
if(i==ItemCM_amaxx)lcdprintPGM("x:");
|
|
|
|
if(i==ItemCM_amaxy)lcdprintPGM("y:");
|
|
|
|
if(i==ItemCM_amaxz)lcdprintPGM("z:");
|
|
|
|
if(i==ItemCM_amaxe)lcdprintPGM("e:");
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100));lcdprintPGM("00");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
max_acceleration_units_per_sq_second[i-ItemCM_amaxx]= encoderpos*100;
|
2011-11-05 13:13:20 +00:00
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<1) encoderpos=1;
|
|
|
|
if(encoderpos>990) encoderpos=990;
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCM_aret://float retract_acceleration = 7000;
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" A-retract:");
|
|
|
|
lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));lcdprintPGM("00");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
encoderpos=(int)retract_acceleration/100;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
retract_acceleration= encoderpos*100;
|
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<10) encoderpos=10;
|
|
|
|
if(encoderpos>990) encoderpos=990;
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
2011-11-20 13:43:47 +00:00
|
|
|
case ItemCM_esteps://axis_steps_per_unit[i] = code_value();
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Esteps/mm:");
|
2011-11-05 13:13:20 +00:00
|
|
|
lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
|
|
|
|
}
|
|
|
|
|
|
|
|
if((activeline==line) )
|
|
|
|
{
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=!linechanging;
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
encoderpos=(int)axis_steps_per_unit[3];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
|
|
|
|
position[E_AXIS]=lround(position[E_AXIS]*factor);
|
|
|
|
//current_position[3]*=factor;
|
|
|
|
axis_steps_per_unit[E_AXIS]= encoderpos;
|
|
|
|
encoderpos=activeline*lcdslow;
|
|
|
|
|
|
|
|
}
|
|
|
|
BLOCK;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
if(linechanging)
|
|
|
|
{
|
|
|
|
if(encoderpos<5) encoderpos=5;
|
|
|
|
if(encoderpos>9999) encoderpos=9999;
|
|
|
|
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
2011-11-20 13:43:47 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
line++;
|
|
|
|
}
|
|
|
|
updateActiveLines(ItemCM_esteps,encoderpos);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ItemC_exit,ItemC_temp,ItemC_move,
|
|
|
|
ItemC_store, ItemC_load,ItemC_failsafe
|
|
|
|
};
|
|
|
|
|
|
|
|
void MainMenu::showControl()
|
|
|
|
{
|
|
|
|
uint8_t line=0;
|
|
|
|
clearIfNecessary();
|
|
|
|
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
|
|
|
|
{
|
|
|
|
switch(i)
|
|
|
|
{
|
|
|
|
case ItemC_exit:
|
|
|
|
MENUITEM( lcdprintPGM(" Control \x7E") , BLOCK;status=Main_Menu;beepshort(); ) ;
|
|
|
|
break;
|
|
|
|
case ItemC_temp:
|
|
|
|
MENUITEM( lcdprintPGM(" Temperature \x7E") , BLOCK;status=Sub_TempControl;beepshort(); ) ;
|
|
|
|
break;
|
|
|
|
case ItemC_move:
|
|
|
|
MENUITEM( lcdprintPGM(" Motion \x7E") , BLOCK;status=Sub_MotionControl;beepshort(); ) ;
|
|
|
|
break;
|
2011-11-05 13:13:20 +00:00
|
|
|
case ItemC_store:
|
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Store EPROM");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
if((activeline==line) && CLICKED)
|
|
|
|
{
|
|
|
|
//enquecommand("M84");
|
|
|
|
beepshort();
|
|
|
|
BLOCK;
|
|
|
|
StoreSettings();
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
case ItemC_load:
|
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Load EPROM");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
if((activeline==line) && CLICKED)
|
|
|
|
{
|
|
|
|
//enquecommand("M84");
|
|
|
|
beepshort();
|
|
|
|
BLOCK;
|
|
|
|
RetrieveSettings();
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
case ItemC_failsafe:
|
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" Restore Failsafe");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
if((activeline==line) && CLICKED)
|
|
|
|
{
|
|
|
|
//enquecommand("M84");
|
|
|
|
beepshort();
|
|
|
|
BLOCK;
|
|
|
|
RetrieveSettings(true);
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
line++;
|
|
|
|
}
|
2011-11-20 10:55:33 +00:00
|
|
|
updateActiveLines(ItemC_failsafe,encoderpos);
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
2011-11-06 22:34:40 +00:00
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
|
|
|
|
|
2011-11-06 20:39:53 +00:00
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
void MainMenu::showSD()
|
|
|
|
{
|
|
|
|
#ifdef SDSUPPORT
|
|
|
|
uint8_t line=0;
|
|
|
|
|
2011-11-20 10:55:33 +00:00
|
|
|
clearIfNecessary();
|
2011-11-05 13:13:20 +00:00
|
|
|
static uint8_t nrfiles=0;
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-06 21:48:15 +00:00
|
|
|
if(card.cardOK)
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
2011-11-06 20:39:53 +00:00
|
|
|
nrfiles=card.getnrfilenames();
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nrfiles=0;
|
|
|
|
lineoffset=0;
|
|
|
|
}
|
|
|
|
}
|
2011-11-20 13:43:47 +00:00
|
|
|
bool enforceupdate=false;
|
2011-11-05 13:13:20 +00:00
|
|
|
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
|
|
|
|
{
|
|
|
|
switch(i)
|
|
|
|
{
|
|
|
|
case 0:
|
2011-11-20 10:55:33 +00:00
|
|
|
MENUITEM( lcdprintPGM(" File") , BLOCK;status=Main_Menu;beepshort(); ) ;
|
|
|
|
break;
|
2011-11-20 13:43:47 +00:00
|
|
|
// case 1:
|
|
|
|
// {
|
|
|
|
// if(force_lcd_update)
|
|
|
|
// {
|
|
|
|
// lcd.setCursor(0,line);
|
|
|
|
// #ifdef CARDINSERTED
|
|
|
|
// if(CARDINSERTED)
|
|
|
|
// #else
|
|
|
|
// if(true)
|
|
|
|
// #endif
|
|
|
|
// {
|
|
|
|
// lcdprintPGM(" \004Refresh");
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// lcdprintPGM(" \004Insert Card");
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// if((activeline==line) && CLICKED)
|
|
|
|
// {
|
|
|
|
// BLOCK;
|
|
|
|
// beepshort();
|
|
|
|
// card.initsd();
|
|
|
|
// force_lcd_update=true;
|
|
|
|
// nrfiles=card.getnrfilenames();
|
|
|
|
// }
|
|
|
|
// }break;
|
2011-11-05 13:13:20 +00:00
|
|
|
case 1:
|
2011-11-20 13:43:47 +00:00
|
|
|
MENUITEM( lcdprintPGM(" ..") , BLOCK;card.updir();enforceupdate=true;lineoffset=0;beepshort(); ) ;
|
|
|
|
|
|
|
|
break;
|
2011-11-05 13:13:20 +00:00
|
|
|
default:
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
#define FIRSTITEM 2
|
|
|
|
if(i-FIRSTITEM<nrfiles)
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
2011-11-20 13:43:47 +00:00
|
|
|
card.getfilename(i-FIRSTITEM);
|
2011-11-05 13:13:20 +00:00
|
|
|
//Serial.print("Filenr:");Serial.println(i-2);
|
2011-11-20 13:43:47 +00:00
|
|
|
lcd.setCursor(0,line);lcdprintPGM(" ");
|
|
|
|
if(card.filenameIsDir) lcd.print("\005");
|
|
|
|
lcd.print(card.filename);
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
if((activeline==line) && CLICKED)
|
|
|
|
{
|
|
|
|
BLOCK
|
2011-11-20 13:43:47 +00:00
|
|
|
card.getfilename(i-FIRSTITEM);
|
|
|
|
if(card.filenameIsDir)
|
|
|
|
{
|
|
|
|
for(int8_t i=0;i<strlen(card.filename);i++)
|
|
|
|
card.filename[i]=tolower(card.filename[i]);
|
|
|
|
card.chdir(card.filename);
|
|
|
|
lineoffset=0;
|
|
|
|
enforceupdate=true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char cmd[30];
|
|
|
|
for(int8_t i=0;i<strlen(card.filename);i++)
|
|
|
|
card.filename[i]=tolower(card.filename[i]);
|
|
|
|
sprintf(cmd,"M23 %s",card.filename);
|
|
|
|
//sprintf(cmd,"M115");
|
|
|
|
enquecommand(cmd);
|
|
|
|
enquecommand("M24");
|
|
|
|
beep();
|
|
|
|
status=Main_Status;
|
|
|
|
lcd_status(card.filename);
|
|
|
|
}
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
line++;
|
|
|
|
}
|
2011-11-20 13:43:47 +00:00
|
|
|
updateActiveLines(FIRSTITEM+nrfiles-1,encoderpos);
|
|
|
|
if(enforceupdate)
|
|
|
|
{
|
|
|
|
force_lcd_update=true;
|
|
|
|
enforceupdate=false;
|
|
|
|
}
|
2011-11-05 13:13:20 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
enum {ItemM_watch, ItemM_prepare, ItemM_control, ItemM_file };
|
|
|
|
void MainMenu::showMainMenu()
|
|
|
|
{
|
2011-11-20 10:55:33 +00:00
|
|
|
|
2011-11-06 18:23:08 +00:00
|
|
|
#ifndef ULTIPANEL
|
|
|
|
force_lcd_update=false;
|
|
|
|
#endif
|
2011-11-20 15:05:42 +00:00
|
|
|
if(tune)
|
|
|
|
{
|
|
|
|
if(!(movesplanned() ||card.sdprinting))
|
|
|
|
{
|
|
|
|
force_lcd_update=true;
|
|
|
|
tune=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(movesplanned() ||card.sdprinting)
|
|
|
|
{
|
|
|
|
force_lcd_update=true;
|
|
|
|
tune=true;
|
|
|
|
}
|
|
|
|
}
|
2011-11-20 10:55:33 +00:00
|
|
|
clearIfNecessary();
|
2011-11-06 22:21:12 +00:00
|
|
|
for(int8_t line=0;line<LCD_HEIGHT;line++)
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
|
|
|
switch(line)
|
|
|
|
{
|
|
|
|
case ItemM_watch:
|
2011-11-20 10:55:33 +00:00
|
|
|
MENUITEM( lcdprintPGM(" Watch") , BLOCK;status=Main_Status;beepshort(); ) ;
|
|
|
|
break;
|
2011-11-05 13:13:20 +00:00
|
|
|
case ItemM_prepare:
|
2011-11-20 15:05:42 +00:00
|
|
|
MENUITEM( if(!tune) lcdprintPGM(" Prepare \x7E");else lcdprintPGM(" Tune \x7E"); , BLOCK;status=Main_Prepare;beepshort(); ) ;
|
2011-11-20 10:55:33 +00:00
|
|
|
break;
|
2011-11-05 13:13:20 +00:00
|
|
|
|
|
|
|
case ItemM_control:
|
2011-11-20 10:55:33 +00:00
|
|
|
MENUITEM( lcdprintPGM(" Control \x7E") , BLOCK;status=Main_Control;beepshort(); ) ;
|
|
|
|
break;
|
2011-11-06 18:23:08 +00:00
|
|
|
#ifdef SDSUPPORT
|
2011-11-05 13:13:20 +00:00
|
|
|
case ItemM_file:
|
|
|
|
{
|
|
|
|
if(force_lcd_update)
|
|
|
|
{
|
|
|
|
lcd.setCursor(0,line);
|
2011-11-06 18:23:08 +00:00
|
|
|
#ifdef CARDINSERTED
|
|
|
|
if(CARDINSERTED)
|
|
|
|
#else
|
|
|
|
if(true)
|
|
|
|
#endif
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
2011-11-06 21:48:15 +00:00
|
|
|
if(card.sdprinting)
|
2011-11-07 21:33:13 +00:00
|
|
|
lcdprintPGM(" Stop Print \x7E");
|
2011-11-05 13:13:20 +00:00
|
|
|
else
|
2011-11-07 21:33:13 +00:00
|
|
|
lcdprintPGM(" Card Menu \x7E");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-07 21:33:13 +00:00
|
|
|
lcdprintPGM(" No Card");
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef CARDINSERTED
|
2011-11-06 18:23:08 +00:00
|
|
|
if(CARDINSERTED)
|
2011-11-05 13:13:20 +00:00
|
|
|
#endif
|
|
|
|
if((activeline==line)&&CLICKED)
|
|
|
|
{
|
2011-11-06 21:48:15 +00:00
|
|
|
card.sdprinting = false;
|
2011-11-05 13:13:20 +00:00
|
|
|
BLOCK;
|
|
|
|
status=Main_SD;
|
|
|
|
beepshort();
|
|
|
|
}
|
|
|
|
}break;
|
2011-11-20 10:55:33 +00:00
|
|
|
#else
|
|
|
|
case ItemM_file:
|
|
|
|
break;
|
2011-11-06 18:23:08 +00:00
|
|
|
#endif
|
2011-11-05 13:13:20 +00:00
|
|
|
default:
|
2011-11-09 19:27:15 +00:00
|
|
|
SERIAL_ERROR_START;
|
|
|
|
SERIAL_ERRORLNPGM("Something is wrong in the MenuStructure.");
|
2011-11-05 13:13:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-11-20 10:55:33 +00:00
|
|
|
updateActiveLines(3,encoderpos);
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainMenu::update()
|
|
|
|
{
|
|
|
|
static MainStatus oldstatus=Main_Menu; //init automatically causes foce_lcd_update=true
|
|
|
|
static long timeoutToStatus=0;
|
|
|
|
static bool oldcardstatus=false;
|
2011-11-06 18:23:08 +00:00
|
|
|
#ifdef CARDINSERTED
|
|
|
|
if((CARDINSERTED != oldcardstatus))
|
2011-11-05 13:13:20 +00:00
|
|
|
{
|
2011-11-06 18:23:08 +00:00
|
|
|
force_lcd_update=true;
|
|
|
|
oldcardstatus=CARDINSERTED;
|
|
|
|
//Serial.println("echo: SD CHANGE");
|
|
|
|
if(CARDINSERTED)
|
|
|
|
{
|
2011-11-06 20:39:53 +00:00
|
|
|
card.initsd();
|
2011-11-20 10:55:33 +00:00
|
|
|
LCD_MESSAGEPGM("Card inserted");
|
2011-11-06 18:23:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-06 21:48:15 +00:00
|
|
|
card.release();
|
2011-11-20 10:55:33 +00:00
|
|
|
LCD_MESSAGEPGM("Card removed");
|
2011-11-06 18:23:08 +00:00
|
|
|
}
|
2011-11-05 13:13:20 +00:00
|
|
|
}
|
2011-11-06 18:23:08 +00:00
|
|
|
#endif
|
2011-11-05 13:13:20 +00:00
|
|
|
|
|
|
|
if(status!=oldstatus)
|
|
|
|
{
|
|
|
|
force_lcd_update=true;
|
|
|
|
encoderpos=0;
|
|
|
|
lineoffset=0;
|
|
|
|
|
|
|
|
oldstatus=status;
|
|
|
|
}
|
|
|
|
if( (encoderpos!=lastencoderpos) || CLICKED)
|
|
|
|
timeoutToStatus=millis()+STATUSTIMEOUT;
|
|
|
|
|
|
|
|
switch(status)
|
|
|
|
{
|
|
|
|
case Main_Status:
|
|
|
|
{
|
|
|
|
showStatus();
|
|
|
|
if(CLICKED)
|
|
|
|
{
|
|
|
|
linechanging=false;
|
|
|
|
BLOCK
|
|
|
|
status=Main_Menu;
|
|
|
|
timeoutToStatus=millis()+STATUSTIMEOUT;
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
case Main_Menu:
|
|
|
|
{
|
|
|
|
showMainMenu();
|
|
|
|
linechanging=false;
|
|
|
|
}break;
|
|
|
|
case Main_Prepare:
|
|
|
|
{
|
2011-11-20 15:05:42 +00:00
|
|
|
if(tune)
|
|
|
|
{
|
|
|
|
showTune();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
showPrepare();
|
|
|
|
}
|
2011-11-05 13:13:20 +00:00
|
|
|
}break;
|
|
|
|
case Main_Control:
|
|
|
|
{
|
|
|
|
showControl();
|
|
|
|
}break;
|
2011-11-20 13:43:47 +00:00
|
|
|
case Sub_MotionControl:
|
|
|
|
{
|
|
|
|
showControlMotion();
|
|
|
|
}break;
|
|
|
|
case Sub_TempControl:
|
|
|
|
{
|
|
|
|
showControlTemp();
|
|
|
|
}break;
|
2011-11-05 13:13:20 +00:00
|
|
|
case Main_SD:
|
|
|
|
{
|
|
|
|
showSD();
|
|
|
|
}break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(timeoutToStatus<millis())
|
|
|
|
status=Main_Status;
|
2011-11-20 13:43:47 +00:00
|
|
|
//force_lcd_update=false;
|
2011-11-05 13:13:20 +00:00
|
|
|
lastencoderpos=encoderpos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-06 22:34:40 +00:00
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
|
2011-11-06 18:23:08 +00:00
|
|
|
// convert float to string with +123.4 format
|
2011-11-05 13:13:20 +00:00
|
|
|
char *ftostr3(const float &x)
|
|
|
|
{
|
|
|
|
//sprintf(conv,"%5.1f",x);
|
|
|
|
int xx=x;
|
|
|
|
conv[0]=(xx/100)%10+'0';
|
|
|
|
conv[1]=(xx/10)%10+'0';
|
|
|
|
conv[2]=(xx)%10+'0';
|
|
|
|
conv[3]=0;
|
|
|
|
return conv;
|
|
|
|
}
|
2011-11-06 18:23:08 +00:00
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
char *itostr2(const uint8_t &x)
|
|
|
|
{
|
|
|
|
//sprintf(conv,"%5.1f",x);
|
|
|
|
int xx=x;
|
|
|
|
conv[0]=(xx/10)%10+'0';
|
|
|
|
conv[1]=(xx)%10+'0';
|
|
|
|
conv[2]=0;
|
|
|
|
return conv;
|
|
|
|
}
|
2011-11-06 18:23:08 +00:00
|
|
|
|
|
|
|
// convert float to string with +123.4 format
|
2011-11-05 13:13:20 +00:00
|
|
|
char *ftostr31(const float &x)
|
|
|
|
{
|
|
|
|
int xx=x*10;
|
|
|
|
conv[0]=(xx>=0)?'+':'-';
|
|
|
|
xx=abs(xx);
|
|
|
|
conv[1]=(xx/1000)%10+'0';
|
|
|
|
conv[2]=(xx/100)%10+'0';
|
|
|
|
conv[3]=(xx/10)%10+'0';
|
|
|
|
conv[4]='.';
|
|
|
|
conv[5]=(xx)%10+'0';
|
|
|
|
conv[6]=0;
|
|
|
|
return conv;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *itostr31(const int &xx)
|
|
|
|
{
|
|
|
|
conv[0]=(xx>=0)?'+':'-';
|
|
|
|
conv[1]=(xx/1000)%10+'0';
|
|
|
|
conv[2]=(xx/100)%10+'0';
|
|
|
|
conv[3]=(xx/10)%10+'0';
|
|
|
|
conv[4]='.';
|
|
|
|
conv[5]=(xx)%10+'0';
|
|
|
|
conv[6]=0;
|
|
|
|
return conv;
|
|
|
|
}
|
2011-11-06 18:23:08 +00:00
|
|
|
|
2011-11-05 13:13:20 +00:00
|
|
|
char *itostr3(const int &xx)
|
|
|
|
{
|
|
|
|
conv[0]=(xx/100)%10+'0';
|
|
|
|
conv[1]=(xx/10)%10+'0';
|
|
|
|
conv[2]=(xx)%10+'0';
|
|
|
|
conv[3]=0;
|
|
|
|
return conv;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *itostr4(const int &xx)
|
|
|
|
{
|
|
|
|
conv[0]=(xx/1000)%10+'0';
|
|
|
|
conv[1]=(xx/100)%10+'0';
|
|
|
|
conv[2]=(xx/10)%10+'0';
|
|
|
|
conv[3]=(xx)%10+'0';
|
|
|
|
conv[4]=0;
|
|
|
|
return conv;
|
|
|
|
}
|
|
|
|
|
2011-11-06 18:23:08 +00:00
|
|
|
// convert float to string with +1234.5 format
|
2011-11-05 13:13:20 +00:00
|
|
|
char *ftostr51(const float &x)
|
|
|
|
{
|
|
|
|
int xx=x*10;
|
|
|
|
conv[0]=(xx>=0)?'+':'-';
|
|
|
|
xx=abs(xx);
|
|
|
|
conv[1]=(xx/10000)%10+'0';
|
|
|
|
conv[2]=(xx/1000)%10+'0';
|
|
|
|
conv[3]=(xx/100)%10+'0';
|
|
|
|
conv[4]=(xx/10)%10+'0';
|
|
|
|
conv[5]='.';
|
|
|
|
conv[6]=(xx)%10+'0';
|
|
|
|
conv[7]=0;
|
|
|
|
return conv;
|
|
|
|
}
|
|
|
|
|
2011-11-06 18:23:08 +00:00
|
|
|
|
|
|
|
#endif //ULTRA_LCD
|
2011-11-06 13:03:41 +00:00
|
|
|
|
|
|
|
|