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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @file lcdprint_u8g.cpp
  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. #if HAS_MARLINUI_U8GLIB
  11. #include "marlinui_DOGM.h"
  12. #include "../marlinui.h"
  13. #include "../../MarlinCore.h"
  14. #include "../fontutils.h"
  15. #include "u8g_fontutf8.h"
  16. #include "../lcdprint.h"
  17. int lcd_glyph_height() { return u8g_GetFontBBXHeight(u8g.getU8g()); }
  18. void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) { u8g.setPrintPos(col, row); }
  19. void lcd_put_int(const int i) { u8g.print(i); }
  20. // return < 0 on error
  21. // return the advanced pixels
  22. int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) {
  23. if (c < 256) {
  24. u8g.print((char)c);
  25. return u8g_GetFontBBXWidth(u8g.getU8g());
  26. }
  27. u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(),
  28. ret = uxg_DrawWchar(u8g.getU8g(), x, y, c, max_length);
  29. u8g.setPrintPos(x + ret, y);
  30. return ret;
  31. }
  32. int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) {
  33. u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(),
  34. ret = uxg_DrawUtf8Str(u8g.getU8g(), x, y, utf8_str, max_length);
  35. u8g.setPrintPos(x + ret, y);
  36. return ret;
  37. }
  38. int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) {
  39. u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(),
  40. ret = uxg_DrawUtf8StrP(u8g.getU8g(), x, y, utf8_pstr, max_length);
  41. u8g.setPrintPos(x + ret, y);
  42. return ret;
  43. }
  44. #endif // HAS_MARLINUI_U8GLIB