One of the limitations of the Nextion Simulator is that it does not emit the startup messages as the actual screens do (notably 00 00 00 ff ff ff
(“start up”) and 88 ff ff ff
(“ready”)). Since I rely on these messages and need my Nextion firmware to work without modification in the Simulator, I had to come up with some sort of emulation.
The easy way is obviously to just use printh
for both messages in the Program.s
file. However, that would cause the actual screens to send the “fake” messages, too - which might lead to issues. A better solution would be to send them only if the firmware is running in the simulator. So the question is how to detect that.
This is where another limitation of the simulator comes in handy: bauds
is fixed to 9600
- even after assigning another value to it. So if bauds
remains unchanged after an assignment, you know that you’re running in the debugger. That trick might be useful for other stuff, too.
Note: this limitation may drop in future versions and thus break the detection. Latest version at the time of writing: v1.63.3.
Source code using the tricks above: Nextion Simulator Detection and Startup Messages · GitHub
Kind regards,
Max