Menu
JAQForum Ver 19.10.27

Forum Index : Microcontroller and PC projects : PicoMite V6.01.00 betas

   Page 8 of 12    
Posted: 02:53pm
21 Aug 2025
Copy link to clipboard
stanleyella
Guru


Don't you have to put gui controls in a program?
 cls
'define touch areas  
 gui area 1,0,199,80,40 ':line 0,239,80,239,rgb(blue)'left button
 gui area 2,140,199,80,40 ':line 140,239,220,239,rgb(blue)'right button
 gui area 3,279,40,40,80 ':line 319,40,319,120,rgb(blue)'up button
 gui area 4,279,159,40,80 ':line 319,179,319,239,rgb(blue)'down button
 
Posted: 03:18pm
21 Aug 2025
Copy link to clipboard
Volhout
Guru

At Ville56,

Confirmed. OPTION GUI CONTROLS X kills MMBasic V6.01.00b9.

Volhout
Edited 2025-08-22 01:26 by Volhout
 
Posted: 04:42pm
21 Aug 2025
Copy link to clipboard
stanleyella
Guru


Confirmed. OPTION GUI CONTROLS 4 kills MMBasic V6.01.00b8. as well rpi 2350A
had to flash clear_flash to flash b7 until it's fixed. found flash_nuke.. what's that?
Edited 2025-08-22 03:32 by stanleyella
 
Posted: 06:34pm
21 Aug 2025
Copy link to clipboard
matherp
Guru

Should be fixed


PicoMiteV6.01.00b10.zip
 
Posted: 06:41pm
21 Aug 2025
Copy link to clipboard
ville56
Senior Member

Thanks Peter, it works now as expected.
 
Posted: 07:20pm
21 Aug 2025
Copy link to clipboard
stanleyella
Guru


It accepts option gui controls n now. thanks, what/when it happened?

PicoMite MMBasic USB RP2350A Edition V6.01.00b10
OPTION SERIAL CONSOLE COM2,GP8,GP9
OPTION SYSTEM SPI GP18,GP19,GP16
OPTION FLASH SIZE 4194304
OPTION COLOURCODE ON
OPTION KEYBOARD UK
OPTION CPUSPEED (KHz) 378000
OPTION LCDPANEL CONSOLE
OPTION DISPLAY 20, 40
OPTION LCDPANEL ILI9341, LANDSCAPE,GP15,GP14,GP13
OPTION GUI CONTROLS 4
OPTION TOUCH GP12,GP11
GUI CALIBRATE 0, 3900, 3816, -886, -658
OPTION SDCARD GP22
OPTION AUDIO GP0,GP1', ON PWM CHANNEL 0
Edited 2025-08-22 05:22 by stanleyella
 
Posted: 10:03pm
21 Aug 2025
Copy link to clipboard
stanleyella
Guru


A simple tron game for ili9341 using screen area for left,right,up,down but the box draw to show where the button areas were is commented out because the touch stopped working??
'option gui control 4 is needed in option list
 OPTION EXPLICIT
 OPTION DEFAULT NONE
 OPTION DEFAULT INTEGER
 OPTION BASE 1 'arrays start at 1
 option autorun on
 dim px,py,pdx,pdy
 dim cx(3),cy(3),cdx(3),cdy(3),cpa(3)
 dim ts,tr,csc=0,psc=0,cm
 
 cls
'define touch areas  
 gui area 1,0,199,80,40 ':line 0,239,80,239,rgb(blue)'left button
 gui area 2,140,199,80,40 ':line 140,239,220,239,rgb(blue)'right button
 gui area 3,279,40,40,80 ':line 319,40,319,120,rgb(blue)'up button
 gui area 4,279,159,40,80 ':line 319,179,319,239,rgb(blue)'down button

'draw direction buttons... stops touch working
 'box 0,199,80,40,3,rgb(white),rgb(blue)'left button
 'box 140,199,80,40,3,rgb(white),rgb(blue)'right button
 'box 279,40,40,80,3,rgb(white),rgb(blue) 'up button
 'box 279,159,40,80,3,rgb(white),rgb(blue)'down button
 'do
  'tr=TOUCH(REF)
 'loop until tr>0
 'pause 5000
 'cls
do
'init players start positions
 px=260:py=rnd*120+60:pdx=-1:pdy=0
 cx(1)=rnd*100+80:cy(1)=50:cdx(1)=0:cdy(1)=1:cpa(1)=1
 cx(2)=rnd*100+80:cy(2)=190:cdx(2)=0:cdy(2)=-1:cpa(2)=1
 cx(3)=rnd*50+50:cy(3)=rnd*80+80:cdx(3)=1:cdy(3)=0:cpa(3)=1
 
