My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

string_format.cpp 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*********************
  2. * string_format.cpp *
  3. *********************/
  4. /****************************************************************************
  5. * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
  6. * *
  7. * This program is free software: you can redistribute it and/or modify *
  8. * it under the terms of the GNU General Public License as published by *
  9. * the Free Software Foundation, either version 3 of the License, or *
  10. * (at your option) any later version. *
  11. * *
  12. * This program is distributed in the hope that it will be useful, *
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15. * GNU General Public License for more details. *
  16. * *
  17. * To view a copy of the GNU General Public License, go to the following *
  18. * location: <http://www.gnu.org/licenses/>. *
  19. ****************************************************************************/
  20. #include "../config.h"
  21. #if ENABLED(TOUCH_UI_FTDI_EVE)
  22. #include "screens.h"
  23. #define ROUND(val) uint16_t((val)+0.5)
  24. #pragma GCC diagnostic push
  25. #pragma GCC diagnostic ignored "-Wno-format"
  26. /**
  27. * Formats a temperature string (e.g. "100°C")
  28. */
  29. void format_temp(char *str, float t1) {
  30. sprintf_P(str, PSTR("%3d" S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C));
  31. }
  32. /**
  33. * Formats a temperature string for an idle heater (e.g. "100 °C / idle")
  34. */
  35. void format_temp_and_idle(char *str, float t1) {
  36. sprintf_P(str, PSTR("%3d" S_FMT " / " S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
  37. }
  38. /**
  39. * Formats a temperature string for an active heater (e.g. "100 / 200°C")
  40. */
  41. void format_temp_and_temp(char *str, float t1, float t2) {
  42. sprintf_P(str, PSTR("%3d / %3d" S_FMT), ROUND(t1), ROUND(t2), GET_TEXT(MSG_UNITS_C));
  43. }
  44. /**
  45. * Formats a temperature string for a material (e.g. "100°C (PLA)")
  46. */
  47. void format_temp_and_material(char *str, float t1, const char *material) {
  48. sprintf_P(str, PSTR("%3d" S_FMT " (" S_FMT ")"), ROUND(t1), GET_TEXT(MSG_UNITS_C), material);
  49. }
  50. /**
  51. * Formats a position value (e.g. "10 mm")
  52. */
  53. void format_position(char *str, float p) {
  54. dtostrf(p, 5, 1, str);
  55. strcat_P(str, PSTR(" "));
  56. strcat_P(str, GET_TEXT(MSG_UNITS_MM));
  57. }
  58. /**
  59. * Formats a position vector (e.g. "10; 20; 30 mm")
  60. */
  61. void format_position(char *str, float x, float y, float z) {
  62. char num1[7], num2[7], num3[7];
  63. dtostrf(x, 4, 2, num1);
  64. dtostrf(y, 4, 2, num2);
  65. dtostrf(z, 4, 2, num3);
  66. sprintf_P(str, PSTR("%s; %s; %s " S_FMT), num1, num2, num3, GET_TEXT(MSG_UNITS_MM));
  67. }
  68. #pragma GCC diagnostic pop
  69. #endif // TOUCH_UI_FTDI_EVE