|
Forum Index : Microcontroller and PC projects : Getting the mouse to work in the GUI
| Author | Message | ||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2189 |
Well guy's I am trying to get the mouse working in my first start on the pico 3 using MMBasic while I wait for the psram and wifi chips to arrive. With the new GUI for HDMI just getting a mouse going is my first step and this is my code so far OPTION EXPLICIT OPTION DEFAULT NONE option console serial gui cursor on colour rgb(grey), rgb(white) cls const topcaption= 1, btmcaption = 2, Memcar = 3, Memlog = 4, Memfin = 5 const topF = 6, list1 = 7 'fill = rgb(white) gui frame #1, "", 4, 4, 636, 30, rgb(grey) gui frame #2, "", 4, 450, 636, 30, rgb(grey) 'gui frame #topF, "", 4, 4, 636, 30, rgb(red) dim k$ dim club$(4) length 16 club$(0) = "Member Number" : club$(1) = "Member Name" :club$(2) = "Car" club$(3) = "Logbook Number" : club$(4) = "Status" gui listbox #list1, club$(), 5, 5, 200, 30, rgb(white), rgb(red) do k$ = Inkey$ If k$ <> "" Then ' Default step 4 px; if the key arrived shifted, MMBasic delivers ' a different code. Keep it simple: hold Shift-equivalent on PS/2 ' by using upper-case letters of D/U as "fast". stepx = 4 Select Case Asc(k$) Case &H82 ' LEFT mx = mx - Stepx Case &H83 ' RIGHT mx = mx + Stepx Case &H80 ' UP my = my - Stepx Case &H81 ' DOWN my = my + Stepx Case 32 ' SPACE -> momentary click GUI Click mx, my Case 100, 68 ' 'd' or 'D' -> press-and-hold If held = 0 Then GUI Cursor mx, my GUI Click Down held = 1 EndIf Case 117, 85 ' 'u' or 'U' -> release If held = 1 Then GUI Click Up held = 0 EndIf Case 27, 113, 81 ' ESC / 'q' / 'Q' -> quit Exit Do End Select ' Clamp to screen. If mx < 0 Then mx = 0 If my < 0 Then my = 0 If mx > cw - 1 Then mx = cw - 1 If my > ch - 1 Then my = ch - 1 GUI Cursor mx, my endif pause 1000 loop sub touchdown local integer tx, ty tx = touch(x) : ty = touch(y) if not (tx = -1 or ty = -1) then gui cursor tx, ty ' mx = tx : my = ty endif Now looking on search I did see the mouse option and I put the mouse dongle in the usb hub which works in edit but sadly not in my code. > option mouse sensitivity 1.0000 > Mouse Type: Gaming 16-bit X/Y bits: 16/16 Buttons: 5 Report length: 7 bytes Has wheel: Yes (byte 5) Has pan: No USB Mouse Connected on channel 2 > US USB Keyboard Connected on channel 1 > option list PicoMiteHDMI MMBasic USB RP2350B Edition V6.03.00 OPTION SERIAL CONSOLE COM2,GP8,GP9 OPTION SYSTEM I2C GP20,GP21 OPTION FLASH SIZE 16777216 OPTION COLOURCODE ON OPTION MOUSE SENSITIVITY 1.0000 OPTION KEYBOARD US OPTION PICO OFF OPTION RESOLUTION 640x480 @ 315000KHz OPTION HDMI PINS 1, 3, 5, 7 OPTION GUI CONTROLS 75 OPTION SDCARD GP33, GP30, GP31, GP28 OPTION AUDIO I2S GP10,GP22', ON PWM CHANNEL 11 OPTION RTC AUTO ENABLE OPTION COUNT GP34,GP35,GP36,GP37 OPTION MODBUFF ENABLE 512 OPTION PLATFORM PICO COMPUTER 3 OPTION HEARTBEAT PIN GP25 |
||||
| mozzie Guru Joined: 15/06/2020 Location: AustraliaPosts: 407 |
G'day Bryan, I think the command you are looking for is: GUI CURSOR LINK MOUSE That should get it working with a bit of luck The PCB's arrived Monday, now I just need to find time to tinker with them. Thanks again. Regards, Lyle. |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2189 |
Nope that didn't work now I used the code from the Advanced Graphic's Manual which I got off Peter's github site and it is dated to 2015 where the GUI Cursor on is used. Now using that code an arrow is displayed at the centre of the screen which is static so I did try using the arrow keys only to find [64] GUI Cursor mx, my Error : -1 is invalid (valid is 0 to 639) So copying code from the manual has got me again Also I'm going to get back my pico 2 as trying to play a mp.3 on this pico 3 in both micropython and MMBasic won't work where when I tried morning in MMBasic get a heap memory error when I tried a MP.3 where with the pico 2 it just worked. Edited 2026-07-23 17:09 by Bryan1 |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4361 |
Are you by accident looking at CMM2 manual or the like instead of PicoMite manual? John |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 3331 |
That is well before the PicoMite. Latest PicoMite V6.03.00 firmware package on Geoff's site has Advanced Graphics Functions.pdf in the Extra Documentation folder. And there is the Keyboard/Mouse/Gamepad chapter in the main manual. Edited 2026-07-23 18:33 by phil99 |
||||
| mozzie Guru Joined: 15/06/2020 Location: AustraliaPosts: 407 |
Hi Bryan, You may just be over-thinking it, the GUI system looks after most of the mouse stuff. Just tried this and it works on the Pico Computer 3 received Monday. RESET Pico first to clear previous stuff in memory then at prompt: GUI CURSOR LINK MOUSE GUI CURSOR ON And now the cursor is moving around the screen with the mouse Regards, Lyle. |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2189 |
First with that Advanced Graphics Manual I downloaded it off the github to get the newest version. I went and grabbed my pico 2 so I can try both tomorrow. Thanks for that tip Lyle and it's the first thing I'll do in the morning now mate could you try playing a mp.3 to see if you get that heap error,Regards Bryan |
||||
| mozzie Guru Joined: 15/06/2020 Location: AustraliaPosts: 407 |
Hi Bryan, Tried playing 196kbps MP3 from FM and command prompt and both working fine from SDCard, not sure why you are having trouble, our option list is almost the same. I normally disable the MODBUFF as I have the game playing skill of a Sloth crossed with a Hippo but testing with it enabled makes no difference. Perhaps try a flash-nuke / reflash and see if it makes a difference. Also MP3 playback uses 81kb of memory and GUI controls use a bit as well, maybe PSRAM will help? (none fitted on this board) Regards, Lyle. Edited 2026-07-24 02:14 by mozzie |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2189 |
Just looked at the update from Mouser and the psram and wifi chips should be here on Monday so not long I will do a flash nuke and try again this morning, now for a laugh yesterday I tried loading up a JPG only to find the error progressive JPG's are not supported so tried a BMP of one of the scope pic's not realizing it was 1.27mB put it on at 3.30pm and at 3.45pm about 30% of the screen was done so did a reset. |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2189 |
Well had a session with Claude and it went down the non GUI route where it is keyboard input and ran out of my time limit for 5 hours so I will try and again later as when I asked for a photo to be attached went over my quota.carclub_checkin.zip Regards Bryan |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2189 |
Well downloaded over 75 car JPg's and for the first reduced the size to 640x480 to reduce the file size to 68KB and got this error A:/ <DIR> . <DIR> .. 00:00 00-00-1980 46 .fm 10:00 24-07-2026 4 bootcount 14:03 24-07-2026 296 MEMBERS.CSV 2 directories, 3 files, 14467072 bytes free > xmodem recieve Error : Not enough memory > A:/ Error : Invalid syntax > <DIR> . 0 > <DIR> .. 0 > 00:00 00-00-1980 46 .fm 0 Error : Expression syntax > 10:00 24-07-2026 4 bootcount 10 Error : Expression syntax > 14:03 24-07-2026 296 MEMBERS.CSV 14 Error : Expression syntax > 2 directories, 3 files, 14467072 bytes free Error : Expression syntax > > xmodem recieve Error : Expression syntax > Error : Not enough memory So may try a nuke/reflash and try again Edited 2026-07-24 14:42 by Bryan1 |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2189 |
Well just paid for 12 months with Claude and when I get a thought the answer is there, I have done this so I can get this car club project done where in the chat it was said where I asked when a member brings up a phone how can we get the jpg across and is MMBasic or Micropyton the best. Well the answer was micro python hands down with the wifi like when I asked for the best way to get a picture from a members phone the wifi can act an acces point but to render the pic to suit the OS a new pyton app needs to be made to handle this so I have paused this project until I can get the psram and wifi chips on But the future is looking good as when I get a thought it can be put to code. Regards Bryan |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4361 |
Not sure it matters, but RECIEVE should be RECEIVE John |
||||
Bryan1![]() Guru Joined: 22/02/2006 Location: AustraliaPosts: 2189 |
deleted Edited 2026-07-26 10:13 by Bryan1 |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |