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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2022 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 Enhanced implementation for PRO UI
  25. * Author: Miguel A. Risco-Castillo (MRISCOC)
  26. * Version: 3.17.1
  27. * Date: 2022/04/12
  28. *
  29. * Modded for JYERSUI by LCH-77
  30. * Version: 1.9
  31. * Date: Jun 16, 2022
  32. */
  33. #include "dwin_lcd.h"
  34. #include "../common/dwin_set.h"
  35. #include "../common/dwin_font.h"
  36. #include "../common/dwin_color.h"
  37. #include "../common/dwin_api.h"
  38. // Custom icons
  39. //#define DWIN_CREALITY_LCD_CUSTOM_ICONS
  40. #if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS)
  41. // index of every custom icon should be >= CUSTOM_ICON_START
  42. #define CUSTOM_ICON_START ICON_Checkbox_F
  43. #define ICON_Checkbox_F 200
  44. #define ICON_Checkbox_T 201
  45. #define ICON_Fade 202
  46. #define ICON_Mesh 203
  47. #define ICON_Tilt 204
  48. #define ICON_Brightness 205
  49. #define ICON_AxisD 249
  50. #define ICON_AxisBR 250
  51. #define ICON_AxisTR 251
  52. #define ICON_AxisBL 252
  53. #define ICON_AxisTL 253
  54. #define ICON_AxisC 254
  55. #else
  56. #define ICON_Fade ICON_Version
  57. #define ICON_Mesh ICON_Version
  58. #define ICON_Tilt ICON_Version
  59. #define ICON_Brightness ICON_Version
  60. #define ICON_AxisD ICON_Axis
  61. #define ICON_AxisBR ICON_Axis
  62. #define ICON_AxisTR ICON_Axis
  63. #define ICON_AxisBL ICON_Axis
  64. #define ICON_AxisTL ICON_Axis
  65. #define ICON_AxisC ICON_Axis
  66. #define ICON_ESDiag ICON_Info
  67. #define ICON_Lock ICON_Cool
  68. #define ICON_Reboot ICON_ResumeEEPROM
  69. #define ICON_ProbeAlarm ICON_SetEndTemp
  70. #define ICON_ProbeMargin ICON_PrintSize
  71. #define ICON_ProbeSelfTest ICON_SetEndTemp
  72. #define ICON_ProbeSet ICON_SetEndTemp
  73. #define ICON_ProbeDeploy ICON_SetEndTemp
  74. #define ICON_ProbeTest ICON_SetEndTemp
  75. #define ICON_ProbeTestCount ICON_SetEndTemp
  76. #define ICON_ProbeZSpeed ICON_MaxSpeedZ
  77. #define ICON_FWRetLength ICON_StepE
  78. #define ICON_FWRetSpeed ICON_Setspeed
  79. #define ICON_FWRetZRaise ICON_MoveZ
  80. #define ICON_FWRecExtLength ICON_StepE
  81. #define ICON_FWRecSpeed ICON_Setspeed
  82. #define ICON_HSMode ICON_StockConfiguration
  83. #define ICON_Sound ICON_Cool
  84. #define ICON_CaseLight ICON_Motion
  85. #define ICON_LedControl ICON_Motion
  86. #define ICON_MeshActive ICON_HotendTemp
  87. #define ICON_Park ICON_Motion
  88. #endif
  89. // Buttons
  90. #define BTN_Continue 85
  91. #define BTN_Cancel 87
  92. #define BTN_Confirm 89
  93. #define BTN_Print 90
  94. #define BTN_Save 91
  95. #define BTN_Purge 92
  96. // Extended UI Colors
  97. #define Color_Aqua RGB(0,63,31)
  98. #define Color_Light_White 0xBDD7
  99. #define Color_Green RGB(0,63,0)
  100. #define Color_Light_Green 0x3460
  101. #define Color_Cyan 0x07FF
  102. #define Color_Light_Cyan 0x04F3
  103. #define Color_Blue RGB(0,0,31)
  104. #define Color_Light_Blue 0x3A6A
  105. #define Color_Magenta 0xF81F
  106. #define Color_Light_Magenta 0x9813
  107. #define Color_Light_Red 0x8800
  108. #define Color_Orange 0xFA20
  109. #define Color_Light_Orange 0xFBC0
  110. #define Color_Light_Yellow 0x8BE0
  111. #define Color_Brown 0xCC27
  112. #define Color_Light_Brown 0x6204
  113. #define Color_Black 0x0000
  114. #define Color_Grey 0x18E3
  115. #define Check_Color 0x4E5C
  116. #define Confirm_Color 0x34B9
  117. #define Cancel_Color 0x3186
  118. // UI element defines and constants
  119. #define DWIN_FONT_MENU font8x16
  120. #define DWIN_FONT_STAT font10x20
  121. #define DWIN_FONT_HEAD font10x20
  122. #define DWIN_FONT_ALERT font10x20
  123. #define STATUS_Y 354
  124. #define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16
  125. // Minimum unit (0.1) : multiple (10)
  126. #define UNITFDIGITS 1
  127. #define MINUNITMULT POW(10, UNITFDIGITS)
  128. constexpr uint8_t TITLE_HEIGHT = 30, // Title bar height
  129. MLINE = 53, // Menu line height
  130. TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows
  131. MROWS = TROWS - 1, // Other-than-Back
  132. ICOX = 26, // Menu item icon X position
  133. LBLX = 60, // Menu item label X position
  134. VALX = 210, // Menu item value X position
  135. MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16
  136. STAT_CHR_W = 10;
  137. // Menuitem Y position
  138. #define MYPOS(L) (TITLE_HEIGHT + MLINE * (L))
  139. // Menuitem caption Offset
  140. #define CAPOFF ((MLINE - MENU_CHR_H) / 2)
  141. // Menuitem caption Y position
  142. #define MBASE(L) (MYPOS(L) + CAPOFF)
  143. typedef struct { uint16_t left, top, right, bottom; } rect_t;
  144. typedef struct { uint16_t x, y, w, h; } frame_rect_t;
  145. namespace DWINUI {
  146. extern xy_int_t cursor;
  147. extern uint16_t pencolor;
  148. extern uint16_t textcolor;
  149. extern uint16_t backcolor;
  150. extern uint16_t buttoncolor;
  151. extern uint8_t font;
  152. extern FSTR_P const Author;
  153. // DWIN LCD Initialization
  154. void init();
  155. // Set text/number font
  156. void setFont(uint8_t cfont);
  157. // Get font character width
  158. uint8_t fontWidth(uint8_t cfont);
  159. inline uint8_t fontWidth() { return fontWidth(font); };
  160. // Get font character height
  161. uint8_t fontHeight(uint8_t cfont);
  162. inline uint8_t fontHeight() { return fontHeight(font); };
  163. // Get screen x coordinates from text column
  164. uint16_t ColToX(uint8_t col);
  165. // Get screen y coordinates from text row
  166. uint16_t RowToY(uint8_t row);
  167. // Set text/number color
  168. void SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor);
  169. void SetTextColor(uint16_t fgcolor);
  170. void SetBackgroundColor(uint16_t bgcolor);
  171. // Moves cursor to point
  172. // x: abscissa of the display
  173. // y: ordinate of the display
  174. // point: xy coordinate
  175. void MoveTo(int16_t x, int16_t y);
  176. void MoveTo(xy_int_t point);
  177. // Moves cursor relative to the actual position
  178. // x: abscissa of the display
  179. // y: ordinate of the display
  180. // point: xy coordinate
  181. void MoveBy(int16_t x, int16_t y);
  182. void MoveBy(xy_int_t point);
  183. // Draw a line from the cursor to xy position
  184. // color: Line segment color
  185. // x/y: End point
  186. inline void LineTo(uint16_t color, uint16_t x, uint16_t y) {
  187. DWIN_Draw_Line(color, cursor.x, cursor.y, x, y);
  188. }
  189. inline void LineTo(uint16_t x, uint16_t y) {
  190. DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y);
  191. }
  192. // Extend a frame box
  193. // v: value to extend
  194. inline frame_rect_t ExtendFrame(frame_rect_t frame, uint8_t v) {
  195. frame_rect_t t;
  196. t.x = frame.x - v;
  197. t.y = frame.y - v;
  198. t.w = frame.w + 2 * v;
  199. t.h = frame.h + 2 * v;
  200. return t;
  201. }
  202. // Draw an Icon with transparent background from the library ICON
  203. // icon: Icon ID
  204. // x/y: Upper-left point
  205. inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) {
  206. DWIN_ICON_Show(ICON, icon, x, y);
  207. }
  208. // Draw an Icon from the library ICON with its background
  209. // icon: Icon ID
  210. // x/y: Upper-left point
  211. inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) {
  212. DWIN_ICON_Show(true, false, false, ICON, icon, x, y);
  213. }
  214. inline void DRAW_IconWB(uint8_t libID, uint8_t icon, uint16_t x, uint16_t y) {
  215. DWIN_ICON_Show(true, false, false, libID, icon, x, y);
  216. }
  217. // Draw a numeric integer value
  218. // bShow: true=display background color; false=don't display background color
  219. // signedMode: 1=signed; 0=unsigned
  220. // size: Font size
  221. // color: Character color
  222. // bColor: Background color
  223. // iNum: Number of digits
  224. // x/y: Upper-left coordinate
  225. // value: Integer value
  226. void Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value);
  227. // Draw a positive integer
  228. inline void Draw_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
  229. Draw_Int(bShow, 0, size, color, bColor, iNum, x, y, value);
  230. }
  231. inline void Draw_Int(uint8_t iNum, long value) {
  232. Draw_Int(false, 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. Draw_Int(false, 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. Draw_Int(false, 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. Draw_Int(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. Draw_Int(true, 0, size, color, bColor, iNum, x, y, value);
  246. }
  247. // Draw a signed integer
  248. inline void Draw_Signed_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
  249. Draw_Int(bShow, 1, size, color, bColor, iNum, x, y, value);
  250. }
  251. inline void Draw_Signed_Int(uint8_t iNum, long value) {
  252. Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
  253. MoveBy(iNum * fontWidth(font), 0);
  254. }
  255. inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
  256. Draw_Int(false, 1, font, textcolor, backcolor, iNum, x, y, value);
  257. }
  258. inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) {
  259. Draw_Int(false, 1, font, color, backcolor, iNum, x, y, value);
  260. }
  261. inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
  262. Draw_Int(true, 1, font, color, bColor, iNum, x, y, value);
  263. }
  264. inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) {
  265. Draw_Int(true, 1, size, color, bColor, iNum, x, y, value);
  266. }
  267. // Draw a numeric float value
  268. // bShow: true=display background color; false=don't display background color
  269. // signedMode: 1=signed; 0=unsigned
  270. // size: Font size
  271. // color: Character color
  272. // bColor: Background color
  273. // iNum: Number of digits
  274. // fNum: Number of decimal digits
  275. // x/y: Upper-left coordinate
  276. // value: float value
  277. void Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
  278. // Draw a positive floating point number
  279. inline void Draw_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  280. Draw_Float(bShow, 0, size, color, bColor, iNum, fNum, x, y, value);
  281. }
  282. inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
  283. Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
  284. MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
  285. }
  286. inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  287. Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
  288. }
  289. inline void Draw_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  290. Draw_Float(false, 0, size, textcolor, backcolor, iNum, fNum, x, y, value);
  291. }
  292. inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  293. Draw_Float(true, 0, font, color, bColor, iNum, fNum, x, y, value);
  294. }
  295. 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) {
  296. Draw_Float(true, 0, size, color, bColor, iNum, fNum, x, y, value);
  297. }
  298. // Draw a signed floating point number
  299. inline void Draw_Signed_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  300. Draw_Float(bShow, 1, size, color, bColor, iNum, fNum, x, y, value);
  301. }
  302. inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
  303. Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
  304. MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
  305. }
  306. inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  307. Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, x, y, value);
  308. }
  309. inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
  310. Draw_Float(false, 1, size, textcolor, backcolor, iNum, fNum, x, y, value);
  311. }
  312. 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) {
  313. Draw_Float(true, 1, font, color, bColor, iNum, fNum, x, y, value);
  314. }
  315. 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) {
  316. Draw_Float(true, 1, size, color, bColor, iNum, fNum, x, y, value);
  317. }
  318. // Draw a char
  319. // color: Character color
  320. // x: abscissa of the display
  321. // y: ordinate of the display
  322. // c: ASCII code of char
  323. void Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c);
  324. inline void Draw_Char(uint16_t x, uint16_t y, const char c) { Draw_Char(textcolor, x, y, c); };
  325. // Draw a char at cursor position and increment cursor
  326. void Draw_Char(uint16_t color, const char c);
  327. inline void Draw_Char(const char c) { Draw_Char(textcolor, c); }
  328. // Draw a string at cursor position
  329. // color: Character color
  330. // *string: The string
  331. // rlimit: For draw less chars than string length use rlimit
  332. void Draw_String(const char * const string, uint16_t rlimit = 0xFFFF);
  333. void Draw_String(uint16_t color, const char * const string, uint16_t rlimit = 0xFFFF);
  334. inline void Draw_String(FSTR_P string, uint16_t rlimit = 0xFFFF) {
  335. Draw_String(FTOP(string), rlimit);
  336. }
  337. inline void Draw_String(uint16_t color, FSTR_P string, uint16_t rlimit = 0xFFFF) {
  338. Draw_String(color, FTOP(string), rlimit);
  339. }
  340. // Draw a string
  341. // size: Font size
  342. // color: Character color
  343. // bColor: Background color
  344. // x/y: Upper-left coordinate of the string
  345. // *string: The string
  346. inline void Draw_String(uint16_t x, uint16_t y, const char * const string) {
  347. DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string);
  348. }
  349. inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) {
  350. DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title));
  351. }
  352. inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) {
  353. DWIN_Draw_String(false, font, color, backcolor, x, y, string);
  354. }
  355. inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) {
  356. DWIN_Draw_String(false, font, color, backcolor, x, y, title);
  357. }
  358. inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
  359. DWIN_Draw_String(true, font, color, bgcolor, x, y, string);
  360. }
  361. inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
  362. DWIN_Draw_String(true, font, color, bgcolor, x, y, title);
  363. }
  364. inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) {
  365. DWIN_Draw_String(true, size, color, bgcolor, x, y, string);
  366. }
  367. inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) {
  368. DWIN_Draw_String(true, size, color, bgcolor, x, y, title);
  369. }
  370. // Draw a centered string using DWIN_WIDTH
  371. // bShow: true=display background color; false=don't display background color
  372. // size: Font size
  373. // color: Character color
  374. // bColor: Background color
  375. // y: Upper coordinate of the string
  376. // *string: The string
  377. void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string);
  378. inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
  379. Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string);
  380. }
  381. inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) {
  382. Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string));
  383. }
  384. inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) {
  385. Draw_CenteredString(true, font, color, bcolor, y, string);
  386. }
  387. inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) {
  388. Draw_CenteredString(false, size, color, backcolor, y, string);
  389. }
  390. inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) {
  391. Draw_CenteredString(false, size, color, backcolor, y, title);
  392. }
  393. inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) {
  394. Draw_CenteredString(false, font, color, backcolor, y, string);
  395. }
  396. inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) {
  397. Draw_CenteredString(false, font, color, backcolor, y, title);
  398. }
  399. inline void Draw_CenteredString(uint16_t y, const char * const string) {
  400. Draw_CenteredString(false, font, textcolor, backcolor, y, string);
  401. }
  402. inline void Draw_CenteredString(uint16_t y, FSTR_P title) {
  403. Draw_CenteredString(false, font, textcolor, backcolor, y, title);
  404. }
  405. // Draw a box
  406. // mode: 0=frame, 1=fill, 2=XOR fill
  407. // color: Rectangle color
  408. // frame: Box coordinates and size
  409. inline void Draw_Box(uint8_t mode, uint16_t color, frame_rect_t frame) {
  410. DWIN_Draw_Box(mode, color, frame.x, frame.y, frame.w, frame.h);
  411. }
  412. // Draw a circle
  413. // Color: circle color
  414. // x: abscissa of the center of the circle
  415. // y: ordinate of the center of the circle
  416. // r: circle radius
  417. void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
  418. inline void Draw_Circle(uint16_t color, uint8_t r) {
  419. Draw_Circle(color, cursor.x, cursor.y, r);
  420. }
  421. // Draw a checkbox
  422. // Color: frame color
  423. // bColor: Background color
  424. // x/y: Upper-left point
  425. // checked : 0 : unchecked, 1 : checked
  426. void Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked);
  427. inline void Draw_Checkbox(uint16_t x, uint16_t y, bool checked=false) {
  428. Draw_Checkbox(textcolor, backcolor, x, y, checked);
  429. }
  430. // Color Interpolator
  431. // val : Interpolator minv..maxv
  432. // minv : Minimum value
  433. // maxv : Maximum value
  434. // color1 : Start color
  435. // color2 : End color
  436. uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
  437. // ------------------------- Buttons ------------------------------//
  438. void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption);
  439. inline void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) {
  440. Draw_Button(color, bcolor, x1, y1, x2, y2, FTOP(caption));
  441. }
  442. inline void Draw_Button(FSTR_P caption, uint16_t x, uint16_t y) {
  443. Draw_Button(textcolor, buttoncolor, x, y, x + 99, y + 37, caption);
  444. }
  445. void Draw_Button(uint8_t id, uint16_t x, uint16_t y);
  446. // -------------------------- Extra -------------------------------//
  447. // Draw a circle filled with color
  448. // bcolor: fill color
  449. // x: abscissa of the center of the circle
  450. // y: ordinate of the center of the circle
  451. // r: circle radius
  452. void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r);
  453. inline void Draw_FillCircle(uint16_t bcolor, uint8_t r) {
  454. Draw_FillCircle(bcolor, cursor.x, cursor.y, r);
  455. }
  456. // Color Interpolator through Red->Yellow->Green->Blue
  457. // val : Interpolator minv..maxv
  458. // minv : Minimum value
  459. // maxv : Maximum value
  460. uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv);
  461. // Write buffer data to the SRAM
  462. // addr: SRAM start address 0x0000-0x7FFF
  463. // length: Bytes to write
  464. // data: address of the buffer with data
  465. inline void WriteToSRAM(uint16_t addr, uint16_t length, uint8_t *data) {
  466. DWIN_WriteToMem(0x5A, addr, length, data);
  467. }
  468. // Write buffer data to the Flash
  469. // addr: Flash start address 0x0000-0x3FFF
  470. // length: Bytes to write
  471. // data: address of the buffer with data
  472. inline void WriteToFlash(uint16_t addr, uint16_t length, uint8_t *data) {
  473. DWIN_WriteToMem(0xA5, addr, length, data);
  474. }
  475. // Clear by filling the area with background color
  476. // Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1)
  477. void ClearMainArea();
  478. };