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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 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. 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. int lastactiveline=activeline;
  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. 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(PSTR(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. 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