Skip to content

Commit c7aee12

Browse files
author
Ville Vilpas
committed
Bugfixes and cleanup
1 parent 43bd7e0 commit c7aee12

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# ESPNexUpload
2-
ESP8266 library for uploading .tft file to Nextion display using SPIFFS.
2+
ESP8266 library for uploading .tft file to Nextion display using SPIFFS and SoftwareSerial. Currently it isn't possible to use HardwareSerial.
33

44
## Usage
5-
See example. Library expects that given file path is found at ESP8266 flash memory(SPIFFS). Included example provides webserver with file upload to SPIFFS.
5+
See example. Library expects that given file path is found at ESP8266 flash memory(SPIFFS). Included example provides webserver with file upload to SPIFFS. Sometimes upload doesnt work -> try to power cycle display.
66

7-
## BUGS
8-
- Doesn't work with esp8266 2.4.0 version. Use 2.3.0 until fixed.
7+
## Note on baudrates
8+
- Nextion <-> ESP8266 communication seems to be quite fault prone.
9+
- With ESP8266 arduino core v2.4.0: Doesn't work with 115200 baudrate.
10+
57600 seems to work fine.
11+
- With ESP8266 arduino core v2.3.0: 115200 works fine.
912

1013
## Releases
14+
- v0.2.0 - Removed unnecessary delays. Works now with latest ESP8266 arduinocore (see notes)
1115
- v0.1.1 - Updated to comply with Arduino Library manager
1216
- v0.1.0 - Working with basic functionality.
1317

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ESPNexUpload
2-
version=0.1.1
2+
version=0.2.0
33
author=Ville Vilpas <[email protected]>
44
maintainer=Ville Vilpas <[email protected]>
55
sentence=Uploading UI file to Nextion display using ESP8266 SPIFFS

src/ESPNexUpload.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Modified to work with ESP8266 and SoftwareSerial
77
* @author Ville Vilpas ([email protected])
88
* @date 2018/2/3
9-
* @version 0.1.1
9+
* @version 0.2.0
1010
*
1111
* Original version (a part of https://github.com/itead/ITEADLIB_Arduino_Nextion)
1212
* @author Chen Zengpeng (email:<[email protected]>)
@@ -32,7 +32,7 @@
3232
#include <FS.h>
3333
#include <SoftwareSerial.h>
3434

35-
#define DEBUG_SERIAL_ENABLE
35+
//#define DEBUG_SERIAL_ENABLE
3636

3737
#ifdef DEBUG_SERIAL_ENABLE
3838
#define dbSerialPrint(a) Serial.print(a)
@@ -91,6 +91,7 @@ bool ESPNexUpload::upload(String &statusMessage)
9191

9292
uint16_t ESPNexUpload::_getBaudrate(void)
9393
{
94+
_baudrate = 0;
9495
uint32_t baudrate_array[7] = {115200,19200,9600,57600,38400,4800,2400};
9596
for(uint8_t i = 0; i < 7; i++)
9697
{
@@ -188,18 +189,14 @@ bool ESPNexUpload::_setDownloadBaudrate(uint32_t baudrate)
188189
String filesize_str = String(_undownloadByte,10);
189190
String baudrate_str = String(baudrate);
190191
cmd = "whmi-wri " + filesize_str + "," + baudrate_str + ",0";
191-
192-
dbSerialPrintln(cmd);
193192

194193
this->sendCommand("");
195194
this->sendCommand(cmd.c_str());
196-
delay(50);
197-
nexSerial->begin(baudrate);
198-
199-
dbSerialPrintln("Baudrate changed");
200-
delay(50);
201195

202-
this->recvRetString(string,500);
196+
dbSerialPrintln("Changing baudrate...");
197+
nexSerial->begin(baudrate);
198+
199+
this->recvRetString(string);
203200

204201
if(string.indexOf(0x05) != -1)
205202
{

src/ESPNexUpload.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Modified to work with ESP8266 and SoftwareSerial
77
* @author Ville Vilpas ([email protected])
88
* @date 2018/2/3
9-
* @version 0.1.1
9+
* @version 0.2.0
1010
*
1111
* Original version (a part of https://github.com/itead/ITEADLIB_Arduino_Nextion)
1212
* @author Chen Zengpeng (email:<[email protected]>)
@@ -130,12 +130,12 @@ class ESPNexUpload
130130
* @return the length of string buffer.
131131
*
132132
*/
133-
uint16_t recvRetString(String &string, uint32_t timeout = 100,bool recv_flag = false);
133+
uint16_t recvRetString(String &string, uint32_t timeout = 500,bool recv_flag = false);
134134

135135
private: /* data */
136136
uint32_t _baudrate; /*nextion serail baudrate*/
137137
const char *_file_name; /*nextion tft file name*/
138-
File _myFile; /*nextion ftf file*/
138+
File _myFile; /*nextion tft file*/
139139
uint32_t _undownloadByte; /*undownload byte of tft file*/
140140
uint32_t _download_baudrate; /*download baudrate*/
141141
SoftwareSerial *nexSerial;

0 commit comments

Comments
 (0)