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

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