![]() |
Forum Index : Microcontroller and PC projects : Picomite HID device
Author | Message | ||||
pwillard Guru ![]() Joined: 07/06/2022 Location: United StatesPosts: 313 |
I'm going to just say it... I know it sounds dumb. One of the most common devices I see made with the PICO NOT running MMBASIC is making a HID keyboard for things like OBS controls. I'm assuming that creating this sort of HID-type device is one of the things MMBASIC on a PICO is NOT suited for. Am I right? |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3348 |
Links? PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
pwillard Guru ![]() Joined: 07/06/2022 Location: United StatesPosts: 313 |
One of the SIMPLER examples. Instructable There is also the KEYBOW2040 which is a fully built 16 Key Keyboard with an onboard 2040 Of course, I can program with Python... but Basic is more fun. Edited 2022-09-21 22:26 by pwillard |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4032 |
Why use USB HID with all its pain for so few keys? John |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Because it "just works" Why fix something that isn't broken Edit: Obviously I wouldn't for so few keys, but USB just works with almost anything these days, PS2 keyboards do not Edited 2022-09-22 01:17 by lew247 |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10181 |
The PicoMite doesn't support HID and won't ever support HID. It has one USB port and that is dedicated to CDC. |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4032 |
Only with a vast amount of support code / hardware. The Pico lacks those so struggles and expecting HID as well as CDC is beyond it most likely. Especially if you want MMBasic as well. John |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7820 |
USB is very deceptive. There's a serious amount of hardware and firmware engineering go in to make it "just work". On the other hand, PS2 could hardly be simpler to interface as it's basically I2C. Like a lot of things, you can make the Pico do them, but not have enough resources left to run MMBasic and have a decent amount of space for the user program. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9585 |
Well said, Mick. ![]() Especially the USB is very deceptive. There's a serious amount of hardware and firmware engineering go in to make it "just work". bit. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
bigmik![]() Guru ![]() Joined: 20/06/2011 Location: AustraliaPosts: 2947 |
Hi Pwillard, ALL, It is not a dumb question. I read in the latest APC (Australian Personal Computer) Magazine an article for a `Rubber Ducky' that can emulate a keyboard. Sometimes these can be for criminal purposes to take control of a PC or, less nefariously, just be for adding keys/macros as a keyboard. I have discussed this with my 'partner in crime' AndrewG and we have come up with the following code: 'Rubber Ducky v5.BAS ' OPTION EXPLICIT OPTION DEFAULT NONE option Base 1 'Each array will start with the index 1 'OPTION AUTORUN ON 'Issue from console Dim Integer I, XMax = 320, YMax = 480, T_Ref Dim String Caption(8) 'This is what appears on the button the "~" starts a new line Dim string Message(8) 'Can be upto 256 characters long 'Options for Mick to set: Dim Integer PauseTime = 250 'A short delay to prevent multiple sends from the one tap - change to suit 'The "~" starts a new line on the button Caption(1) = "bigmick58@~bigpond.com" : Message(1) = "bigmick58@bigpond.com" Caption(2) = "Father~Christmas" : Message(2) = "Father Christmas" Caption(3) = "PicoMuP is~Great" : Message(3) = "PicoMuP is Great" Caption(4) = "I love Stout" : Message(4) = "I love Stout" Caption(5) = "40 Bellevue~Blvd~HILLSIDE": Message(5) = "40 Bellevue Blvd HILLSIDE" Caption(6) = "0402001620" : Message(6) = "0402001620" Caption(7) = "Andrew~Garrett~Makes Wine" : Message(7) = "Andrew Garrett Makes Wine" Caption(8) = "I love golf~but golf~HATES me" : Message(8) = "I love golf but Golf hates me" SETPIN GP5, GP4, COM2 'Mick's PicoMuP pins 'This assumes your keyboard interface is attached to COM2 OPEN "COM2:9600" as #2 'Edit the speed to suit CLS Font 2 'MICK NOTE the font change 'Column 1: For I = 1 to 4 GUI BUTTON I, Caption(I), 4, (I-1)*2*60+4, XMax/2-6, 2*57-2, RGB(white), RGB(magenta) Next I 'Column 2: For I = 5 to 8 GUI BUTTON I, Caption(I), 4+XMax/2, (I-1-4)*2*60+4, XMax/2-6, 2*57-2, RGB(yellow), RGB(red) Next I GUI INTERRUPT PenDown ', PenUp GUI Show All 'MMMMMMMMMMMMMM Start of Main Loop MMMMMMMMMMMMMMMMMMMMM Do ' ' . . . ' Watchdog 10000 'If the program stalls for more than 10 seconds it will re-boot (because you have used the console to set "OPTION AUTORUN ON" - haven't you . . . If T_Ref > 0 then 'T_Ref = 0 does pop up and causes errors so let's use it print #2, Message(T_Ref):print Message(T_Ref) If T_Ref <5 then Box 0, (T_Ref-1)*2*60, XMax/2, 2*60,, RGB(green) pause PauseTime 'insert a short pause to prevent multiple sends from the one tap Box 0, (T_Ref-1)*2*60, XMax/2, 2*60,, RGB(black) 'Erase box Else Box XMax/2, (T_Ref-1-4)*2*60, XMax/2, 2*60,, RGB(green) pause PauseTime 'insert a short pause to prevent multiple sends from the one tap Box XMax/2, (T_Ref-1-4)*2*60, XMax/2, 2*60,, RGB(black) 'Erase box End If T_Ref = 0 'Use as a flag to only process once per tap End If ' ' . . . ' Loop 'mmmmmmmmmmmmm End of Main Loop mmmmmmmmmmmmmmmmmmmmmmmm Sub PenDown T_Ref = Touch(Ref) End Sub 'Pendown Sub PenUp 'This probably won't be used. If not can be deleted. ' T_Ref = Touch(LastRef) 'Not needed, can delete this line End Sub 'PenUp Now this sets up on a 480 x 320 display (the picture below shows an ILI9481 but an ILI9488 can also be used) as an extra/programmable keypad that sits nicely next to my keyboard. I simply tap the key I want and it sends a string to a serial port. Currently I am using the Console serial port but It ultimately will also work using the serial port (and a USB-TTL adapter) to feed strings into a USB (set as a COM port on the PC). This is not currently tested. ![]() Now, I hear you all screaming that getting data into your PC's COM port wont work as a keyboard. Of course you are correct, however I found a neat little Utility called >>> DATASNIP <<< that is a `keyboard wedge' that redirects a COM port into the keyboard buffer. Datasnip comes as a free to use "basic' version which does work however using the Serial Console at random intervals (usually 30seconds or so) an ESC sequence appears as key presses, [?25h which I believe is a `Cursor ON' command and is part of the VT100 emulation of MMBasic Console. No other escape sequences appear. The paid for version at $11AU inc GST or about $6US has some very nice features including a find string and replace it with something (or nothing). I wasn't able to actually get the [?25h code to be captured but I was able to capture ?25h ie. no [ character and replace with a backspace to delete the [. OK, That is a bit of a PitA but in my application it hasn't been an issue for me. If it was I would simply dedicate a USB-TTL adapter and use the pure COM port from the PicoMite which will have no VT100 emulations. Then the free version of Datasnip could be used. As Datasnip (the paid version) has 2 programmable keys that can send a string out of the COM port I am currently working on adding a second page of buttons that can be toggled by a `hot' key. Alright, I hear you saying there are many keyboard wedge programs out there BUT this has the advantage of showing what the key you press is without having to remember what hot key to use and what that hotkey is associated with. Anyway, it is still a work in progress, Both Andrew and I hope that you will find some use or interest in this. In my case it also got `rid of' an ILI9481 display that is much slower than the similar ILI9488. Thank You AndrewG for creating the bulk of the code listed above. And apologies for my feeble additions. Kind Regards, Mick EDIT ** Here is a Picture of the Inside showing one of my PicoMuPs on the display. The 4 screws are adjusted to hit the bottom of the case and absorb any heavy handed pressing of the touch screen the `hot snot' is simply to stop the screen moving vertically and horizontally. ![]() Mik Edited 2022-09-22 11:28 by bigmik Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6266 |
That escape sequence is sent after 30 seconds of inactivity on the USB port as a 'keep alive' to stop the pico's USB from having a nana nap. It can be a pain at times but the pico USB library always seems to be a pain... Jim VK7JH MMedit |
||||
bigmik![]() Guru ![]() Joined: 20/06/2011 Location: AustraliaPosts: 2947 |
Thanks Jim, I thought it was something like an `I am still here' command but in any case it shouldn't be an issue if the actual PM com port was used, and indeed with creative use of the filter I have worked around it, I just haven't got around to testing the COM port side yet. Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
Andrew_G Guru ![]() Joined: 18/10/2016 Location: AustraliaPosts: 868 |
Hello to Pwillard, Mick, Jim et al, Mick's photo above - ie the back of the LCD with the 'Hot Snot' - also shows Mick's PicoMup. I'm not sure that he has 'released' it yet but one of these will form the basis of my Weather Station upgrade. It houses WiFi, DS18B20, HC-12, BM180, RTC and can connect to VGA or LCD, and breaks out all of the Pico's available data pins - plus more. All in a very small footprint. The code that Mick oversaw for the Datasnip button-box can easily be amended to: - capture data sent by Datasnip (in the OPEN command include an interrupt Subroutine to receive and process the data) - show the date and time etc. (Mick prefers not). Another example of how useful the PicoMite and MMBasic are. Cheers, Andrew |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |