Skip to content

Commit a2c1576

Browse files
enigmaquipvgadreau
authored andcommitted
Add more DWIN commands, docs (MarlinFirmware#19395)
1 parent e5691d0 commit a2c1576

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

Marlin/src/lcd/dwin/dwin_lcd.cpp

+92
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ void DWIN_Frame_Clear(const uint16_t color) {
153153
DWIN_Send(i);
154154
}
155155

156+
// Draw a point
157+
// width: point width 0x01-0x0F
158+
// height: point height 0x01-0x0F
159+
// x,y: upper left point
160+
void DWIN_Draw_Point(uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
161+
size_t i = 0;
162+
DWIN_Byte(i, 0x02);
163+
DWIN_Byte(i, width);
164+
DWIN_Byte(i, height);
165+
DWIN_Word(i, x);
166+
DWIN_Word(i, y);
167+
DWIN_Send(i);
168+
}
169+
156170
// Draw a line
157171
// color: Line segment color
158172
// xStart/yStart: Start point
@@ -221,6 +235,10 @@ void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size,
221235
uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) {
222236
size_t i = 0;
223237
DWIN_Byte(i, 0x11);
238+
// Bit 7: widthAdjust
239+
// Bit 6: bShow
240+
// Bit 5-4: Unused (0)
241+
// Bit 3-0: size
224242
DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
225243
DWIN_Word(i, color);
226244
DWIN_Word(i, bColor);
@@ -244,6 +262,11 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t
244262
uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint16_t value) {
245263
size_t i = 0;
246264
DWIN_Byte(i, 0x14);
265+
// Bit 7: bshow
266+
// Bit 6: 1 = signed; 0 = unsigned number;
267+
// Bit 5: zeroFill
268+
// Bit 4: zeroMode
269+
// Bit 3-0: size
247270
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
248271
DWIN_Word(i, color);
249272
DWIN_Word(i, bColor);
@@ -360,4 +383,73 @@ void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
360383
DWIN_Send(i);
361384
}
362385

386+
// Animate a series of icons
387+
// animID: Animation ID; 0x00-0x0F
388+
// animate: true on; false off;
389+
// libID: Icon library ID
390+
// picIDs: Icon starting ID
391+
// picIDe: Icon ending ID
392+
// x/y: Upper-left point
393+
// interval: Display time interval, unit 10mS
394+
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
395+
NOMORE(x, DWIN_WIDTH - 1);
396+
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
397+
size_t i = 0;
398+
DWIN_Byte(i, 0x28);
399+
DWIN_Word(i, x);
400+
DWIN_Word(i, y);
401+
// Bit 7: animation on or off
402+
// Bit 6: start from begin or end
403+
// Bit 5-4: unused (0)
404+
// Bit 3-0: animID
405+
DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
406+
DWIN_Byte(i, libID);
407+
DWIN_Byte(i, picIDs);
408+
DWIN_Byte(i, picIDe);
409+
DWIN_Byte(i, interval);
410+
DWIN_Send(i);
411+
}
412+
413+
// Animation Control
414+
// state: 16 bits, each bit is the state of an animation id
415+
void DWIN_ICON_AnimationControl(uint16_t state) {
416+
size_t i = 0;
417+
DWIN_Byte(i, 0x28);
418+
DWIN_Word(i, state);
419+
DWIN_Send(i);
420+
}
421+
422+
/*---------------------------------------- Memory functions ----------------------------------------*/
423+
// The LCD has an additional 32KB SRAM and 16KB Flash
424+
425+
// Data can be written to the sram and save to one of the jpeg page files
426+
427+
// Write Data Memory
428+
// command 0x31
429+
// Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
430+
// Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
431+
// Data: data
432+
//
433+
// Flash writing returns 0xA5 0x4F 0x4B
434+
435+
// Read Data Memory
436+
// command 0x32
437+
// Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
438+
// Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
439+
// Length: leangth of data to read; 0x01-0xF0
440+
//
441+
// Response:
442+
// Type, Address, Length, Data
443+
444+
// Write Picture Memory
445+
// Write the contents of the 32KB SRAM data memory into the designated image memory space
446+
// Issued: 0x5A, 0xA5, PIC_ID
447+
// Response: 0xA5 0x4F 0x4B
448+
//
449+
// command 0x33
450+
// 0x5A, 0xA5
451+
// PicId: Picture Memory location, 0x00-0x0F
452+
//
453+
// Flash writing returns 0xA5 0x4F 0x4B
454+
363455
#endif // DWIN_CREALITY_LCD

Marlin/src/lcd/dwin/dwin_lcd.h

+21
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ void DWIN_UpdateLCD(void);
6767
// color: Clear screen color
6868
void DWIN_Frame_Clear(const uint16_t color);
6969

70+
// Draw a point
71+
// width: point width 0x01-0x0F
72+
// height: point height 0x01-0x0F
73+
// x,y: upper left point
74+
void DWIN_Draw_Point(uint8_t width, uint8_t height, uint16_t x, uint16_t y);
75+
7076
// Draw a line
7177
// color: Line segment color
7278
// xStart/yStart: Start point
@@ -190,3 +196,18 @@ inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
190196
// x/y: Screen paste point
191197
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
192198
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
199+
200+
// Animate a series of icons
201+
// animID: Animation ID up to 16
202+
// animate: animation on or off
203+
// libID: Icon library ID
204+
// picIDs: Icon starting ID
205+
// picIDe: Icon ending ID
206+
// x/y: Upper-left point
207+
// interval: Display time interval, unit 10mS
208+
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
209+
uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
210+
211+
// Animation Control
212+
// state: 16 bits, each bit is the state of an animation id
213+
void DWIN_ICON_AnimationControl(uint16_t state);

0 commit comments

Comments
 (0)