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.

plot.cpp 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2022 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. * DWIN Single var plot
  24. * Author: Miguel A. Risco-Castillo
  25. * Version: 2.0
  26. * Date: 2022/01/31
  27. *
  28. * This program is free software: you can redistribute it and/or modify
  29. * it under the terms of the GNU Lesser General Public License as
  30. * published by the Free Software Foundation, either version 3 of the License, or
  31. * (at your option) any later version.
  32. *
  33. * This program is distributed in the hope that it will be useful,
  34. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  35. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  36. * GNU General Public License for more details.
  37. *
  38. * You should have received a copy of the GNU Lesser General Public License
  39. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  40. *
  41. * For commercial applications additional licenses can be requested
  42. */
  43. #include "../../../inc/MarlinConfigPre.h"
  44. #ifdef DWIN_LCD_PROUI
  45. #include "dwin_defines.h"
  46. #if HAS_PIDPLOT
  47. #include "plot.h"
  48. #include "../../../core/types.h"
  49. #include "../../marlinui.h"
  50. #include "dwin_lcd.h"
  51. #include "dwinui.h"
  52. #include "dwin.h"
  53. #define Plot_Bg_Color RGB( 1, 12, 8)
  54. PlotClass Plot;
  55. uint16_t grphpoints, r, x2, y2 = 0;
  56. frame_rect_t grphframe = {0};
  57. float scale = 0;
  58. void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) {
  59. grphframe = frame;
  60. grphpoints = 0;
  61. scale = frame.h / max;
  62. x2 = frame.x + frame.w - 1;
  63. y2 = frame.y + frame.h - 1;
  64. r = round((y2) - ref * scale);
  65. DWINUI::Draw_Box(1, Plot_Bg_Color, frame);
  66. for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) DWIN_Draw_VLine(Line_Color, i * 50 + frame.x, frame.y, frame.h);
  67. DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1));
  68. DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w);
  69. }
  70. void PlotClass::Update(const float value) {
  71. if (!scale) return;
  72. uint16_t y = round((y2) - value * scale);
  73. if (grphpoints < grphframe.w) {
  74. DWIN_Draw_Point(Color_Yellow, 1, 1, grphpoints + grphframe.x, y);
  75. }
  76. else {
  77. DWIN_Frame_AreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2);
  78. if ((grphpoints % 50) == 0) DWIN_Draw_VLine(Line_Color, x2 - 1, grphframe.y + 1, grphframe.h - 2);
  79. DWIN_Draw_Point(Color_Red, 1, 1, x2 - 1, r);
  80. DWIN_Draw_Point(Color_Yellow, 1, 1, x2 - 1, y);
  81. }
  82. grphpoints++;
  83. }
  84. #endif // HAS_PIDPLOT
  85. #endif // DWIN_LCD_PROUI