From 989c220cea7b5f1896e49dde3874c16dea57becd Mon Sep 17 00:00:00 2001 From: zengpeng <371162105@qq.com> Date: Wed, 20 Apr 2016 14:26:41 +0800 Subject: [PATCH] modify library name to upload --- NexDownload.cpp => NexUpload.cpp | 26 +++++++++---------- NexDownload.h => NexUpload.h | 18 ++++++------- .../Download.ino => Upload/Upload.ino} | 4 +-- 3 files changed, 24 insertions(+), 24 deletions(-) rename NexDownload.cpp => NexUpload.cpp (87%) rename NexDownload.h => NexUpload.h (88%) rename examples/{Download/Download.ino => Upload/Upload.ino} (65%) diff --git a/NexDownload.cpp b/NexUpload.cpp similarity index 87% rename from NexDownload.cpp rename to NexUpload.cpp index 3e2def5..ff85eb9 100644 --- a/NexDownload.cpp +++ b/NexUpload.cpp @@ -1,5 +1,5 @@ /** - * @file NexDownload.cpp + * @file NexUpload.cpp * * The implementation of download tft file for nextion. * @@ -13,7 +13,7 @@ * the License, or (at your option) any later version. */ -#include "NexDownload.h" +#include "NexUpload.h" #include //#define USE_SOFTWARE_SERIAL @@ -32,19 +32,19 @@ SoftwareSerial dbSerial(3, 2); /* RX:D3, TX:D2 */ #define dbSerialBegin(a) do{}while(0) #endif -NexDownload::NexDownload(const char *file_name,const uint8_t SD_chip_select,uint32_t download_baudrate) +NexUpload::NexUpload(const char *file_name,const uint8_t SD_chip_select,uint32_t download_baudrate) { _file_name = file_name; _SD_chip_select = SD_chip_select; _download_baudrate = download_baudrate; } -NexDownload::NexDownload(const String file_Name,const uint8_t SD_chip_select,uint32_t download_baudrate) +NexUpload::NexUpload(const String file_Name,const uint8_t SD_chip_select,uint32_t download_baudrate) { - NexDownload(file_Name.c_str(),SD_chip_select,download_baudrate); + NexUpload(file_Name.c_str(),SD_chip_select,download_baudrate); } -void NexDownload::startDownload(void) +void NexUpload::upload(void) { dbSerialBegin(9600); if(!_checkFile()) @@ -70,7 +70,7 @@ void NexDownload::startDownload(void) dbSerialPrintln("download ok\r\n"); } -uint16_t NexDownload::_getBaudrate(void) +uint16_t NexUpload::_getBaudrate(void) { uint32_t baudrate_array[7] = {115200,19200,9600,57600,38400,4800,2400}; for(uint8_t i = 0; i < 7; i++) @@ -85,7 +85,7 @@ uint16_t NexDownload::_getBaudrate(void) return _baudrate; } -bool NexDownload::_checkFile(void) +bool NexUpload::_checkFile(void) { dbSerialPrintln("start _checkFile"); if(!SD.begin(_SD_chip_select)) @@ -105,7 +105,7 @@ bool NexDownload::_checkFile(void) return 1; } -bool NexDownload::_searchBaudrate(uint32_t baudrate) +bool NexUpload::_searchBaudrate(uint32_t baudrate) { String string = String(""); nexSerial.begin(baudrate); @@ -119,7 +119,7 @@ bool NexDownload::_searchBaudrate(uint32_t baudrate) return 0; } -void NexDownload::sendCommand(const char* cmd) +void NexUpload::sendCommand(const char* cmd) { while (nexSerial.available()) @@ -133,7 +133,7 @@ void NexDownload::sendCommand(const char* cmd) nexSerial.write(0xFF); } -uint16_t NexDownload::recvRetString(String &string, uint32_t timeout,bool recv_flag) +uint16_t NexUpload::recvRetString(String &string, uint32_t timeout,bool recv_flag) { uint16_t ret = 0; uint8_t c = 0; @@ -167,7 +167,7 @@ uint16_t NexDownload::recvRetString(String &string, uint32_t timeout,bool recv_f return ret; } -bool NexDownload::_setDownloadBaudrate(uint32_t baudrate) +bool NexUpload::_setDownloadBaudrate(uint32_t baudrate) { String string = String(""); String cmd = String(""); @@ -189,7 +189,7 @@ bool NexDownload::_setDownloadBaudrate(uint32_t baudrate) return 0; } -bool NexDownload::_downloadTftFile(void) +bool NexUpload::_downloadTftFile(void) { uint8_t c; uint16_t send_timer = 0; diff --git a/NexDownload.h b/NexUpload.h similarity index 88% rename from NexDownload.h rename to NexUpload.h index d0014d9..c3c57b1 100644 --- a/NexDownload.h +++ b/NexUpload.h @@ -1,7 +1,7 @@ /** - * @file NexDownload.h + * @file NexUpload.h * - * The definition of class NexDownload. + * The definition of class NexUpload. * * @author Chen Zengpeng (email:) * @date 2016/3/29 @@ -13,8 +13,8 @@ * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. */ -#ifndef __NEXDOWNLOAD_H__ -#define __NEXDOWNLOAD_H__ +#ifndef __NEXUPLOAD_H__ +#define __NEXUPLOAD_H__ #include #include #include @@ -29,7 +29,7 @@ * * Provides the API for nextion to download the ftf file. */ -class NexDownload +class NexUpload { public: /* methods */ @@ -40,7 +40,7 @@ public: /* methods */ * @param SD_chip_select - sd chip select pin. * @download_baudrate - set download baudrate. */ - NexDownload(const char *file_name,const uint8_t SD_chip_select,uint32_t download_baudrate); + NexUpload(const char *file_name,const uint8_t SD_chip_select,uint32_t download_baudrate); /** * Constructor. @@ -49,20 +49,20 @@ public: /* methods */ * @param SD_chip_select - sd chip select pin. * @download_baudrate - set download baudrate. */ - NexDownload(const String 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); /** * destructor. * */ - ~NexDownload(){} + ~NexUpload(){} /* * start download. * * @return none. */ - void startDownload(); + void upload(); private: /* methods */ diff --git a/examples/Download/Download.ino b/examples/Upload/Upload.ino similarity index 65% rename from examples/Download/Download.ino rename to examples/Upload/Upload.ino index b3f7c9b..8d371a9 100644 --- a/examples/Download/Download.ino +++ b/examples/Upload/Upload.ino @@ -1,8 +1,8 @@ #include "NexDownload.h" -NexDownload nex_download("nex.tft",10,115200); +NexUpload nex_download("nex.tft",10,115200); void setup() { // put your setup code here, to run once: - nex_download.startDownload(); + nex_download.upload(); } void loop() {