My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ultralcd.h 4.1KB

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