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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. #pragma once
  20. #include <stdint.h>
  21. // Relies on XPT2046-compatible mode of ADS7843,
  22. // hence no Z1 / Z2 measurements are possible.
  23. #define XPT2046_DFR_MODE 0x00
  24. #define XPT2046_SER_MODE 0x04
  25. #define XPT2046_CONTROL 0x80
  26. enum XPTCoordinate : uint8_t {
  27. XPT2046_X = 0x10,
  28. XPT2046_Y = 0x50,
  29. XPT2046_Z1 = 0x30,
  30. XPT2046_Z2 = 0x40
  31. };
  32. #ifndef XPT2046_Z1_THRESHOLD
  33. #define XPT2046_Z1_THRESHOLD 10
  34. #endif
  35. class XPT2046 {
  36. public:
  37. static void init();
  38. static uint8_t read_buttons();
  39. bool getTouchPoint(uint16_t &x, uint16_t &y);
  40. static bool isTouched();
  41. inline void waitForRelease() { while (isTouched()) { /* nada */ } }
  42. inline void waitForTouch(uint16_t &x, uint16_t &y) { while (!getTouchPoint(x, y)) { /* nada */ } }
  43. private:
  44. static uint16_t getInTouch(const XPTCoordinate coordinate);
  45. };
  46. extern XPT2046 touch;