@ -82,20 +82,27 @@ inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
// Send the data in the buffer and the packet end
inline void DWIN_Send ( size_t & i ) {
+ + i ;
LOOP_L_N ( n , i ) { MYSERIAL1 . write ( DWIN_SendBuf [ n ] ) ; delayMicroseconds ( 1 ) ; }
LOOP_L_N ( n , 4 ) { MYSERIAL1 . write ( DWIN_BufTail [ n ] ) ; delayMicroseconds ( 1 ) ; }
LOOP_L_N ( n , i ) { LCD_SERIAL . write ( DWIN_SendBuf [ n ] ) ; delayMicroseconds ( 1 ) ; }
LOOP_L_N ( n , 4 ) { LCD_SERIAL . write ( DWIN_BufTail [ n ] ) ; delayMicroseconds ( 1 ) ; }
}
/*-------------------------------------- System variable function --------------------------------------*/
// Handshake (1: Success, 0: Fail)
bool DWIN_Handshake ( void ) {
# ifndef LCD_BAUDRATE
# define LCD_BAUDRATE 115200
# endif
LCD_SERIAL . begin ( LCD_BAUDRATE ) ;
const millis_t serial_connect_timeout = millis ( ) + 1000UL ;
while ( ! LCD_SERIAL & & PENDING ( millis ( ) , serial_connect_timeout ) ) { /*nada*/ }
size_t i = 0 ;
DWIN_Byte ( i , 0x00 ) ;
DWIN_Send ( i ) ;
while ( MYSERIAL1 . available ( ) > 0 & & recnum < ( signed ) sizeof ( databuf ) ) {
databuf [ recnum ] = MYSERIAL1 . read ( ) ;
while ( LCD_SERIAL . available ( ) > 0 & & recnum < ( signed ) sizeof ( databuf ) ) {
databuf [ recnum ] = LCD_SERIAL . read ( ) ;
// ignore the invalid data
if ( databuf [ 0 ] ! = FHONE ) { // prevent the program from running.
if ( recnum > 0 ) {