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.cpp 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. * lcdprint.cpp
  24. */
  25. #include "../inc/MarlinConfigPre.h"
  26. #if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT
  27. #include "marlinui.h"
  28. #include "lcdprint.h"
  29. /**
  30. * lcd_put_u8str_ind_P
  31. *
  32. * Print a string with an index substituted within it:
  33. *
  34. * = displays '0'....'10' for indexes 0 - 10
  35. * ~ displays '1'....'11' for indexes 0 - 10
  36. * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL)
  37. */
  38. 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*/) {
  39. uint8_t *p = (uint8_t*)pstr;
  40. int8_t n = maxlen;
  41. while (n > 0) {
  42. wchar_t ch;
  43. p = get_utf8_value_cb(p, read_byte_rom, &ch);
  44. if (!ch) break;
  45. if (ch == '=' || ch == '~' || ch == '*') {
  46. if (ind >= 0) {
  47. if (ch == '*') { lcd_put_wchar('E'); n--; }
  48. if (n) {
  49. int8_t inum = ind + ((ch == '=') ? 0 : LCD_FIRST_TOOL);
  50. if (inum >= 10) {
  51. lcd_put_wchar('0' + (inum / 10)); n--;
  52. inum %= 10;
  53. }
  54. if (n) { lcd_put_wchar('0' + inum); n--; }
  55. }
  56. }
  57. else {
  58. PGM_P const b = ind == -2 ? GET_TEXT(MSG_CHAMBER) : GET_TEXT(MSG_BED);
  59. n -= lcd_put_u8str_max_P(b, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
  60. }
  61. if (n) {
  62. n -= lcd_put_u8str_max_P((PGM_P)p, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
  63. break;
  64. }
  65. }
  66. else if (ch == '$' && inStr) {
  67. n -= lcd_put_u8str_max_P(inStr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
  68. }
  69. else {
  70. lcd_put_wchar(ch);
  71. n--;
  72. }
  73. }
  74. return n;
  75. }
  76. #endif // HAS_WIRED_LCD