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.

dwin_popup.cpp 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2021 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 Enhanced implementation for PRO UI
  24. * Author: Miguel A. Risco-Castillo (MRISCOC)
  25. * Version: 3.11.1
  26. * Date: 2022/02/28
  27. */
  28. #include "../../../inc/MarlinConfigPre.h"
  29. #if ENABLED(DWIN_LCD_PROUI)
  30. #include "dwin.h"
  31. #include "dwinui.h"
  32. #include "dwin_popup.h"
  33. #include "../../../MarlinCore.h" // for wait_for_user
  34. popupDrawFunc_t popupDraw = nullptr;
  35. popupClickFunc_t popupClick = nullptr;
  36. popupChangeFunc_t popupChange = nullptr;
  37. uint16_t HighlightYPos = 280;
  38. void Draw_Select_Highlight(const bool sel, const uint16_t ypos) {
  39. HighlightYPos = ypos;
  40. HMI_flag.select_flag = sel;
  41. const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_color,
  42. c2 = sel ? HMI_data.PopupBg_color : HMI_data.Highlight_Color;
  43. DWIN_Draw_Rectangle(0, c1, 25, ypos - 1, 126, ypos + 38);
  44. DWIN_Draw_Rectangle(0, c1, 24, ypos - 2, 127, ypos + 39);
  45. DWIN_Draw_Rectangle(0, c2, 145, ypos - 1, 246, ypos + 38);
  46. DWIN_Draw_Rectangle(0, c2, 144, ypos - 2, 247, ypos + 39);
  47. }
  48. void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2) {
  49. HMI_SaveProcessID(WaitResponse);
  50. DWIN_Draw_Popup(icon, fmsg1, fmsg2, BTN_Continue); // Button Continue
  51. DWIN_UpdateLCD();
  52. }
  53. void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2) {
  54. DWIN_Draw_Popup(ICON_BLTouch, F("Please confirm"), fmsg2);
  55. DWINUI::Draw_Button(BTN_Confirm, 26, 280);
  56. DWINUI::Draw_Button(BTN_Cancel, 146, 280);
  57. Draw_Select_Highlight(HMI_flag.select_flag);
  58. DWIN_UpdateLCD();
  59. }
  60. void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick/*=nullptr*/, const popupChangeFunc_t fnChange/*=nullptr*/) {
  61. popupDraw = fnDraw;
  62. popupClick = fnClick;
  63. popupChange = fnChange;
  64. HMI_SaveProcessID(Popup);
  65. HMI_flag.select_flag = false;
  66. popupDraw();
  67. }
  68. void HMI_Popup() {
  69. if (!wait_for_user) {
  70. if (popupClick) popupClick();
  71. return;
  72. }
  73. else {
  74. EncoderState encoder_diffState = get_encoder_state();
  75. if (encoder_diffState == ENCODER_DIFF_CW || encoder_diffState == ENCODER_DIFF_CCW) {
  76. const bool change = encoder_diffState != ENCODER_DIFF_CW;
  77. if (popupChange) popupChange(change); else Draw_Select_Highlight(change, HighlightYPos);
  78. DWIN_UpdateLCD();
  79. }
  80. }
  81. }
  82. #endif // DWIN_LCD_PROUI