dwin uart lcm software development guide v3 software development guide... · profesional,...

53
DWIN SOFTWARE DEVELOPMENT GUIDE V3.2 BEIJING DWIN TECHNOLOGY CO., LTD. PROFESSIONAL, CREDITABLE, SUCCESSFULL DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 2012-03-16 Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel400-018-9008

Upload: dinhhanh

Post on 20-Jan-2019

238 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

DWIN SOFTWARE DEVELOPMENT GUIDE V3.2

BEIJING DWIN TECHNOLOGY CO., LTD. PROFESSIONAL, CREDITABLE, SUCCESSFULL

DWIN UART LCM

SOFTWARE

DEVELOPMENT

GUIDE V3.2

2012-03-16

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 1

Page 2: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008

Index

1 TEXT ..................................................................................................................................................... 1 1.1 Display Text in Programs Directly (C & ASM51) ..................................................................... 1 1.2 Textbox Format Control ............................................................................................................ 2 1.3 Adjust ASCII Characters Spacing Automatically ....................................................................... 2 1.4 Display Text Without Its Background ....................................................................................... 2 1.5 WordArt Characters (Special characters) Display .................................................................... 3 1.6 Vertical Text Display ................................................................................................................. 3 1.7 Numerical Parameter Display .................................................................................................. 4 1.8 Display Rolling Text ................................................................................................................... 5

2 CURVE .................................................................................................................................................. 8 2.1 Move Curve to AchieveDynamic Curve Display ....................................................................... 8 2.2 Dynamic Curve: Zoom and Playback History by the Movement of Windows ........................ 9

3 PICTURE, ICON AND ANIMATION ...................................................................................................... 10 3.1 Progress Bar Display ............................................................................................................... 10 3.2 Analog Dial Display ................................................................................................................. 11 3.3 Picture Overlap Display .......................................................................................................... 11 3.4 Backup and Restore Current Screen ....................................................................................... 12 3.5 Pointer and Dashboard Display .............................................................................................. 13 3.6 Flowchart Animation (Auto-execution at fixed time) ........................................................... 14

4 TOUCH SCREEN INTERFACE ............................................................................................................... 15 4.1 Touching Function Interface (Programming-free) Design ..................................................... 15 4.2 Input Parameters on Touch Screen ........................................................................................ 16 4.3 Input Chinese with Touch Screen (GBK font) ......................................................................... 17

5 The System Configuration and Peripherals ....................................................................................... 18 5.1 System Configuration Parameters Specification .................................................................... 18 5.2 RTC .......................................................................................................................................... 18 5.3 Backlight Brightness Adjustment and Screensaver Brightness Setting ................................. 21 5.4 Visual Angle Adjustment ........................................................................................................ 21 5.5 Read/Write Intrinsic Database ............................................................................................... 22 5.6 Video Play ............................................................................................................................... 24 5.7 Buzzer ...................................................................................................................................... 24

6 RECOMMENDATION OF USERS’ PROGRAM DESIGN......................................... 错误!未定义书签。 7 SOFTWARE RELATED PARAMETERS’ INSTRUCTIONS ........................................................................ 26

7.1 Font Specification ................................................................................................................... 26 7.2 Picture Storage Quantity ........................................................................................................ 26 7.3 Executive Time of Typical Commands ................................................................................... 27

APPENDIX 1: DWIN UART LCM COMMANDS TABLE ............................................................................ 28 APPENDIX 2: ASM 51 APPLICATION EXAMPLE: CLOCK ........................................................................ 31 APPENDIX 3: ASM 51 APPLICATION EXAMPLE: SIMPLE OSCILLOSCOPE ............................................. 37 APPENDIX 4: C51 SERIAL COMMUNICATION PROGRAM REFERENCE ................................................. 46 APPENDIX 5: C51 FUNCTION PROTOTYPES REFERENCE ...................................................................... 47

Page 3: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 1

1 TEXT

Command Description

0x40 Set palettes

0x42 Select color to the background palette

0x41 Set the character spacing

0x45 Set/cancel the textbox limitation

0xE0

The configuration display mode: PARA1.2: 0=normal display 1= 90°display PARA2.4(H600 and K600+ only): 0=automatically restore the background when text is displayed 1=display text in accordance with the specific background color

0x53 Display the 8×8 string in ASCII, relating to the 0x00 font.

0x6E Display the 12×12 Chinese string in GBK, relating to the 0x20 font (Chinese) and the 0x00 font (ASCII).

0x54 Display 16×16 Chinese string in GBK, relating to the 0x21 font(Chinese) and the 0x00

(ASCII).

0x6F Display the 24×24 Chinese string in GB2312, relating to the 0x22 font(Chinese) and the

0x00 font (ASCII)

0x55 Display the 32×32 Chinese string in GB2312, relating to the 0x23 font(Chinese) and the

0x00 font (ASCII)

0x98 Display any dot matrix and any encoding string, relating to the custom font library. But the 0x00 font is used with ASCII on the GB2312 and GBK mode

0x9C Cut icon from the specific picture and the background of picture is automatically filtered out. Automatically restore the current background before paste

0x9D Cut icon from the specific picture and the background of picture is automatically filtered out.

0xC108 Parameters are identified and displayed automatically based on parameters displaying in temporary buffer

1.1 Display Text in Programs Directly (C & ASM51) C language:

uchar *HZSTR="汉字显示OK"; //The Chinese string uint x, y, color; prints (0x54, x, y, HZSTR) //The 16 dots matrix (GBK Chinese string) display, (x,y) is the

//coordinates. It can also be written as:

prints (0x54, x, y," 汉字显示OK") ASM51

HZSTR: DB "汉字显示测试OK", 0xFE ; The 0xFE is the end of string MOV DPTR, #HZSTR LCALL TXROMS

Note: In Chinese GBK code operating system, C or ASM complier will translate “汉字显示测试OK”(A Chinese string) to GBK code automatically. The Chinese GBK encoding (Extended character) is downward compatible with GB2312 (Primary, secondary fonts).

Page 4: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 2

1.2 Textbox Format Control The procedures of effects shown as the right picture: Use the 0x41 command to set character spacing: dx=0 dy=12 Use the 0x45 command to set textbox on (Xs,Ys) (Xe,Ye). Use the 0x98 command to display text Use the 0x0D and 0x0A commands to control the linefeed. C_Mode.6=0 means the background color does not displayed.

1.3 Automatically Adjust ASCII Characters Spacing Each character in dot matrix font has fixed a size. So the ASCII characters such as “i”, “l” and “.” will be displayed a bit loose. Users can use the 0x98 command and set C_Mode.4=1 to solve this problem. Take the WiFi as an example: When C_Mode.4=0, “W I F I” is displayed; When C_Mode.4=1, “WiFi” is displayed. When C_Mode.4=1, Characters must be 8-bit encoding and the downloaded fonts need to rotated 90° (TS3, Portrait mode 1).

1.4 Display Text Without Its Background

Procedure to make the textbox of a solid color background: Select the background color on (x-1, y) with the 0x42 command. Display the text. Please set: The background color and foreground color are both displayed. Advantages: The previous data will be automatically covered when refreshing data because the background color and foreground color are both displayed.

Page 5: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 3

Procedure to make the textbox of non-solid color (Pictures) background: Method 1:

Use the 0x71 picture cutting command to recover the background color of textbox display area (The cyan area in the above picture) to erase the previous text display; Use the 0x98 text display command to display. Set the background color of textbox not-display (C_Mode.6=0). Advantages: This method can be applied to overlay text in any picture background. Text display command must be the 0x98 command. Method 2: (H600 and K600+ only).

Use the 0xE0 command to revise Para2.4=0 and recover the background automatically when displaying the text. Use the text display command again and text background will be ignored automatically. Advantages: This method is valid for any text display command. But the background must be the current picture instead of cutting or copying background from other pages.

1.5 WordArt Characters (Special characters) Display

How to display “620” as shown above: Display case one area is on the current picture: Use the 0x9D command to cut and paste the value icon from the icon library on the display area;

