Skip to content

modify library name #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions NexDownload.cpp → NexUpload.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file NexDownload.cpp
* @file NexUpload.cpp
*
* The implementation of download tft file for nextion.
*
Expand All @@ -13,7 +13,7 @@
* the License, or (at your option) any later version.
*/

#include "NexDownload.h"
#include "NexUpload.h"
#include <SoftwareSerial.h>

//#define USE_SOFTWARE_SERIAL
Expand All @@ -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())
Expand All @@ -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++)
Expand All @@ -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))
Expand All @@ -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);
Expand All @@ -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())
Expand All @@ -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;
Expand Down Expand Up @@ -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("");
Expand All @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions NexDownload.h → NexUpload.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file NexDownload.h
* @file NexUpload.h
*
* The definition of class NexDownload.
* The definition of class NexUpload.
*
* @author Chen Zengpeng (email:<[email protected]>)
* @date 2016/3/29
Expand All @@ -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 <Arduino.h>
#include <SPI.h>
#include <SD.h>
Expand All @@ -29,7 +29,7 @@
*
* Provides the API for nextion to download the ftf file.
*/
class NexDownload
class NexUpload
{
public: /* methods */

Expand All @@ -40,7 +40,7 @@ class NexDownload
* @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.
Expand All @@ -49,20 +49,20 @@ class NexDownload
* @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 */

Expand Down
6 changes: 3 additions & 3 deletions examples/Download/Download.ino → examples/Upload/Upload.ino
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "NexDownload.h"
NexDownload nex_download("nex.tft",10,115200);
#include "NexUpload.h"
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() {
Expand Down