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 ;}}