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.7KB

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