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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. /**
  23. * DWIN Enhanced implementation for PRO UI
  24. * Author: Miguel A. Risco-Castillo (MRISCOC)
  25. * Version: 3.10.1
  26. * Date: 2022/03/06
  27. */
  28. #include "../../../inc/MarlinConfigPre.h"
  29. #if ENABLED(DWIN_LCD_PROUI)
  30. #include "../../../inc/MarlinConfig.h"
  31. #include "dwin_lcd.h"
  32. /*---------------------------------------- Picture related functions ----------------------------------------*/
  33. // Display QR code
  34. // The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix
  35. // QR_Pixel: The pixel size occupied by each point of the QR code: 0x01-0x0F (1-16)
  36. // (Nx, Ny): The coordinates of the upper left corner displayed by the QR code
  37. // str: multi-bit data
  38. void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, char *string) {
  39. size_t i = 0;
  40. DWIN_Byte(i, 0x21);
  41. DWIN_Word(i, x);
  42. DWIN_Word(i, y);
  43. DWIN_Byte(i, QR_Pixel);
  44. DWIN_Text(i, string);
  45. DWIN_Send(i);
  46. }
  47. // Draw an Icon with transparent background
  48. // libID: Icon library ID
  49. // picID: Icon ID
  50. // x/y: Upper-left point
  51. void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
  52. DWIN_ICON_Show(false, false, true, libID, picID, x, y);
  53. }
  54. // Copy area from current virtual display area to current screen
  55. // xStart/yStart: Upper-left of virtual area
  56. // xEnd/yEnd: Lower-right of virtual area
  57. // x/y: Screen paste point
  58. void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
  59. size_t i = 0;
  60. DWIN_Byte(i, 0x26);
  61. DWIN_Word(i, xStart);
  62. DWIN_Word(i, yStart);
  63. DWIN_Word(i, xEnd);
  64. DWIN_Word(i, yEnd);
  65. DWIN_Word(i, x);
  66. DWIN_Word(i, y);
  67. DWIN_Send(i);
  68. }
  69. // Copy area from virtual display area to current screen
  70. // IBD: background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
  71. // BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
  72. // BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
  73. // cacheID: virtual area number
  74. // xStart/yStart: Upper-left of virtual area
  75. // xEnd/yEnd: Lower-right of virtual area
  76. // x/y: Screen paste point
  77. void DWIN_Frame_AreaCopy(bool IBD, bool BIR, bool BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
  78. size_t i = 0;
  79. DWIN_Byte(i, 0x27);
  80. DWIN_Byte(i, (IBD & 1) << 7 | (BIR & 1) << 6 | (BFI & 1) << 5 | cacheID);
  81. DWIN_Word(i, xStart);
  82. DWIN_Word(i, yStart);
  83. DWIN_Word(i, xEnd);
  84. DWIN_Word(i, yEnd);
  85. DWIN_Word(i, x);
  86. DWIN_Word(i, y);
  87. DWIN_Send(i);
  88. }
  89. // Copy area from virtual display area to current screen with transparent background
  90. // cacheID: virtual area number
  91. // xStart/yStart: Upper-left of virtual area
  92. // xEnd/yEnd: Lower-right of virtual area
  93. // x/y: Screen paste point
  94. void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
  95. DWIN_Frame_AreaCopy(false, false, true, cacheID, xStart, yStart, xEnd, yEnd, x, y);
  96. }
  97. // Write buffer data to the SRAM or Flash
  98. // mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
  99. // addr: start address
  100. // length: Bytes to write
  101. // data: address of the buffer with data
  102. void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data) {
  103. const uint8_t max_size = 128;
  104. uint16_t pending = length;
  105. uint16_t to_send;
  106. uint16_t indx;
  107. uint8_t block = 0;
  108. while (pending > 0) {
  109. indx = block * max_size;
  110. to_send = _MIN(pending, max_size);
  111. size_t i = 0;
  112. DWIN_Byte(i, 0x31);
  113. DWIN_Byte(i, mem);
  114. DWIN_Word(i, addr + indx); // start address of the data block
  115. ++i;
  116. LOOP_L_N(j, i) { LCD_SERIAL.write(DWIN_SendBuf[j]); delayMicroseconds(1); } // Buf header
  117. for (uint16_t j = indx; j <= indx + to_send - 1; j++) LCD_SERIAL.write(*(data + j)); delayMicroseconds(1); // write block of data
  118. LOOP_L_N(j, 4) { LCD_SERIAL.write(DWIN_BufTail[j]); delayMicroseconds(1); }
  119. block++;
  120. pending -= to_send;
  121. }
  122. }
  123. // Write the contents of the 32KB SRAM data memory into the designated image memory space.
  124. // picID: Picture memory space location, 0x00-0x0F, each space is 32Kbytes
  125. void DWIN_SRAMToPic(uint8_t picID) {
  126. size_t i = 0;
  127. DWIN_Byte(i, 0x33);
  128. DWIN_Byte(i, 0x5A);
  129. DWIN_Byte(i, 0xA5);
  130. DWIN_Byte(i, picID);
  131. DWIN_Send(i);
  132. }
  133. //--------------------------Test area -------------------------
  134. //void DWIN_ReadSRAM(uint16_t addr, const uint8_t length, const char * const data) {
  135. // size_t i = 0;
  136. // DWIN_Byte(i, 0x32);
  137. // DWIN_Byte(i, 0x5A); // 0x5A Read from SRAM - 0xA5 Read from Flash
  138. // DWIN_Word(i, addr); // 0x0000 to 0x7FFF
  139. // const size_t len = _MIN(0xF0, length);
  140. // DWIN_Byte(i, len);
  141. // DWIN_Send(i);
  142. //}
  143. #endif // DWIN_LCD_PROUI