My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ultralcd.h 3.8KB

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