LCD1602 applet, lcd1602

Source: Internet
Author: User

LCD1602 applet, lcd1602

1. Display Data

typedef struct {  unsigned long int mL_data;  unsigned long int L_data;  unsigned long int M3_data;}water_date;extern water_date water_data1;

2. Data processing functions

/** Handle * @ brief data processing function * @ param none * @ arg the start address of the data structure to be processed * @ retval data start address struct */unsigned char * DATA_DEAL (water_date t) {unsigned char DIS_DATA [] = {"000 mL; 000L; 000M3"}; if (t. mL_data | t. l_data | t. m3_data) {DIS_DATA [0] = (t. mL_data * 1000/450) % 1000/100 + 0x30; DIS_DATA [1] = (t. mL_data * 1000/450) % 100/10 + 0x30; DIS_DATA [2] = (t. mL_data * 1000/450) % 10 + 0x30; DIS_DATA [6] = t. l_data % 1000/100 + 0x30; DIS_DATA [7] = t. l_data % 100/10 + 0x30; DIS_DATA [8] = t. l_data % 10 + 0x30; DIS_DATA [11] = t. m3_data % 1000/100 + 0x30; DIS_DATA [12] = t. m3_data % 100/10 + 0x30; DIS_DATA [13] = t. m3_data % 10 + 0x30; return DIS_DATA;} else return 0 ;}

3. display functions

/** --------------------------------------------------------------------------------- * @ Brief corresponding position display function * @ param y: 1, 2 (write from the nth row) x: 0-15 (write from the nth digit of the row) * @ arg NULL * @ retval null character */unsigned char LCD1602_WRITE (unsigned char y, unsigned char x, unsigned char * write_data) {unsigned char I; LCD _wcmd (0x06 ); // move the cursor to the right if (y = 1) {LCD _pos (X); // set the display position to the 1st character I = 0 in the first line; while (* (write_data + I )! = '\ 0') {// The display character "wlcome to" LCD _wdat (* (write_data + I); I ++; // delay (200 ); // control the display speed between two words if (I> 15) {LCE1602_STATUS = WRITE_NO; return LCE1602_STATUS ;}} LCE1602_STATUS = WRITE_ OK; return LCE1602_STATUS ;} else {LCD _pos (0x40 + x); // set the display position to 0 for the first line of the 1st characters I = 0; while (* (write_data + I )! = '\ 0') {// The display character "wlcome to" LCD _wdat (* (write_data + I); I ++; // delay (200 ); // control the display speed between two words if (I> 15) {LCE1602_STATUS = WRITE_NO; return LCE1602_STATUS ;}} LCE1602_STATUS = WRITE_ OK; return LCE1602_STATUS ;}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.