Trouble Using Switches to Change an OLED Screen...

Robbier3

New Member
Good Day Everyone,

I recently started playing with an Axe133 OLED, with the help of a few kind members of this site I managed to do quite a lot of what I was hoping to do, however I am having a problem now with changing from one screen to the next using push buttons.

I can see what the problem is, I just can't think of a way how to resolve it. I am assuming that whatever time I put in for my sentence on the screen to show for is effecting when the button I press is registered, as I have to hold it for that time before it does anything. Is there a way to be able to press a button that will automatically change to another screen, I have tried everything and have hit a brick wall, any assistance would be greatly appreciated, thank you in advance. Please see below what I have so far...

#picaxe 20x2
symbol oled=b.7 ;the pin the data line to the OLED screen is on
symbol baud=N2400 ; the baud rate you send data to the screen
symbol home=128 ;leftmost position of line 1 of display
symbol base=192 ;leftmost position of line 2 of display
Symbol Left = pinB.6
Symbol Right = pinB.1

main:
serout oled,baud,(254,1): pause 30;clear OLED display
homescreen:
serout oled,baud,(254,home,"Home ");there are only 16 characters on each line
serout oled,baud,(254,base,"Page 1 ");there are only 16 characters on each line
if Left = 1 then
goto SecondScreen
endif
goto homescreen

SecondScreen:
serout oled,baud,(254,home,"welcome to ");there are only 16 characters on each line
serout oled,baud,(254,base,"Enter Back");there are only 16 characters on each line
pause 1000
if Right = 1 then
goto homescreen
endif
serout oled,baud,(254,home,"Page 1 please");there are only 16 characters on each line
pause 1000
if Right = 1 then
goto homescreen
endif
serout oled,baud,(254,home," Press Enter ");there are only 16 characters on each line
pause 1000
if Right = 1 then
goto homescreen
endif
goto SecondScreen

end; end of program statements
 

hippy

Ex-Staff (retired)
What you probably need to do is divide those 1000 millisecond pauses into smaller periods, say 100 milliseconds, and keep checking if the button is pushed ...

Code:
pause 1000
if Right = 1 then
  goto homescreen
endif
becomes ...

Code:
for b0 = 1 to 10
  pause 100
  if Right = 1 then
    goto homescreen
  endif
next
 
Top