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 : PicoMite USB betas
Page 1 of 5 | |||||
Author | Message | ||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9115 |
Please find attached the first beta for the USB enabled version of the PicoMiteVGA PicoMiteVGAUSB.zip This supports USB keyboards, mouse, PS4 controller, PS3 controller and a generic (SNES) type gamepad The Pico must be powered with 5V on the VBUS pin and you can connect a USB-TTL converter as a console to pins 11 and 12 of the Pico (GP8=TX and GP9=RX) A maximum of 4 devices may be connected at any one time. These are reference by an channel index number (1-4). Use MM.INFO(USB n) to return the device code for any device connected to channel n. Returns are: 0=not in use, 1=keyboard, 2=mouse, 128=ps4, 129=ps3, 130=SNES/Generic You should be able to use more than one of any of the controllers, mice, or keyboard tested with two keyboards) Please see the demo video showing simultaneous support for a keyboard, mouse, PS4 controller and PS3 controller The code to run this demo is attached below: A USB keyboard acts exactly like any other console keyboard The mouse and controllers are supported through the DEVICE command and function as in the example The mouse is constrained to return x and y values between 0 and MM.HRes-1 and 0 and MM.VRES-1 The scroll wheel on the mouse will act as a button but the wheel itself is not currently enabled (I Don't know the USB report to send to enable Intellimouse mode) All buttons on the various controllers can be selectively enabled to provide interrupts as per the Wii Classic in the documentation Note: The TinyUSB host code is far from robust and devices and hubs can get into undefined states, particularly with powered hubs. To ensure things work, start by powering everything off, disconnect everything from the hub. Then power the hub (or connect an unpowered hub the the Pico. Power the Pico and then one at a time add devices into the hub. Both and power-off and reset with an unpowered hub should result in the devices reconnecting. Powering off the Pico and not a powered hub may give problems Const ps4=128 Const ps3=129 Const snes=130 Const mouse=2 MODE 2 FRAMEBUFFER layer Sprite load "redmouse" CLS For i=1 To 4 If MM.Info(usb i)=mouse Then mousechannel=i Print "Mouse found on channel ",mousechannel EndIf If MM.Info(usb i)=ps3 Then PS3channel=i Print "PS3 controller found on channel ",PS3channel EndIf If MM.Info(usb i)=ps4 Then PS4channel=i Print "PS4 controller found on channel ",PS4channel EndIf If MM.Info(usb i)=130 Then SNESchannel=i Print "SNES controler found on channel ",SNESchannel EndIf Next FRAMEBUFFER write l Sprite show 1,MM.HRes\2,MM.VRes\2,1 If mousechannel Then Device mouse interrupt enable mousechannel,mouseint If PS4channel Then Device gamepad interrupt enable PS4channel,ps4int If PS3channel Then Device gamepad interrupt enable PS3channel,ps3int If SNESchannel Then Device gamepad interrupt enable SNESchannel,genericint Device mouse set mousechannel,MM.HRes\2,MM.VRes\2,0 Pause 1000 Do If mousechannel Then Sprite show 1,DEVICE(MOUSE mousechannel,x),DEVICE(mouse mousechannel,y),1 Pause 20 EndIf Loop Sub mouseint Static int L,R,M FRAMEBUFFER write n Print "Mouse Interrupt: "; If L<> DEVICE(mouse mousechannel,L) And L Then Print "L_UP" If R<> DEVICE(mouse mousechannel,R) And R Then Print "R_UP" If M<> DEVICE(mouse mousechannel,M) And M Then Print "M_UP" If L<> DEVICE(mouse mousechannel,L) And L=0 Then Print "L_DOWN" If R<> DEVICE(mouse mousechannel,R) And R=0 Then Print "R_DOWN" If M<> DEVICE(mouse mousechannel,M) And M=0 Then Print "M_DOWN" If DEVICE(MOUSE mousechannel,D) Then Print "double click" L=DEVICE(mouse mousechannel,L) R=DEVICE(mouse mousechannel,R) M=DEVICE(mouse mousechannel,M) FRAMEBUFFER write l End Sub Sub ps3int FRAMEBUFFER write n Print "PS3 interrupt: "; myint ps3channel FRAMEBUFFER write L End Sub Sub ps4int FRAMEBUFFER write n Print "PS4 interrupt: "; myint ps4channel FRAMEBUFFER write l End Sub Sub genericint FRAMEBUFFER write n Print "Generic interrupt: "; myint SNESchannel FRAMEBUFFER write l End Sub Sub myint(USBchan) Print DEVICE(gamepad USBchan, lx); Print DEVICE(gamepad USBchan, ly); Print DEVICE(gamepad USBchan, rx); Print DEVICE(gamepad USBchan, ry); Print DEVICE(gamepad USBchan, l); Print DEVICE(gamepad USBchan, r) Static integer l%=0 m%=1 a%=DEVICE(gamepad USBchan, b) t%=l% Xor a% If t% And m% Then If a% And m% Then : Print "R_ON":Else : Print "R_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "Start_ON":Else : Print "Start_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "Home_ON":Else : Print "Home_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "Select_ON":Else : Print "Select_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "L_ON":Else : Print "L_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "DOWN_ON":Else : Print "DOWN_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "RIGHT_ON":Else : Print "RIGHT_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "UP_ON":Else : Print "UP_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "LEFT_ON":Else : Print "LEFT_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "ZR_ON":Else : Print "ZR_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "X_ON":Else : Print "X_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "A_ON":Else : Print "A_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "Y_ON":Else : Print "Y_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "B_ON":Else : Print "B_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "ZL_ON":Else : Print "ZL_OFF":EndIf EndIf Inc m%,m% If t% And m% Then If a% And m% Then : Print "TPAD_ON":Else : Print "TPAD_OFF":EndIf EndIf l%=a% End Sub |
||||
homa Guru Joined: 05/11/2021 Location: GermanyPosts: 351 |
Hi Peter, quick question. Is it possible to establish a USB (serial) data connection to e.g. TeraTerm using a USB hub in addition to the keyboard/HIDs? Matthias |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9115 |
No: would need another protocol and yet more resource |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6786 |
Thanks Peter. :) Connecting console via USB is not the sort of thing you should consider anyway. The console's main job is to do special things or get you out of a problem. If that problem is something to do with the USB then the console could be your only way to rescue the system without having to fully reload MMBasic from scratch - possibly losing everything stored in flash. Edited 2024-02-02 22:53 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4233 |
Hi Peter, I guess that using a FTDI or other interface for the console port, will require you to set the correct baudrate. At least for the serial comms between FTDI and Pico. I see no mention of the baudrate anywhere. Did you default 115200 ? Or 38400 ? Volhout Edited 2024-02-03 01:30 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 858 |
I know absolutely nothing about PS4 controllers but I see that there is a wireless version. These should be compatible, right? |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9115 |
I see no mention of the baudrate anywhere. Did you default 115200 ? Or 38400 ? 115200 I know absolutely nothing about PS4 controllers but I see that there is a wireless version. These should be compatible, right? No idea. If they have a dedicated wireless dongle then > 50%. If they use bluetooth then <0%. I use it wired. NB: The wired PS4 is the preferred controller as I'm in the process of implementing things like haptic feedback and flashing lights and if I can work out the protocol then accelerometer output should also be possible |
||||
PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 858 |
DOH!!! Senior moment. It was only last week that I located the PS4 BT protocol for someone else....and it looked horrible |
||||
aFox Regular Member Joined: 28/02/2023 Location: GermanyPosts: 76 |
In my opinion, this feature would also be useful for the other versions. Thus could use the mouse buttons and scroll wheel for input. That is also possible in conjunction with SNES controllers. Gregor |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9115 |
Here is a version for the PicoMite PicoMiteUSB.zip Exactly the same - serial console on gp8,gp9, 5V on VBUS and here is a simple test program for a USB mouse FRAMEBUFFER create FRAMEBUFFER layer FRAMEBUFFER write f CLS RGB(red) Dim a%=Peek(cfunaddr sprites) For i=1 To 4 If MM.Info(usb i)=2 Then mousechannel=i Print mousechannel Next Do If mousechannel Then FRAMEBUFFER write l CLS Blit compressed a%, DEVICE(mouse mousechannel,x),DEVICE(mouse mousechannel,y) FRAMEBUFFER merge EndIf Loop CSub SPRITES 00000000 'balloon 'Offset 0 002A001E 010F7E08 777F0C7E 06777F08 7F047B7F 047A047B 047A047C 027A027C 757F0474 7F047402 7D7F0275 027D7F02 757F0474 7A047402 7C047A02 7C047A04 047B7F04 7F047B7F 7B7F047B 7F027204 04720273 737F0272 72067202 72027E02 7E027208 72087202 72047A04 7A047208 720A7204 72047604 7604720C 720C7204 72047604 7604720C 720E7204 72047204 0472010F 0F720472 72047201 010F7204 04720472 7A030F72 0F7A050F 050F7A05 7A050F7A 0F7A050F 090F7607 00000C76 End CSub Edited 2024-02-03 05:45 by matherp |
||||
Bleep Guru Joined: 09/01/2022 Location: United KingdomPosts: 509 |
Hi Peter, I have managed to get this going on a GameMite using the serial console and successfully played flappybird using a USB keeboard, I also got your balloon mouse test program working fine as well. Anyone interested in using minicom on Linux, you will need:- sudo minicom --device /dev/ttyUSB0 --color=on I have a few questions/problems. My options are:- > option list PicoMite MMBasic Version 5.08.00b0 OPTION SERIAL CONSOLE COM2,GP8,GP9 OPTION SYSTEM SPI GP6,GP3,GP4 OPTION SYSTEM I2C GP26,GP27 OPTION COLOURCODE ON OPTION KEYBOARD UK OPTION CPUSPEED 252000 'KHz OPTION LCDPANEL CONSOLE OPTION DISPLAY 30, 53 OPTION LCDPANEL ILI9341, LANDSCAPE,GP2,GP1,GP0 OPTION TOUCH GP5,GP7 OPTION SDCARD GP22 OPTION AUDIO GP20,GP21', ON PWM CHANNEL 2 OPTION MODBUFF ENABLE 180 OPTION PLATFORM Game*Mite OPTION DEFAULT FONT 7, 1 1) I'm assuming that I do have to set the 'option lcdpanel console' to get this usable on a LCD? or is there a better way, as it will always have to be console? 2) Is it possible to allow operation with the screen Reversed (upside down) as when I tried to set console, it refused saying it had to be 'landscape' so presumably 'RLANDSCAPE' was not acceptable? 3) Using the USB keyboard, if I get the screen to scroll, so type 'option list' a couple of times, as soon as the list stops, having scrolled the whole screen, I get a double prompt, ie two '>' instead of one, and the USB keyboard stops working. OPTION DEFAULT FONT 7, 1 4) now that you have improved the Screen/framebuffer blit/copy are there any optimisations you are able to do to help with speeding up scrolling, like copy whole screen, apart from top line, then blit whole screen, shifted up one line, insert bottom line? I suspect the answer is no, because the LCD in console is not using a framebuffer, but any improvements will be great.> >_ Otherwise so far so good, :-) I'll try and do some more testing over the next few days. Thanks for your time, Regards, Kevin. Edited 2024-02-04 01:56 by Bleep |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9115 |
You always have the serial console available but to use the LCD panel as a console it must be in landscape mode and not reverse landscape. My view FWIW has always been that it is only a SSD1963 that can really be used in console mode both from the perspective of resolution and also speed (it has H/W scroll in the landscape direction) All the SPI displays will only H/W scroll in the portrait direction so the only way of scrolling is to ready the display and re-write it line by line. You could envisage having a screen text buffer in memory holding just the ascii but even then you would have to re-write the whole screen every time it scrolls. You can't use a framebuffer as things like the editor need the memory. GameMites (my versions included) are not really a useful platforms for USB as you need 5V on VBUS which conflicts with the whole battery circuitry. Yes you can hack them but it would really need a different design. This will be because the USB task isn't being polled while the scroll is taking place. That I could probably fix but given the above its not really worth it. As above, we are limited by the H/W. The parallel ILI9341 is better for this but still doesn't have H/W scroll like the SSD1963 |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 828 |
Hi, I use a ILI9488 display as a console. I had previously used it with version 5.07.06 as a reverse landscape - what a pity that this is no longer possible! If I mount it the other way around, the SD card holder is no longer accessible... Yes, the scrolling is underground slow!!! But is that even important? Wouldn't it be better anyway if the whole page was always switched to LIST? (As with PAGE UP/DOWN in the editor?) Otherwise, isn't scrolling really used at all??? In addition, not only one page scrolls through until a keystroke is requested, but two or three pages... Speaking of PAGE UP/DOWN: I just realized that the keyboard I wanted to use has no PAGE UP/DOWN buttons! Is it possible to achieve this with a different key combination? In the meantime, the SSD1963 displays have become very difficult to obtain and very expensive. I still have some of the ILI9341 and the ILI9488 and things are looking a bit better in terms of availability and price. Yes, I would also like the SSD1963 better - but they cost almost five times as much as the ILI displays here... Frank |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6786 |
It takes a relatively long time to redraw the entire screen on any SPI display. Without hardware scrolling handled by the display chip you have to send every pixel. Page up/down is consequently still pretty slow - and you still have to scroll up if someone enters text on the bottom line. There is a parallel version of the ILI9341 which is fairly common on AE and reasonably priced. Pin compatible with the SSD1963. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 828 |
I can't confirm that. For me, the speed is sufficient for the complete picture composition. Only the scrolling is catastrophic... I have found the solution for my missing PAGE UP/DOWN buttons in the manual: Ctrl-P and Ctrl-L do the trick! Frank |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6786 |
That's handy to know. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
hi Peter, just did some quick testing with the .uf2 file you posting at the top, and notice that f4 and f5 do not auto-repeat. is this for some reason, or an oversight? personally, i prefer for none of the function keys f1 to f20 to auto-repeat (they don't in GFXterm), but it seems that in a real vt220 they all should. i also see you have changed the single keycodes returned by inkey$ for shifted function keys from being in the 0xB0 range to being in the 0xD0 range. why? and while input$(n, #0) now returns the same (single) keycodes as inkey$ for VT keys, i guess that is to be expected and likely the same as you do with PS/2 keyboards. HID2CDC sticks with VT escape sequences for non-ascii keys, which is what is then returned by input$(n, #0) finally, there appears to be no way from the USB keyboard to enter null (0x00) or the four control characters beyond escape. ie, 0x1C, 0x1D, 0x1E and 0x1F. normally escape onwards would be mapped to: 0x1B - ctrl-[ 0x1C - ctrl-\ 0x1D - ctrl-] 0x1E - ctrl-~ 0x1F - ctrl-? while 0x00 would be mapped onto ctrl-space or ctrl-0. cheers, rob :-) Edited 2024-02-05 21:32 by robert.rozee |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9115 |
The keyboard behaves the same as the CMM2 - see Appendix F of the CMM2 manual for keycodes Edited 2024-02-05 22:54 by matherp |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2350 |
so f4 and f5 do not auto-repeat on the CMM2? nor is there any way on the CMM2 keyboard to enter the control characters above escape, or null? cheers, rob :-) |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 9115 |
Correct |
||||
Page 1 of 5 |
Print this page |