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.

dwinui.h 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2021 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. /**
  24. * DWIN UI Enhanced implementation
  25. * Author: Miguel A. Risco-Castillo
  26. * Version: 3.9.1
  27. * Date: 2021/11/21
  28. */
  29. #include "dwin_lcd.h"
  30. #include "../common/dwin_set.h"
  31. #include "../common/dwin_font.h"
  32. #include "../common/dwin_color.h"
  33. // Extra Icons
  34. #define ICON_Brightness ICON_Motion
  35. #define ICON_Cancel ICON_StockConfiguration
  36. #define ICON_CustomPreheat ICON_SetEndTemp
  37. #define ICON_Error ICON_TempTooHigh
  38. #define ICON_ESDiag ICON_Info
  39. #define ICON_ExtrudeMinT ICON_HotendTemp
  40. #define ICON_FilLoad ICON_WriteEEPROM
  41. #define ICON_FilMan ICON_ResumeEEPROM
  42. #define ICON_FilSet ICON_ResumeEEPROM
  43. #define ICON_FilUnload ICON_ReadEEPROM
  44. #define ICON_Flow ICON_StepE
  45. #define ICON_FWRetLength ICON_StepE
  46. #define ICON_FWRetSpeed ICON_Setspeed
  47. #define ICON_FWRetZRaise ICON_MoveZ
  48. #define ICON_FWRecSpeed ICON_Setspeed
  49. #define ICON_HomeX ICON_MoveX
  50. #define ICON_HomeY ICON_MoveY
  51. #define ICON_HomeZ ICON_MoveZ
  52. #define ICON_LevBed ICON_SetEndTemp
  53. #define ICON_Lock ICON_Cool
  54. #define ICON_ManualMesh ICON_HotendTemp
  55. #define ICON_MeshNext ICON_Axis
  56. #define ICON_MeshSave ICON_WriteEEPROM
  57. #define ICON_MeshViewer ICON_HotendTemp
  58. #define ICON_MoveZ0 ICON_HotendTemp
  59. #define ICON_Park ICON_Motion
  60. #define ICON_PIDbed ICON_SetBedTemp
  61. #define ICON_PIDcycles ICON_ResumeEEPROM
  62. #define ICON_PIDValue ICON_Contact
  63. #define ICON_PrintStats ICON_PrintTime
  64. #define ICON_PrintStatsReset ICON_RemainTime
  65. #define ICON_ProbeDeploy ICON_SetEndTemp
  66. #define ICON_ProbeSet ICON_SetEndTemp
  67. #define ICON_ProbeStow ICON_SetEndTemp
  68. #define ICON_ProbeTest ICON_SetEndTemp
  69. #define ICON_Pwrlossr ICON_Motion
  70. #define ICON_Reboot ICON_ResumeEEPROM
  71. #define ICON_Runout ICON_MaxAccE
  72. #define ICON_Scolor ICON_MaxSpeed
  73. #define ICON_SetCustomPreheat ICON_SetEndTemp
  74. #define ICON_Sound ICON_Cool
  75. // Extended and default UI Colors
  76. #define Color_Black 0
  77. #define Color_Green RGB(0,63,0)
  78. #define Color_Aqua RGB(0,63,31)
  79. #define Color_Blue RGB(0,0,31)
  80. // UI element defines and constants
  81. #define DWIN_FONT_MENU font8x16
  82. #define DWIN_FONT_STAT font10x20
  83. #define DWIN_FONT_HEAD font10x20
  84. #define DWIN_FONT_ALERT font10x20
  85. #define STATUS_Y 354
  86. #define LCD_WIDTH (DWIN_WIDTH / 8)
  87. constexpr uint16_t TITLE_HEIGHT = 30, // Title bar height
  88. MLINE = 53, // Menu line height
  89. TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows
  90. MROWS = TROWS - 1, // Other-than-Back
  91. ICOX = 26, // Menu item icon X position
  92. LBLX = 60, // Menu item label X position
  93. VALX = 210, // Menu item value X position
  94. MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16
  95. STAT_CHR_W = 10;
  96. // Menuitem Y position
  97. #define MYPOS(L) (TITLE_HEIGHT + MLINE * (L))
  98. // Menuitem caption Offset
  99. #define CAPOFF ((MLINE - MENU_CHR_H) / 2)
  100. // Menuitem caption Y position
  101. #define MBASE(L) (MYPOS(L) + CAPOFF)
  102. // Create and add a MenuItem object to the menu array
  103. #define ADDMENUITEM(V...) DWINUI::MenuItemsAdd(new MenuItemClass(V))
  104. #define ADDMENUITEM_P(V...) DWINUI::MenuItemsAdd(new MenuItemPtrClass(V))
  105. typedef struct { uint16_t left, top, right, bottom; } rect_t;
  106. typedef struct { uint16_t x, y, w, h; } frame_rect_t;
  107. class TitleClass {
  108. public:
  109. char caption[32] = "";
  110. uint8_t frameid = 0;
  111. rect_t frame = {0};
  112. void draw();
  113. void SetCaption(const char * const title);
  114. inline void SetCaption(FSTR_P title) { SetCaption((char *)title); }
  115. void ShowCaption(const char * const title);
  116. inline void ShowCaption(FSTR_P title) { ShowCaption((char *)title); }
  117. void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
  118. void SetFrame(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
  119. void FrameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
  120. void FrameCopy(uint16_t x, uint16_t y, uint16_t h, uint16_t v);
  121. };
  122. extern TitleClass Title;
  123. class MenuItemClass {
  124. protected:
  125. public:
  126. int8_t pos = 0;
  127. uint8_t icon = 0;
  128. char caption[32] = "";
  129. uint8_t frameid = 0;
  130. rect_t frame = {0};
  131. void (*onDraw)(MenuItemClass* menuitem, int8_t line) = nullptr;
  132. void (*onClick)() = nullptr;
  133. MenuItemClass() {};
  134. MenuItemClass(uint8_t cicon, const char * const text=nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
  135. MenuItemClass(uint8_t cicon, FSTR_P text = nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr) : MenuItemClass(cicon, FTOP(text), ondraw, onclick){}
  136. MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
  137. void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
  138. virtual ~MenuItemClass(){};
  139. virtual void draw(int8_t line);
  140. };
  141. class MenuItemPtrClass: public MenuItemClass {
  142. public:
  143. void *value = nullptr;
  144. using MenuItemClass::MenuItemClass;
  145. MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val);
  146. MenuItemPtrClass(uint8_t cicon, FSTR_P text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemPtrClass(cicon, FTOP(text), ondraw, onclick, val){}
  147. };
  148. class MenuClass {
  149. public:
  150. int8_t topline = 0;
  151. int8_t selected = 0;
  152. TitleClass MenuTitle;
  153. MenuClass();
  154. virtual ~MenuClass(){};
  155. inline int8_t line() { return selected - topline; };
  156. inline int8_t line(uint8_t pos) {return pos - topline; };
  157. void draw();
  158. void onScroll(bool dir);
  159. void onClick();
  160. MenuItemClass* SelectedItem();
  161. };
  162. extern MenuClass *CurrentMenu;
  163. namespace DWINUI {
  164. extern xy_int_t cursor;
  165. extern uint16_t pencolor;
  166. extern uint16_t textcolor;
  167. extern uint16_t backcolor;
  168. extern uint8_t font;
  169. extern void (*onCursorErase)(const int8_t line);
  170. extern void (*onCursorDraw)(const int8_t line);
  171. extern void (*onTitleDraw)(TitleClass* title);
  172. extern void (*onMenuDraw)(MenuClass* menu);
  173. // DWIN LCD Initialization
  174. void init();
  175. // Set text/number font
  176. void setFont(uint8_t cfont);
  177. // Get font character width
  178. uint8_t fontWidth(uint8_t cfont);
  179. inline uint8_t fontWidth() { return fontWidth(font); };
  180. // Get font character height
  181. uint8_t fontHeight(uint8_t cfont);
  182. inline uint8_t fontHeight() { return fontHeight(font); };
  183. // Get screen x coordinates from text column
  184. uint16_t ColToX(uint8_t col);
  185. // Get screen y coordinates from text row
  186. uint16_t RowToY(uint8_t row);
  187. // Set text/number color
  188. void SetColors(uint16_t fgcolor, uint16_t bgcolor);
  189. void SetTextColor(uint16_t fgcolor);
  190. void SetBackgroundColor(uint16_t bgcolor);
  191. // Moves cursor to point
  192. // x: abscissa of the display
  193. // y: ordinate of the display
  194. // point: xy coordinate
  195. void MoveTo(int16_t x, int16_t y);
  196. void MoveTo(xy_int_t point);
  197. // Moves cursor relative to the actual position
  198. // x: abscissa of the display
  199. // y: ordinate of the display
  200. // point: xy coordinate
  201. void MoveBy(int16_t x, int16_t y);
  202. void MoveBy(xy_int_t point);
  203. // Draw a line from the cursor to xy position
  204. // color: Line segment color
  205. // x/y: End point
  206. inline void LineTo(uint16_t color, uint16_t x, uint16_t y) {
  207. DWIN_Draw_Line(color, cursor.x, cursor.y, x, y);
  208. }
  209. inline void LineTo(uint16_t x, uint16_t y) {
  210. DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y);
  211. }
  212. // Draw an Icon with transparent background from the library ICON
  213. // icon: Icon ID
  214. // x/y: Upper-left point
  215. inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) {
  216. DWIN_ICON_Show(ICON, icon, x, y);
  217. }
  218. // Draw a positive integer
  219. // bShow: true=display background color; false=don't display background color
  220. // zeroFill: true=zero fill; false=no zero fill
  221. // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
  222. // size: Font size
  223. // color: Character color
  224. // bColor: Background color
  225. // iNum: Number of digits
  226. // x/y: Upper-left coordinate
  227. // value: Integer value
  228. inline void Draw_Int(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
  229. DWIN_Draw_IntValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, x, y, value);
  230. }
  231. inline void Draw_Int(uint8_t iNum, long value) {
  232. DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
  233. MoveBy(iNum * fontWidth(font), 0);
  234. }
  235. inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
  236. DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value);
  237. }
  238. inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
  239. DWIN_Draw_IntValue(false, true, 0, font, color, backcolor, iNum, x, y, value);
  240. }
  241. inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
  242. DWIN_Draw_IntValue(true, true, 0, font, color, bColor, iNum, x, y, value);
  243. }
  244. inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
  245. DWIN_Draw_IntValue(true, true, 0, size, color, bColor, iNum, x, y, value);
  246. }
  247. // Draw a floating point number
  248. // bShow: true=display background color; false=don't display background color
  249. // zeroFill: true=zero fill; false=no zero fill
  250. // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
  251. // size: Font size
  252. // color: Character color
  253. // bColor: Background color
  254. // iNum: Number of whole digits
  255. // fNum: Number of decimal digits
  256. // x/y: Upper-left point
  257. // value: Float value
  258. inline void Draw_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  259. DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value);
  260. }
  261. inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
  262. DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
  263. MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
  264. }
  265. inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  266. DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
  267. }
  268. inline void Draw_Float(uint16_t color, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  269. DWIN_Draw_FloatValue(false, true, 0, font, color, backcolor, iNum, fNum, x, y, value);
  270. }
  271. inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  272. DWIN_Draw_FloatValue(true, true, 0, font, color, bColor, iNum, fNum, x, y, value);
  273. }
  274. inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  275. DWIN_Draw_FloatValue(true, true, 0, size, color, bColor, iNum, fNum, x, y, value);
  276. }
  277. // Draw a signed floating point number
  278. // bShow: true=display background color; false=don't display background color
  279. // zeroFill: true=zero fill; false=no zero fill
  280. // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
  281. // size: Font size
  282. // bColor: Background color
  283. // iNum: Number of whole digits
  284. // fNum: Number of decimal digits
  285. // x/y: Upper-left point
  286. // value: Float value
  287. void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
  288. inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
  289. Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
  290. MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
  291. }
  292. inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  293. Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
  294. }
  295. inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  296. Draw_Signed_Float(false, true, 0, size, textcolor, backcolor, iNum, fNum, x, y, value);
  297. }
  298. inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  299. Draw_Signed_Float(true, true, 0, font, color, bColor, iNum, fNum, x, y, value);
  300. }
  301. inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  302. Draw_Signed_Float(true, true, 0, size, color, bColor, iNum, fNum, x, y, value);
  303. }
  304. // Draw a char at cursor position
  305. void Draw_Char(const char c);
  306. // Draw a string at cursor position
  307. // color: Character color
  308. // *string: The string
  309. // rlimit: For draw less chars than string length use rlimit
  310. void Draw_String(const char * const string, uint16_t rlimit = 0xFFFF);
  311. void Draw_String(uint16_t color, const char * const string, uint16_t rlimit = 0xFFFF);
  312. inline void Draw_String(FSTR_P string, uint16_t rlimit = 0xFFFF) {
  313. Draw_String(FTOP(string), rlimit);
  314. }
  315. inline void Draw_String(uint16_t color, FSTR_P string, uint16_t rlimit = 0xFFFF) {
  316. Draw_String(color, FTOP(string), rlimit);
  317. }
  318. // Draw a string
  319. // size: Font size
  320. // color: Character color
  321. // bColor: Background color
  322. // x/y: Upper-left coordinate of the string
  323. // *string: The string
  324. inline void Draw_String(uint16_t x, uint16_t y, const char * const string) {
  325. DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string);
  326. }
  327. inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) {
  328. DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title));
  329. }
  330. inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) {
  331. DWIN_Draw_String(false, font, color, backcolor, x, y, string);
  332. }
  333. inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) {
  334. DWIN_Draw_String(false, font, color, backcolor, x, y, title);
  335. }
  336. inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
  337. DWIN_Draw_String(true, font, color, bgcolor, x, y, string);
  338. }
  339. inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
  340. DWIN_Draw_String(true, font, color, bgcolor, x, y, title);
  341. }
  342. inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
  343. DWIN_Draw_String(true, size, color, bgcolor, x, y, string);
  344. }
  345. inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
  346. DWIN_Draw_String(true, size, color, bgcolor, x, y, title);
  347. }
  348. // Draw a centered string using DWIN_WIDTH
  349. // bShow: true=display background color; false=don't display background color
  350. // size: Font size
  351. // color: Character color
  352. // bColor: Background color
  353. // y: Upper coordinate of the string
  354. // *string: The string
  355. void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string);
  356. inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) {
  357. Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string));
  358. }
  359. inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) {
  360. Draw_CenteredString(true, font, color, bcolor, y, string);
  361. }
  362. inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) {
  363. Draw_CenteredString(false, size, color, backcolor, y, string);
  364. }
  365. inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) {
  366. Draw_CenteredString(false, size, color, backcolor, y, title);
  367. }
  368. inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) {
  369. Draw_CenteredString(false, font, color, backcolor, y, string);
  370. }
  371. inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) {
  372. Draw_CenteredString(false, font, color, backcolor, y, title);
  373. }
  374. inline void Draw_CenteredString(uint16_t y, const char * const string) {
  375. Draw_CenteredString(false, font, textcolor, backcolor, y, string);
  376. }
  377. inline void Draw_CenteredString(uint16_t y, FSTR_P title) {
  378. Draw_CenteredString(false, font, textcolor, backcolor, y, title);
  379. }
  380. // Draw a box
  381. // mode: 0=frame, 1=fill, 2=XOR fill
  382. // color: Rectangle color
  383. // frame: Box coordinates and size
  384. inline void Draw_Box(uint8_t mode, uint16_t color, frame_rect_t frame) {
  385. DWIN_Draw_Box(mode, color, frame.x, frame.y, frame.w, frame.h);
  386. }
  387. // Draw a circle
  388. // Color: circle color
  389. // x: abscissa of the center of the circle
  390. // y: ordinate of the center of the circle
  391. // r: circle radius
  392. void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
  393. inline void Draw_Circle(uint16_t color, uint8_t r) {
  394. Draw_Circle(color, cursor.x, cursor.y, r);
  395. }
  396. // Draw a checkbox
  397. // Color: frame color
  398. // bColor: Background color
  399. // x/y: Upper-left point
  400. // checked : 0 : unchecked, 1 : checked
  401. void Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked);
  402. inline void Draw_Checkbox(uint16_t x, uint16_t y, bool checked=false) {
  403. Draw_Checkbox(textcolor, backcolor, x, y, checked);
  404. }
  405. // Color Interpolator
  406. // val : Interpolator minv..maxv
  407. // minv : Minimum value
  408. // maxv : Maximum value
  409. // color1 : Start color
  410. // color2 : End color
  411. uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
  412. // -------------------------- Extra -------------------------------//
  413. // Draw a circle filled with color
  414. // bcolor: fill color
  415. // x: abscissa of the center of the circle
  416. // y: ordinate of the center of the circle
  417. // r: circle radius
  418. void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r);
  419. inline void Draw_FillCircle(uint16_t bcolor, uint8_t r) {
  420. Draw_FillCircle(bcolor, cursor.x, cursor.y, r);
  421. }
  422. // Color Interpolator through Red->Yellow->Green->Blue
  423. // val : Interpolator minv..maxv
  424. // minv : Minimum value
  425. // maxv : Maximum value
  426. uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv);
  427. // Write buffer data to the SRAM
  428. // addr: SRAM start address 0x0000-0x7FFF
  429. // length: Bytes to write
  430. // data: address of the buffer with data
  431. inline void WriteToSRAM(uint16_t addr, uint16_t length, uint8_t *data) {
  432. DWIN_WriteToMem(0x5A, addr, length, data);
  433. }
  434. // Write buffer data to the Flash
  435. // addr: Flash start address 0x0000-0x3FFF
  436. // length: Bytes to write
  437. // data: address of the buffer with data
  438. inline void WriteToFlash(uint16_t addr, uint16_t length, uint8_t *data) {
  439. DWIN_WriteToMem(0xA5, addr, length, data);
  440. }
  441. // Clear Menu by filling the area with background color
  442. // Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1)
  443. void ClearMenuArea();
  444. // Clear MenuItems array and free MenuItems elements
  445. void MenuItemsClear();
  446. // Prepare MenuItems array
  447. void MenuItemsPrepare(int8_t totalitems);
  448. // Add elements to the MenuItems array
  449. MenuItemClass* MenuItemsAdd(MenuItemClass* menuitem);
  450. };