My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ultralcd.h 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #ifndef ULTRALCD_H
  2. #define ULTRALCD_H
  3. #include "Marlin.h"
  4. #ifdef ULTRA_LCD
  5. #include "language.h"
  6. #if LANGUAGE_CHOICE == 6
  7. #include "LiquidCrystalRus.h"
  8. #else
  9. #include <LiquidCrystal.h>
  10. #endif
  11. void lcd_status();
  12. void lcd_init();
  13. void lcd_status(const char* message);
  14. void beep();
  15. void buttons_init();
  16. void buttons_check();
  17. #define LCD_UPDATE_INTERVAL 100
  18. #define STATUSTIMEOUT 15000
  19. #if LANGUAGE_CHOICE == 6
  20. extern LiquidCrystalRus lcd;
  21. #else
  22. extern LiquidCrystal lcd;
  23. #endif
  24. extern volatile char buttons; //the last checked buttons in a bit array.
  25. #ifdef NEWPANEL
  26. #define EN_C (1<<BLEN_C)
  27. #define EN_B (1<<BLEN_B)
  28. #define EN_A (1<<BLEN_A)
  29. #define CLICKED (buttons&EN_C)
  30. #define BLOCK {blocking=millis()+blocktime;}
  31. #if (SDCARDDETECT > -1)
  32. #ifdef SDCARDDETECTINVERTED
  33. #define CARDINSERTED (READ(SDCARDDETECT)!=0)
  34. #else
  35. #define CARDINSERTED (READ(SDCARDDETECT)==0)
  36. #endif
  37. #endif //SDCARDTETECTINVERTED
  38. #else
  39. //atomatic, do not change
  40. #define B_LE (1<<BL_LE)
  41. #define B_UP (1<<BL_UP)
  42. #define B_MI (1<<BL_MI)
  43. #define B_DW (1<<BL_DW)
  44. #define B_RI (1<<BL_RI)
  45. #define B_ST (1<<BL_ST)
  46. #define EN_B (1<<BLEN_B)
  47. #define EN_A (1<<BLEN_A)
  48. #define CLICKED ((buttons&B_MI)||(buttons&B_ST))
  49. #define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
  50. #endif
  51. // blocking time for recognizing a new keypress of one key, ms
  52. #define blocktime 500
  53. #define lcdslow 5
  54. enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl,Sub_RetractControl, Sub_PreheatPLASettings, Sub_PreheatABSSettings};
  55. class MainMenu{
  56. public:
  57. MainMenu();
  58. void update();
  59. int8_t activeline;
  60. MainStatus status;
  61. uint8_t displayStartingRow;
  62. void showStatus();
  63. void showMainMenu();
  64. void showPrepare();
  65. void showTune();
  66. void showControl();
  67. void showControlMotion();
  68. void showControlTemp();
  69. void showControlRetract();
  70. void showAxisMove();
  71. void showSD();
  72. void showPLAsettings();
  73. void showABSsettings();
  74. bool force_lcd_update;
  75. long lastencoderpos;
  76. int8_t lineoffset;
  77. int8_t lastlineoffset;
  78. bool linechanging;
  79. bool tune;
  80. private:
  81. FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
  82. {
  83. if(linechanging) return; // an item is changint its value, do not switch lines hence
  84. lastlineoffset=lineoffset;
  85. long curencoderpos=encoderpos;
  86. force_lcd_update=false;
  87. if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
  88. {
  89. lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' ');
  90. if(curencoderpos<0)
  91. {
  92. lineoffset--;
  93. if(lineoffset<0) lineoffset=0;
  94. curencoderpos=lcdslow-1;
  95. }
  96. if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow)
  97. {
  98. lineoffset++;
  99. curencoderpos=(LCD_HEIGHT-1)*lcdslow;
  100. if(lineoffset>(maxlines+1-LCD_HEIGHT))
  101. lineoffset=maxlines+1-LCD_HEIGHT;
  102. if(curencoderpos>maxlines*lcdslow)
  103. curencoderpos=maxlines*lcdslow;
  104. }
  105. lastencoderpos=encoderpos=curencoderpos;
  106. activeline=curencoderpos/lcdslow;
  107. if(activeline<0) activeline=0;
  108. if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
  109. if(activeline>maxlines)
  110. {
  111. activeline=maxlines;
  112. curencoderpos=maxlines*lcdslow;
  113. }
  114. if(lastlineoffset!=lineoffset)
  115. force_lcd_update=true;
  116. lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
  117. }
  118. }
  119. FORCE_INLINE void clearIfNecessary()
  120. {
  121. if(lastlineoffset!=lineoffset ||force_lcd_update)
  122. {
  123. force_lcd_update=true;
  124. lcd.clear();
  125. }
  126. }
  127. };
  128. //conversion routines, could need some overworking
  129. char *ftostr51(const float &x);
  130. char *ftostr52(const float &x);
  131. char *ftostr31(const float &x);
  132. char *ftostr3(const float &x);
  133. #define LCD_INIT lcd_init();
  134. #define LCD_MESSAGE(x) lcd_status(x);
  135. #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
  136. #define LCD_ALERTMESSAGEPGM(x) lcd_alertstatuspgm(MYPGM(x));
  137. #define LCD_STATUS lcd_status()
  138. #else //no lcd
  139. #define LCD_INIT
  140. #define LCD_STATUS
  141. #define LCD_MESSAGE(x)
  142. #define LCD_MESSAGEPGM(x)
  143. #define LCD_ALERTMESSAGEPGM(x)
  144. FORCE_INLINE void lcd_status() {};
  145. #define CLICKED false
  146. #define BLOCK ;
  147. #endif
  148. void lcd_statuspgm(const char* message);
  149. void lcd_alertstatuspgm(const char* message);
  150. char *ftostr3(const float &x);
  151. char *itostr2(const uint8_t &x);
  152. char *ftostr31(const float &x);
  153. char *ftostr32(const float &x);
  154. char *itostr31(const int &xx);
  155. char *itostr3(const int &xx);
  156. char *itostr4(const int &xx);
  157. char *ftostr51(const float &x);
  158. #endif //ULTRALCD