I am working on an altimeter project using an 18M2, an MPL3115 altimeter board from Sparkfun, and a 240x320 enhanced display from Nextion. I have used the program from rq3, on this forum, as the beginning point. My first implementation used the Nex to display results and set the local barometric pressure. That all works fine. I use serout to send the altitude to the Nex and and hserin to read two bytes that represent the barometer reading. This has been working fine. I used hserin because I could not get regular serin to work at all.
Then I got the bright idea that for some kinds of uses, it would be handy to zero the reading and go by relative changes instead of absolute. I use a flag set to 0 for relative readings, and 1 for absolute. If I hard code the flag, it all works fine, but I cannot get a flag send back to the Picaxe from the Nex. Here is the relevant section of code:
hserin b10 'first byte of new kolls (w5) Kolls is the local barometer x 100, typical is 2992
hserin b11 'second byte of new kolls
'hserin b26 'this is where I try to get the flag Note: only need one bit, may use more bits later for some other options
'pause 10
goto main_routine
end
To try to sort this out, I wrote a short program to receive data from the Nex and then printed it out on the terminal. I could receive the flag just fine if I didn't try to read both the flag and the barometer at the same time. The time to get a new reading from the altimeter is about 1/2 second, so updates from the Nex can come at anytime in the cycle.
So, My next tack will be delaying the Nex update so there is at least a cycle between inputs. I wish there was a better explanation on how the inputs for serial ports work. I think I need some continuing education. Will appreciate some of your thoughts. If you want to see all the code, it is about 100 lines. I just found the other code insertion thing, so here is the whole works, I hope this works........It didn't. So lets start with short version first.
tom