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.

lcdprint.h 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * @file lcdprint.h
  24. * @brief LCD print api
  25. * @author Yunhui Fu (yhfudev@gmail.com)
  26. * @version 1.0
  27. * @date 2016-08-19
  28. * @copyright GPL/BSD
  29. */
  30. #pragma once
  31. #include "fontutils.h"
  32. #include "../inc/MarlinConfig.h"
  33. #if HAS_GRAPHICAL_LCD
  34. #include "dogm/u8g_fontutf8.h"
  35. typedef u8g_uint_t lcd_uint_t;
  36. typedef u8g_int_t lcd_int_t;
  37. // Only Western languages support big / small fonts
  38. #if DISABLED(DISPLAY_CHARSET_ISO10646_1)
  39. #undef USE_BIG_EDIT_FONT
  40. #undef USE_SMALL_INFOFONT
  41. #endif
  42. #define MENU_FONT_NAME ISO10646_1_5x7
  43. #define MENU_FONT_WIDTH 6
  44. #define MENU_FONT_ASCENT 10
  45. #define MENU_FONT_DESCENT 2
  46. #define MENU_FONT_HEIGHT (MENU_FONT_ASCENT + MENU_FONT_DESCENT)
  47. #if ENABLED(USE_BIG_EDIT_FONT)
  48. #define EDIT_FONT_NAME u8g_font_9x18
  49. #define EDIT_FONT_WIDTH 9
  50. #define EDIT_FONT_ASCENT 10
  51. #define EDIT_FONT_DESCENT 3
  52. #else
  53. #define EDIT_FONT_NAME MENU_FONT_NAME
  54. #define EDIT_FONT_WIDTH MENU_FONT_WIDTH
  55. #define EDIT_FONT_ASCENT MENU_FONT_ASCENT
  56. #define EDIT_FONT_DESCENT MENU_FONT_DESCENT
  57. #endif
  58. #define EDIT_FONT_HEIGHT (EDIT_FONT_ASCENT + EDIT_FONT_DESCENT)
  59. // Get the Ascent, Descent, and total Height for the Info Screen font
  60. #if ENABLED(USE_SMALL_INFOFONT)
  61. extern const u8g_fntpgm_uint8_t u8g_font_6x9[];
  62. #define INFO_FONT_ASCENT 7
  63. #else
  64. #define INFO_FONT_ASCENT 8
  65. #endif
  66. #define INFO_FONT_DESCENT 2
  67. #define INFO_FONT_HEIGHT (INFO_FONT_ASCENT + INFO_FONT_DESCENT)
  68. #define INFO_FONT_WIDTH 6
  69. #define SETCURSOR(col, row) lcd_moveto(col * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT))
  70. #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH), (row + 1) * (MENU_FONT_HEIGHT))
  71. #else
  72. #define _UxGT(a) a
  73. typedef uint8_t lcd_uint_t;
  74. typedef int8_t lcd_int_t;
  75. #define MENU_FONT_WIDTH 1
  76. #define MENU_FONT_HEIGHT 1
  77. #define EDIT_FONT_WIDTH 1
  78. #define EDIT_FONT_HEIGHT 1
  79. #define INFO_FONT_WIDTH 1
  80. #define INFO_FONT_HEIGHT 1
  81. #define LCD_PIXEL_WIDTH LCD_WIDTH
  82. #define LCD_PIXEL_HEIGHT LCD_HEIGHT
  83. #define SETCURSOR(col, row) lcd_moveto(col, row)
  84. #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_WIDTH - (len), row)
  85. #endif
  86. #define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr)
  87. #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
  88. int lcd_glyph_height();
  89. int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length);
  90. /**
  91. * @brief Draw a UTF-8 string
  92. *
  93. * @param utf8_str : the UTF-8 string
  94. * @param max_length : the pixel length of the string allowed (or number of slots in HD44780)
  95. *
  96. * @return the pixel width
  97. *
  98. * Draw a UTF-8 string
  99. */
  100. int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length);
  101. /**
  102. * Set the print baseline position
  103. */
  104. void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row);
  105. /**
  106. * @brief Draw a ROM UTF-8 string
  107. *
  108. * @param utf8_str_P : the ROM UTF-8 string
  109. * @param max_length : the pixel length of the string allowed (or number of slots in HD44780)
  110. *
  111. * @return the pixel width
  112. *
  113. * Draw a ROM UTF-8 string
  114. */
  115. int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length);
  116. inline int lcd_put_u8str_max_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P utf8_str_P, pixel_len_t max_length) {
  117. lcd_moveto(col, row);
  118. return lcd_put_u8str_max_P(utf8_str_P, max_length);
  119. }
  120. void lcd_put_int(const int i);
  121. inline void lcd_put_int(const lcd_uint_t col, const lcd_uint_t row, const int i) {
  122. lcd_moveto(col, row);
  123. lcd_put_int(i);
  124. }
  125. inline int lcd_put_u8str_P(PGM_P const pstr) { return lcd_put_u8str_max_P(pstr, PIXEL_LEN_NOLIMIT); }
  126. inline int lcd_put_u8str_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P const pstr) {
  127. lcd_moveto(col, row);
  128. return lcd_put_u8str_P(pstr);
  129. }
  130. lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const inStr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH);
  131. inline lcd_uint_t lcd_put_u8str_ind_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P const pstr, const int8_t ind, PGM_P const inStr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) {
  132. lcd_moveto(col, row);
  133. return lcd_put_u8str_ind_P(pstr, ind, inStr, maxlen);
  134. }
  135. inline int lcd_put_u8str(const char* str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); }
  136. inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, PGM_P const str) {
  137. lcd_moveto(col, row);
  138. return lcd_put_u8str(str);
  139. }
  140. inline int lcd_put_wchar(const wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); }
  141. inline int lcd_put_wchar(const lcd_uint_t col, const lcd_uint_t row, const wchar_t c) {
  142. lcd_moveto(col, row);
  143. return lcd_put_wchar(c);
  144. }