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.

dwin_lcd.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. * @file lcd/e3v2/jyersui/dwin_lcd.cpp
  24. * @brief DWIN screen control functions
  25. ********************************************************************************/
  26. #include "../../../inc/MarlinConfigPre.h"
  27. #if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
  28. #include "dwin_lcd.h"
  29. /*-------------------------------------- System variable function --------------------------------------*/
  30. void DWIN_Startup() {}
  31. /*---------------------------------------- Drawing functions ----------------------------------------*/
  32. // Draw the degree (°) symbol
  33. // Color: color
  34. // x/y: Upper-left coordinate of the first pixel
  35. void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) {
  36. DWIN_Draw_Point(Color, 1, 1, x + 1, y);
  37. DWIN_Draw_Point(Color, 1, 1, x + 2, y);
  38. DWIN_Draw_Point(Color, 1, 1, x, y + 1);
  39. DWIN_Draw_Point(Color, 1, 1, x + 3, y + 1);
  40. DWIN_Draw_Point(Color, 1, 1, x, y + 2);
  41. DWIN_Draw_Point(Color, 1, 1, x + 3, y + 2);
  42. DWIN_Draw_Point(Color, 1, 1, x + 1, y + 3);
  43. DWIN_Draw_Point(Color, 1, 1, x + 2, y + 3);
  44. }
  45. /*---------------------------------------- Picture related functions ----------------------------------------*/
  46. // Draw an Icon with transparent background
  47. // libID: Icon library ID
  48. // picID: Icon ID
  49. // x/y: Upper-left point
  50. void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
  51. DWIN_ICON_Show(false, false, true, libID, picID, x, y);
  52. }
  53. // From DWIN Enhanced implementation for PRO UI v3.10.1
  54. // Write buffer data to the SRAM or Flash
  55. // mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
  56. // addr: start address
  57. // length: Bytes to write
  58. // data: address of the buffer with data
  59. void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data) {
  60. const uint8_t max_size = 128;
  61. uint16_t pending = length;
  62. uint16_t to_send;
  63. uint16_t indx;
  64. uint8_t block = 0;
  65. while (pending > 0) {
  66. indx = block * max_size;
  67. to_send = _MIN(pending, max_size);
  68. size_t i = 0;
  69. DWIN_Byte(i, 0x31);
  70. DWIN_Byte(i, mem);
  71. DWIN_Word(i, addr + indx); // start address of the data block
  72. ++i;
  73. LOOP_L_N(j, i) { LCD_SERIAL.write(DWIN_SendBuf[j]); delayMicroseconds(1); } // Buf header
  74. for (uint16_t j = indx; j <= indx + to_send - 1; j++) LCD_SERIAL.write(*(data + j)); delayMicroseconds(1); // write block of data
  75. LOOP_L_N(j, 4) { LCD_SERIAL.write(DWIN_BufTail[j]); delayMicroseconds(1); }
  76. block++;
  77. pending -= to_send;
  78. }
  79. }
  80. #endif // DWIN_CREALITY_LCD_JYERSUI