Skip to content

Commit

Permalink
- STD_SERIAL_BAUD -> NEX_SERIAL_DEFAULT_BAUD
Browse files Browse the repository at this point in the history
- Version information updated
  • Loading branch information
jyberg committed Jul 24, 2020
1 parent 93d7066 commit bfe0922
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 250 deletions.
13 changes: 8 additions & 5 deletions NexConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@
// #define STD_SUPPORT

/**
* Define serial communication baud
* Define serial communication default baud.
* it is recommended that do not change defaul baud on Nextion, because it can forgot it on re-start
* If changing this value check that vakue is the same as factory set default baud in the used display.
*
*/
#define STD_SERIAL_BAUD 9600
#define NEX_SERIAL_DEFAULT_BAUD 9600

/**
* Define standard or fast timeout
* Define standard (dafault) or fast timeout, you may use fast timeout in case of baudrate higher than 115200
*
*/
//#define NEX_TIMEOUT_STANDARD
#define NEX_TIMEOUT_FAST
#define NEX_TIMEOUT_STANDARD
//#define NEX_TIMEOUT_FAST

#ifdef NEX_TIMEOUT_FAST
#define NEX_TIMEOUT_CONNECT 10
Expand All @@ -50,6 +52,7 @@
#define NEX_TIMEOUT_COMMAND 200
#define NEX_TIMEOUT_RETURN 100
#endif

/**
* Define NEX_DEBUG_SERIAL_ENABLE to enable debug serial.
* Comment it to disable debug serial.
Expand Down
6 changes: 4 additions & 2 deletions NexHardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,11 @@ bool nexInit(const uint32_t baud)
bool ret1 = false;
bool ret2 = false;

nexSerial.begin(STD_SERIAL_BAUD); // default baud, it is recommended that do not change defaul baud on Nextion, because it can forgot it on re-start
if(baud!=STD_SERIAL_BAUD)
// try to connect first with default baud as display may have forgot set baud
nexSerial.begin(NEX_SERIAL_DEFAULT_BAUD); // default baud, it is recommended that do not change defaul baud on Nextion, because it can forgot it on re-start
if(baud!=NEX_SERIAL_DEFAULT_BAUD)
{
// change baud to wanted
char cmd[14];
sprintf(cmd,"baud=%i",baud);
sendCommand(cmd);
Expand Down
2 changes: 1 addition & 1 deletion NexHardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ bool RecvTransparendDataModeFinished(size_t timeout = 200);
*
* @return true if success, false for failure.
*/
bool nexInit(const uint32_t baud=9600);
bool nexInit(const uint32_t baud=NEX_SERIAL_DEFAULT_BAUD);

/**
* Listen touch event and calling callbacks attached before.
Expand Down
Loading

0 comments on commit bfe0922

Please sign in to comment.