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_common_HD44780.h 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifndef ULTRALCD_COMMON_HD44780_H
  23. #define ULTRALCD_COMMON_HD44780_H
  24. /**
  25. * Implementation of the LCD display routines for a Hitachi HD44780 display.
  26. * These are the most common LCD character displays.
  27. */
  28. #include "../inc/MarlinConfig.h"
  29. #if LCD_HEIGHT > 3
  30. #include "../libs/duration_t.h"
  31. #endif
  32. #if ENABLED(AUTO_BED_LEVELING_UBL)
  33. #include "../feature/bedlevel/ubl/ubl.h"
  34. #if ENABLED(ULTIPANEL)
  35. #define ULTRA_X_PIXELS_PER_CHAR 5
  36. #define ULTRA_Y_PIXELS_PER_CHAR 8
  37. #define ULTRA_COLUMNS_FOR_MESH_MAP 7
  38. #define ULTRA_ROWS_FOR_MESH_MAP 4
  39. #define N_USER_CHARS 8
  40. #define TOP_LEFT _BV(0)
  41. #define TOP_RIGHT _BV(1)
  42. #define LOWER_LEFT _BV(2)
  43. #define LOWER_RIGHT _BV(3)
  44. #endif
  45. #endif
  46. extern volatile uint8_t buttons; //an extended version of the last checked buttons in a bit array.
  47. ////////////////////////////////////
  48. // Setup button and encode mappings for each panel (into 'buttons' variable
  49. //
  50. // This is just to map common functions (across different panels) onto the same
  51. // macro name. The mapping is independent of whether the button is directly connected or
  52. // via a shift/i2c register.
  53. #if ENABLED(ULTIPANEL)
  54. //
  55. // Setup other button mappings of each panel
  56. //
  57. #if ENABLED(LCD_I2C_VIKI)
  58. #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
  59. // button and encoder bit positions within 'buttons'
  60. #define B_LE (BUTTON_LEFT << B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
  61. #define B_UP (BUTTON_UP << B_I2C_BTN_OFFSET)
  62. #define B_MI (BUTTON_SELECT << B_I2C_BTN_OFFSET)
  63. #define B_DW (BUTTON_DOWN << B_I2C_BTN_OFFSET)
  64. #define B_RI (BUTTON_RIGHT << B_I2C_BTN_OFFSET)
  65. #undef LCD_CLICKED
  66. #if BUTTON_EXISTS(ENC)
  67. // the pause/stop/restart button is connected to BTN_ENC when used
  68. #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
  69. #define LCD_CLICKED (buttons & (B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
  70. #else
  71. #define LCD_CLICKED (buttons & (B_MI|B_RI))
  72. #endif
  73. // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
  74. #define LCD_HAS_SLOW_BUTTONS
  75. #elif ENABLED(LCD_I2C_PANELOLU2)
  76. #if !BUTTON_EXISTS(ENC) // Use I2C if not directly connected to a pin
  77. #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
  78. #define B_MI (PANELOLU2_ENCODER_C << B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
  79. #undef LCD_CLICKED
  80. #define LCD_CLICKED (buttons & B_MI)
  81. // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
  82. #define LCD_HAS_SLOW_BUTTONS
  83. #endif
  84. #elif DISABLED(NEWPANEL) // old style ULTIPANEL
  85. // Shift register bits correspond to buttons:
  86. #define BL_LE 7 // Left
  87. #define BL_UP 6 // Up
  88. #define BL_MI 5 // Middle
  89. #define BL_DW 4 // Down
  90. #define BL_RI 3 // Right
  91. #define BL_ST 2 // Red Button
  92. #define B_LE (_BV(BL_LE))
  93. #define B_UP (_BV(BL_UP))
  94. #define B_MI (_BV(BL_MI))
  95. #define B_DW (_BV(BL_DW))
  96. #define B_RI (_BV(BL_RI))
  97. #define B_ST (_BV(BL_ST))
  98. #define LCD_CLICKED (buttons & (B_MI|B_ST))
  99. #endif
  100. #endif // ULTIPANEL
  101. ////////////////////////////////////
  102. // Create LCD class instance and chipset-specific information
  103. #if ENABLED(LCD_I2C_TYPE_PCF8575)
  104. // NOTE: These are register-mapped pins on the PCF8575 controller, not Arduino pins.
  105. #define LCD_I2C_PIN_BL 3
  106. #define LCD_I2C_PIN_EN 2
  107. #define LCD_I2C_PIN_RW 1
  108. #define LCD_I2C_PIN_RS 0
  109. #define LCD_I2C_PIN_D4 4
  110. #define LCD_I2C_PIN_D5 5
  111. #define LCD_I2C_PIN_D6 6
  112. #define LCD_I2C_PIN_D7 7
  113. #include <Wire.h>
  114. #include <LCD.h>
  115. #include <LiquidCrystal_I2C.h>
  116. #define LCD_CLASS LiquidCrystal_I2C
  117. #elif ENABLED(LCD_I2C_TYPE_MCP23017)
  118. // For the LED indicators (which may be mapped to different events in lcd_implementation_update_indicators())
  119. #define LED_A 0x04 //100
  120. #define LED_B 0x02 //010
  121. #define LED_C 0x01 //001
  122. #define LCD_HAS_STATUS_INDICATORS
  123. #include <Wire.h>
  124. #include <LiquidTWI2.h>
  125. #define LCD_CLASS LiquidTWI2
  126. #elif ENABLED(LCD_I2C_TYPE_MCP23008)
  127. #include <Wire.h>
  128. #include <LiquidTWI2.h>
  129. #define LCD_CLASS LiquidTWI2
  130. #elif ENABLED(LCD_I2C_TYPE_PCA8574)
  131. #include <LiquidCrystal_I2C.h>
  132. #define LCD_CLASS LiquidCrystal_I2C
  133. // 2 wire Non-latching LCD SR from:
  134. // https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
  135. #elif ENABLED(SR_LCD_2W_NL)
  136. extern "C" void __cxa_pure_virtual() { while (1); }
  137. #include <LCD.h>
  138. #include <LiquidCrystal_SR.h>
  139. #define LCD_CLASS LiquidCrystal_SR
  140. #elif ENABLED(LCM1602)
  141. #include <Wire.h>
  142. #include <LCD.h>
  143. #include <LiquidCrystal_I2C.h>
  144. #define LCD_CLASS LiquidCrystal_I2C
  145. #else
  146. // Standard directly connected LCD implementations
  147. #include <LiquidCrystal.h>
  148. #define LCD_CLASS LiquidCrystal
  149. #endif
  150. #include "fontutils.h"
  151. #include "lcdprint.h"
  152. #if ENABLED(LCD_PROGRESS_BAR)
  153. #define LCD_STR_PROGRESS "\x03\x04\x05"
  154. #endif
  155. enum HD44780CharSet : char {
  156. CHARSET_MENU,
  157. CHARSET_INFO,
  158. CHARSET_BOOT
  159. };
  160. #endif // ULTRALCD_COMMON_HD44780_H