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.

base_numeric_adjustment_screen.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /************************************
  2. * base_numeric_adjustment_screen.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: <https://www.gnu.org/licenses/>. *
  20. ****************************************************************************/
  21. #pragma once
  22. #define FTDI_BASE_NUMERIC_ADJ_SCREEN
  23. #define FTDI_BASE_NUMERIC_ADJ_SCREEN_CLASS BaseNumericAdjustmentScreen
  24. struct BaseNumericAdjustmentScreenData {
  25. uint8_t increment;
  26. };
  27. class BaseNumericAdjustmentScreen : public BaseScreen {
  28. public:
  29. enum precision_default_t {
  30. DEFAULT_LOWEST,
  31. DEFAULT_MIDRANGE,
  32. DEFAULT_HIGHEST
  33. };
  34. protected:
  35. class widgets_t {
  36. private:
  37. draw_mode_t _what;
  38. uint8_t _line;
  39. uint32_t _color;
  40. uint8_t _decimals;
  41. FSTR_P _units;
  42. enum style_t {
  43. BTN_NORMAL,
  44. BTN_ACTION,
  45. BTN_TOGGLE,
  46. BTN_DISABLED,
  47. TEXT_AREA,
  48. TEXT_LABEL
  49. } _style;
  50. protected:
  51. void _draw_increment_btn(CommandProcessor &, uint8_t line, const uint8_t tag);
  52. void _button(CommandProcessor &, uint8_t tag, int16_t x, int16_t y, int16_t w, int16_t h, FSTR_P, bool enabled = true, bool highlight = false);
  53. void _button_style(CommandProcessor &cmd, style_t style);
  54. public:
  55. widgets_t(draw_mode_t);
  56. widgets_t &color(uint32_t color) {_color = color; return *this;}
  57. widgets_t &units(FSTR_P units) {_units = units; return *this;}
  58. widgets_t &draw_mode(draw_mode_t what) {_what = what; return *this;}
  59. widgets_t &precision(uint8_t decimals, precision_default_t = DEFAULT_HIGHEST);
  60. void heading (FSTR_P label);
  61. void adjuster_sram_val (uint8_t tag, FSTR_P label, const char *value, bool is_enabled = true);
  62. void adjuster (uint8_t tag, FSTR_P label, const char *value, bool is_enabled = true);
  63. void adjuster (uint8_t tag, FSTR_P label, float value=0, bool is_enabled = true);
  64. void button (uint8_t tag, FSTR_P label, bool is_enabled = true);
  65. void text_field (uint8_t tag, FSTR_P label, const char *value, bool is_enabled = true);
  66. void two_buttons (uint8_t tag1, FSTR_P label1,
  67. uint8_t tag2, FSTR_P label2, bool is_enabled = true);
  68. void toggle (uint8_t tag, FSTR_P label, bool value, bool is_enabled = true);
  69. void home_buttons (uint8_t tag);
  70. void increments ();
  71. };
  72. static float getIncrement();
  73. public:
  74. static void onEntry();
  75. static bool onTouchEnd(uint8_t tag);
  76. };