'draw play area & 4 random triangles on border
 box 0,0,319,239,1,rgb(white),rgb(black)
 ts=rnd*160+40
 triangle 0,ts,12,ts+8,0,ts+16,rgb(White)
 ts=rnd*160+40
 triangle 319,ts,307,ts+8,319,ts+16,rgb(White)
 ts=rnd*240+40
 triangle ts,0,ts+8,10,ts+16,0,rgb(White)
 ts=rnd*240+40
 triangle ts,239,ts+8,228,ts+16,239,rgb(White)
 line 0,239,80,239,1,rgb(blue)'left button
 line 140,239,220,239,1,rgb(blue)'right button
 line 319,40,319,120,1,rgb(blue)'up button
 line 319,179,319,239,1,rgb(blue)'down button
 'main
 do
'check user button pressed
   tr=TOUCH(REF)
   if tr>0 then
     select case tr
       case 1 'left pressed
         if pdx=0 then pdy=0:pdx=-1
       case 2 'right pressed
         if pdx=0 then pdy=0:pdx=1
       case 3 'up pressed
         if pdy=0 then pdx=0:pdy=-1
       case 4 'down pressed
         if pdy=0 then pdx=0:pdy=1
     end select
   end if
   px=px+pdx:py=py+pdy
'has player crashed  
   if pixel (px,py) >0 then 'player crashed
     box 0,0,319,239,1,rgb(white),rgb(black)
     text 60,100,"You Lost",l,5:pause 5000:exit do
   end if
   pixel px,py,rgb(magenta)      
'computer move
   for cm=1 to 3
     if cpa(cm)=1 then
       if cdx(cm)<>0 then
         if pixel (cx(cm)+cdx(cm),cy(cm)) >0 then
           cdx(cm)=0:cdy(cm)=(py>cy(cm))-(py<cy(cm))
         end if
       else
         if pixel (cx(cm),cy(cm)+cdy(cm)) >0 then
           cdy(cm)=0:cdx(cm)=(px>cx(cm))-(px<cx(cm))
         end if
       end if  
       cx(cm)=cx(cm)+cdx(cm):cy(cm)=cy(cm)+cdy(cm)
 'has computer player crashed      
       if pixel (cx(cm),cy(cm)) >0 then
         cpa(cm)=0'computer crashed
         if cpa(1)+cpa(2)+cpa(3)=0 then 'all crashed
           box 0,0,319,239,1,rgb(white),rgb(black)
           text 70,100,"You Won",l,5:pause 5000:exit do
         end if
       end if
         pixel cx(cm),cy(cm),rgb(yellow)
     end if  
   next cm
   
   pause 50
 loop
 
 loop
 
Posted: 11:25pm
21 Aug 2025
Copy link to clipboard
stanleyella
Guru


I don't know why drawing over gui area stops touch working as above tron
 
Posted: 07:32am
22 Aug 2025
Copy link to clipboard
Volhout
Guru

@Peter,

There is no RP2040 non VGA non USB version in this b10 zip (used in Game*Mite).
In the b9 zip there was no 2040+VGA+USB version included.

This is purely based on the filenames...

Volhout
Edited 2025-08-22 17:36 by Volhout
 
Posted: 07:48am
22 Aug 2025
Copy link to clipboard
matherp
Guru

 
Posted: 09:24am
22 Aug 2025
Copy link to clipboard
ville56
Senior Member

@stanleyella:

I think it has nothing to do with the BOX statements ... the following code (the first part of your code) runs and touch reacts and has the BOX enabled. Just added the print and pause to see what happens. The problem must be somwhere else ....


OPTION EXPLICIT
OPTION DEFAULT NONE
OPTION DEFAULT INTEGER
OPTION BASE 1 'arrays start at 1
option autorun on
dim px,py,pdx,pdy
dim cx(3),cy(3),cdx(3),cdy(3),cpa(3)
dim ts,tr,csc=0,psc=0,cm

cls
'define touch areas  
gui area 1,0,199,80,40 ':line 0,239,80,239,rgb(blue)'left button
gui area 2,140,199,80,40 ':line 140,239,220,239,rgb(blue)'right button
gui area 3,279,40,40,80 ':line 319,40,319,120,rgb(blue)'up button
gui area 4,279,159,40,80 ':line 319,179,319,239,rgb(blue)'down button

'draw direction buttons... stops touch working
box 0,199,80,40,3,rgb(white),rgb(blue)'left button
box 140,199,80,40,3,rgb(white),rgb(blue)'right button
box 279,40,40,80,3,rgb(white),rgb(blue) 'up button
box 279,159,40,80,3,rgb(white),rgb(blue)'down button
do
 tr=TOUCH(REF)
 if tr>0 then print tr
 pause 100

loop 'until tr>0
'pause 5000
'cls
 
Posted: 03:32pm
22 Aug 2025
Copy link to clipboard
stanleyella
Guru


@ville56 I know
do
tr=TOUCH(REF)
loop until tr>0
works after drawing boxes. touch any and game starts but touch doesn't work.
no boxes and game works with touch. strange.
regards stan
 
Posted: 03:36pm
22 Aug 2025
Copy link to clipboard
Mixtel90
Guru


