Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Trouble changing pages
Author | Message | ||||
skyv Newbie Joined: 14/03/2015 Location: AustraliaPosts: 14 |
Hi All I'm using an MM+ (5.04.04) with 7" display and want to change between pages. I've read the manual and the below code is my reading of it. When I select AA, it should change to page 2 but goes to blank screen. LL on page 2 should return to page 1. I'm obviously misreading the manual . Any pointers in the right direction would be appreciated. Code below. Thanks Laz K..... [code] CLS Option explicit Const AA=7 Const BB=8 Const CC=9 Const DD=10 Const EE=11 Const FF=12 Const GG=13 Const HH=14 Const II=15 Const JJ=16 Const KK=17 Const LL=18 Const MM=19 Const NN=20 Const OO=21 GUI setup 1 CLS GUI interrupt pendown Font #4:Colour RGB(blue) GUI displaybox #2, 250,20,300,100 GUI caption #3,"Test ",300,32 GUI caption #4,"1",350,73 GUI button #7,"AA",50,200,120,90,RGB(RED),RGB(BROWN) GUI BUTTON #8,"BB",300,200,120,90,RGB(RED),RGB(BLUE) GUI BUTTON #9,"CC",550,200,120,90,RGB(RED),RGB(GREEN) Do:Loop GUI setup 2 CLS GUI interrupt pendown GUI button #10,"DD",50,5,110,80,RGB(white),RGB(green) GUI button #11,"EE",350,10,110,80,RGB(white),RGB(green) GUI button #12,"FF",50,140,110,80,RGB(white),RGB(brown) GUI button #13,"GG",350,140,110,80,RGB(white),RGB(brown) GUI button #14,"HH",50,270,110,80,RGB(white),RGB(blue) GUI button #15,"II",350,270,110,80,RGB(white),RGB(blue) GUI button #16,"JJ",50,400,110,80,RGB(white),RGB(100,120,128) GUI button #17,"KK",350,400,110,80,RGB(white),RGB(100,220,128) GUI button #18,"LL",650,400,110,80,RGB(white),RGB(red) GUI led #19,"MM",700,50,20,RGB(red) GUI led #20,"NN",700,180,20,RGB(red) GUI led #21,"OO",700,300,20,RGB(red) Do:Loop Sub pendown Select Case Touch(ref) Case AA Page 2 Case BB Page 1 Case CC Page 1 Case LL Page 2 End Select End Sub |
||||
GoodToGo! Senior Member Joined: 23/04/2017 Location: AustraliaPosts: 188 |
Ok, Had a crack at this. First of all, below is your code with some corrections:- CLS Option explicit Const AA=7 Const BB=8 Const CC=9 Const DD=10 Const EE=11 Const FF=12 Const GG=13 Const HH=14 Const II=15 Const JJ=16 Const KK=17 Const LL=18 Const MM=19 Const NN=20 Const OO=21 GUI setup 1 GUI interrupt pendown Font #4:Colour RGB(blue) GUI displaybox #2, 250,20,300,100 GUI caption #3,"Test ",300,32 GUI caption #4,"1",350,73 GUI button #7,"AA",50,200,120,90,RGB(RED),RGB(BROWN) GUI BUTTON #8,"BB",300,200,120,90,RGB(RED),RGB(BLUE) GUI BUTTON #9,"CC",550,200,120,90,RGB(RED),RGB(GREEN) GUI setup 2 GUI interrupt pendown GUI button #10,"DD",50,5,110,80,RGB(white),RGB(green) GUI button #11,"EE",350,10,110,80,RGB(white),RGB(green) GUI button #12,"FF",50,140,110,80,RGB(white),RGB(brown) GUI button #13,"GG",350,140,110,80,RGB(white),RGB(brown) GUI button #14,"HH",50,270,110,80,RGB(white),RGB(blue) GUI button #15,"II",350,270,110,80,RGB(white),RGB(blue) GUI button #16,"JJ",50,400,110,80,RGB(white),RGB(100,120,128) GUI button #17,"KK",350,400,110,80,RGB(white),RGB(100,220,128) GUI button #18,"LL",650,400,110,80,RGB(white),RGB(red) GUI led #19,"MM",700,50,20,RGB(red) GUI led #20,"NN",700,180,20,RGB(red) GUI led #21,"OO",700,300,20,RGB(red) 'Main Program Do 'Stuff Loop 'Subroutines Sub pendown Select Case Touch(ref) Case AA print "AA touched" 'Prints to console to show which button pressed Page 2 Case BB print "BB touched" 'Prints to console to show which button pressed Page 1 Case CC print "CC touched" 'Prints to console to show which button pressed Page 2 Case LL print "LL touched" 'Prints to console to show which button pressed Page 1 'Fixed this up to point back to Page 1. End Select End Sub So, the GUI Setups only need to be run once, they don't need to form part of the Main loop, nor do they need stuff like CLS in them. Sometimes it's handy to place them all in a subroutine somewhere need the end of your code and call the subroutine during the initialisation of your program. (eg. Create a Sub called "SetupGUIPages" and call it after your CONST statements) When you call the "PAGE x" command, it automatically 'HIDES' all the GUI controls currently on display and then 'SHOWS' the PAGE you call. So no need to have CLS before or after a PAGE x command. (And it doesn't need them in the GUI Setups because of this.) I added some 'PRINT' statements so I could see what was happening on the Console. That's when I realised that there was no call to go back to Page 1 once Page 2 was displayed. (BB is on Page 1 so calls itself, LL is on Page and was calling itself.) Try that for starters and see how you go. Cheers, GTG! ...... Don't worry mate, it'll be GoodToGo! |
||||
GoodToGo! Senior Member Joined: 23/04/2017 Location: AustraliaPosts: 188 |
And taking it a step further to incorporate your constants and placing the GUI SETUPS in their own Subroutine..... CLS Option explicit Const AA=7 Const BB=8 Const CC=9 Const DD=10 Const EE=11 Const FF=12 Const GG=13 Const HH=14 Const II=15 Const JJ=16 Const KK=17 Const LL=18 Const MM=19 Const NN=20 Const OO=21 SetupGuiPages 'Main Program Do 'Stuff Loop 'Subroutines Sub Pendown Select Case Touch(ref) Case AA print "AA touched" Page 2 Case BB print "BB touched" Page 1 Case CC print "CC touched" Page 2 Case LL print "LL touched" Page 1 End Select End Sub sub SetupGuiPages GUI setup 1 GUI interrupt Pendown Font #4:Colour RGB(blue) GUI displaybox #2, 250,20,300,100 GUI caption #3,"Test ",300,32 GUI caption #4,"1",350,73 GUI button AA,"AA",50,200,120,90,RGB(RED),RGB(BROWN) GUI BUTTON BB,"BB",300,200,120,90,RGB(RED),RGB(BLUE) GUI BUTTON CC,"CC",550,200,120,90,RGB(RED),RGB(GREEN) GUI setup 2 GUI interrupt pendown GUI button DD,"DD",50,5,110,80,RGB(white),RGB(green) GUI button EE,"EE",350,10,110,80,RGB(white),RGB(green) GUI button FF,"FF",50,140,110,80,RGB(white),RGB(brown) GUI button GG,"GG",350,140,110,80,RGB(white),RGB(brown) GUI button HH,"HH",50,270,110,80,RGB(white),RGB(blue) GUI button II,"II",350,270,110,80,RGB(white),RGB(blue) GUI button JJ,"JJ",50,400,110,80,RGB(white),RGB(100,120,128) GUI button KK,"KK",350,400,110,80,RGB(white),RGB(100,220,128) GUI button LL,"LL",650,400,110,80,RGB(white),RGB(red) GUI led MM,"MM",700,50,20,RGB(red) GUI led NN,"NN",700,180,20,RGB(red) GUI led OO,"OO",700,300,20,RGB(red) end sub Have fun! GTG ...... Don't worry mate, it'll be GoodToGo! |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3165 |
Wow GTG, that is a great analysis. Geoff Geoff Graham - http://geoffg.net |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9066 |
Yes, our GTG is coming along famously with the GUI work - keep it up, my man! I'm not sure I would bother putting the GUI INTERRUPT's inside the GUI setup pages, but I guess it does no harm? IE: I would switch the GUI Interrupts off and on as needed within the main loop, not within the setup routines - but that is just me. Oh, and welcome aboard, skyv. Smoke makes things work. When the smoke gets out, it stops! |
||||
skyv Newbie Joined: 14/03/2015 Location: AustraliaPosts: 14 |
Thanks all for the help especially GoodToGo! I've tried the code and works exactly as I want so now I'm ready to expand it and move on to the next part. Thanks again laz K..... |
||||
Print this page |