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_u8g.cpp 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * @file lcdprint_u8g.c
  3. * @brief LCD print api for u8glib
  4. * @author Yunhui Fu (yhfudev@gmail.com)
  5. * @version 1.0
  6. * @date 2016-08-19
  7. * @copyright GPL/BSD
  8. */
  9. #include "../inc/MarlinConfigPre.h"
  10. #include "../inc/MarlinConfig.h"
  11. #define USE_LCDPRINT_U8G ENABLED(ULTRA_LCD) && ENABLED(DOGLCD)
  12. #if USE_LCDPRINT_U8G
  13. #include <U8glib.h>
  14. extern U8GLIB *pu8g;
  15. #define _lcd_write(a) pu8g->print(a)
  16. #define _lcd_setcursor(col, row) pu8g->setPrintPos((col), (row));
  17. #include "ultralcd.h"
  18. #include "../Marlin.h"
  19. #include "fontutils.h"
  20. #include "u8g_fontutf8.h"
  21. #include "lcdprint.h"
  22. int lcd_glyph_height(void) {
  23. return u8g_GetFontBBXHeight(pu8g->getU8g());
  24. //return u8g_GetFontBBXOffY(pu8g->getU8g());
  25. }
  26. void lcd_moveto(int col, int row) {
  27. TRACE("Move to: (%d,%d)", col, row);
  28. _lcd_setcursor(col, row);
  29. }
  30. int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
  31. if (c < 256) {
  32. TRACE("draw char: regular %d", (int)c);
  33. _lcd_write((char)c);
  34. return u8g_GetFontBBXWidth(pu8g->getU8g());
  35. }
  36. unsigned int x = pu8g->getPrintCol(),
  37. y = pu8g->getPrintRow(),
  38. ret = uxg_DrawWchar(pu8g->getU8g(), x, y, c, max_length);
  39. TRACE("uxg_DrawWchar(x=%d,y=%d,maxlen=%d", x, y, max_length);
  40. TRACE("u8g->setPrintPos(x=%d + ret=%d,y=%d", x, ret, y);
  41. pu8g->setPrintPos(x + ret, y);
  42. return ret;
  43. }
  44. int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
  45. unsigned int x = pu8g->getPrintCol(),
  46. y = pu8g->getPrintRow(),
  47. ret = uxg_DrawUtf8Str(pu8g->getU8g(), x, y, utf8_str, max_length);
  48. TRACE("uxg_DrawUtf8Str(x=%d,y=%d,maxlen=%d", x, y, max_length);
  49. TRACE("u8g->setPrintPos(x=%d + ret=%d,y=%d", x, ret, y);
  50. pu8g->setPrintPos(x + ret, y);
  51. return ret;
  52. }
  53. int lcd_put_u8str_max_rom(const char * utf8_str_P, pixel_len_t max_length) {
  54. unsigned int x = pu8g->getPrintCol(),
  55. y = pu8g->getPrintRow(),
  56. ret = uxg_DrawUtf8StrP(pu8g->getU8g(), x, y, utf8_str_P, max_length);
  57. TRACE("uxg_DrawUtf8StrP(x=%d,y=%d,maxlen=%d", x, y, max_length);
  58. TRACE("u8g->setPrintPos(x=%d + ret=%d,y=%d", x, ret, y);
  59. pu8g->setPrintPos(x + ret, y);
  60. return ret;
  61. }
  62. #else // !USE_LCDPRINT_U8G
  63. #define _lcd_write(a) TRACE("Write LCD: %c (%d)", (a), (int)(a));
  64. #define _lcd_setcursor(col, row) TRACE("Set cursor LCD: (%d,%d)", (col), (row));
  65. #endif // !USE_LCDPRINT_U8G