2011-11-15 22:50:43 +01:00
|
|
|
#ifndef __ULTRALCDH
|
|
|
|
#define __ULTRALCDH
|
2011-12-04 12:40:18 +01:00
|
|
|
#include "Marlin.h"
|
2011-11-15 22:50:43 +01:00
|
|
|
#ifdef ULTRA_LCD
|
2011-12-22 12:38:50 +01:00
|
|
|
#include <LiquidCrystal.h>
|
2011-11-15 22:50:43 +01:00
|
|
|
void lcd_status();
|
|
|
|
void lcd_init();
|
|
|
|
void lcd_status(const char* message);
|
|
|
|
void beep();
|
2012-05-03 15:48:44 +02:00
|
|
|
void buttons_init();
|
2011-11-15 22:50:43 +01:00
|
|
|
void buttons_check();
|
|
|
|
|
|
|
|
#define LCD_UPDATE_INTERVAL 100
|
|
|
|
#define STATUSTIMEOUT 15000
|
|
|
|
extern LiquidCrystal lcd;
|
2012-05-19 17:57:52 +02:00
|
|
|
extern volatile char buttons; //the last checked buttons in a bit array.
|
2012-02-21 23:05:43 +01:00
|
|
|
|
2011-11-15 22:50:43 +01:00
|
|
|
#ifdef NEWPANEL
|
|
|
|
#define EN_C (1<<BLEN_C)
|
|
|
|
#define EN_B (1<<BLEN_B)
|
|
|
|
#define EN_A (1<<BLEN_A)
|
|
|
|
|
|
|
|
#define CLICKED (buttons&EN_C)
|
|
|
|
#define BLOCK {blocking=millis()+blocktime;}
|
2012-02-06 12:22:44 +01:00
|
|
|
#if (SDCARDDETECT > -1)
|
2012-02-21 20:36:43 +01:00
|
|
|
#ifdef SDCARDDETECTINVERTED
|
|
|
|
#define CARDINSERTED (READ(SDCARDDETECT)!=0)
|
|
|
|
#else
|
|
|
|
#define CARDINSERTED (READ(SDCARDDETECT)==0)
|
|
|
|
#endif
|
|
|
|
#endif //SDCARDTETECTINVERTED
|
2012-02-19 00:56:31 +01:00
|
|
|
|
2011-11-15 22:50:43 +01:00
|
|
|
#else
|
|
|
|
|
|
|
|
//atomatic, do not change
|
|
|
|
#define B_LE (1<<BL_LE)
|
|
|
|
#define B_UP (1<<BL_UP)
|
|
|
|
#define B_MI (1<<BL_MI)
|
|
|
|
#define B_DW (1<<BL_DW)
|
|
|
|
#define B_RI (1<<BL_RI)
|
|
|
|
#define B_ST (1<<BL_ST)
|
|
|
|
#define EN_B (1<<BLEN_B)
|
|
|
|
#define EN_A (1<<BLEN_A)
|
|
|
|
|
|
|
|
#define CLICKED ((buttons&B_MI)||(buttons&B_ST))
|
|
|
|
#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
|
|
|
|
|
2012-06-02 20:32:28 +02:00
|
|
|
enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl,Sub_RetractControl};
|
2011-11-15 22:50:43 +01:00
|
|
|
|
|
|
|
class MainMenu{
|
|
|
|
public:
|
|
|
|
MainMenu();
|
|
|
|
void update();
|
2011-11-20 14:43:47 +01:00
|
|
|
int8_t activeline;
|
2011-11-15 22:50:43 +01:00
|
|
|
MainStatus status;
|
|
|
|
uint8_t displayStartingRow;
|
|
|
|
|
|
|
|
void showStatus();
|
|
|
|
void showMainMenu();
|
|
|
|
void showPrepare();
|
2011-11-20 16:05:42 +01:00
|
|
|
void showTune();
|
2011-11-15 22:50:43 +01:00
|
|
|
void showControl();
|
2011-11-20 14:43:47 +01:00
|
|
|
void showControlMotion();
|
|
|
|
void showControlTemp();
|
2012-06-02 20:32:28 +02:00
|
|
|
void showControlRetract();
|
2012-02-07 12:58:05 +01:00
|
|
|
void showAxisMove();
|
2011-11-15 22:50:43 +01:00
|
|
|
void showSD();
|
|
|
|
bool force_lcd_update;
|
2012-05-11 15:19:09 +02:00
|
|
|
long lastencoderpos;
|
2011-11-15 22:50:43 +01:00
|
|
|
int8_t lineoffset;
|
|
|
|
int8_t lastlineoffset;
|
|
|
|
|
|
|
|
bool linechanging;
|
2011-11-20 11:55:33 +01:00
|
|
|
|
2011-11-20 16:05:42 +01:00
|
|
|
bool tune;
|
|
|
|
|
2011-11-20 11:55:33 +01:00
|
|
|
private:
|
2012-05-11 15:19:09 +02:00
|
|
|
FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
|
2011-11-20 11:55:33 +01:00
|
|
|
{
|
|
|
|
if(linechanging) return; // an item is changint its value, do not switch lines hence
|
|
|
|
lastlineoffset=lineoffset;
|
2012-05-11 15:19:09 +02:00
|
|
|
long curencoderpos=encoderpos;
|
2011-11-20 11:55:33 +01:00
|
|
|
force_lcd_update=false;
|
|
|
|
if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
|
|
|
|
{
|
|
|
|
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' ');
|
|
|
|
if(curencoderpos<0)
|
|
|
|
{
|
|
|
|
lineoffset--;
|
|
|
|
if(lineoffset<0) lineoffset=0;
|
2011-11-20 16:05:42 +01:00
|
|
|
curencoderpos=lcdslow-1;
|
2011-11-20 11:55:33 +01:00
|
|
|
}
|
|
|
|
if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow)
|
|
|
|
{
|
|
|
|
lineoffset++;
|
|
|
|
curencoderpos=(LCD_HEIGHT-1)*lcdslow;
|
|
|
|
if(lineoffset>(maxlines+1-LCD_HEIGHT))
|
|
|
|
lineoffset=maxlines+1-LCD_HEIGHT;
|
|
|
|
if(curencoderpos>maxlines*lcdslow)
|
|
|
|
curencoderpos=maxlines*lcdslow;
|
|
|
|
}
|
2011-11-20 16:05:42 +01:00
|
|
|
lastencoderpos=encoderpos=curencoderpos;
|
2011-11-20 11:55:33 +01:00
|
|
|
activeline=curencoderpos/lcdslow;
|
|
|
|
if(activeline<0) activeline=0;
|
|
|
|
if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
|
|
|
|
if(activeline>maxlines)
|
|
|
|
{
|
|
|
|
activeline=maxlines;
|
|
|
|
curencoderpos=maxlines*lcdslow;
|
|
|
|
}
|
2011-11-20 16:37:01 +01:00
|
|
|
if(lastlineoffset!=lineoffset)
|
2011-11-20 16:05:42 +01:00
|
|
|
force_lcd_update=true;
|
2011-11-20 11:55:33 +01:00
|
|
|
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-27 16:04:58 +01:00
|
|
|
FORCE_INLINE void clearIfNecessary()
|
2011-11-20 11:55:33 +01:00
|
|
|
{
|
|
|
|
if(lastlineoffset!=lineoffset ||force_lcd_update)
|
|
|
|
{
|
|
|
|
force_lcd_update=true;
|
|
|
|
lcd.clear();
|
|
|
|
}
|
|
|
|
}
|
2011-11-15 22:50:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
//conversion routines, could need some overworking
|
|
|
|
char *ftostr51(const float &x);
|
2012-02-29 15:33:23 +01:00
|
|
|
char *ftostr52(const float &x);
|
2011-11-15 22:50:43 +01:00
|
|
|
char *ftostr31(const float &x);
|
|
|
|
char *ftostr3(const float &x);
|
|
|
|
|
|
|
|
|
2012-05-03 14:28:17 +02:00
|
|
|
#define LCD_INIT lcd_init();
|
2011-11-15 22:50:43 +01:00
|
|
|
#define LCD_MESSAGE(x) lcd_status(x);
|
2011-12-04 12:40:18 +01:00
|
|
|
#define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
|
2011-11-15 22:50:43 +01:00
|
|
|
#define LCD_STATUS lcd_status()
|
|
|
|
#else //no lcd
|
2012-05-03 14:28:17 +02:00
|
|
|
#define LCD_INIT
|
2011-11-15 22:50:43 +01:00
|
|
|
#define LCD_STATUS
|
|
|
|
#define LCD_MESSAGE(x)
|
|
|
|
#define LCD_MESSAGEPGM(x)
|
2011-11-27 16:04:58 +01:00
|
|
|
FORCE_INLINE void lcd_status() {};
|
2012-02-29 15:33:23 +01:00
|
|
|
|
|
|
|
#define CLICKED false
|
2011-11-15 22:50:43 +01:00
|
|
|
#define BLOCK ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void lcd_statuspgm(const char* message);
|
|
|
|
|
2011-12-22 16:43:28 +01:00
|
|
|
char *ftostr3(const float &x);
|
|
|
|
char *itostr2(const uint8_t &x);
|
|
|
|
char *ftostr31(const float &x);
|
|
|
|
char *ftostr32(const float &x);
|
|
|
|
char *itostr31(const int &xx);
|
|
|
|
char *itostr3(const int &xx);
|
|
|
|
char *itostr4(const int &xx);
|
|
|
|
char *ftostr51(const float &x);
|
2011-11-15 22:50:43 +01:00
|
|
|
#endif //ULTRALCD
|