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.

event_loop.h 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /****************
  2. * event_loop.h *
  3. ****************/
  4. /****************************************************************************
  5. * Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
  6. * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
  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. * To view a copy of the GNU General Public License, go to the following *
  19. * location: <http://www.gnu.org/licenses/>. *
  20. ****************************************************************************/
  21. #pragma once
  22. #define STATUS_UPDATE_INTERVAL 1000
  23. #define TOUCH_UPDATE_INTERVAL 50
  24. #define TOUCH_REPEATS_PER_SECOND 4
  25. #define DEBOUNCE_PERIOD 150
  26. class UIData {
  27. private:
  28. typedef union {
  29. struct {
  30. uint8_t touch_start_sound : 1;
  31. uint8_t touch_end_sound : 1;
  32. uint8_t touch_repeat_sound : 1;
  33. uint8_t show_animations : 1;
  34. uint8_t touch_debouncing : 1;
  35. uint8_t ignore_unpress : 1;
  36. uint8_t prevent_reentry : 1;
  37. } bits;
  38. uint8_t value;
  39. } flags_t;
  40. public:
  41. static flags_t flags;
  42. static uint8_t get_persistent_data_mask();
  43. static uint8_t get_persistent_data();
  44. static void set_persistent_data(uint8_t value);
  45. static void reset_persistent_data();
  46. static void enable_touch_sounds(bool enabled);
  47. static bool touch_sounds_enabled();
  48. static void enable_animations(bool enabled);
  49. static bool animations_enabled();
  50. };
  51. namespace FTDI {
  52. class EventLoop {
  53. private:
  54. static constexpr FTDI::effect_t press_sound = FTDI::CHACK;
  55. static constexpr FTDI::effect_t repeat_sound = FTDI::CHACK;
  56. static constexpr FTDI::effect_t unpress_sound = FTDI::POP;
  57. static void process_events();
  58. public:
  59. static void setup();
  60. static void loop();
  61. static uint8_t get_pressed_tag();
  62. static bool is_touch_held();
  63. };
  64. }