My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

touch_buttons.h 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #pragma once
  23. #include <stdint.h>
  24. #include "../../inc/MarlinConfig.h"
  25. #include "../scaled_tft.h"
  26. #define UPSCALE0(M) ((M) * (GRAPHICAL_TFT_UPSCALE))
  27. #define UPSCALE(A,M) (UPSCALE0(M) + (A))
  28. #define BUTTON_DRAW_WIDTH 32
  29. #define BUTTON_DRAW_HEIGHT 20
  30. #define BUTTON_WIDTH UPSCALE0(BUTTON_DRAW_WIDTH)
  31. #define BUTTON_HEIGHT UPSCALE0(BUTTON_DRAW_HEIGHT)
  32. // calc the space between buttons
  33. #define BUTTON_SPACING (((TFT_WIDTH) - (BUTTON_WIDTH * 4)) / 5)
  34. #define BUTTOND_X_LO BUTTON_SPACING
  35. #define BUTTOND_X_HI BUTTOND_X_LO + BUTTON_WIDTH - 1
  36. #define BUTTONA_X_LO BUTTOND_X_HI + BUTTON_SPACING
  37. #define BUTTONA_X_HI BUTTONA_X_LO + BUTTON_WIDTH - 1
  38. #define BUTTONB_X_LO BUTTONA_X_HI + BUTTON_SPACING
  39. #define BUTTONB_X_HI BUTTONB_X_LO + BUTTON_WIDTH - 1
  40. #define BUTTONC_X_LO BUTTONB_X_HI + BUTTON_SPACING
  41. #define BUTTONC_X_HI BUTTONC_X_LO + BUTTON_WIDTH - 1
  42. #define BUTTON_Y_HI (TFT_HEIGHT) - BUTTON_SPACING
  43. #define BUTTON_Y_LO BUTTON_Y_HI - BUTTON_HEIGHT
  44. #define TSLP_PREINIT 0
  45. #define TSLP_SLEEPING 1
  46. class TouchButtons {
  47. public:
  48. static void init();
  49. static uint8_t read_buttons();
  50. #if HAS_TOUCH_SLEEP
  51. static millis_t next_sleep_ms;
  52. static bool isSleeping() { return next_sleep_ms == TSLP_SLEEPING; }
  53. static void sleepTimeout();
  54. static void wakeUp();
  55. #endif
  56. };
  57. extern TouchButtons touchBt;