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 4.5KB

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