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.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #if ENABLED(DOGLCD)
  11. #include <U8glib.h>
  12. extern U8GLIB *pu8g;
  13. #define _lcd_write(a) pu8g->print(a)
  14. #define _lcd_setcursor(col, row) pu8g->setPrintPos((col), (row));
  15. #include "ultralcd.h"
  16. #include "../Marlin.h"
  17. #include "fontutils.h"
  18. #include "u8g_fontutf8.h"
  19. #include "lcdprint.h"
  20. int lcd_glyph_height(void) {
  21. return u8g_GetFontBBXHeight(pu8g->getU8g());
  22. }
  23. void lcd_moveto(int col, int row) {
  24. _lcd_setcursor(col, row);
  25. }
  26. // return < 0 on error
  27. // return the advanced pixels
  28. int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
  29. if (c < 256) {
  30. _lcd_write((char)c);
  31. return u8g_GetFontBBXWidth(pu8g->getU8g());
  32. }
  33. unsigned int x = pu8g->getPrintCol(),
  34. y = pu8g->getPrintRow(),
  35. ret = uxg_DrawWchar(pu8g->getU8g(), x, y, c, max_length);
  36. pu8g->setPrintPos(x + ret, y);
  37. return ret;
  38. }
  39. int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
  40. unsigned int x = pu8g->getPrintCol(),
  41. y = pu8g->getPrintRow(),
  42. ret = uxg_DrawUtf8Str(pu8g->getU8g(), x, y, utf8_str, max_length);
  43. pu8g->setPrintPos(x + ret, y);
  44. return ret;
  45. }
  46. int lcd_put_u8str_max_P(const char * utf8_str_P, pixel_len_t max_length) {
  47. unsigned int x = pu8g->getPrintCol(),
  48. y = pu8g->getPrintRow(),
  49. ret = uxg_DrawUtf8StrP(pu8g->getU8g(), x, y, utf8_str_P, max_length);
  50. pu8g->setPrintPos(x + ret, y);
  51. return ret;
  52. }
  53. #endif // DOGLCD