My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

lcdprint.h 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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) SETCURSOR(LCD_WIDTH - (len), row)
  85. #endif
  86. #define SETCURSOR_X(col) SETCURSOR(col, _lcdLineNr)
  87. #define SETCURSOR_X_RJ(len) SETCURSOR_RJ(len, _lcdLineNr)
  88. #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
  89. int lcd_glyph_height();
  90. int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length);
  91. /**
  92. * @brief Draw a UTF-8 string
  93. *
  94. * @param utf8_str : the UTF-8 string
  95. * @param max_length : the pixel length of the string allowed (or number of slots in HD44780)
  96. *
  97. * @return the pixel width
  98. *
  99. * Draw a UTF-8 string
  100. */
  101. int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length);
  102. /**
  103. * Set the print baseline position
  104. */
  105. void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row);
  106. /**
  107. * @brief Draw a ROM UTF-8 string
  108. *
  109. * @param utf8_str_P : the ROM UTF-8 string
  110. * @param max_length : the pixel length of the string allowed (or number of slots in HD44780)
  111. *
  112. * @return the pixel width
  113. *
  114. * Draw a ROM UTF-8 string
  115. */
  116. int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length);
  117. 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) {
  118. lcd_moveto(col, row);
  119. return lcd_put_u8str_max_P(utf8_str_P, max_length);
  120. }
  121. void lcd_put_int(const int i);
  122. inline void lcd_put_int(const lcd_uint_t col, const lcd_uint_t row, const int i) {
  123. lcd_moveto(col, row);
  124. lcd_put_int(i);
  125. }
  126. inline int lcd_put_u8str_P(PGM_P const pstr) { return lcd_put_u8str_max_P(pstr, PIXEL_LEN_NOLIMIT); }
  127. inline int lcd_put_u8str_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P const pstr) {
  128. lcd_moveto(col, row);
  129. return lcd_put_u8str_P(pstr);
  130. }
  131. 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);
  132. 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) {
  133. lcd_moveto(col, row);
  134. return lcd_put_u8str_ind_P(pstr, ind, inStr, maxlen);
  135. }
  136. inline int lcd_put_u8str(const char* str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); }
  137. inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, PGM_P const str) {
  138. lcd_moveto(col, row);
  139. return lcd_put_u8str(str);
  140. }
  141. inline int lcd_put_wchar(const wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); }
  142. inline int lcd_put_wchar(const lcd_uint_t col, const lcd_uint_t row, const wchar_t c) {
  143. lcd_moveto(col, row);
  144. return lcd_put_wchar(c);
  145. }