variable value lost and not displaced on OLED after a sleep

jon_nic

New Member
Hi,
Curious problem with a missing variable that I am displaying on an OLED. It displays fine first and then the picaxe is put in to sleep for some time, then woken up and the same variable is sent to the OLED as an ASCII again but this time does not display, and never displays untill a reset.

here is the logic:

perform some maths and store the value in b0

serout B.7, N2400, ("the value is", #B0)

sleep 10

perform the same maths and store in b0
serout B.7, N2400, ("the value now is", #B0)


and this is where the OLED displays " the value now is " and the value is missing, and does not display no matter how many times i re-apply the serout command

what could cause this?

Regards Jon
 

geoff07

Senior Member
It would help if you posted the actual program. Your description seems fine but it is the detail that causes the problems!
 
A sleep command is like a Reset command :)
After sleep the picaxe code begin at row 0 and all variables are set to zero

before you perform a sleep , store the varibale into the EEPROM
 

srnet

Senior Member
A sleep command is like a Reset command :)
After sleep the picaxe code begin at row 0 and all variables are set to zero

before you perform a sleep , store the varibale into the EEPROM
Sleep is very different to reset.

After a sleep, program execution continues at the line after the sleep, with all variables and RAM retained.
 

geoff07

Senior Member
It occurred to me that you do not set the character position for writing. It may be that the subsequent writes are actually being written into a black hole. We don't know how many characters or lines your display has. But don't make the mistake of assuming that character positions across lines are consequtively numbered. Try adding '254,128,' at the start of each write, which will move the (invisible) cursor to the top left position.

On a four line, 20 character, display, the lines begin with positions 128, 192, 148, and 212 in order. So if you write off the end of line one it continues on line three. On a two-line display, if you go off the end of line one it just disappears.
 

tony_g

Senior Member
how many characters is your display per line?

"the value now is" including spaces this is 16 characters so if you are using a 16 x xxx display then you would have to send the value of b0 to line two or change the message to something shorter like ("new value is", #B0) which would be 12 characters for message plus 4 left for b0 value for one line display assuming it is a 16 character line.

tony
 

westaust55

Moderator
Concur with tony_g's thoughts in the first instance with the limited information provided.

But if your display is wider than 16 characters then try commenting out the sleep command and see what happens.
Should make no difference but is a quick test to try.
 

jon_nic

New Member
thanks for comments, I dont have the code with me now but I think i do set the position of the cursor before asking it to displaying #b0. I'll check the code later and i'll also remove the sleep and replace with a pause command to see if it is the sleep command that is the problem OR if it is just an error in my cursor positioning after the sleep command

jon.
 

westaust55

Moderator
You have not indicated what format the display is...
If it is 16 x 2 then as already indicated, even if you set the message to start at the left edge of the display the scone message will have the value off the right side.
With 16 character wide displays there are about 8 hidden characters at the end of the lines before wrap around occurs. Those extra characters are visible if you use "shift display left" commands.
 

tony_g

Senior Member
any success with getting this problem sorted?

post back just in case it is something that could help someone else in the future when they do a forum search.


tony
 
Top