LOGOD9D(300,200,6); LOGOD9D(330,200,2); LOGOD9D(360,200,0); void LOGOD9D (uint x, uint y, uchar i) { uint logoxy[]={0,0,40,40,40,0,80,40,80,0,120,40,120,0,160,40,160,0,200,40,

200,0,240,40,240,0,280,40,280,0,320,40,320,0,360,40,360,0,400,40}; //The coordinates of icon uchar j; txword (0xaa9d); txword(50); //The page location where icon has been stored for(j=0;j<4;j++)

{ txword(logoxy[i*4+j];} txxy(x,y); txeof(); // 0xCC 33 C3 3C are the end of string }

Display case two area is not on current picture (such as temporary pop-up warning message box) Use the 0x71 command to restore the display area in order to erase the last contents. Then use the 0x9C command to cut values icon from icon library and paste them into the display area. Piccut (0x71, 7, 0, 0, 90, 30, 300, 200) //Assume background Is an area icon on the 0x07 page LOGOD9C (300, 200, 6); LOGOD9C (330, 200, 2); LOGOD9C (360, 200, 0);

1.6 Vertical Text Display

Page 6: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 4

Use the 0x98 command to set C_Mode.5=1 in order to achieve the vertical text display as shown in the picture above.

1.7 Numerical Parameter Display In many cases, in the users’ program parameters are saved in HEX mode. But it needs to convert into ASCII code when it is displayed: INTDSP(100,200,620); void INTDSP(uint x,uint y,int value) { uint i=10000;

uchar j,k; txword(0xaa98); txxy(x,y); txbye(0x21); //16*16 GBK txword(0xc201); //The foreground color and background color are both displayed //with 16*16 in GBK encoding. txword(0x0000); // The typeface is black txlong(0xffff); //The background is white if(value<0) txbyte("-"); //Display the minus for(j=0;j<5;j++)

{ k=value/i; txbyte(k+0x30); value=value-k*i; i=i/10;} txeof();} //0xCC 33 C3 3C are the end of string.

But it is inconvenient for users to manage the problems such as text alignment and invalid zero shielding. In the case, the 0xC108 command can be applied to solve these problems. Firstly, use the 0xC0 command to write parameters to be displayed in temporary buffer with according format; Then use the 0xC108 command to call parameters. Multiple parameters can be called each time. INTDC108(0x6305,100,200,123450); // Display 123.450 in 16*32 dot matrix. Align right. At the //(100,200) position void INTDC108(unit m,uint x,uint y,long value) { txword(0xaac0); //Firstly, write the temporary buffer

txword(0x0000); //The temporary buffer address txword(m); //Display modes txxy(x,y); txword(0x0000) //The typeface is black txword(0xffff); //The background color is white txlong(value); txeof(); // 0xCC 33 C3 3C are the end of string txbyte(0xaa); txword(0xc108); txword(0x0000); txbyte(0x01); txeof();}

Page 7: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 5

Tips: Users can also use the 0xC108 command to achieve the synchronous display of mass parameters. (If the display command is sent separately by each parameter when many parameters are displayed, communication and data processing will take a lot of time. So it is hard to achieve the synchronous display. The effect of visual parameters will be inconsecutive.)

1.8 Display Rolling Text In some applications, because of the limitation of display area size or aiming to draw, it requires to display rolling text.

The entire text can be seen as a string pointer (Array). In fact, roll means continue to modify the result of the starting position. The horizontally rolling text (Display rolling textbox in single line) is achieved with 0x71 and 0x98 commands together. The process is shown as follows: A. Use 0x71 command to restore the background of display area; B. Use 0x98 command to display the starting text of specific pointer’s position (Note: when C_Mode.6=0, text without background color) C. Modify the pointer’s position. Repeat steps A-C recursively to achieve to display rolling text. If the background of text area is solid color, use the 0x42 command to select color. When using the 0x98 command, if set the background color to display too, it needn’t use the 0x71 command to restore the background and text is displayed very quickly. Similarly, if the textbox limitation is set with the 0x42 command and the textbox can be seen as a “segment” of the text string, you can easily flip up and down rolling easily by modifying the display buffer pointer. void hzroll(uint xs, uint ys, uint xe, uint ye, uchar pos, uchar num, uchar *str) { uchar i,j,k; i=uchar(sizeof(str)); // Find out the pointer tial’s position logod71(0,xs,ys,xe,ye,xs,ys); // Restore the background

if(pos>i) pos=0; txword(0xaa98); // Display text txxy(xs,ys); txword(0x2381); // The background color does not displayed with 32*32 Chinese //characters txbyte(0x03); txword(0xf800); // The color of typeface is red txword(0x0000); k=pos; for(j=0;j<8;j++) // Characters are displays at most 8 characters in each line

Page 8: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 6

{ txbyte(str+k); k++; txbyte(str+k); k++; if(k>i) k=0;} pos=pos+2;} // Move the pointer’s position to achieve the rolling text. Only one //Chinese character

(2 bytes) is moved each time

ASM51 demonstration JNB RTCOK,START LCALL HZROLL //The rolling effect is recursively called CLR RTCOK

TEST: DB 'Dear Customer: We introduce the latest financial management plan to meet your needs!'0FFH,0FFH CMD71: DW 0AA71H,0,0,440,271,479,0,440,0CC33H,0C33CH,0FEFEH // The 0x71 command format: //AA 71

<Pic_ID> <Xs> <Ys> //<Xe> <Ye> <X> <Y> CC 33 //C3 3C

CMD98: DW 0AA98H,0,440 DB 23H,81H,03H DW 0F800H,0000H,0FEFEH HZROLL: MOV DPTR,#CMD71 // Restore the background. LCALL TXROMS MOV DPTR,#CMD98 LCALL TXROMS MOV R7,#8 //8 Chinese characters (272/32=8.5) can be only //displayed each line.

Digital is displayed with SBC case MOV DPH,HZ_DPH MOV DPL,HZ_DPL // The display starting address .

HZROLL1:CLR A MOVC A,@A+DPTR MOV R6,A INC DPTR CLR A MOVC A,@A+DPTR MOV R5,A INC DPTR CJNE R6,#0FFH,HZROLL2 CJNE R5,#0FFH,HZROLL2 MOV R4,DPH // Save the point’s tail MOV R3,DPL MOV DPTR,#TEST SJMP HZROLL1

HZROLL2:MOV A,R6 LCALL TXBYTE

MOV A,R5 LCALL TXBYTE DJNZ R7,HZROLL1 MOV A,HZ_DPL // Modify position of the movement pointer. ADD A,#2 // One Chinese character (2 byte) is moved each time MOV HZ_DPL,A CLR A ADDC A,HZ_DPH MOV HZ_DPH,A MOV A,HZ_DPL // Check it whether pointer’s position is overflowed (Over the pointer’s tail) SUBB A,R3 MOV A,HZ_DPH SUBB A,R4

Page 9: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 7

JC HZROLL3 MOV DPTR,#TEST MOV HZ_DPH,DPH MOV HZ_DPL,DPL

HZROLL3:MOV DPTR,#CMDTTL // CC 33 C3 3C are the end of string LCALL TXROMS RET

Page 10: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 8

2 CURVE

Command Description

0x40 Set palettes

0x56 Connection line in accordance with the specific points

0xC106 Zoom and display a two-way line chart of window limited with data in temporary buffer

2.1 Move Curve to Achieve Dynamic Curve Display Procedure: A. Use the 0x71 command to restore the background picture on (X, Ymin) (X+dX, Ymax) area in order to erase the previous curve; B. Use the 0x40 command to set a red foreground color. Use the 0x56 command to connect a red curve between (X, Y1now-1) and (X+dX, Y1now); C. Use the 0x40 command to set a green foreground color. Use the 0x56 command to connect a green curve between (X, Y2now-1) and (X+dX, ^2now); D. Use the 0xD0 command to compulsively refresh screen once to ensure a smoothly moving curve; E. X=x+dx. Repeat steps A-E. if(RTCOK) // It is time for A/D sampling {y1now=185-rdad(0x00)/2; // The first curve is the CHO 8bit A/D values, 185 is the zero point of Y

//axis. y2now=185-rdad(0x01)/2; piccut(0x71,3,x,ymin,x+dx,ymax,x,ymin); // Restore the current background to erase historical

curves setcolor(0xF800,0x0000); line(x,y1old,x+dx,y1now); setcolor(0x07e0,0x0000); line(x,y2old,x+dx,y2now); fdisp(); // Compulsively refresh once to display with AA D0 CC 33 C3 3C y1old=y1now; y2old=y2now; RTCOK=0; x=x+dx; if(x>Xmax) x=Xmin;}

Because of the limitation of serial communication speed and command executing time, the curve movement mode to achieve the dynamic curve display is only suitable for the low sampling rate (Usually lower than 10 times per second).

Page 11: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 9

2.2 Dynamic Curve: Zoom and Playback History with the Movement of Windows

Users can temporarily store curves in temporary buffer. The current display window is just a “segment” of the entire curves. It is very convenient to move and playback curves by modifying the staring address in buffer. The result is shown as above. Automatically zoom the curve in temporary buffer and check the bounds of curves’ window with the 0xC106 command: if(RTCOK) // It is time for A/D sampling {WRbuffer(Buf_adr,rdad(0x00)); // Store A/D values to the temporary buffer Buf_adr++; WRbuffer(Buf_adr,rdad(0x01)); Buf_adr++; if(Buf_adr>40959) Buf_adr=0;} if(DSPOK) // It is time to display and refresh {piccut(0x71,3,xmin,ymin,xmax,ymax,xmin,ymin); //Restore the current window to erase the

//previous curves DisBufLine(Dis_adr,100,0xf800); // Display curve 1 DisBufLine(Dis_adr+1,100,0x07e0); // Display curve 2 Dis_adr=Dis_adr+200; //The width of window is 100 dots, two curves. Each time the length

//of entire window is moved if(Dis_adr>40959) Dis_adr=0; } void DisBufLine(uint adr,unit num,unit color) //Display curves in temporary buffer with the

//0xC106 {txbyte(0xaa); txword(0xc106); txword(adr); txword(xmin); txword(ymax); // The zero point position in Y axis. Set (ymin+ymax)/2, if the curve is negative txword(num); txword(0x0202) //Address intervals is 2 in temporary buffer. X coordinate intervals is 2 txword(0x0102) // Curve is enlarged by 0x01/0x02=0.5 times txword(color); txword(ymin); // Display the limitation of curves’ window txword(ymax); txeof();} The maximal length of DWIN UART LCM buffer is 40Kword and can store 40960/N sampling points at maximum (N is the curve number). The historical curves can be saved in a time of 204.8 seconds at a sampling rate of 200SPS (200 records per second) for one curve. Refer to Appendix 3 to see detailed applications of ASM51 code.

Page 12: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 10

3 PICTURE, ICON AND ANIMATION

Command Description

0x70 Display a full screen picture saved in the terminal.

0x71 Cut an area from a picture which is stored in the terminal and then paste it on the current specific position

0x9C Cut an area from a picture which is stored in the terminal and then paste it on the current specific position after filtering the background color

0x9D

Cut an area from a picture which is stored in the terminal and then paste it on the current specific position after filtering the background color The 0x71 command is automatically executed once before pasting and restoring the background by the current page.

0x9E Cut an area from a picture which is stored in the terminal and then paste it on the current specific position after rotating specific angles. You can select to filter the background color when pasting. H600 and K600+ only

0x97 Displays an icon in ICON library. K600+ only

0xE2 Save current background picture to terminal.

0x59 Display rectangle with the foreground color.

0x69 Display rectangle with the background color.

0x5A Fill the rectangle area with the background color.

0x5B Fill the rectangle area with the foreground color.

0x5C Reverse the specific rectangular area (Restore the original display by reversing again).

0x64 Fill the specific enclosed area

0x9A Open/Close to be automatic commands cycle; the configure files of commands are saved in the 0x1C font.

Theoretically, any complexes GUI can be divided into icon to display because 24bit uncompressed pictures are supported by DWIN HIM.

3.1 Progress Bar Display

Take the progress bar above as an example. The procedure of achieving progress bar includes 5 steps (Cut pictures to achieve the crystal progress bar):

A. Use the 0x40 command to set the foreground color (Black frame) and background color (The white background);

B. Use the 0x59 command to draw a frame and use the 0x5A command to fill the background; C. Use the 0x40 command to set the foreground color (Black characters) and the background

color (The blue progress bar); D. Use the 0x5A command to fill according to the progress; E. Display the progress value using the text display does not have background (0x98,

C_Mode.6=0). stepdsp(100,100,0x0000,0xffff,0x0000,0x001f,100,75) // Display a progress bar. ( x,y) is the display position. w is the width of progress bar and height is //22. Font is 16 dots matrix and st is the progress.

void stepdsp(uint x,uint y,uint color1,uint color2,uint color3,uint color4,uchar w,uchar st) {setcolor(color1,color2); fillw(0x59,x,y,x+2+w, y+22); fillw(0x5a,x+1,y+1,x+3+w,y+21); // Display a solid rectangle

Page 13: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 11

setcolor(color3,color4); fillw(0x5a,x+2,y+2,x+2+w*st/100,y+20); // Fill the progress bar hex2dsp(x+w/2,y+3,st); // Display the progress characters with 0x98 command, C_Mode.6=0 print98(0x21,0x81,0x01,color3,color4,x+24+w/2,y+3,"%");}

3.2 Analog Dial Display The analog dial is actually a “nonlinear” special progress bar. Directly use the 0x64 command to fill as shown in the picture below:

setcolor(0xf800,0x0000); // Set the connection lines to red line(30,55,40,56); // Line fillfree(48,100,0xf800); // Fill the semi-circle area with red // (x, y) is the seed point. Fill the arbitrary boundary around the area with “color” void fillfree(uint x,uint y,uint color); { txword(0xaa64);

txxy(x,y); txword(color); txeof();}

If the area boundary being filled does not connected by the convex polygon, the user program is needed to fill every area one by one.

3.3 Overlap Picture

Sometimes, pictures are overlap icons with the 0x9D command (Such as the battery icon in the

left-down picture above): Firstly, design icons and save them in one picture. Note: The background color must be a solid

color (Such as the gray area in the picture). The result is shown as below:

Cut the corresponding area and paste it on the specific position with the 0x9D command based on the requirement, such as the above example:

Page 14: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 12

logod9d(50,70,0,140,40,0,440); // Assume the battery icons are saved in the 50th picture Note: Automatically restore the background of current picture with the 0x9D command. So restore the background with the 0x71 command, if paste the icon which is cut from the other picture, and then display the icon with the 0x9C command. Recommend to use the 0x97 command in order to design and call icons easily for K600+ kernel DWIN screen.

3.4 Backup and Restore Current Screen

As shown in the picture above, users will often meet the occasion of “temporary interrupt” in current screen. The description is shown as followings: Users often need a dialog box (The keyboard in the picture above for instance) in current non-picture background (Text and curve). The previous background will be recovered after completing operation. It will be complex to record and refresh the parameters status. Users can use the 0xE2 and 0x70 commands to solve this problem. Use the 0xE2 command to backup and save current screen at a valid picture position (Such as

the fiftieth picture) before pop-up windows; Pop-up Windows; After finishing the operating windows, use the 0x70 command to restore the previous saved picture. The intrinsic picture memory of DWIN UART LCM uses NAND flash, which can save up to 100 thousand times in one picture location.

Page 15: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 13

3.5 Pointer and Dashboard Display

Picture 0 picture 1 Overlap the picture 0 and picture 1 As in pictures above, the pointer has an intuitive, dynamic, strong sense of the characteristics. In many projects, the 0x9E command (H600 and K600+ only) could be used to achieve this effect easily. Separate the procedure of pointer design and dashboard as shown in picture 0 and picture 1, and put the pointer and 0’clock to make it easier to transfer by software. Save picture 0 and picture 1 to DWIN UART LCM terminal; In programs, calculate the rotation angle according the pointer’s position. Use 0x9E command to cut the pointer picture and paste it on the dashboard. Use the 0x71 command to restore the dashboard background in order to erase the last pointer position. posdsp(1.2); // Display the pointer position. The previous dashboard is in page 0 and pointer in //page 1

//value 0-1=0-80°, 1-1.5=80-135° 0--1=360-225° void posdsp(float value) {uint alpha; // The angle of rotating pointer if(value<0) alpha=360-value*135; // Calculate the rotating angles according to parameters else {if(value>1) alpha=80+(value-1)*110; else alpha=value*80;} alpha=alpha*2; // The Unit of rotating angle is 0.5° piccut(0x71,0,304,158,509,338,304,158) // Recover dial background to erase previous pointer display txword(0xaa9e); txbyte(0x00); // Filter out the background color txword(0x0001); // The pointer is in picture 1 txarea(761,483,790,586); //The area of pointer in picture 1 txxy(776,572); // The rotating center of pointer in picture 1 txword(alpha); // The rotating angle of pointer txxy(401,247); // The rotating center of pointer after being pasted on picture 0 txeof();}

Users can cut, rotate and paste any picture with the 0x9E command. So the 0x9E command can be used in many other applications:

The rotation of icons such as motors, gears and other circular motion; Design some cartoon icons. Modify the rotating angle and rotating center in order to achieve the rolling and bounce effect using 0x9E command to cut and paste icons. The “Compass display mode”: The display contents always points to operators, using the angle sensors to feedback, control and adjust (The gravity sensors or encoders).

Page 16: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 14

3.6 Flowchart Animation (Auto executing at fixed time)

In the processing of display automated flowchart, we hope to show the dynamic process to users. So it involves a lot of small areas animation (Update contents at fixed time) in order to show the effect of the users’ movement, such as the operation of the conveyor, the flowing liquid in the pipeline and so on. If these animations rely on the user program to timing refresh, it will cause three problems: (1) Clients have to write a mass of codes. But these codes have to be modified in order to bring a lot of workload. (2) CPU resources will be occupied when data is sent frequently. (3) High-speed and large-scale animation effects cannot be easily achieved because of the limited speed of serial communication. It would be easy to handle these problems using 0x1C configuration files and 0x9A command. The specific procedure is shown as follows: A. Edit the animation to display commands into configuration files (Each command group includes up to 64 commands, at most 8 groups). B. Download configuration file to 0x1C font library of DWIN terminal C. In the user’s program, open or close command groups are automatically executed according to the needs. Command groups will be automatically executed in accordance with the setting interval time after opening command groups. They are not interrupted by the customers’ programs. void cmdon(uchar cmd_id) { txword(0xaa9a);

txbyte(cmd_id); // Open cmd_id specific command group txeof();} void cmdoff()

{ txword(0xaa9a); txbyte(0xff); //Close command group auto execution txeof();}

Page 17: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 15

4 TOUCH SCREEN INTERFACE Command Description

0xE4 Touch screen calibration

0xE0 The configuration touch screen processing mode, parameters will not be saved when power is off

0xE3 The configuration touch screen processing mode, parameters will be saved when power is off

0x7C Use the touch screen to input ASCII characters or Chinese. (H600 and K600+ only)

0x72 Uploading data from UART LCM: the coordinate’s position of touching

0x73

0x78 Uploading data from UART LCM: the key code of touching function.

0x79

Configuration File

Description

0x01 Download GBK library must be at 0x01 position if using the touch screen Chinese input method,

0x1A The file of touching function command is used to special returned command of users

0x1E The touching switch configuration file is generated by PC software tools which are provided by DWIN

The design of human-computer interaction based on UART LCM is really closed to “zero code” by complete touching function and touch screen in both Chinese and English input function!

4.1 Touching Function Interface (User code without interference) Design

DWIN touching function interface software specifications

Page 18: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 16

The steps of touching function interface development: Step 1: Design the user interface which is the same as the UART LCM physical resolution and it the UART LCM (Terminal).

Step 2:Use the "DWIN touching function interface configuration software" to generate a configuration file.

Step 3:The configuration file is downloaded to the UART LCM (terminal). Configure UART LCM to the touching function mode with the 0xE0 command.

Step 4:Match interface switching writing additional codes, such as the refresh of cures and parameters, input parameters and so on. Debugging and finalize the design. The user’s software structure is the parallel functional module of "Message trigger" using touching function mode for the purpose of debugging and easy maintenance.

4.2 Input Parameters on Touch Screen

Users want to pop-up the left-up dialog when clicking on the right-down “Clock” icon, and use this keyboard dialog to modify the time of clock. In this case, the 0x7C01 touch screen ASCII input command could be used to achieve this function easily. uchar CMD7C[]={0xaa,0x7C,0x01,0x00,0x01,0,1,0,34,0,40,12,3,0,0,0xcc,0x33,0xc3,0x3c}; if((Rxcmd==0x78)&&(Rxdat0==0x00)&&(Rxdat1==0x01)) // Receive touching function key codes { piccut(0x71,1,0,0,206,344,0,0); // Pop-up little keyboard by cutting icon mode

txstr(CMD7C); // Send the touch screen ASCII input command. Input is be completed by UART LCM } if((Rxcmd==0x7c)&&(Rxdat0==0x00)&&(Rxdat1==0x01)) //Finish touch screen input and check R_ID { piccut(0x71,0,0,0,206,344,0,0); // Close the little keyboard wrrtc(); //Input parameters are saved into serial port buffer } Users need to select an input return ID as “message” to trigger programs accessing to manage by the 0x7C command. In the processing of the 0x7C command, touch screen will be completely processed by UART LCM and data will not be sent to users. The other functions of UART LCM are normal. In other words, other programs are normally processed by users’ CPU when inputting parameters. It easily achieves multi-task management. As above example, clocks and hands will run normally while inputting the parameters to touch screen. 0x7C, H600 and K600+ only Refer to appendix 2: Clock to see the entire ASM51 code.

Page 19: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 17

4.3 Input Chinese with Touch Screen (GBK font)

Users need to modify 24 different English/Chinese parameters with the touch screen using the 0x7C02 English/Chinese characters input command. Calling program of 0x7C02 command and 0x7C01 command are basically the same. This is ASM51 codes below:

MOV A,RXCMD ; Valid data frame is received with Serial port CJNE A,#78H,START2 ;Touching function key code MOV DPTR,#CMD7C1 ;Open English/Chinese input method LCALL TXROMS MOV R0,#RXDAT

MOV R7,#2 ;Use key code as the index of parameter return LCALL TXREG MOV DPTR,#CMD7C2 LCALL TXROMS LJMP STARTE

START2: CJNE A,#7CH,STARTE ;Finish and return the touch screen input MOV DPTR,#CMD70 LCALL

TXROMS ; Return screen 0 MOV A,RXDAT CJNE A,#02H,START20 MOV A,RXIDL ; Preinstalled R_ID to direct the parameter to be modified MOV B,#32 MUL AB MOV DPH,B MOV DPL,A MOV R0,#RXNUM MOV A,@R0 JZ STARTE ; Length of returned parameters data LCALL WRXRAM ; Save parameters

0x7C, H600 and k600+ only

Page 20: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 18

5 The System Configuration and Peripherals

Command Description

0x5E Turn off the background or set the backlight mode of touching function

0x5F Adjust backlight brightness

0x79 The specific length time of buzzer

0x9B Clock on/off RTC in current interface

0x9B5A Read RTC time in Gregorian calendar

0x9B5B Read RTC time in Traditional Chinese calendar

0xE7 Adjust RTC time

0xE0 Modify backlight, buzzer, visual angle and serial port mode. Parameters will be saved when power is off

0x90 Write intrinsic database

0x91 Read intrinsic database

0x7A Shitting between UART LCM and video function

0xD0 Refresh a full screen compulsively once (K600, H600 and K600+ only)

5.1 System Configuration Parameters Specification The sent and returned commands: Tx: AA E0 55 AA 5A A5 <TFT_ID> <Bode_Set> <Para1> <Para2> CC 33 C3 3C Rx: AA E0 <TFT_ID> <Bode_Set> <Para1> <Para2> CC 33 C3 3C The 0xE0 command parameters will not be saved when power is off. Please use the tool software which is provided by DWIN, if users need to save permanently when power is off. <TFT_ID>: Configure TFT panel parameters; (V5.3 or later versions are not open to users, please write 0x00): <Bode_Set>: <Bode_Set>: Set the baud rate of serial communication:

Bode_set 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07

Baud rate 1200 2400 4800 9600 19200 38400 57600 115200

The following baud rate is not supported by the PC port, please set carefully

Bode_set 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F

Baud rate 28800 76800 62500 125000 250000 230400 345600 691200

The following baud rate is only supported by K600+ kernel serial port setting

Bode_set 0x10

Baud rate 921600

<Para1>: Configure the touch screen and the keyboard work mode as follows:

Para1 Bit Description

.7

0= After clicking on the touch screen, the 0x73 command is automatically uploaded when releasing the touch screen. It must be set to 0 in the touch mode. 1= After clicking on the touch screen, it does not upload 0x72 command when leaving the touch screen.

.6

In the coordinates returning mode: 0=After clicking on the touch screen, the 0x73 command is automatically uploaded with the interval of time of 100 ms until releasing the touch screen. 1=After clicking on the touch screen, the 0x73 command is automatically uploaded only once. On the touch mode, Para1.0=1:

Page 21: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 19

0= After clicking on the touch screen, the 0x79 command is automatically uploaded with the interval time of 100 ms until releasing the touch screen. 1= After clicking on the touch screen, the 0x79 command is automatically uploaded only once.

.5

0= After clicking on the touch screen, the UART LCM touch interface will not be switched automatically. 1= After clicking on the touch screen, the UART LCM touch interface will be switched automatically according to 0x1E configuration files.

.4

0= Backlight will not be controlled by touch screen or keyboard. 1= Backlight will be controlled by touch screen or keyboard. At the same time, the user can also through the 0x5E/0x5F command forced switch to control backlight.

.3 0= Buzzer switched on for touch screen or keyboard; 1= Buzzer switched off for touch screen or keyboard

.2 0= 0°display; 1= 90°display.

.1

0= In the touching function mode, buzzer is always switched on; 1= in the touching function mode, buzzer is only screamed once when clicking

on the effective position; if Para1.1=1, set Para1.3=1 at the same time.

.0 In the touching function mode: 0= Not-Upload 0x79 command; 1= Upload 0x79 command.

<Para2>: Configuration mode, set up as follows: (The previous internal software V6.0 is not opened for users. It is unnecessary to write this byte. H600 and K600+ only)

Para2 Bit Description

.7

0=The previous V5.0 version refresh way (Automatically high-speed update, together with 0x71+0x98 will cause jittering); 1=automatically refresh to display with 200ms. The command is executed automatically after the extension of the refresh time to ensure that specification can be simultaneously displayed.

.6

Return back the touch screen coordinates mode: 0= The touch screen coordinates don’t changed the following Para1.2 when setting them back. 1=The touch screen coordinates are changed following Para1.2 when setting

them back (Deflection 90°).

.5 0=Display deflection 180° (Reverse angle display); 1=Normal angle display.

.4

0=Text display (0x53、0x54、0x55、0x6E、0x6F、0x98), the picture background does not restored automatically and the text background color is ignored; 1=When text is displayed, the picture background does not automatically restored.

.3 Reservation and set to 1.

.2 0=Stop automatically refresh. Display must be refreshed with the 0xDo command; 1=Enable automatically refresh. The refresh interval is decided by Para2.7

.1 Reservation and set to 1.

.0 Reservation and set to 1.

Page 22: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 20

5.2 RTC Most of DWIN UART LCM has the intrinsic 2000-2099 RTC. RTC can be read and modified with commands. Or RTC is automatically overplayed on the specific background pictures according to the user’s need. UART LCM has intrinsic backup battery. RTC will run regularly when power is off.

void rtcon(unit x,unit y,unit color,uchar mode,uchar scale) //Activate RTC overlying display on (x,y) { txword(0xaa9b); txbyte(0xff); txbyte(mode); txbyte(scale); txword(color); txxy(x,y); txeof();} void rtcoff() //Turn off the RTC overlying display { txword(0xaa9b); txbyte(0x00); txeof();} void rtcset(uchar *s) //Set RTC, S=YYMMDDHHMMSS, BCD code, such as 0x11 0x07 0x25 0x12

//0x00 0x00 { txword(0xaae7); txword(0x55aa); txword(0x5aa5); txstr(s); txeof();} void rdrtc_en() //Read the Gregorian calendar and return BCD code. The format is YY MM DD

//WW HH MM SS. WW is represented week. { txword(0xaa9b); txbyte(0x5a); txeof();} void rdrtc_cn() //Read the traditional Chinese calendar. The format is YY MM DD { txword(0xaa9b); txbyte(0x5b); txeof();}

Page 23: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 21

5.3 Backlight Brightness Adjustment and Screensaver Brightness Setting The 64-step backlight brightness adjustment is valid for all of LED-backlighting DWIN UART LCM. Backlight switching on/off is supported by the minority of CCFL backlight UART LCM in order to avoid reducing the lifetime and effect of light when adjusting the brightness.

light(50); //Adjust backlight brightness to 50% void light(uchar i) //Correspond to 0-64 steps of brightness adjustment, when i=0-100% {txword(0xaa5f); txbyte(uchar((i*64)/100));}

In some applications, the user needs to control the brightness of screensaver: Set brightness at L1 when operating regularly. Set brightness at L2 when operating infrequently. The user does not click on the touch screen or

keyboard for a long time. When screensaver brightness is L2, if clicking on the touch screen or keyboard, the first

operation is ignored but the backlight brightness will be adjusted to L1. It only needs modulation once for touch screen UART LCM using 0x5E and 0xE0 commands. lightset(100,20,10); //Set the normal brightness at the maximal brightness, screensaver

//brightness at 20% and touch screen trigger time at 10 seconds; //Set the touch screen backlight control: brightness is L1, screensaver

//brightness is L2 and touch screen trigger time is t (0-127) second; void lightset(uchar l1,uchar l2,uchar t) {rdconfig(); //Read configuration parameter back; PARA1=PARA1|0x10; //Set the backlight brightness can be controlled by touch screen; wrconfig(); //Configuration parameters is modified with the 0xe0 command; txword(0xaa5e); txxy(0xaa55,0x5aa5); txbyte(uchar((l1*64)/100)); txbyte(uchar((l2*64)/100)); if(t>127) t=127; txbyte(t*2); txeof();}

5.4 Visual Angle Adjustment Any visual angle is adjusted with 0xE0 (Or 0xE3) command in DWIN UART LCM. The result is shown as follows:

”DWIN Technology” in the pictures above are written on (0,0) with the text display command. Users must implement particular settings when downloading pictures. The picture is shown as follows:

Page 24: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 22

Select Toolbar 0° =0°and 180°; 90° =90°and 270°.

5.5 Read/Write Intrinsic Database

DWIN UART LCM has an NAND Flash database which is at most 30.063MB (30MB ranked storage and 64KB random storage). The user can read and write data using 0x90 and 0x91 commands in order to record and storage data on second development time. void wrdbaser(uint adr,uchar *s) //Write the random data memory { txword(0xaa90); txword(0x55aa); txword(0x5aa5); txword(0x01de); txword(adr); txstr(s); txeof();} void wrdbases(long adr,uchar *s) //Write the random data memory { txword(0xaa90); txword(0x55aa); txword(0x5aa5); if(adr>0x01ddfffff) adr=0; //Check it whether the address is overflowed txlong(adr); txstr(s); txeof();} void rddbaser(uint adr,uint len,uchar *s) //Read the random data memory {uint i; txword(0xaa91); txword(0x01de); txword(adr); txword(len); txeof(); //Receive data. Serial port must be big enough if read-back data is excessive. Otherwise take the inquiry

//receiving mode as follows EA=0; //Close interrupt while(!(RXDATA==0xaa)) rxbyte(200); //Receive a byte in serial port. Exit if serial port does not received or

//exceed time in 200ms for(i=0;i<6;i++) {rxbyte(200);} for(i=0;i<len;i++) {rxbyte(); *s=RXDATA; s++;} EA=1;}

Page 25: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 23

void rddbases(long adr,uint len,uchar *s) //Read sequential data memory {uint i; txword(0xaa91); txlong(adr); txword(len); txeof(); // Receive data. Serial port must be big enough if read-back data is excessive. Otherwise take the query

//receiving mode as follows EA=0; //Close interrupt while(!(RXDATA==0xaa)) rxbyte(200); //Exit if the serial port does not received or exceed time in 200ms for(i=0;i<6;i++) {rxbyte(200);} for(i=0;i<len;i++) {rxbyte(); *s=RXDATA; s++;} EA=1;}

Page 26: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 24

5.6 Video play Analog video (CVBS signal such DVD video output and camera video output) or digital multimedia video in SD card (DVD, MP3 or MP4) is supported by certain DWIN UART LCM products. All of these videos will be played in full screen mode. So the user needs to switch between UART LCM mode and video mode. videoplay(PAL,0x00) //Play video in CHO channel and PAL format sdplay(PLAY); //Play video and music in current folder sdplay(NULL); //Play analog video #define PAL 0x00 //PAL video #define NTSC 0x01 //NTSC video //Play digital video #define NULL 0x00 //Null operation. Send this program once when leaving buttons #define PLAY 0x01 //Play and stop #define SPKON 0x02 //Turn on loudspeaker #define SPKOFF 0x03 //Turn off loudspeaker #define ENTER 0x04 //Confirm #define DOWN 0x05 //The next one or fast forward #define UP 0x06 //The previous one or fast back #define CANCEL 0x07 //Cancel #define SPKADD 0x08 //Turn up volume #define SPKSUB 0x09 //Turn down volume #define LANG 0x0a //Switch between Chinese and English menu void UART LCMmode() //Back to UART LCM mode { txword(0xaa7a); txbyte(0x00); txword(0x0000); txeof();} void videoplay(uchar mode,uchar ch) //Switch to analog video mode { txword(0xaa7a); txbyte(0x01); txbyte(mode); txbyte(ch); txeof();} void sdplay(uchar sdkey) //SD digital video playing management { txword(0xaa7a); txbyte(0x01); txbyte(sdkey); txeof();}

The functions of UART LCM are run normally in video mode without displayed in the touch screen.

5.7 Buzzer Most of DWIN UART LCM has a buzzer for the touch screen. The user can also send commands to control a buzzer: buzzon(100); //Buzzer beeps 1 second void buzzon(uchar ontime) //Set buzzer time. The unit is 10ms { txword(0xaa79); txbyte(ontime); txeof();

Page 27: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 25

6 RECOMMENDATION OF USER’S PROGRAM DESIGN

The user’s program is basically simplified into two functions for the users who use DWIN UART LCM as human-machine interface, especially DWIN UART LCM touch screen users:

The user is very familiar with the realization of products algorithm function, such as data collection, peripheral control and so on.

Normally the user is not very familiar with the realization of human-machine interface function with DWIN UART LCM.

DWIN UART LCM is communicated through the serial port with user programs which are the relatively independent system and manage the “random” cases (communicate with the user). But the algorithm function deals with “fixed” cases. So programs should be structured in the method as following in order to improve the efficiency of the R&D and program stability:

Adopt the program structures of the foreground/background. The applications programs are put in the foreground to be managed with the query and scan mode. The programs which directly communicate with hardware are put in the background and managed by interrupt mode, such as serial port, A/D conversion The foreground and background programs are exchanged data by memory (The global variable). The foreground programs are triggered by background message. Use a timer to generate intrinsic order to coordinate the different application programs. All of the programs are designed into the independent parallel subroutines in the foreground according to functions in order to be tested and transmitted (Several engineers can work independently at the same time and integrate after testing).

The procedure of development with DWIN UART LCM touch screen:

The hardware designer designs hardware; The professional designer conducts the interface design (It is extremely important to design the interface in all procedures. The professional GUI designer only need to be paid at 50-200 RMB per page ) The touch screen configuration interface is designed by DWIN touch screen configuration software. Test and revise for customers. The procedure can be divided into some independent procedures to develop if software designs a lot of functions. Integration, debugging, test, check and finalize the design.

Please refer to codes in the case of appendix to see the detail software structures.

Application 1 Application N Application 2 Message Processing

……

Trigger message and Buffer variable

Uart ISP Timer ISP Other ISP

System Clock

Hardware Interface

Page 28: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 26

7 SOFTWARE RELATED PARAMETERS’ INSTRUCTIONS

7.1 Font Specification

Lib_ID Font size

Content Description Remarks

0x00 128KB DWINASC.HZK ASCII Font in various dot matrix Factory preassemble

0x01 128KB DWIN_PY_GBK_01.BIN GBK Pinyin input Font Reservation

0x02-0x19 128KB Undefined Users save their own Font

0x1A 128KB User defined Index Font for 0x1E touching function commands

Reservation

0x1B 128KB User defined Keyboard control configuration files

Reservation

0x1C 128KB User defined Auto loop commands library Reservation

0x1D 128KB User defined Icon display configuration files Reservation

0x1E 128KB User defined Touching function configuration files

Reservation

0x1F 128KB Undefined Users save their own Font

0x20 1MB GBK12_Song.HZK 12×12, Song typeface in GBK Font Factory preassemble

0x21 1MB GBK16_ Song.HZK 16×16, Song typeface in GBK Font Factory preassemble

0x22 1MB GB2312_24_ Song.HZK 24×24, Song typeface in GB2312 Font

Factory preassemble

0x23 1MB GB2312_32_ Song.HZK 32×32, Song typeface in GB2312 Font

Factory preassemble

0x24-0x3B 1MB Undefined Users save their own Font

7.2 Picture Storage Quantity

Resolution M100、M600、K600 Kernel H600、K600+ kernel

Standard (128MB)

Extension (1GB) Standard (128/256MB)

Extension (2/3GB)

320×240 374 3888 708 7456

480×272 374 3888 708 7456

640×480 149 1555 236 2485

800×480 124 1296 236 2485

800×600 93 972 177 1864

1024×600 74 777 141 1491

1024×768 62 648 118 1242

1280×800 *** *** 88 932

1365×768 *** *** 88 932

The number of storage pictures will not be reduced if the user uses the 64KB random database; The number of storage pictures will be reduced 1/3 according to the standard (128MB) if the user uses the 30KB sequential database.

Page 29: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 27

7.3 Executive Time Of Typical Commands

Resolution

Refresh Frequency (Hz)

0x70 (Full screen display,

ms)

0x54 (16*16 Chinese

display, ms)

0xD0 (Refresh full screen, ms)

M100 M600

K600 H600 M100 M600

K600 H600 M100 M600

K600 H600 K600 H600

320×240 70 70 70 60 12 9 0.40 0.11 0.09 3.5 3.5

480×272 60 70 70 85 20 15 0.30 0.11 0.09 6.0 6.0

640×480 55 67 67 225 48 38 0.38 0.11 0.09 14.0 14.0

800×480 *** 68 68 *** 125 55 *** 0.11 0.09 20.0 20.0

800×600 *** 68 68 *** 130 56 *** 0.11 0.09 21.0 21.0

1024×600 *** 75 75 *** 205 67 *** 0.11 0.09 29.0 29.0

1024×768 *** 68 68 *** 260 85 *** 0.11 0.11 27.0 27.0

1280×800 *** *** 67 *** *** 145 *** *** 0.12 *** 48.0

1365×768 *** *** 81 *** *** 125 *** *** 0.11 *** 37.0

The auto-execution 0xD0 command time is included by the 0x70 command executive time. The 0x54 command executive time is the time of display a 16×16 Chinese character. Other size Chinese characters are converted according to the scale of dot matrix ration.

In H600 kernel,the 800×600 resolution typical command time(Other kernels and resolution 0x54

command by conversion ratio in the list below):

Command 0x51 0x42 Line segment

(such as 0x56) Area (Such as 0x5A) 0xE2

H600_800*600 time

1.4us/point 1.1us (0.8-1.5)us/point (1.6*Line number+

0.4us*points) us 80ms

Page 30: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 28

APPENDIX 1: DWIN UART LCM COMMANDS TABLE

CATEGORY COMMAND DESCRIPTION

Handshake 0x00 Check the configuration and version information

Display Parameter Configuration

0x40 Set palette

0x41 Set characters spacing

0x42 select color to the background color palette

0x43 select color to the Foreground color palette

0x44 Set cursor display mode

Text Display

0x53 8×8 dot matrix ASCII characters

0x54 16×16 dot matrix GBK extended string to display

0x55 32×32 dot matrix GB2312 internal code string display

0x6E 12×12 dot matrix GBK extended code string display

0x6F 24×24 dot matrix GB2312 internal code string display

0x98 Any dot matrix, any code string display

0x45 Open/Close the text frame limitation

Put Pixel

0x50 Put multiple pixels with background color (Delete pixels)

0x51 Put multiple pixels with foreground color

0x74 Dynamic curve fast puts pixels

0x72 Direct memory operation

Line &Polygon

0x56 Connect specific pixels with the Foreground color line(Display polygon)

0x5D Connect specific pixels with the background color line (Delete polygon)

0x75 Fast Draw continuous vertical line (Spectrum)

0x76 Fast Draw line chart

0x78 Connect offset

Arc &Circle Area

0x57 Reverse/Display multiple arc or circle area

Rectangle 0x59

Draw multiple rectangular with foreground color (Display rectangle)

0x69 Draw multiple rectangular with background color (Delete rectangle)

Areas Operation

0x73 Fill special area with double color bitmap

0x64 Fill special area

0x52 Clear screen

0x5A Clear many special areas

0x5B Fill many specific areas

0x5C Reverse many specific areas color

0x60 Many specific areas loop and shift left

0x61 Many specific areas loop and shift right

0x62 Many specific areas shift left

0x63 Many specific areas shift right

Draw 0x70 Draw a full screen picture

Page 31: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 29

Picture/Icon 0x7B Draw a full screen picture and calculate CRC checksum

0x71 Cut icon from the specific picture and paste to the current page

0x9C Cut icon from the specific picture to filter out background and paste to the current page. Automatically restore the original background before paste

0x9D Cut icon from the specific picture to filter out the background and paste to the current page.

0x9E Cut icon from the specific picture and paste to the current page after rotate specific angles. You can select to filter out background. 0x9E, H600 only

0xE2 Save the current picture to the terminal

0x97 Draw ICON (The maximum size is 255*255). K600+ only

0x99 Users define icon display

0xD0 Refresh a full screen compulsively once. K600, K600+ and H600 only

Animation Support

0x9A Open/Close automatic execution command set that users presets

Temporary buffer operation (1280*800 and 1365*768 don’t supported by DWIN)

0xC0 Write data to temporary buffer

0xC101 Display data points of temporary buffer

0xC102 Display data lines of temporary buffer

0xC103 Display line chart with date point in temporary buffer (Zoom dynamic curve)

0xC104 High-speed no flashing with date point in temporary buffer (Oscilloscopes)

0xC105 Zoom and display line chart with data in temporary buffer

0xC106 Zoom and display window to limit the two-way line chart with data in temporary buffer

0xC107 Empty the pixel buffer

0xC107 Put pixel in the pixel buffer

0xC107 Restore the pixel buffer to the current page

0xC108 Display parameters with temporary buffer

0xC110 Simultaneous display by the command of temporary buffer

0xC2 Read data back from temporary buffer

Database Operation

0xF2 Download font (Download ICON picture library must use SD card)

0x90 Write date to users database

0x91 Read date from users database

Keyboard Operation

0x71 Upload key code

0xE5 Configure the key code interface

Touch Screen Operation

0x72 After releasing touch screen, upload data the last time (Set to turn off with the 0xE0 command)

0x73 After press touch screen, upload data (Set to upload only once with the 0xE0 command)

0xE4 Touch screen calibration

0x78 In the touching function interface auto-switch mode, when touch screen is released, the default key code is automatically uploaded

0x79 In the touch interface auto-switch mode, when touch screen is pressed, the default key code is automatically uploaded

Page 32: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 30

0x7C01 Touch screen input ASCII strings. K600+, H600 only

0x7C02 Touch screen input mixed string in both Chinese and English. K600+ and H600 only

Buzzer Control 0x79 Buzzer screams one time

Video Switching

0x7A Switch video and UART LCM

Backlight Operation

0x5E Close backlighting or set the touching function(Key control)backlight model

0x5F Open backlighting or PWM model to adjust the backlight brightness

Clock Operation

0x9B Open/Close clock automatically overlay and display; read the current clock

0xE7 Set clock

Parameter Configuration

0xE0 Configure the speed of user serial port, touch screen data upload format, backlight control mode and display mode;H600/K600+ kernel does not save when power-down

0xE3 Similarly 0xE0 command functions, but the power to save; H600 and K600+ only

Practical Algorithm

0xB001 Pinyin input method based in the first level of font

0xB002 Calculate(A×B+C)/D,E is 4 bytes quotient,F is two bytes remainder

0xB003 Unsigned integer(2 bytes) array sort

0xB004 GBK font-based Pinyin input query

Sound Operation

0x30 Play music that specific storage location

0x32 Real-time volume adjustment

0x33 Immediately stop playing

0x3F Sound operation response

Software Upgrade

DWIN_M600_BOOT! Kernels software are upgraded online by serial port

The sequence of kernel development keeps downward compatible with command set. The

development order is : M100、M600、K600、H600、K600+ kernel. M100 kernel and M600 kernel command set are completely same; Kernels above K600 have different drivers. So we increase the 0xD0 command on the basis of

M100、M600;K600, M100 and M600 kernels command set are completely same;

Under the premise of H600 compatible with K600, we add the 0x7C、0x9E and 0xE3 commands. The part of serial port screens support SD card to download;

Under the premise of K600+ compatible with H600, we add the 0x97 command. Download is completely supported with SD card in corresponding serial port screens;

Page 33: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 31

APPENDIX 2: ASM51 APPLICATION EXAMPLE: CLOCK

Design hands of clock with DMG80600S104_02WT. Rotate the hands with 0x9E command and modify time with 0x7C command on touch screen. $include (MOD52) SYSFLG EQU 20H TI0FLG BIT SYSFLG.7 ;Send a TI sign back to main program’s serial port RXAAOK BIT SYSFLG.6 ;0xAA frame header is connected to serial port RXFRMOK BIT SYSFLG.5 ; Data frames are received by serial port RTCOK BIT SYSFLG.4 ; 250ms timer sign RTC250 EQU 30H ;The times are counted by timer in 100mS RTCOLD EQU 31H RXCC EQU 43H ; Judge the array with the terminator frames which are received by serial port RX33 EQU 44H RXC3 EQU 45H RX3C EQU 46H RXPOS EQU 47H ; 48H-9FH RXCMD EQU 48H ;The buffer is received with the serial port 48H-67H, at most

32Byte RXDAT EQU 49H RTCYEAR EQU 4AH RTCMON EQU 4BH RTCDAY EQU 4CH RTCWEK EQU 4DH RTCHR EQU 4EH RTCMIN EQU 4FH RTCSEC EQU 50H ORG 0000H LJMP MAIN ORG 000BH LJMP SYSCLK ;The 10ms timer ORG 0023H LJMP UARTPRO ; Serial port interrupt (IRQ) ORG 0080H MAIN: CLR EA MOV SP,#68H ORL PCON,#80H ;The initialize serial port

Page 34: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 32

MOV SCON,#50H MOV TMOD,#21H MOV TH1,#255 ;115200 bps 115200/(256-TH1) MOV TL1,#255 SETB TR1 MOV TH0,#0B8H ;10ms MOV TL0,#00H SETB TR0 MOV RTC250,#200 MOV SYSFLG,#00H SETB ET0 SETB ES SETB EA JNB RTCOK,$ CLR RTCOK ; Delay 2s when power is on MOV A,#00H LCALL PICDSP MOV DPTR,#RTCON LCALL TXROMS MOV RTCOLD,#00H

; Different modules are triggered by checking messages in the foreground programs part START: JNB RTCOK,START1 MOV DPTR,#RDRTC LCALL TXROMS CLR RTCOK START1: JNB RXFRMOK,START MOV A,RXCMD ;Valid data frames are received by the serial port CJNE A,#9BH,START2 MOV A,RXDAT CJNE A,#5AH,STARTE LCALL RTCDSP ; Display the pointer’s position LJMP STARTE START2: CJNE A,#78H,START3 MOV DPTR,#CMD7C ;Modify the time LCALL TXROMS LJMP STARTE START3: CJNE A,#7CH,STARTE ;The input is over and return MOV A,#00H LCALL PICDSP MOV A,RTCDAY CJNE A,#12,STARTE LCALL WRRTC STARTE: CLR RXFRMOK LJMP START PICDSP: PUSH ACC MOV A,#0AAH LCALL TXBYTE MOV A,#70H LCALL TXBYTE POP ACC LCALL TXBYTE MOV DPTR,#CMDTTL LCALL TXROMS RET ;Send to UART LCM after modifying clock WRRTC: MOV DPTR,#CMDE7

Page 35: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 33

LCALL TXROMS MOV R0,#RTCWEK MOV R1,#6 WRRTC1: MOV A,@R0 CLR C SUBB A,#30H SWAP A MOV R7,A INC R0 MOV A,@R0 INC R0 CLR C SUBB A,#30H ADD A,R7 LCALL TXBYTE DJNZ R1,WRRTC1 MOV DPTR,#CMDTTL LCALL TXROMS RET RTCDSP: MOV R0,#RTCHR MOV R1,#3 ; Convert to HEX RTCDSP1:MOV A,@R0 LCALL BCDHEX MOV @R0,A INC R0 DJNZ R1,RTCDSP1 MOV R0,#RTCSEC MOV A,@R0 CJNE A,RTCOLD,RTCDSP2 RET RTCDSP2:MOV RTCOLD,A MOV DPTR,#CMD71 LCALL TXROMS ; Calculate the angel of HOUR MOV R0,#RTCHR MOV A,@R0 MOV B,#60 MUL AB MOV R7,B MOV R6,A MOV R0,#RTCMIN MOV A,@R0 ADD A,R6 MOV R6,A CLR A ADDC A,R7 MOV R7,A MOV DPTR,#HRPOS LCALL TXROMS MOV A,R7 LCALL TXBYTE MOV A,R6 LCALL TXBYTE MOV DPTR,#RTCCEN LCALL TXROMS ; Calculate the angle of MIN MOV R0,#RTCMIN

Page 36: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 34

MOV A,@R0 MOV B,#12 MUL AB MOV R7,B MOV R6,A MOV R0,#RTCSEC MOV A,@R0 MOV B,#5 DIV AB ADD A,R6 MOV R6,A CLR A ADDC A,R7 MOV R7,A MOV DPTR,#MINPOS LCALL TXROMS MOV A,R7 LCALL TXBYTE MOV A,R6 LCALL TXBYTE MOV DPTR,#RTCCEN LCALL TXROMS ; Calculate the angle of SEC MOV R0,#RTCSEC MOV A,@R0 MOV B,#12 MUL AB MOV R7,B MOV R6,A MOV DPTR,#SECPOS LCALL TXROMS MOV A,R7 LCALL TXBYTE MOV A,R6 LCALL TXBYTE MOV DPTR,#RTCCEN LCALL TXROMS MOV DPTR,#CMDD0 LCALL TXROMS RET ; Send 1 byte to the serial port TXBYTE: MOV SBUF,A JNB TI0FLG,$ CLR TI0FLG RET ; Convert BCD to HEX BCDHEX: MOV B,#16 DIV AB PUSH B MOV B,#10 MUL AB POP B ADD A,B RET

Page 37: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 35

; Send a fixed data string to the serial port. 0xFE is the end of the data string TXROMS: CLR A MOVC A,@A+DPTR CJNE A,#0FEH,TXROMS1 RET TXROMS1:MOV SBUF,A INC DPTR JNB TI0FLG,$ CLR TI0FLG SJMP TXROMS RET

; The service programs of the interrupt in background ;***************The service programs of serial port interrupt ************* UARTPRO:PUSH ACC PUSH PSW SETB RS0 SETB RS1 JB RI,UARTRCV CLR TI SETB TI0FLG LJMP UARTEND UARTRCV:MOV A,SBUF CLR RI JB RXFRMOK,UARTEND ;Data is not processed in the serial port JB RXAAOK,URCVD CJNE A,#0AAH,UARTEND SETB RXAAOK MOV RXPOS,#RXCMD LJMP UARTEND URCVD: MOV R0,RXPOS MOV @R0,A INC RXPOS MOV RXCC,RX33 MOV RX33,RXC3 MOV RXC3,RX3C MOV RX3C,A CJNE A,#3CH,UARTEND MOV A,RXC3 CJNE A,#0C3H,UARTEND MOV A,RX33 CJNE A,#33H,UARTEND MOV A,RXCC CJNE A,#0CCH,UARTEND SETB RXFRMOK CLR RXAAOK UARTEND:POP PSW POP ACC RETI

;*************** The service programs of the 10ms timer interrupt*********** SYSCLK: PUSH PSW CLR TF0 MOV TH0,#0B8H MOV TL0,#00H DJNZ RTC250,SYSCLKE MOV RTC250,#10 ;100ms timer SETB RTCOK SYSCLKE:POP PSW

Page 38: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 36

RETI CMDD0: DB 0AAH,0D0H,0CCH,33H,0C3H,3CH,0FEH ; Refresh screen at once CMD7C: DB 0AAH,71H,01H ; Switch keyboard on the first page to the current page DW 0,0,206,344,0,0 DB 0CCH,33H,0C3H,3CH DB 0AAH,07CH,01H,00H,01H ; Input 12 ASCII characters to modify the clock with English DW 1,34,40,0C03H,0000H DB 0CCH,33H,0C3H,3CH,0FEH CMDE7: DB 0AAH,0E7H,55H,0AAH,05AH,0A5H,0FEH ;Modify UART LCM clock RTCON: DB 0AAH,9BH,0FFH,01H,05H,0FFH,0FFH ;Display UART LCM intrinsic clock DW 200,567,0CC33H,0C33CH,0FEFEH RDRTC: DB 0AAH,9BH,5AH,0CCH,33H,0C3H,3CH,0FEH ;Read current time from UART LCM CMD71: DB 0AAH,71H,00H DW 207,96,593,520,207,96,0CC33H,0C33CH,0FEFEH ;Recover the background of the dashboard HRPOS: DB 0AAH,9EH,00H,00H,01H ;The positions of hour, minute and second hand icons DW 449,281,494,432,471,382,0FEFEH MINPOS: DB 0AAH,9EH,00H,00H,01H DW 383,248,427,434,406,382,0FEFEH SECPOS: DB 0AAH,9EH,00H,00H,01H DW 335,232,374,434,356,382,0FEFEH RTCCEN: DW 386,301,0CC33H,0C33CH,0FEFEH ;The center of the rotation dashboard CMDTTL: DB 0CCH,33H,0C3H,3CH,0FEH ; Frame terminators END

Page 39: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 37

APPENDIX 3: ASM 51 APPLICATION EXAMPLE: SIMPLE OSCILLOSCOPE

Collect electrets Mic output voice signal and display them based on DMG80480C070-01WT with the C8051F410 which is intrinsic 12bit A/D. Zoom in and zoom out X axis (Time) and Y axis (Amplitude) by the 0xc106 command.

The display interface of design

The actual operating result:(X=6.67mS/DIV Y=50mV/DIV)

Page 40: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 38

ASM51 code as follows: $include (C8051F410.inc) WDT BIT P0.7 ; It is the watchdog feeding signal AD_IN BIT P1.4 ; A/D SYSFLG EQU 20H TI0FLG BIT SYSFLG.7 ; Send a TI sign back to main program’s serial port

RXAAOK BIT SYSFLG.6 ;Serial port is connected to 0xAA frame header RXFRMOK BIT SYSFLG.5 ; Data framed are received by serial port RTCOK BIT SYSFLG.4 ; Timer sign NUMOK BIT SYSFLG.3 ; Data in UART LCM buffer is transferred OK

RTC250 EQU 31H ;The times are counted with timers ADS_H EQU 32H ; A/D data is saved in pointer (The address is 0000-03FFF)

ADS_L EQU 33H ADT_H EQU 34H ; A/D data is sent from pointer (0000-03FFF) ADT_L EQU 35H ADN_H EQU 36H ; Collected pixels which are not sent ADN_L EQU 37H KY EQU 38H ; The Y axis magnification KX EQU 39H ; The X axis magnification C0_DPH EQU 3AH C0_DPL EQU 3BH ; The UART LCM buffer pointer position RXCC EQU 70H ; Terminator frames are received to judge array by serial port

RX33 EQU 71H RXC3 EQU 72H RX3C EQU 73H RXPOS EQU 74H ; 78H-9FH RXCMD EQU 78H ; The buffer is received by serial port 78H-9FH, at most 40Byte

RXDAT0 EQU 79H RXDAT1 EQU 7AH ORG 0000H LJMP MAIN ORG 0023H LJMP UARTPRO ; The serial port interrupt (IRQ) ORG 002BH LJMP SYSCLK ; 0.4ms timer is used for A/D sampling ORG 0100H MAIN: CLR EA MOV SP,#0B0H LCALL INITCPU ; Set the serial port is 115200bps and 8n1 mode

MOV SYSFLG,#00H SETB ES0 ; Open the serial port interrupt (IRQ)

SETB ET2 ;Open timer 2 interrupt(10ms system timer) MOV ADS_H,#00H MOV ADS_L,#00H SETB EA LCALL ACKLCD ; Check the UART LCM power is on or off. MOV A,#00H LCALL PICDSP CLR EA MOV ADS_H,#00H MOV ADS_L,#00H MOV ADT_H,#00H MOV ADT_L,#00H

Page 41: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 39

MOV ADN_H,#00H MOV ADN_L,#00H MOV C0_DPH,#00H MOV C0_DPL,#00H MOV KX,#3 MOV KY,#1 SETB EA

LCALL XYDSP ; Show X、Y magnification START: CPL WDT JNB RXFRMOK,START1 MOV A,RXCMD ; The valid data frames are received by serial port

CJNE A,#78H,START0E ; The touching function command MOV A,RXDAT1 CJNE A,#00H,START01 ; The X magnification MOV A,KX CLR C SUBB A,#9 JNC START0E INC KX LJMP START0E START01:CJNE A,#01H,START02 ; X Narrow MOV A,KX JZ START0E DEC KX LJMP START0E START02:CJNE A,#02H,START03 ; Y magnification MOV A,KY CLR C SUBB A,#9 JNC START0E INC KY LJMP START0E START03:CJNE A,#03H,START0E ; Y Narrow MOV A,KY JZ START0E DEC KY START0E:CLR RXFRMOK LCALL XYDSP START1: MOV DPTR,#60 ; Improve the efficiency of the serial if buffer data is over 120

bytes CLR C MOV A,ADN_L SUBB A,DPL MOV A,ADN_H SUBB A,DPH JC START CLR EA MOV A,ADN_L CLR C SUBB A,DPL MOV ADN_L,A MOV A,ADN_H SUBB A,DPH MOV ADN_H,A SETB EA MOV A,KX ;Calculated data to display the points of R7:R6 according to

the X axis amplifier

Page 42: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 40

CLR C RLC A PUSH ACC MOV DPTR,#NUM_TAB MOVC A,@A+DPTR MOV R7,A POP ACC INC A MOVC A,@A+DPTR MOV R6,A MOV A,#0AAH LCALL TXBYTE MOV A,#0C0H LCALL TXBYTE MOV A,C0_DPH LCALL TXBYTE MOV A,C0_DPL LCALL TXBYTE MOV DPH,ADT_H MOV DPL,ADT_L MOV R1,#60 START11:MOVX A,@DPTR INC DPTR LCALL TXBYTE MOVX A,@DPTR INC DPTR LCALL TXBYTE ANL DPH,#03H MOV ADT_H,DPH MOV ADT_L,DPL MOV A,C0_DPL ADD A,#01H MOV C0_DPL,A CLR A ADDC A,C0_DPH MOV C0_DPH,A ;C0_DPTR++ CLR C MOV A,R6 SUBB A,C0_DPL MOV A,R7 SUBB A,C0_DPH JNC START12 SETB NUMOK MOV C0_DPH,#00H MOV C0_DPL,#00H LJMP START13 START12:DJNZ R1,START11 CLR NUMOK START13:MOV DPTR,#CMDTTL LCALL TXROMS JNB NUMOK,START2 MOV DPTR,#CMDC106A ;Show the curve LCALL TXROMS MOV A,R7 LCALL TXBYTE ;Show the number of curve MOV A,R6 LCALL TXBYTE MOV DPTR,#CMDC106B

Page 43: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 41

LCALL TXROMS MOV A,KX INC A LCALL TXBYTE MOV A,KY ; amplification rate from 1 to 10 INC A LCALL TXBYTE MOV DPTR,#CMDC106C LCALL TXROMS MOV DPTR,#CMDD0 LCALL TXROMS START2: NOP LJMP START ; Send the 0x00 handshake command to confirm the UART LCM power is on. ACKLCD: CLR RXFRMOK ACKLCD1:MOV DPTR,#CMD00 LCALL TXROMS CLR RTCOK MOV RTC250,#100 JNB RTCOK,$ CLR RTCOK JNB RXFRMOK,ACKLCD1 CLR RXFRMOK MOV A,RXCMD CJNE A,#00H,ACKLCD1 RET

; Show the amplification rate XYDSP: MOV DPTR,#CMD401 LCALL TXROMS MOV DPTR,#CMD551 LCALL TXROMS MOV A,KX ADD A,#30H LCALL TXBYTE MOV DPTR,#CMD552 LCALL TXROMS MOV A,KY ADD A,#30H LCALL TXBYTE MOV DPTR,#CMDTTL LCALL TXROMS MOV DPTR,#CMDD0 LCALL TXROMS RET

; Send the number of data. X axis is 750 pixels,N=750/(kx+1)

NUM_TAB:DW 750,375,250,187,150,125,107,93,83,75 CMD401: DW 0AA40H,0000H,001FH,0CC33H,0C33CH DW 0AA42H,0,0,0CC33H,0C33CH,0FEFEH CMD551: DW 0AA55H,349,434 DB 'X=',0FEH CMD552: DB ' Y=',0FEH CMDD0: DB 0AAH,0D0H,0CCH,33H,0C3H,3CH,0FEH CMDC106A:DW 0AA71H,0,24,7,776,409,24,7,0CC33H,0C33CH DB 0AAH,0C1H,06H,00H,00H

Page 44: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 42

DW 25,208,0FEFEH CMDC106B:DB 01H,0FEH CMDC106C:DB 1 DW 0F800H,8,408,0CC33H,0C33CH,0FEFEH CMD00: DB 0AAH,00H,0CCH,033H,0C3H,3CH,0FEH CMDTTL: DB 0CCH,33H,0C3H,3CH,0FEH ;Send 1 bit to the serial port TXBYTE: MOV SBUF0,A JNB TI0FLG,$ CLR TI0FLG RET ;Send 1 bit to the serial port TXWORD: MOV SBUF0,DPH JNB TI0FLG,$ CLR TI0FLG MOV SBUF0,DPL JNB TI0FLG,$ CLR TI0FLG RET ; Send a fixed data to the serial port to judge the end data string 0xFE0xFE TXROMS: CLR A MOVC A,@A+DPTR CJNE A,#0FEH,TXROMS1 RET TXROMS1:MOV SBUF0,A INC DPTR JNB TI0FLG,$ CLR TI0FLG CPL WDT SJMP TXROMS RET PICDSP: PUSH ACC MOV A,#0AAH LCALL TXBYTE MOV A,#70H LCALL TXBYTE POP ACC LCALL TXBYTE MOV DPTR,#CMDTTL LCALL TXROMS RET

;***************The programs of the serial port interrupt (IRQ) *************

UARTPRO:PUSH ACC PUSH PSW SETB RS0 SETB RS1 JB RI0,UARTRCV CLR TI0 SETB TI0FLG LJMP UARTEND UARTRCV:MOV A,SBUF0 CLR RI0

Page 45: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 43

JB RXFRMOK,UARTEND ; Data is not be processed in serial port JB RXAAOK,URCVD CJNE A,#0AAH,UARTEND SETB RXAAOK MOV RXPOS,#RXCMD LJMP UARTEND URCVD: MOV R0,RXPOS MOV @R0,A INC RXPOS MOV RXCC,RX33 MOV RX33,RXC3 MOV RXC3,RX3C MOV RX3C,A CJNE A,#3CH,UARTEND MOV A,RXC3 CJNE A,#0C3H,UARTEND MOV A,RX33 CJNE A,#33H,UARTEND MOV A,RXCC CJNE A,#0CCH,UARTEND SETB RXFRMOK CLR RXAAOK UARTEND:POP PSW POP ACC RETI

;*************** The service programs of 0.4ms timer interrupt ***********

SYSCLK: PUSH PSW SETB RS1 CLR RS0 PUSH DPH PUSH DPL MOV TMR2CN,#04H MOV R7,ADC0H MOV R6,ADC0L MOV ADC0CN,#90H MOV DPTR,#511 MOV A,ADN_L SUBB A,DPL MOV A,ADN_H SUBB A,DPH JNC SYSCK2 CLR C MOV A,R6 SUBB A,#00H ;Remove DC MOV R4,A MOV A,R7 SUBB A,#08H MOV R5,A JNC SYSCK1 MOV A,#00H CLR C SUBB A,R6 MOV R4,A MOV A,#08H SUBB A,R7 SETB ACC.7

Page 46: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 44

MOV R5,A SYSCK1: MOV DPH,ADS_H MOV DPL,ADS_L MOV A,R5 MOVX @DPTR,A INC DPTR MOV A,R4 MOVX @DPTR,A INC DPTR ANL DPH,#03H MOV ADS_H,DPH MOV ADS_L,DPL MOV A,ADN_L ADD A,#01H MOV ADN_L,A CLR A ADDC A,ADN_H MOV ADN_H,A SYSCK2: DJNZ RTC250,SYSCLKE MOV RTC250,#250 ;100ms timer SETB RTCOK SYSCLKE:POP DPL POP DPH POP PSW RETI

;***************The CPU initialization***********

INITCPU:MOV VDM0CN,#0C0H MOV RSTSRC,#02H MOV PCA0CN,#00H MOV PCA0MD,#00H MOV P0MDIN,#0FFH MOV P0MDOUT,#90H ;0001 0000B P0. 4 IS TXD MOV P0SKIP,#00H MOV P1MDIN,#0EBH ;1110 1011 MOV P1MDOUT,#00H MOV P1SKIP,#014H ;0000 0100B SKIP VERF-M A/D MOV XBR0,#01H MOV XBR1,#40H MOV OSCXCN,#00H MOV OSCICN,#0C7H CLR A DJNZ ACC,$ CPL WDT MOV CLKMUL,#00H NOP ORL CLKMUL,#03H NOP ORL CLKMUL,#10H NOP ORL CLKMUL,#80H NOP CLR A DJNZ ACC,$

Page 47: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 45

NOP ORL CLKMUL,#0C0H NOP OSCWT2:MOV A,CLKMUL JNB ACC.5,OSCWT2 NOP MOV CLKSEL,#02H ; 49MHz SYSTEM CLOCK MOV A,#07H ; Set the baud rate of the serial port, 7=115200 MOV B,#2 MUL AB MOV DPTR,#BODE_TAB MOV B,A MOVC A,@A+DPTR MOV CKCON,A MOV A,B INC DPTR MOVC A,@A+DPTR MOV TH1,A MOV TL1,A MOV SCON0,#50H SETB TR1 MOV TMR2RLH,#0F9H ;2ms=0DF73 1ms=EFB9 0.4ms=F97D MOV TMR2H,#0F9H MOV TMR2RLL,#07DH MOV TMR2L,#07DH MOV TMR2CN,#04H MOV IE,#00H MOV EIE1,#00H MOV REF0CN,#33H MOV ADC0MX,#0CH ;A/D=P1.4

MOV ADC0CF,#28H ;AD converts the clock to the system clock. The system clock is 10 points frequency

MOV ADC0CN,#90H ; AD is converted by AD0BUSY MOV ADC0TK,#0CH ;AD is only converted once RET ; Baud rate register table 1.2 2.4 4.8 9.6 19.2 38.4 57.6 115.2 ; 0=2041667 1=6125000 2=510417 BODE_TAB:DB 2,43 ;2400 00 DB 2,43 ;2400 01 DB 2,150 ;4800 02 DB 0,43 ;9600 03 DB 0,150 ;19200 04 DB 1,96 ;38400 05 DB 1,150 ;57600 06 DB 1,203 ;115200 07 END

Page 48: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 46

APPENDIX 4: C51 SERIAL COMMUNICATION PROGRAM REFERENCE

#define uchar unsigned char #define uint unsigned int bit RXAAOK; // The 0xAA frame header is connected to the serial port bit RXFRMOK; // A valid data frame is received by serial port bit TI0FLAG; //Send a TI sign back to the main program’s serial port uchar RXBUF[32]; // Buffer is received and saved by serial port. But the buffer must be remove 0XAA frame head and

//the UART LCM response of un-fixed format has the length return. So it needs to record length uchar Rx_P; // Data position is received and saved by serial port // The program of serial port Interrupt void UART0_ISR() interrupt 4 { uchar i; if(RI) // The interrupt is received by the serial port { i=SBUF; RI=0; if(RXFRMOK==0) //If RXFRMOK=1 means that the current data is not be processed in foreground ground and

//remove { if(RXAAOK) //Receive 0xAA { RXBUF[Rx_P]=i; if((Rx_P>3)&&(RXBUF[Rx_P-3]==0xCC)&&(RXBUF[Rx_P-2]==0x33)&&(RXBUF[Rx_P-1]==0xC3)&&(RXBUF[RX_P]==0x3C)) {RXFRMOK=1; RXAAOK=0;} Rx_P++;} if(!RXAAOK&&(i==0xaa)) { RXAAOK=1; Rx_P=0;}} } if(TI) { TI=0; TI0FLAG=1;} //The FSTA register should be cleared 0 to the CPU of taking FRAME_ERROR interrupt in DSP and

//ARM } if(RXFRMOK) //Check it whether the UART LCM data is received by serial port in foreground //main program { if(RXBUF[0]==0x78) //Touching function buttons {} if(RXBUF[0]==0x7C) // Pinyin input is over on touch screen {} RXFRMOK=0; //Finish and clear messages }

Page 49: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 47

APPENDIX 5: DOCUMENT RELATED TO THE C51 FUNCTION PROTOTYPES

void T2_ISR(void) interrupt 5 //The system timing and demonstrate are generated with 10ms timer interrupt 2 { TF2H=0; RTCOK=1; if(delay10ms) delay10ms--;} //Delay10ms. RTCOK is the global variable void delay10ms(uchar i) //Delay i*10ms { delay10ms=i; while(delay10ms);} void acklcd() //When power is on, send the 0x00 handshaking command to check whether LCD is ready.

//Otherwise waiting LCD is ready. { RXFRMOK=0; while(RXFRMOK==0) { txword(0xaa00); txeof(); delay10ms(10);} RXFRMOK=0;} void txbyte(uchar i) //A byte is sent to serial port with the query mode { SBUF=i; whilie(TI0FLG==0); TI0FLG=0;} void txword(uint i) // Send a byte to the serial port { txbyte(i/256); txbyte(i%256);} void txlong(ulong i) // Send 2 bytes to the serial port { txword(i/65536); txword(i%65536);} void txxy(uint x,uint y) //Send coordinates to the serial port { txword(x); txword(y);} void txarea(uint xs,uint ys,uint xe,unit ye) // Send coordinates of the rectangle area to the serial //port { txword(xs); txword(ys); txword(xe); txword(ye);} void txstr(uchar *s) //Send strings to the serial port. 0x00 is the end of string { while(*s) { txbyte(*s); s++;}} void txroms(uchar *s) //Send strings to the serial port. 0xFE is the end of string { whilie(!(*s==0xFE)) { txbyte(*s); s++;}} void txeof() //Send frame terminators to the serial port { txxy(0xcc33,0xc33c);}

Page 50: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 48

void fdisp() //Force a full screen to refresh once { txword(0xaad0); txeof();} void setcolor(uint color,uint bcolor) //Set palettes { txword(0xaa40); txxy(color,bcolor); txeof();} void line(uint xs,uint ys,uint xe,uint ye) //Connect lines { txword(0xaa56); txarea(xs,ys,xe,ye); txeof();} void picdsp(uint p) //Display pictures { txword(0xaa70); txword(p); txeof();} void piccut(uint cmd,uint p,uint xs,uint ys,uint xe,uintye,unit x,uint y) // Display the cutting icons { txbyte(0xaa); txbyte(cmd); txword(p); txarea(xs,ys,xe,ye); txxy(x,y); txeof();} void prints(uchar cmd,uint x,uint y,uchar *s) //0x00 is the end of string when string is displayed by other commands

//except the 0x98 command. { txbyte(0xaa); txbyte(cmd); txxy(x,y); txstr(s);} // If the frame terminator does not included by the pointer string, it needs to require to additionally

//send the frame terminator. // 0xfe is the end of string when string is displayed by the 0x98 command void print98(uchar lib,uchar mode,uchar dot,uint color,uint bcolor,uint x,uint y uchar *s) { txword(0xaa98); txxy(x,y); txbyte(lib); txbyte(mode); txbyte(dot); txxy(color,bcolor); txroms(s);} // If the frame terminator does not included by the pointer string, it needs to require to additionally

//send the frame terminator.

void fillw(uchar cmd,uint xs,uint ys,uint xe,uint ye) //Area commands: 0x59、0x69、0x5A、0x5B、0x5C { txbyte(0xaa); txbyte(cmd); txarea(xs,ys,xe,ye);

txeof()} void pixel(uint x,uint y) //Put pixel { txword(0xaa51); txxy(x,y); txeof();}

Page 51: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 49

//Input Chinese and English on touch screen (Chinese is in GBK font) void scans(uint rid,uint pid,uint x,uint y,uint x1,uint yi1,uchar len,uint color0,uint color1) {txword(0xaa7c); txbyte(0x02); //01=ASCII 02=input both Chinese and English txword(rid); // The returning index ID after the input is over txword(pid); //The index ID of the touching function configuration txxy(x,y); // The starting coordinates of the display area when inputting the text txbyte(len); //The maximum length of input txbyte(0x00); txxy(color0,color1); //Color0=The display color of input text color1=The display text color in the //processing of

input txxy(x1,y1); //The starting coordinates of display text in input process txeof();} //The input process is automatically completed by UART LCM without the interference of the user //software //The result of input string is returned by UART LCM after the end of input if((rxcmd==0x7C)&&(rxdat[2]==0x01)) //0x01 is the ID which is returned by the user specific //corresponding to the

above code rid {wrxram(rxdat[3],0x0800);} // Save parameters. The radat[3] is the length of input parameter.

Page 52: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 50

Beijing DWIN Technology Co., Ltd. is a leading global company with cutting-edge

technology mainly focuses on UART LCM (Industrial serial port screen) researching, manufacturing and sales. DWIN has 150 employees across China. We located in the central area of Zhong Guancun, where is well-known as Chinese Silicon Valley. Branches and regional offices have established in Shenzhen, Shanghai, Northern Europe and the United States sales channels have established in India, Turkey and Brazil around globe. And sterilized assembly line, enhanced the QC centre, laboratory and aging test workshop have established in Beijing Shangdi Information Industry Base which are a total area about 5000 m2 . With the effort of ninth years’ devotion, we have been following the philosophy of “Professional, Creditable and Successful”, and achieving doubled increase in annual average sales that stressed to create value for customers in order that customers and our company rapidly improve and develop together. Relying on product function, quality, service, price and competitive advantage, DWIN focuses on industrial TFT display market, especially in reliability-em0070hasized industry fields, which include engineering machinery, medical instruments as well as high-level civilian goods. Our products have been gained reputation from clients all over the world with satisfactory services, such as

CHINA SANY Group , GM , SIEMENS and other customers. Our goal is go after ‘Double Win’ between customers and our company, realizing joint growth by market-oriented and technology innovations and being as an ideal partner.

Page 53: DWIN UART LCM SOFTWARE DEVELOPMENT GUIDE V3 Software Development Guide... · PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2 Beijing DWIN Technology

PROFESIONAL, CREDITABLE, SUCCESSFULL DWIN_UART LCM SOFTWARE DEVELOPMENT GUIDE V3.2

Beijing DWIN Technology Co., Ltd. www.dwin.com.cn/en Tel:400-018-9008 51

Beijing DWIN Technology Co., Ltd. Address: Room 901-904, Building A, Floor 9, Hao Jing Plaza, No.108 Zhichun Road, Haidian District, Beijing, P.R.China 100086 Tel: 400-018-9008

You can also call the following telephone: Product Purchase: 010-62104079 62101462 62104686 Technical Support: 010-62555372 62102321 62102090 Complaint: 010-62101180 Head Office: 010-62102630 62105007 62636805

Fax: (86) 10-62628562 Website: www.dwin.com.cn/en