Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 19:22 06 May 2024 Privacy Policy
Jump to

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 : Advice on GUI PAGE Command

Author Message
martrogers
Newbie

Joined: 15/09/2019
Location: Australia
Posts: 11
Posted: 07:58pm 27 Feb 2024
Copy link to clipboard 
Print this post

Hello All

I am coding a calendar type device using a Picomite, ILI9341 and MMBasic 5.08.00.

All goes well in sub rel_entry first time round the loop but second time when GUI PAGE 2 is called nothing is drawn on the screen. So I know that GUI PAGE 2 is a permitted screen but don’t know why it will not draw multiple times.

I would appreciate some advice on what I’ve done wrong, apologies for the unprofessional code.

Regards
Martin

'1-22 elements used
 OPTION EXPLICIT
 OPTION DEFAULT NONE
 
 dim integer PDnEf, PUpEf, hourx, dayx, weekx, monthx, choose1
 dim integer exit_flag, eflag
 
 GUI interrupt penDown, penUp
 
 gui beep 300  'click on screen input
 
 cls
 const Enter_new=1 ' button names, so button #1 is called Enter_new
 const Up=2
 const Down=3
 const set_months =4
 const set_weeks =5
 const set_days =6
 const set_hours =7
 const done =8
 const rel_box =9
 const hourxx =10
 const dayxx=11
 const weekxx=12
 const monthxx=13
 const yearxx=14
 CONST abs_box =15
 
 gui SETUP 1   ' screen 1
 font #3     'large font
 gui button Enter_new, "Enter New",0,190,155,50, rgb(black),rgb(lightgrey)
 gui button Up, "Up", 170,190,50,50, rgb(black),rgb(pink)
 gui button Down, "Down", 240,190,80,50, rgb(black),rgb(gold)
 
 gui SETUP 2
 font #3
 gui displaybox rel_box,10,0,300,50,rgb(BLACK), RGB(BLUE)
 CtrlVal(rel_box)="Time to Alarm"
 gui button set_hours, "Hours",15,55,120,50, rgb(black),rgb(lightgrey)
 gui button set_days, "Days",15,125,120,50, rgb(black),rgb(lightgrey)
 gui button set_weeks, "Weeks",180,55,120,50, rgb(black),rgb(lightgrey)
 gui button set_months, "Months",180,125,120,50, rgb(black),rgb(lightgrey)
 gui button done, "Done",70,190,200,50, rgb(black),rgb(gold)
 
 gui SETUP 3
 font #1
 gui formatbox 15, DATETIME1, 170,100, 150,50,rgb(black),rgb(yellow)
 
 gui SETUP 4
 font #3
 gui displaybox 16,10,0,300,50,rgb(BLACK), RGB(BLUE)
 CtrlVal(16)="Repeating?"
 gui button 17, "Daily",1,60,150,50, rgb(black),rgb(beige)
 gui button 18, "Weekly",1,120,150,50, rgb(black),rgb(beige)
 gui button 19, "Monthly",1,180,150,50, rgb(black),rgb(beige)
 gui button 20, "Yearly",150,60,150,50, rgb(black),rgb(beige)
 gui button 21, "Custom",150,120,150,50, rgb(black),rgb(salmon)
 gui button 22, "None",150,180,150,50, rgb(black),rgb(gold)
 
 gui setup 5
 font #3
 gui numberbox hourxx,200,100,120,50,rgb(black),rgb(yellow)
 
 gui setup 6
 font #3
 gui numberbox dayxx, 200, 100, 120, 50, rgb(black), rgb(yellow)
 
 gui setup 7
 font #3
 gui numberbox weekxx, 200, 100, 120, 50, rgb(black), rgb(yellow)
 
 gui setup 8
 font #3
 gui numberbox monthxx, 200, 100, 120, 50, rgb(black), rgb(yellow)
 
 do
   select case TOUCH(REF)  ' will return 1 if button 1 is touched, 2 for button 2 etc
       '
     case Enter_new   ' Enter_new button touched
       ''new_entry       'subroutine for this touch
       cls
       font #2
       ' display screen asking absolute or relative entry
       choose1 =MsgBox("Absolute or Relative Alarm~ Abs e.g 10 May 3:30PM~Rel e.g 5 days,10 hrs","Abs","Rel","Exit")
       select case choose1
         case 1
           abs_entry   'absolute date
         case 2        'relative time (timer)
           rel_entry
       end select
       '
       'case Up
       'scroll_up
       'case Down
       'scroll_down
       
   end select
 loop
 
 
