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 : gui touch
Page 1 of 2 | |||||
Author | Message | ||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2135 |
Hi, sorry to bother you but trying gui area on ili9488 and errors. The ili9488 touch is calibrated and the touch test works. I get this error message using gui area 1,2,395,64,14 [17] GUI area 1,2,395,64,14'left button x y w h Error : No memory allocated for GUI controls I spent time reading the latest non vga manual but can't see allocating gui memory. Also would "loop until pixel px%,py%,1 >0" 'test if next pixel is not black work? triangle 2,312,66,305,66,319,rgb(yellow),rgb(blue) gui area 1,2,395,64,14'left button triangle 192,312,130,305,130,319,rgb(yellow),rgb(blue) gui area 2,192,395,64,14'right button triangle 471,2,479,66,464,66,rgb(yellow),rgb(blue) gui area 3,464,2,14,64'up button triangle 471,192,479,130,464,130,rgb(yellow),rgb(blue) gui area 4,464,192,14,64'down button dim px%=400,py%=int(rnd*200)+60,pdx%=-1,pdy%=0 dim cx%=60,cy%=int(rnd*200)+60,cdx%=-1,cdy%=0 do select case touch(ref) case 1'left button pressed if pdx%=0 then pdy%=0:pdx%=-1:end if case 2'right button pressed if pdx%=0 then pdy%=0:pdx%=1:end if case 3'up button pressed if pdy%=0 then pdx%=0:pdy%=-1:end if case 4'down button pressed if pdy%=0 then pdx%=0:pdy%=1:end if end select pause 500 pixel px%,py%,rgb(yellow)'plot new pixel px%=px%+pdx%:py%=py%+pdy% loop until pixel px%,py%,1 >0'test if next pixel is not black |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9139 |
Open the manual. Use the find function to look for text "GUI". Keep Stepping down the file until you find the answer - took me about 10 seconds Page 51 |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3816 |
You're asking about a pixel, so using a FUNCTION, whose return value you want. It would be wise, and may well be mandatory, to use some parentheses. More thinking, less bashing out code :) John Edited 2023-03-17 05:32 by JohnS |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2135 |
gui area 1,2,395,64,14 why the mmedit error? pixel x,y,colour simple'' to plot a pixel pixel x,y,page new.. to read a screen pixel |
||||
panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1101 |
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3816 |
Which page of the manual is that from? John Edited 2023-03-17 09:43 by JohnS |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2135 |
option gui controls 4 in teraterm seems to have sorted gui controls but says maximum is 3 not 4, so set option gui controls 10. pixel (x,y) >0 worked. getting there. Now computer opponent... done it before |
||||
Bowden_P Senior Member Joined: 20/03/2019 Location: United KingdomPosts: 162 |
Hi, I was interested to see how/whether Picomite's "GUI AREA" coped with a co-ordinate off-screen in Stanleyella's:- gui area 1,2,395,,64,14 Admittedly I have a Waveshare ILI9488W screen - 480 x 320 pixels, not stanleyella's exact model, but with :- > option gui controls 1 > gui area 1,2,395,64,14 Error : 1 is invalid (valid is 1 to 0) and :- > option gui controls 2 > gui area 1,2,395,64,14 Error : 395 is invalid (valid is 0 to 320) Error messaging seems a bit unhappy with the single control ! With best regards, Paul. p.s. I have PicoMite MMBasic Version 5.07.07b27 Nothing so constant as change. |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2135 |
Hi Pual. the same error , it was a typo. touch seems to like fingernails more than finger prints, touch supposed to be NOT like a phone touch screen. my first try on ili9488. maybe ili9341 better, will try triangle 2,312,66,305,66,319,rgb(yellow),rgb(blue) gui area 1,1,295,64,16 triangle 192,312,130,305,130,319,rgb(yellow),rgb(blue) gui area 2,128,295,64,16 triangle 471,2,479,66,464,66,rgb(yellow),rgb(blue) gui area 3,464,2,16,64 triangle 471,192,479,130,464,130,rgb(yellow),rgb(blue) gui area 4,464,130,16,64 |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6814 |
Touch on all the LCD displays supported by MMBasic is resistive, not capacitive. That's why you find it works better with fingernals than a finger. The bast way to use these displays is with a stylus (they are often supplied with one). When you want to test an area of the screen it's better to test for the X and Y edges of that rather than for a point. The GUI commands take this into account. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2135 |
Thanks all for helping me. I did read the manual but didn't get gui controls relevance my simple tron 'tron ili9488 OPTION EXPLICIT OPTION DEFAULT NONE cls box 0,0,463,303,1,rgb(white),rgb(black) dim ts% ts%=int(rnd*200)+60 triangle 0,ts%,12,ts%+8,0,ts%+16,rgb(White) ts%=int(rnd*200)+60 triangle 461,ts%,449,ts%+8,461,ts%+16,rgb(White) ts%=int(rnd*360)+60 triangle ts%,0,ts%+8,10,ts%+16,0,rgb(White) ts%=int(rnd*360)+60 triangle ts%,303,ts%+8,293,ts%+16,303,rgb(White) triangle 2,312,66,305,66,319,rgb(yellow),rgb(blue) gui area 1,1,295,64,16 triangle 192,312,130,305,130,319,rgb(yellow),rgb(blue) gui area 2,128,295,64,16 triangle 471,2,479,66,464,66,rgb(yellow),rgb(blue) gui area 3,464,2,16,64 triangle 471,192,479,130,464,130,rgb(yellow),rgb(blue) gui area 4,464,130,16,64 dim px%=400,py%=int(rnd*200)+60,pdx%=-1,pdy%=0 dim cx%=60,cy%=int(rnd*200)+60,cdx%=1,cdy%=0 do if pixel (px%,py%) >0 then end pixel px%,py%,rgb(yellow) px%=px%+pdx%:py%=py%+pdy% if TOUCH(REF) >0 then 'check user button pressed select case touch(ref) case 1 'left if pdx%=0 then pdy%=0:pdx%=-1 case 2 'right if pdx%=0 then pdy%=0:pdx%=1 case 3 'up if pdy%=0 then pdx%=0:pdy%=-1 case 4 'down if pdy%=0 then pdx%=0:pdy%=1 end select end if 'computer move if cdx%=-1 then if pixel (cx%-1,cy%) >0 then cdx%=0 if py%>cy% then cdy%=1 else cdy%=-1 end if end if else if cdx%=1 then if pixel (cx%+1,cy%) >0 then cdx%=0 if py%>cy% then cdy%=1 else cdy%=-1 end if end if else if cdy%=-1 then if pixel (cx%,cy%-1) >0 then cdy%=0 if px%>cx% then cdx%=1 else cdx%=-1 end if end if else if cdy%=1 then if pixel (cx%,cy%+1) >0 then cdy%=0 if px%>cx% then cdx%=1 else cdx%=-1 end if end if end if cx%=cx%+cdx%:cy%=cy%+cdy% if pixel (cx%,cy%) >0 then end pixel cx%,cy%,rgb(cyan) pause 50 loop |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1110 |
Looks fun... Because I can't help compressing code: ' computer move if cdx% then ' moving in x direction if pixel(cx%+cdx%) then ' move blocked cdx% = 0 cdy% = -1 + 2 * (py% > cy%) ' turn toward player endif else ' moving in y direction if pixel(cy%+cdy%) then ' move blocked cdy% = 0 cdx% = -1 + 2 * (px% > cx%) ' turn toward player endif endif cx%=cx%+cdx%:cy%=cy%+cdy% if pixel(cx%,cy%) > 0 then end ' computer can't move! pixel cx%,cy%,rgb(cyan) Visit Vegipete's *Mite Library for cool programs. |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2135 |
working on another algo I thought pixel needed x,y "if pixel(cx%+cdx%) then ' move blocked" ? pixel plotting page 111 pixel reading page 135 |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1110 |
You are right. I was sloppy. Should be: if pixel(cx%+cdx%,cy%) then ' move blocked andif pixel(cx%,cy%+cdy%) then ' move blocked Visit Vegipete's *Mite Library for cool programs. |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Just tried this using version b25 but it doesn't like GUI CONTROLS 4, it needs GUI CONTROLS 5 for some reason. > run [17] GUI area 1,1,295,64,16 Error : No memory allocated for GUI controls > option gui controls 4 > run [23] GUI area 4,464,130,16,64 Error : 4 is invalid (valid is 1 to 3) > option list PicoMite MMBasic Version 5.07.07b25 OPTION SYSTEM SPI GP18,GP19,GP20 OPTION SYSTEM I2C GP0,GP1 OPTION COLOURCODE ON OPTION DISPLAY 40, 100 OPTION LCDPANEL ILI9488, RLANDSCAPE,GP26,GP27,GP28 OPTION GUI CONTROLS 4 OPTION TOUCH GP22,GP21,GP5 GUI CALIBRATE 0, 254, 139, 1289, 841 OPTION SDCARD GP3 > option gui controls 5 > RUN > RUN ' running fine from here |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6814 |
As the amount of RAM used for GUI CONTROLS is rounded up to 2048 bytes anyway there's no point in specifying such low numbers. One control will require 2048 bytes as will 39 controls (39*52=2028 bytes). 40 controls will require 4096 bytes of RAM. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2135 |
@paceman That's the error I got. I thought the gui controls started at zero but don't. Mick- thanks for clearing that up. It's in the manual but option gui controls isn't really mentioned and the number of gui controls could be better explained imho. pixel page 111 and 135,why not same page? This is my first touch test and seems I'm not the only one who found it not as easy as it looks. I didn't want to ask the forum but I was getting errors I couldn't resolve. I can see why mechanical buttons are used and has anyone tried using resistors and buttons and one a-d input pin? Each button giving a different voltage when pressed. cheers, stan. Edited 2023-03-19 01:02 by stanleyella |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6814 |
In most cases I've had no problems with the Gui controls. They can get a bit awkward if you start to try to do odd things, but most of the time I've found them to be very good indeed. You do need to have a good play to get the most out of them. Above all, remember that when you use them everything is controlled by the user, not by your program. You mustn't go doing things that the user hasn't requested or you can get into an awful knot. Edited 2023-03-19 01:05 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2135 |
Hi Mick. I noticed cls after gui area disables them, probably says so somewhere. As you can't re dim or define gui area only once, I stuck it all at the start so I could restart the game in code and found moving cls after gui area disabled it. How to restart the game and use cls? dim px%,py%,pdx%,pdy% dim cx%,cy%,cdx%,cdy% dim ts%,tr% cls 'works here gui area 1,1,295,64,16 'left button gui area 2,128,295,64,16 'right button gui area 3,464,2,16,64 'up button gui area 4,464,130,16,64 'down button 'start 'cls 'disables gui area here |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6814 |
Do you need to CLS? Can you use GUI HIDE to hide all GUI controls and GUI SHOW to bring them back? You can also use GUI REDRAW if the screen has become corrupted. Then GUI SETUP n can set up controls on page n and you can swap them any time with GUI PAGE n. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Page 1 of 2 |
Print this page |