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 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #ifndef __ULTRALCDH
  2. #define __ULTRALCDH
  3. #include "Configuration.h"
  4. #ifdef ULTRA_LCD
  5. void lcd_status();
  6. void lcd_init();
  7. void lcd_status(const char* message);
  8. void beep();
  9. void buttons_check();
  10. #define LCD_UPDATE_INTERVAL 100
  11. #define STATUSTIMEOUT 15000
  12. #include <LiquidCrystal.h>
  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 showControl();
  49. void showControlMotion();
  50. void showControlTemp();
  51. void showSD();
  52. bool force_lcd_update;
  53. int lastencoderpos;
  54. int8_t lineoffset;
  55. int8_t lastlineoffset;
  56. bool linechanging;
  57. private:
  58. inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
  59. {
  60. if(linechanging) return; // an item is changint its value, do not switch lines hence
  61. lastlineoffset=lineoffset;
  62. int curencoderpos=encoderpos;
  63. force_lcd_update=false;
  64. if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
  65. {
  66. lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' ');
  67. if(curencoderpos<0)
  68. {
  69. lineoffset--;
  70. if(lineoffset<0) lineoffset=0;
  71. curencoderpos=lcdslow-1;
  72. force_lcd_update=true;
  73. }
  74. if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow)
  75. {
  76. lineoffset++;
  77. curencoderpos=(LCD_HEIGHT-1)*lcdslow;
  78. if(lineoffset>(maxlines+1-LCD_HEIGHT))
  79. lineoffset=maxlines+1-LCD_HEIGHT;
  80. if(curencoderpos>maxlines*lcdslow)
  81. curencoderpos=maxlines*lcdslow;
  82. force_lcd_update=true;
  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. lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
  94. }
  95. }
  96. inline void clearIfNecessary()
  97. {
  98. if(lastlineoffset!=lineoffset ||force_lcd_update)
  99. {
  100. force_lcd_update=true;
  101. lcd.clear();
  102. }
  103. }
  104. };
  105. //conversion routines, could need some overworking
  106. char *fillto(int8_t n,char *c);
  107. char *ftostr51(const float &x);
  108. char *ftostr31(const float &x);
  109. char *ftostr3(const float &x);
  110. #define LCD_MESSAGE(x) lcd_status(x);
  111. #define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
  112. #define LCD_STATUS lcd_status()
  113. #else //no lcd
  114. #define LCD_STATUS
  115. #define LCD_MESSAGE(x)
  116. #define LCD_MESSAGEPGM(x)
  117. inline void lcd_status() {};
  118. #endif
  119. #ifndef ULTIPANEL
  120. #define CLICKED false
  121. #define BLOCK ;
  122. #endif
  123. void lcd_statuspgm(const char* message);
  124. #endif //ULTRALCD