sub rel_entry
 exit_flag=0
 do            'keep returning to this screen to allow Weeks + Days+ Hours etc to be input
   eflag=0
   print "at Page 2"
   pause 700
   cls
   gui redraw all
   gui page 2   ' hrs, days, weeks, months, done buttons
   gui redraw all
   print "past Page 2"
   do
     select case TOUCH(REF)  ' will return 1 if button 1 is touched, 2 for button 2 etc
         
       case 7 ' Hours selected, input number of hours
         cls
         gui page 5
         CtrlVal(hourxx) = "##Hours"
         'print "Hours selected"
         do
           if PDnEf=1 then   'input box touched
             PDnEf=0
             hourx=ctrlval(hourxx)
           end if
           if PUpEf=1 then ' numbers entered and ENT touched, ENT generates a Pen Up interrupt
             PUpEf=0
             hourx=ctrlval(hourxx) 'numbers pressed
             if hourx>0 then
               eflag=1
               exit do
             endif
           end if
         loop
         print "hours" hourx
         
       case 6 'Days
         cls
         gui page 6
         CtrlVal(dayxx) = "##Days"
         print "Days selected"
         do
           if PDnEf=1 then   'input box touched
             PDnEf=0
             dayx=ctrlval(dayxx)
           end if
           if PUpEf=1 then ' numbers entered and ENT touched, ENT generates a Pen Up interrupt
             PUpEf=0
             dayx=ctrlval(dayxx) 'numbers pressed
             if dayx>0 then
               eflag=1
               exit do
             endif
           end if
         loop
         print "days " dayx
         
       case 5 'Weeks
         cls
         gui page 7
         CtrlVal(weekxx) = "##Weeks"
         print "Weeks selected"
         do
           if PDnEf=1 then   'input box touched
             PDnEf=0
             weekx=ctrlval(weekxx)
           end if
           if PUpEf=1 then ' numbers entered and ENT touched, ENT generates a Pen Up interrupt
             PUpEf=0
             weekx=ctrlval(weekxx) 'numbers pressed
             if weekx>0 then
               eflag=1
               exit do
             endif
           end if
         loop
         print "weeks " weekx
         
       case 4 'Months
         cls
         gui page 8
         CtrlVal(monthxx) = "##Months"
         print "Months selected"
         do
           if PDnEf=1 then   'input box touched
             PDnEf=0
             monthx=ctrlval(monthxx)
           end if
           if PUpEf=1 then ' numbers entered and ENT touched, ENT generates a Pen Up interrupt
             PUpEf=0
             monthx=ctrlval(monthxx) 'numbers pressed
             if monthx>0 then
               eflag=1
               exit do
             endif
           end if
         loop
         print "Months " monthx
         
       case 8  'Done
         'store value as a forward DTG to file
         eflag=1
         exit_flag=1
         
         
     end select
     
   loop while eflag=0
   
   print "select ended" eflag
   if exit_flag =1 then  'all done
     exit sub
   endif
   
 loop
end sub
 
 
sub abs_entry
 gui Page 3
 do
   if PDnEf=1 then   'input box touched
     PDnEf=0
     dtg$=ctrlval(15)
   end if
   if PUpEf=1 then ' numbers entered and ENT touched, ENT generates a Pen Up interrupt
     PUpEf=0
     dtg$=ctrlval(15) 'numbers pressed
     if dtg$<>"" then
       'eflag=1
       exit do
     endif
   end if
 loop
 gui page 4
end sub
 
sub penDown
 PDnEf=1
return
end sub
 
sub penUp
 PuPEf=1
return
end sub
 
end

 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 03:40am 28 Feb 2024
Copy link to clipboard 
Print this post

The GUI PAGE command does work and I'm not sure what you mean by "it will not draw multiple times".  Perhaps you are expecting it to do something other than its intended function?

Your example code does not help as it is way too big to reverse engineer.  If you could cut it down to just a few lines (<10) that demonstrates just your problem the answer might become obvious.

Geoff
Geoff Graham - http://geoffg.net
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5914
Posted: 04:00am 28 Feb 2024
Copy link to clipboard 
Print this post

It would also help if you told us your OPTIONs


It does look like you are doing a CLS while you are still on PAGE 2 (in a number of places).
I am the last person to give advice on GUI programming, but that doesn't look right.

Jim
Edited 2024-02-28 14:31 by TassyJim
VK7JH
MMedit   MMBasic Help
 
martrogers
Newbie

Joined: 15/09/2019
Location: Australia
Posts: 11
Posted: 09:27am 28 Feb 2024
Copy link to clipboard 
Print this post

TassyJim

Thanks for this, you were correct, for some reason it dosent like a CLS before a GUI PAGE. A CLS is not needed anyway because the previous page is hidden by the new GUI PAGE command.

Martin
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1379
Posted: 10:54pm 28 Feb 2024
Copy link to clipboard 
Print this post

FYI: On the rare occasion that you might need to use CLS, simply switch to a dummy page number first before using CLS.
It's all too hard.
Mike.
 
martrogers
Newbie

Joined: 15/09/2019
Location: Australia
Posts: 11
Posted: 09:25am 02 Apr 2024
Copy link to clipboard 
Print this post

Thanks Mike

I've RTFM and on page 71 it says that a CLS also does a GUI HIDE ALL . The CLS now works as I had expected by my issuing a GUI SHOW ALL after the CLS.
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1133
Posted: 11:21am 02 Apr 2024
Copy link to clipboard 
Print this post

  martrogers said  sub penDown
 PDnEf=1
return
end sub

Just one question: what is RETURN for?

Regards
Michael
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 11:43am 02 Apr 2024
Copy link to clipboard 
Print this post

  twofingers said  Just one question: what is RETURN for?


Yeah, you don't want to be doing a RETURN in MMBasic unless you are using a legacy GOSUB call. Instead either flow through to END SUB or return early with EXIT SUB. I'm surprised it isn't all "exploding horribly" in the current state.

Best wishes,

Tom
Edited 2024-04-02 21:44 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1799
Posted: 11:44am 02 Apr 2024
Copy link to clipboard 
Print this post

Manual, Obsolete Commands and Functions.
  Quote  RETURN
RETURN concludes a subroutine called by GOSUB and returns to the
statement after the GOSUB.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024