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.

draw_encoder_settings.cpp 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #include "../../../inc/MarlinConfigPre.h"
  23. #if HAS_TFT_LVGL_UI
  24. #include "draw_ui.h"
  25. #include <lv_conf.h>
  26. #include "../../../inc/MarlinConfig.h"
  27. #if BUTTONS_EXIST(EN1, EN2)
  28. extern lv_group_t *g;
  29. static lv_obj_t *scr;
  30. static lv_obj_t *buttonEncoderState = nullptr;
  31. enum {
  32. ID_ENCODER_RETURN = 1,
  33. ID_ENCODER_STATE
  34. };
  35. static void event_handler(lv_obj_t *obj, lv_event_t event) {
  36. if (event != LV_EVENT_RELEASED) return;
  37. switch (obj->mks_obj_id) {
  38. case ID_ENCODER_RETURN:
  39. lv_clear_encoder_settings();
  40. draw_return_ui();
  41. break;
  42. case ID_ENCODER_STATE:
  43. gCfgItems.encoder_enable ^= true;
  44. lv_screen_menu_item_onoff_update(buttonEncoderState, gCfgItems.encoder_enable);
  45. update_spi_flash();
  46. break;
  47. }
  48. }
  49. void lv_draw_encoder_settings() {
  50. scr = lv_screen_create(ENCODER_SETTINGS_UI, machine_menu.EncoderConfTitle);
  51. buttonEncoderState = lv_screen_menu_item_onoff(scr, machine_menu.EncoderConfText, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ENCODER_STATE, 0, gCfgItems.encoder_enable);
  52. lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACK_POS_X, PARA_UI_BACK_POS_Y, event_handler, ID_ENCODER_RETURN, true);
  53. }
  54. void lv_clear_encoder_settings() {
  55. #if HAS_ROTARY_ENCODER
  56. lv_group_remove_all_objs(g);
  57. #endif
  58. lv_obj_del(scr);
  59. }
  60. #endif // BUTTONS_EXIST(EN1, EN2)
  61. #endif // HAS_TFT_LVGL_UI