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.

custom_user_menus.cpp 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 "../config.h"
  23. #include "../screens.h"
  24. #ifdef FTDI_CUSTOM_USER_MENUS
  25. using namespace FTDI;
  26. using namespace ExtUI;
  27. using namespace Theme;
  28. #define _ITEM_TAG(N) (10+N)
  29. #define _USER_DESC(N) MAIN_MENU_ITEM_##N##_DESC
  30. #define _USER_GCODE(N) MAIN_MENU_ITEM_##N##_GCODE
  31. #define _USER_ITEM(N) .tag(_ITEM_TAG(N)).button(USER_ITEM_POS(N), _USER_DESC(N))
  32. #define _USER_ACTION(N) case _ITEM_TAG(N): injectCommands(F(_USER_GCODE(N))); TERN_(USER_SCRIPT_RETURN, GOTO_SCREEN(StatusScreen)); break;
  33. void CustomUserMenus::onRedraw(draw_mode_t what) {
  34. if (what & BACKGROUND) {
  35. CommandProcessor cmd;
  36. cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
  37. .cmd(CLEAR(true, true, true));
  38. }
  39. #if HAS_USER_ITEM(16, 17, 18, 19, 20)
  40. #define _MORE_THAN_FIFTEEN 1
  41. #else
  42. #define _MORE_THAN_FIFTEEN 0
  43. #endif
  44. #if _MORE_THAN_FIFTEEN || HAS_USER_ITEM(11, 12, 13, 14, 15)
  45. #define _MORE_THAN_TEN 1
  46. #else
  47. #define _MORE_THAN_TEN 0
  48. #endif
  49. #if ENABLED(TOUCH_UI_PORTRAIT)
  50. #define GRID_COLS (1 + _MORE_THAN_TEN)
  51. #define GRID_ROWS 11
  52. #define USER_ITEM_POS(N) BTN_POS((1+((N-1)/10)), ((N-1) % 10 + 1)), BTN_SIZE(1,1)
  53. #define BACK_POS BTN_POS(1,11), BTN_SIZE(1,1)
  54. #else
  55. #if _MORE_THAN_TEN || HAS_USER_ITEM(6, 7, 8, 9, 10)
  56. #define _MORE_THAN_FIVE 1
  57. #else
  58. #define _MORE_THAN_FIVE 0
  59. #endif
  60. #define GRID_COLS (1 + _MORE_THAN_FIVE + _MORE_THAN_TEN + _MORE_THAN_FIFTEEN)
  61. #define GRID_ROWS 6
  62. #define USER_ITEM_POS(N) BTN_POS((1+((N-1)/5)), ((N-1) % 5 + 1)), BTN_SIZE(1,1)
  63. #define BACK_POS BTN_POS(1,6), BTN_SIZE(GRID_COLS,1)
  64. #endif
  65. if (what & FOREGROUND) {
  66. CommandProcessor cmd;
  67. cmd.colors(normal_btn)
  68. .font(Theme::font_medium)
  69. #if HAS_USER_ITEM(1)
  70. _USER_ITEM(1)
  71. #endif
  72. #if HAS_USER_ITEM(2)
  73. _USER_ITEM(2)
  74. #endif
  75. #if HAS_USER_ITEM(3)
  76. _USER_ITEM(3)
  77. #endif
  78. #if HAS_USER_ITEM(4)
  79. _USER_ITEM(4)
  80. #endif
  81. #if HAS_USER_ITEM(5)
  82. _USER_ITEM(5)
  83. #endif
  84. #if HAS_USER_ITEM(6)
  85. _USER_ITEM(6)
  86. #endif
  87. #if HAS_USER_ITEM(7)
  88. _USER_ITEM(7)
  89. #endif
  90. #if HAS_USER_ITEM(8)
  91. _USER_ITEM(8)
  92. #endif
  93. #if HAS_USER_ITEM(9)
  94. _USER_ITEM(9)
  95. #endif
  96. #if HAS_USER_ITEM(10)
  97. _USER_ITEM(10)
  98. #endif
  99. #if HAS_USER_ITEM(11)
  100. _USER_ITEM(11)
  101. #endif
  102. #if HAS_USER_ITEM(12)
  103. _USER_ITEM(12)
  104. #endif
  105. #if HAS_USER_ITEM(13)
  106. _USER_ITEM(13)
  107. #endif
  108. #if HAS_USER_ITEM(14)
  109. _USER_ITEM(14)
  110. #endif
  111. #if HAS_USER_ITEM(15)
  112. _USER_ITEM(15)
  113. #endif
  114. #if HAS_USER_ITEM(16)
  115. _USER_ITEM(16)
  116. #endif
  117. #if HAS_USER_ITEM(17)
  118. _USER_ITEM(17)
  119. #endif
  120. #if HAS_USER_ITEM(18)
  121. _USER_ITEM(18)
  122. #endif
  123. #if HAS_USER_ITEM(19)
  124. _USER_ITEM(19)
  125. #endif
  126. #if HAS_USER_ITEM(20)
  127. _USER_ITEM(20)
  128. #endif
  129. .colors(action_btn)
  130. .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE));
  131. }
  132. }
  133. bool CustomUserMenus::onTouchEnd(uint8_t tag) {
  134. switch (tag) {
  135. #if HAS_USER_ITEM(1)
  136. _USER_ACTION(1)
  137. #endif
  138. #if HAS_USER_ITEM(2)
  139. _USER_ACTION(2)
  140. #endif
  141. #if HAS_USER_ITEM(3)
  142. _USER_ACTION(3)
  143. #endif
  144. #if HAS_USER_ITEM(4)
  145. _USER_ACTION(4)
  146. #endif
  147. #if HAS_USER_ITEM(5)
  148. _USER_ACTION(5)
  149. #endif
  150. #if HAS_USER_ITEM(6)
  151. _USER_ACTION(6)
  152. #endif
  153. #if HAS_USER_ITEM(7)
  154. _USER_ACTION(7)
  155. #endif
  156. #if HAS_USER_ITEM(8)
  157. _USER_ACTION(8)
  158. #endif
  159. #if HAS_USER_ITEM(9)
  160. _USER_ACTION(9)
  161. #endif
  162. #if HAS_USER_ITEM(10)
  163. _USER_ACTION(10)
  164. #endif
  165. #if HAS_USER_ITEM(11)
  166. _USER_ACTION(11)
  167. #endif
  168. #if HAS_USER_ITEM(12)
  169. _USER_ACTION(12)
  170. #endif
  171. #if HAS_USER_ITEM(13)
  172. _USER_ACTION(13)
  173. #endif
  174. #if HAS_USER_ITEM(14)
  175. _USER_ACTION(14)
  176. #endif
  177. #if HAS_USER_ITEM(15)
  178. _USER_ACTION(15)
  179. #endif
  180. #if HAS_USER_ITEM(16)
  181. _USER_ACTION(16)
  182. #endif
  183. #if HAS_USER_ITEM(17)
  184. _USER_ACTION(17)
  185. #endif
  186. #if HAS_USER_ITEM(18)
  187. _USER_ACTION(18)
  188. #endif
  189. #if HAS_USER_ITEM(19)
  190. _USER_ACTION(19)
  191. #endif
  192. #if HAS_USER_ITEM(20)
  193. _USER_ACTION(20)
  194. #endif
  195. case 1: GOTO_PREVIOUS(); break;
  196. default: return false;
  197. }
  198. return true;
  199. }
  200. #endif // FTDI_CUSTOM_USER_MENUS