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

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