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.

plot.cpp 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * Modded for JYERSUI by LCH-77
  29. */
  30. #include "../../../inc/MarlinConfigPre.h"
  31. #ifdef DWIN_CREALITY_LCD_JYERSUI
  32. #include "dwin_defines.h"
  33. #ifdef HAS_PIDPLOT
  34. #include "plot.h"
  35. #include "../../../core/types.h"
  36. #include "../../marlinui.h"
  37. #include "dwin_lcd.h"
  38. #include "dwinui.h"
  39. #include "dwin.h"
  40. #define Plot_Bg_Color RGB( 1, 12, 8)
  41. PlotClass Plot;
  42. uint16_t grphpoints, r, x2, y2 = 0;
  43. frame_rect_t grphframe = {0};
  44. float scale = 0;
  45. void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) {
  46. grphframe = frame;
  47. grphpoints = 0;
  48. scale = frame.h / max;
  49. x2 = frame.x + frame.w - 1;
  50. y2 = frame.y + frame.h - 1;
  51. r = round((y2) - ref * scale);
  52. DWINUI::Draw_Box(1, Plot_Bg_Color, frame);
  53. 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);
  54. DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1));
  55. DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w);
  56. }
  57. void PlotClass::Update(const float value) {
  58. if (!scale) return;
  59. uint16_t y = round((y2) - value * scale);
  60. if (grphpoints < grphframe.w) {
  61. DWIN_Draw_Point(Color_Yellow, 1, 1, grphpoints + grphframe.x, y);
  62. }
  63. else {
  64. DWIN_Frame_AreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2);
  65. if ((grphpoints % 50) == 0) DWIN_Draw_VLine(Line_Color, x2 - 1, grphframe.y + 1, grphframe.h - 2);
  66. DWIN_Draw_Point(Color_Red, 1, 1, x2 - 1, r);
  67. DWIN_Draw_Point(Color_Yellow, 1, 1, x2 - 1, y);
  68. }
  69. grphpoints++;
  70. }
  71. #endif // HAS_PIDPLOT
  72. #endif // DWIN_CREALITY_LCD_JYERSUI