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

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