My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ultralcd_common_HD44780.h 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. #include <binary.h>
  47. extern volatile uint8_t buttons; //an extended version of the last checked buttons in a bit array.
  48. ////////////////////////////////////
  49. // Setup button and encode mappings for each panel (into 'buttons' variable
  50. //
  51. // This is just to map common functions (across different panels) onto the same
  52. // macro name. The mapping is independent of whether the button is directly connected or
  53. // via a shift/i2c register.
  54. #if ENABLED(ULTIPANEL)
  55. //
  56. // Setup other button mappings of each panel
  57. //
  58. #if ENABLED(LCD_I2C_VIKI)
  59. #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
  60. // button and encoder bit positions within 'buttons'
  61. #define B_LE (BUTTON_LEFT << B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
  62. #define B_UP (BUTTON_UP << B_I2C_BTN_OFFSET)
  63. #define B_MI (BUTTON_SELECT << B_I2C_BTN_OFFSET)
  64. #define B_DW (BUTTON_DOWN << B_I2C_BTN_OFFSET)
  65. #define B_RI (BUTTON_RIGHT << B_I2C_BTN_OFFSET)
  66. #undef LCD_CLICKED
  67. #if BUTTON_EXISTS(ENC)
  68. // the pause/stop/restart button is connected to BTN_ENC when used
  69. #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
  70. #define LCD_CLICKED (buttons & (B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
  71. #else
  72. #define LCD_CLICKED (buttons & (B_MI|B_RI))
  73. #endif
  74. // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
  75. #define LCD_HAS_SLOW_BUTTONS
  76. #elif ENABLED(LCD_I2C_PANELOLU2)
  77. #if !BUTTON_EXISTS(ENC) // Use I2C if not directly connected to a pin
  78. #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
  79. #define B_MI (PANELOLU2_ENCODER_C << B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
  80. #undef LCD_CLICKED
  81. #define LCD_CLICKED (buttons & B_MI)
  82. // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
  83. #define LCD_HAS_SLOW_BUTTONS
  84. #endif
  85. #elif DISABLED(NEWPANEL) // old style ULTIPANEL
  86. // Shift register bits correspond to buttons:
  87. #define BL_LE 7 // Left
  88. #define BL_UP 6 // Up
  89. #define BL_MI 5 // Middle
  90. #define BL_DW 4 // Down
  91. #define BL_RI 3 // Right
  92. #define BL_ST 2 // Red Button
  93. #define B_LE (_BV(BL_LE))
  94. #define B_UP (_BV(BL_UP))
  95. #define B_MI (_BV(BL_MI))
  96. #define B_DW (_BV(BL_DW))
  97. #define B_RI (_BV(BL_RI))
  98. #define B_ST (_BV(BL_ST))
  99. #define LCD_CLICKED (buttons & (B_MI|B_ST))
  100. #endif
  101. #endif // ULTIPANEL
  102. ////////////////////////////////////
  103. // Create LCD class instance and chipset-specific information
  104. #if ENABLED(LCD_I2C_TYPE_PCF8575)
  105. // NOTE: These are register-mapped pins on the PCF8575 controller, not Arduino pins.
  106. #define LCD_I2C_PIN_BL 3
  107. #define LCD_I2C_PIN_EN 2
  108. #define LCD_I2C_PIN_RW 1
  109. #define LCD_I2C_PIN_RS 0
  110. #define LCD_I2C_PIN_D4 4
  111. #define LCD_I2C_PIN_D5 5
  112. #define LCD_I2C_PIN_D6 6
  113. #define LCD_I2C_PIN_D7 7
  114. #include <Wire.h>
  115. #include <LCD.h>
  116. #include <LiquidCrystal_I2C.h>
  117. #define LCD_CLASS LiquidCrystal_I2C
  118. #elif ENABLED(LCD_I2C_TYPE_MCP23017)
  119. // For the LED indicators (which may be mapped to different events in lcd_implementation_update_indicators())
  120. #define LED_A 0x04 //100
  121. #define LED_B 0x02 //010
  122. #define LED_C 0x01 //001
  123. #define LCD_HAS_STATUS_INDICATORS
  124. #include <Wire.h>
  125. #include <LiquidTWI2.h>
  126. #define LCD_CLASS LiquidTWI2
  127. #elif ENABLED(LCD_I2C_TYPE_MCP23008)
  128. #include <Wire.h>
  129. #include <LiquidTWI2.h>
  130. #define LCD_CLASS LiquidTWI2
  131. #elif ENABLED(LCD_I2C_TYPE_PCA8574)
  132. #include <LiquidCrystal_I2C.h>
  133. #define LCD_CLASS LiquidCrystal_I2C
  134. // 2 wire Non-latching LCD SR from:
  135. // https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
  136. #elif ENABLED(SR_LCD_2W_NL)
  137. extern "C" void __cxa_pure_virtual() { while (1); }
  138. #include <LCD.h>
  139. #include <LiquidCrystal_SR.h>
  140. #define LCD_CLASS LiquidCrystal_SR
  141. #elif ENABLED(LCM1602)
  142. #include <Wire.h>
  143. #include <LCD.h>
  144. #include <LiquidCrystal_I2C.h>
  145. #define LCD_CLASS LiquidCrystal_I2C
  146. #else
  147. // Standard directly connected LCD implementations
  148. #include <LiquidCrystal.h>
  149. #define LCD_CLASS LiquidCrystal
  150. #endif
  151. #include "fontutils.h"
  152. #include "lcdprint.h"
  153. #if ENABLED(LCD_PROGRESS_BAR)
  154. #define LCD_STR_PROGRESS "\x03\x04\x05"
  155. #endif
  156. enum HD44780CharSet : char {
  157. CHARSET_MENU,
  158. CHARSET_INFO,
  159. CHARSET_BOOT
  160. };
  161. #endif // ULTRALCD_COMMON_HD44780_H