try TOUCH(X) or TOUCH(Y) instead of TOUCH(REF)
 
Posted: 04:46pm
22 Aug 2025
Copy link to clipboard
stanleyella
Guru


Mick there's touch last x and touch last y
but no good for testing a control touched.
it's got me baffled
 
Posted: 04:53pm
22 Aug 2025
Copy link to clipboard
ville56
Senior Member

Stan, I've played around a bit and found out that the CLS may be the showstopper ....

try the following code


OPTION EXPLICIT
OPTION DEFAULT none
dim integer ts,tr,csc=0,psc=0,cm

cls
'define touch areas  
gui area 1,0,199,80,40 ':line 0,239,80,239,rgb(blue)'left button
gui area 2,140,199,80,40 ':line 140,239,220,239,rgb(blue)'right button
gui area 3,279,40,40,80 ':line 319,40,319,120,rgb(blue)'up button
gui area 4,279,159,40,80 ':line 319,179,319,239,rgb(blue)'down button

'draw direction buttons... stops touch working
box 0,199,80,40,3,rgb(white),rgb(blue)'left button
box 140,199,80,40,3,rgb(white),rgb(blue)'right button
box 279,40,40,80,3,rgb(white),rgb(blue) 'up button
box 279,159,40,80,3,rgb(white),rgb(blue)'down button
do
 tr=TOUCH(REF)
 if tr>0 then
   print tr
   pause 100
 end if
loop until tr>0

cls


do
 tr=TOUCH(REF)
 print tr
 pause 100
loop


If you comment out the red CLS, touch(ref) will work, if CLS is included touch(ref) will produce no return value >0 if box is touched.
I do have a slightly different setup (dsiplay), but running the same version of firmware and I suppose the issue (whatever it is) will be in all relevant variants.

Gerald
 
Posted: 05:54pm
22 Aug 2025
Copy link to clipboard
stanleyella
Guru


Hi Gerald, thanks for replying. I mentioned it cos it's a "problem" and indeed I thought the CLS position was a factor. using the advanced graphics pdf for info but cls  having effects not mentioned.
this draws boxes, waits for touch then starts game but touch not working
gui area 1,0,199,80,40 ':line 0,239,80,239,rgb(blue)'left button
 gui area 2,140,199,80,40 ':line 140,239,220,239,rgb(blue)'right button
 gui area 3,279,40,40,80 ':line 319,40,319,120,rgb(blue)'up button
 gui area 4,279,159,40,80 ':line 319,179,319,239,rgb(blue)'down button
'cls
'draw direction buttons
 box 0,199,80,40,3,rgb(white),rgb(blue)'left button
 box 140,199,80,40,3,rgb(white),rgb(blue)'right button
 box 279,40,40,80,3,rgb(white),rgb(blue) 'up button
 box 279,159,40,80,3,rgb(white),rgb(blue)'down button
 do
  tr=TOUCH(REF)
 loop until tr>0
 cls
do
'init players start positions

The idea was show buttons then erase as game uses areas not marked
Edited 2025-08-23 04:04 by stanleyella
 
Posted: 06:13pm
22 Aug 2025
Copy link to clipboard
ville56
Senior Member

I understand ... well, a GUI SHOW ALL after CLS makes it react again. I didn't look into the advanced graphics manual upfront .... so it seems that the effect is documented, but as we know, males do not read manuals  

Gerald
 
Posted: 07:06pm
22 Aug 2025
Copy link to clipboard
Mixtel90
Guru


According to the manual there's TOUCH(REF) which returns the number of the control currently being touched and TOUCH(LASTREF) which returns the number of the control last touched. There's no LAST X or LAST Y.

I suggested TOUCH(X) or TOUCH(Y) to make sure that touch is working and that your loop is working. They have nothing to do with GUI controls so aren't affected by it. Test from the bottom up. :)

.
Edited 2025-08-23 05:09 by Mixtel90
 
Posted: 07:12pm
22 Aug 2025
Copy link to clipboard
Mixtel90
Guru


Why not just draw buttons?
 
Posted: 08:11pm
22 Aug 2025
Copy link to clipboard
stanleyella
Guru


see CLS info... the answer?

Using Basic Drawing Commands
There are two types of objects that can be on the screen. These are the GUI controls and the basic drawing
objects (PIXEL, LINE, TEXT, etc). Mixing the two on the screen is not a good idea because MMBasic does
not track the position of the basic drawing objects and they can clash with the GUI controls.
As a result, unless you are prepared to do some extra programming, you should use either the GUI controls or
the basic drawing objects – but you should not use both. So, for example, do not use TEXT but use GUI
CAPTION instead. If you only use GUI controls MMBasic will manage the screen for you including erasing
and redrawing it as required, for example when a virtual keyboard is displayed.
PicoMite Advanced Graphics Page 15

Note that the CLS command (used to clear the screen) will automatically set any GUI controls on the screen to
hidden (i.e. it does a GUI HIDE ALL before clearing the screen).
 
   Page 8 of 12    
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025