Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 01:42 21 May 2024 Privacy Policy
Jump to

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 : hid2cdc - USB keyboard and mouse for picomite VGA

     Page 2 of 6    
Author Message
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 12:52am 31 Dec 2023
Copy link to clipboard 
Print this post

A function returns a value and requires something to put that value in, for instance


mik:
 do
   a$=_inkeych$()
   if a$<>"" then
     print asc(a$);" ";
   endif
 loop

PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 01:07am 31 Dec 2023
Copy link to clipboard 
Print this post

Hi Lizby, All,

I replaced my snippet at the start with yours and I now get this error

RUN
[12] If Loc(#1)>0 Then
Error : File number is not open

what file # is this referring to?

Mick



.
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1814
Posted: 01:52am 31 Dec 2023
Copy link to clipboard 
Print this post

The console is #0.
This seems to work. Below is the output of the F-keys from TeraTerm, 3 characters each F1 to F9 and 4 characters each F10 to F12.
> LIST
Do
b$ = _inkeych$()     ' I thought this would run the function
If b$<>"" Then Print Asc(b$)
' Print Asc(a$) ' ignore as superflous at this stage
Loop


Function _inkeyCh$()
Local ky$
If Loc(#0)>0 Then
 ky$=Input$(1,#0) ' get a character
Else
 ky$=Inkey$
EndIf
If Asc(ky$)=27 Then ' escape sequence
 Pause 20 ' await additional characters
 ky$=Input$(1,#0): ky$=Input$(1,#0): ky$=UCase$(ky$)
 If ky$="A" Then: ky$=Chr$(128) ' up arrow
 ElseIf ky$="B" Then: ky$=Chr$(129) ' down arrow
 ElseIf ky$="D" Then: ky$=Chr$(130) ' left arrow
 ElseIf ky$="E" Then: ky$=Chr$(131) ' right arrow
 ElseIf ky$="1" Then: ky$=Chr$(134) ' home
 ElseIf ky$="4" Then: ky$=Chr$(135) ' end
 ElseIf ky$="5" Then: ky$=Chr$(136) ' pgup
 ElseIf ky$="6" Then: ky$=Chr$(137) ' pgdn
 ' Function keys are ???
 EndIf
EndIf
_inkeyCh$=ky$
End Function
> RUN
134
49
126
134
50
126
134
51
126
134
52
126
134
53
126
134
55
126
134
56
126
152
50
48
126
50
49
126
155
50
52
126
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 02:04am 31 Dec 2023
Copy link to clipboard 
Print this post

Hi Phil,

That `almost works', thank you.


I am currently only testing directly on the console, (NOT with HID2CDC connected).

This is what I am getting with just `slow, careful' presses of just the F1 key.

Note the key MOSTLY returns

134
49
126

but every now and then it returns a solitary 145

134
49
126
134
49
126
134
49
126
145
134
49
126
134
49
126
145
134
49
126
145
134
49
126

I will try on the HID2CDC anyway to see what occurs

Regards,

Mick



.
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 02:26am 31 Dec 2023
Copy link to clipboard 
Print this post

Hi All,

I have tested the above code on the HID2CDC and every key that doesn't work returns a solitary 0

The Ctrl key sends nothing and with CTRL-c it returns 99 which is the same as c by itself.

I have also noticed some instability in getting the HID2CDC up and running.

Initially, yesterday it wouldn't work at first but then replugging keyboard and the HID2CDC would bring it up and running, it then appeared very stable for my testing. Just now I went through the same hoops and fences to get it running and in the process lost the file in Memory.

I think it may be the length of leads (about 1m and rather thin) that are powering the HUB and kb. (Power originates from the PicoVGA). If it persists I will just make some short cables.

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2296
Posted: 03:47am 31 Dec 2023
Copy link to clipboard 
Print this post

hi mick,
   give this a try, based upon lizby and phil99's code:

Do
  I=Timer
  Do
    If Loc(#0)=0 Then a$="" Else a$=Input$(1, #0)
  Loop Until a$<>""

  If Timer-I>100 Then Print

  If a$=Chr$(13) Then
    Print "<cr>";
  ElseIf a$=Chr$(10) Then
    Print "<lf>";
  ElseIf a$=Chr$(27) Then
    Print "<esc>";
  ElseIf (a$<Chr$(32)) Or (a$>Chr$(126)) Then
    Print "<";Hex$(Asc(a$),2);">";
  Else
    Print a$;
  EndIf
Loop


it looks like on the picomite Inkey$ pre-processes some (but not all) VT key sequences into a single character with the top bit set, while Input$(1, #0) allows access to the raw data.


cheers,
rob   :-)
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 05:00am 31 Dec 2023
Copy link to clipboard 
Print this post

Rob, All,

This will be the last test I can do this year, I have to prep the BBQ for tonight's NY celebrations.


OK, I went through `A LOT' of instability ie. getting the setup to work and recognise the kb. I am sure that is to do with cable lengths and power distribution, something I will address in the coming week when time permits.

Anyway I finally got there, this is what the HID2CDC reports

ESC  <esc>
F1-F12 <00>
numlk, Prnt scn, Scrl lk, Pause/break all report <00>
backspace <08>
home <00>
~ (displays a degrees symbol)
tab <09>
Pg up/down, end, home, 4 arrows all <00>
Caps, Shift, Alt and Ctrl no response at all
| (ruler) <00>
Windows key no response

I hope that helps with the project.

Regards,

Mick

EDIT***

When I have the HID2CDC setup working I can plug an extra keyboard in and both work, could be great for 2 player games.

Mik
Edited 2023-12-31 15:04 by bigmik
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 02:58pm 31 Dec 2023
Copy link to clipboard 
Print this post

  bigmik said  [12] If Loc(#1)>0 Then
Error : File number is not open

what file # is this referring to?


Sorry, Mick. In that code, I was looking for input either from a serial port or from the console. When posting, I forgot to note that in your case, the serial port would not have been opened--I should have omitted that part of the code.

Looks like you have made progress and it appears that the Function keys and other important keys do not return anything (as passed through your HID device--unlike straight from a keyboard or as passed through TeraTerm to the MMBasic console).
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9084
Posted: 12:26am 01 Jan 2024
Copy link to clipboard 
Print this post

What a fascinating thread, now that I have just got to the end of it.

A quite brilliant idea to use a PICO module as a kind of USB interpreter with the output always via a USB serial adaptor via a hub all controlled by the PICO module - very clever of the fella over a Github and thanks to Rob for pursuing this idea with him.

I can see some potential out of this, especially after seeing all of bigmik's testing showing some very promising results.

Watching this thread with interest.

Happy new year.
Smoke makes things work. When the smoke gets out, it stops!
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 12:37am 01 Jan 2024
Copy link to clipboard 
Print this post

No problems Lizby,

It is all a learning exercise for everyone at the moment.

I have had a thought about the instability I have been experiencing and I think I know what it is.

I have a barrel Jack for 5v input on my PicoMuP (configured as a PicoMiteVGA) that I use to power everything.
I have been generally powering the lot by flicking the power switch on the wall where the plugpack is plugged into the wall socket. I have just realised that, I think, when I do get it working I plugged the (already powered) plugpack into the barrel Jack. Possibly the plugpack doesnt power up very cleanly.

I will investigate that because when it does work it works very well.

@Rob, anyone else.

What should the power up procedure ideally be?

Ie HID2CDC first then PicoVGA or vice versa?

Regards,


Mick






.
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 01:33am 01 Jan 2024
Copy link to clipboard 
Print this post

Hi All,

I have hit on the instability issue I was having.

It IS indeed the powering of the plugpack via the mains switch that causes it to occur, by directly plugging the `hot' plug into the Barrel Jack on my PicoMuP, I have successfully powered the setup 9 times out of 10, given the length of leads I figure that this is proof positive.

The powering via the mains power point was to try to power everything up in a `safer' manner, it appears that I actually introduced the instability by doing so.


@Rob,
Incidentally, Rob, on my small keyboard (without keypad) two LEDs light up (caps lock and what I think is scroll lock, it has a down pointing arrow sort of like an LED symbol) on the larger keyboard no LEDs light up.

Even though caps lock illuminates it is in lower case mode.


Now to work off my hangover from last year.  


Kind Regards,

Mick (the Big one)



.
Edited 2024-01-01 11:34 by bigmik
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2296
Posted: 02:24am 01 Jan 2024
Copy link to clipboard 
Print this post

i would suggest feeding 5-volts directly into VBUS (pin 40, ground return to pin 38) of the HID2CDC pico. this will then flow directly into your USB hub and from there power the attached devices (picomite VGA and keyboard).

do you have a reset button fitted to your picomite VGA? if things don't power up correctly, you could try tapping that; my guess is that the USB hub and keyboard will have fairly robust reset circuitry built in, while the two picos less so.

as i recall, USB keyboard LEDs are usually controlled by the host - one way i use to see if a desktop PC is still alive is tapping the caps lock key and see if the corresponding LED changes state. so i wouldn't worry about the LEDs, they will be something for NoOne to fix later. at the moment, i've asked (on github) that the next thing to be got going is the CONTROL key, which will then see us being able to run the picomite's editor.


cheers,
rob   :-)
Edited 2024-01-01 12:26 by robert.rozee
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5773
Posted: 08:56am 01 Jan 2024
Copy link to clipboard 
Print this post

One of the test points under a Pico (TP5) goes to the anode of the heartbeat LED. You can use this to get an extra output. It has a 470R resistor to GP25.

You could try this. On the "first to start" Pico:
Connect TP25 to the 3V3EN pin on the "to be delayed" Pico.
Disable heartbeat.
Start the program with a short PAUSE then set GP25 high.
do another PAUSE to allow the other to boot.

In theory 3V3EN should be low enough to prevent the Pico from powering up. You may need a 470R resistor from 3V3EN to GND, although it's worth trying without first. When the first Pico has booted it will enable the delayed one by putting about 1V8 on its 3V3EN input. The switcher spec specifies a min. of 1.2V for logic high and a max. of 0.4V for logic low.

You can't depend on the Picos to boot at the same speed even if powered simultaneously. They are running from different clocks. The best you can manage is a controlled start.
Edited 2024-01-01 19:01 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2296
Posted: 03:43pm 01 Jan 2024
Copy link to clipboard 
Print this post

further posting from NoOne on github:
https://github.com/No0ne/hid2cdc/issues/1

he suggests mass storage devices (USB flash drives) with xmodem transfer should be possible. mouse support is a litle more complex, though i have an idea myself how it may be achieved in a VT-aware manner.


cheers,
rob   :-)
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 11:07pm 01 Jan 2024
Copy link to clipboard 
Print this post

Hi Rob, All,

This is sounding more and more exciting, ‘possibly’ having access to storage devices as well is icing on the cake.

I am glad to read that ‘no0ne’ expected that the function keys etc would not work, it eliminates anything that I have introduced.

I have noticed, albeit when the setup wasn’t working, that if I unplug then replug the HID2CDC device I would see the picoVGA either lockup or see the report on the screen Invalid Address - Restarting but even after said restart it would not work with the HID2CDC. Now that I know how to get the setup to work on power up every time, I will try unplugging the HID2CDC and see what happens.

Regards,

Mick




.
Edited 2024-01-02 09:08 by bigmik
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2296
Posted: 01:25am 02 Jan 2024
Copy link to clipboard 
Print this post

  bigmik said  if I unplug then replug the HID2CDC device I would see the picoVGA either lockup or see the report on the screen Invalid Address - Restarting but even after said restart it would not work with the HID2CDC


hi Mick,
   that is pretty much as i would expect. think of it in the context of a picomite plugged into the USB port of a regular PC - the picomite is just a peripheral and is seeing the host PC connection disappear. but with a PC that would only happen when the picomite is unplugged from the PC, at which point the pico powers down.

i doubt very much if tinyUSB has ever been tested under the conditions of the USB connection being lost but power remaining on. normally a pico is either tethered to a PC with USB connection and deriving power from said PC, or there is no USB connection and the pico is powered continuously from a battery or plugpack.

note: i have on the odd occasion seen USB printers lose their USB connection without power being interrupted, at which the printer sometimes locks up completely and requires power cycling to recover. simply put, many USB devices are not specifically designed to keep working through a lost USB connection situation.


if you feed 5-volts directly into VBUS (pin 40, ground return to pin 38) of the HID2CDC pico, and only into there, then the above problem should not happen. the power will flow directly into your USB hub and from there power the picomite VGA (and keyboard). if the HID2CDC is unplugged, everything else loses power.


cheers,
rob   :-)
Edited 2024-01-02 11:25 by robert.rozee
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5773
Posted: 08:31am 02 Jan 2024
Copy link to clipboard 
Print this post

Please be careful about putting supplies onto the VBUS terminal. It's so easy to think "I just need to change..." and connect the USB port to your PC - possibly damaging the USB chip in it. All you gain over powering from VSYS is the little drop across a Schottky diode, which is completely irrelevant if you are using the switching supply.

VBUS is great for powering 5V devices *from* though (if you are getting a supply from USB).
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8609
Posted: 08:53am 02 Jan 2024
Copy link to clipboard 
Print this post

Has the issue with function keys, arrow keys, control keys, and anything else that generate escape sequences been solved? It seems to me that until the basics are working this is of limited use and extra functionality (usb drives) should be deferred.

Bluntly, what is there at the moment is just basic TinyUSB functionality. The hard bit is getting things like multiple languages and all the edge cases working. Check the source of any of the MMBasic variants for how much of keyboard handling is dealing with these (nearly all of it). Aus and NZ may choose to us a US keyboard but much of the rest of the world and many of out biggest contributors don't so this stuff is important.
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2296
Posted: 04:15pm 04 Jan 2024
Copy link to clipboard 
Print this post

new version of HID2CDC, with arrow keys now working:
https://github.com/No0ne/hid2cdc/raw/main/hid2cdc.uf2

mick - with the new version are you seeing anything else working, ie, control keys, home/end, pgup/pgdn, insert/delete?


cheers,
rob   :-)
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2296
Posted: 11:55pm 04 Jan 2024
Copy link to clipboard 
Print this post

further update, looks like ALL required keys are now working:
https://github.com/No0ne/hid2cdc/raw/main/hid2cdc.uf2

only key repeat not yet working.

  matherp said  Has the issue with function keys, arrow keys, control keys, and anything else that generate escape sequences been solved?

yes, it seems so.
peter: are you able to test this with a UK keyboard?


cheers,
rob   :-)
Edited 2024-01-05 09:59 by robert.rozee
 
     Page 2 of 6    
Print this page
© JAQ Software 2024