All Classes Files Functions Typedefs Groups Pages
NexUpload.h
Go to the documentation of this file.
#ifndef __NEXUPLOAD_H__
#define __NEXUPLOAD_H__
#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
#include "NexHardware.h"
class NexUpload
{
public: /* methods */
NexUpload(const char *file_name,const uint8_t SD_chip_select,uint32_t download_baudrate);
NexUpload(const String file_Name,const uint8_t SD_chip_select,uint32_t download_baudrate);
~NexUpload(){}
/*
* start download.
*
* @return none.
*/
void upload();
private: /* methods */
/*
* get communicate baudrate.
*
* @return communicate baudrate.
*
*/
uint16_t _getBaudrate(void);
/*
* check tft file.
*
* @return true if success, false for failure.
*/
bool _checkFile(void);
/*
* search communicate baudrate.
*
* @param baudrate - communicate baudrate.
*
* @return true if success, false for failure.
*/
bool _searchBaudrate(uint32_t baudrate);
/*
* set download baudrate.
*
* @param baudrate - set download baudrate.
*
* @return true if success, false for failure.
*/
bool _setDownloadBaudrate(uint32_t baudrate);
bool _downloadTftFile(void);
/*
* Send command to Nextion.
*
* @param cmd - the string of command.
*
* @return none.
*/
void sendCommand(const char* cmd);
/*
* Receive string data.
*
* @param buffer - save string data.
* @param timeout - set timeout time.
* @param recv_flag - if recv_flag is true,will braak when receive 0x05.
*
* @return the length of string buffer.
*
*/
uint16_t recvRetString(String &string, uint32_t timeout = 100,bool recv_flag = false);
private: /* data */
uint32_t _baudrate; /*nextion serail baudrate*/
const char *_file_name; /*nextion tft file name*/
File _myFile; /*nextion ftf file*/
uint32_t _undownloadByte; /*undownload byte of tft file*/
uint8_t _SD_chip_select; /*sd chip select pin*/
uint32_t _download_baudrate; /*download baudrate*/
};
#endif /* #ifndef __NEXDOWNLOAD_H__ */
NexUpload::NexUpload
NexUpload(const char *file_name, const uint8_t SD_chip_select, uint32_t download_baudrate)
Definition: NexUpload.cpp:35
NexUpload
Definition: NexUpload.h:32
NexUpload::~NexUpload
~NexUpload()
Definition: NexUpload.h:58
NexHardware.h