My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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