My Project
 All Classes Files Functions Typedefs Groups Pages
NexUpload.h
Go to the documentation of this file.
1 
16 #ifndef __NEXUPLOAD_H__
17 #define __NEXUPLOAD_H__
18 #include <Arduino.h>
19 #include <SPI.h>
20 #include <SD.h>
21 #include "NexHardware.h"
22 
32 class NexUpload
33 {
34 public: /* methods */
35 
43  NexUpload(const char *file_name,const uint8_t SD_chip_select,uint32_t download_baudrate);
44 
52  NexUpload(const String file_Name,const uint8_t SD_chip_select,uint32_t download_baudrate);
53 
59 
60  /*
61  * start download.
62  *
63  * @return none.
64  */
65  void upload();
66 
67 private: /* methods */
68 
69  /*
70  * get communicate baudrate.
71  *
72  * @return communicate baudrate.
73  *
74  */
75  uint16_t _getBaudrate(void);
76 
77  /*
78  * check tft file.
79  *
80  * @return true if success, false for failure.
81  */
82  bool _checkFile(void);
83 
84  /*
85  * search communicate baudrate.
86  *
87  * @param baudrate - communicate baudrate.
88  *
89  * @return true if success, false for failure.
90  */
91  bool _searchBaudrate(uint32_t baudrate);
92 
93  /*
94  * set download baudrate.
95  *
96  * @param baudrate - set download baudrate.
97  *
98  * @return true if success, false for failure.
99  */
100  bool _setDownloadBaudrate(uint32_t baudrate);
101 
107  bool _downloadTftFile(void);
108 
109  /*
110  * Send command to Nextion.
111  *
112  * @param cmd - the string of command.
113  *
114  * @return none.
115  */
116  void sendCommand(const char* cmd);
117 
118  /*
119  * Receive string data.
120  *
121  * @param buffer - save string data.
122  * @param timeout - set timeout time.
123  * @param recv_flag - if recv_flag is true,will braak when receive 0x05.
124  *
125  * @return the length of string buffer.
126  *
127  */
128  uint16_t recvRetString(String &string, uint32_t timeout = 100,bool recv_flag = false);
129 
130 private: /* data */
131  uint32_t _baudrate; /*nextion serail baudrate*/
132  const char *_file_name; /*nextion tft file name*/
133  File _myFile; /*nextion ftf file*/
134  uint32_t _undownloadByte; /*undownload byte of tft file*/
135  uint8_t _SD_chip_select; /*sd chip select pin*/
136  uint32_t _download_baudrate; /*download baudrate*/
137 };
142 #endif /* #ifndef __NEXDOWNLOAD_H__ */
NexUpload(const char *file_name, const uint8_t SD_chip_select, uint32_t download_baudrate)
Definition: NexUpload.cpp:35
Definition: NexUpload.h:32
~NexUpload()
Definition: NexUpload.h:58