pico-zxspectrum icon indicating copy to clipboard operation
pico-zxspectrum copied to clipboard

Support for original ZX Spectrum Keyboard?

Open wtfrules opened this issue 2 years ago • 17 comments

Hi Guys!

LOVE THIS PROJECT!

I´m wondering if it´s a way to use the original keyboard of a ZX Spectrum directly wo the Raspberry Pico for more enjoy of the project!?

I´ve one to make tests if needed.

Keep up going the good work!

Regards

wtfrules avatar Jul 22 '22 20:07 wtfrules

Quite possibly. Is it a 48k or 128k keyboard?

fruit-bat avatar Jul 23 '22 22:07 fruit-bat

It´s a 48K Keyboard

wtfrules avatar Jul 24 '22 00:07 wtfrules

Ok, so this is mainly for my benefit, with a question mixed in...

The 48k keyboard is an 8 by 5 matrix, which needs 13 GPIO pins...

http://www.breakintoprogram.co.uk/hardware/computers/zx-spectrum/keyboard

So the question is what mix of features can be supported with 28 pins along side:

  • SD Card 4 pins
  • HDMI 8 pins
  • VGA 5 pins
  • PS/2 keyboard 2 pins
  • Audio 1 - 4 pins (DAC 3 pins, should really use at least 2 pins for PWM audio)
  • Serial debug 2 pins

...but do you have preferences out of the above list?

Also, it's possible that a second Pico could be used to scan the keyboard.

fruit-bat avatar Jul 25 '22 06:07 fruit-bat

Hi, I'm interested too in the use of real keyboard, mine is ZX+

My prefs is to get some real stuff (keyboard, audio, deck i/o, joystick and cvbs video) plus SD card

Great job guy... best regards

emilen72 avatar Jul 27 '22 10:07 emilen72

Ok, so this is mainly for my benefit, with a question mixed in...

The 48k keyboard is an 8 by 5 matrix, which needs 13 GPIO pins...

http://www.breakintoprogram.co.uk/hardware/computers/zx-spectrum/keyboard

So the question is what mix of features can be supported with 28 pins along side:

  • SD Card 4 pins
  • HDMI 8 pins
  • VGA 5 pins
  • PS/2 keyboard 2 pins
  • Audio 1 - 4 pins (DAC 3 pins, should really use at least 2 pins for PWM audio)
  • Serial debug 2 pins

...but do you have preferences out of the above list?

Also, it's possible that a second Pico could be used to scan the keyboard.

Good question...

Must have (IMO)

SD Card Audio HDMI

At least

wtfrules avatar Jul 27 '22 16:07 wtfrules

Ok, so this is mainly for my benefit, with a question mixed in... The 48k keyboard is an 8 by 5 matrix, which needs 13 GPIO pins... http://www.breakintoprogram.co.uk/hardware/computers/zx-spectrum/keyboard So the question is what mix of features can be supported with 28 pins along side:

  • SD Card 4 pins
  • HDMI 8 pins
  • VGA 5 pins
  • PS/2 keyboard 2 pins
  • Audio 1 - 4 pins (DAC 3 pins, should really use at least 2 pins for PWM audio)
  • Serial debug 2 pins

...but do you have preferences out of the above list? Also, it's possible that a second Pico could be used to scan the keyboard.

Good question...

Must have (IMO)

SD Card Audio HDMI

At least

Well, I think that will squeeze in. I'll have a think about it but I have promised some work on another board so it may take a while to make the new drivers. It's worth noting here the tricky bit is mapping all the 'normal' keys onto the Spectrum keyboard so the menu can be used; the menu uses USB HID key values and will require its own matrix scanning routines. If you intend to operate the menus from a second usb keyboard it is a much simpler problem... although maybe a messier solution.

fruit-bat avatar Jul 27 '22 18:07 fruit-bat

Hi, I'm interested too in the use of real keyboard, mine is ZX+

My prefs is to get some real stuff (keyboard, audio, deck i/o, joystick and cvbs video) plus SD card

Great job guy... best regards

Correct me if I am wrong but I think the 48k & 128k keyboards use the same connectors (and the extra keys are made by connecting multiple points on the matrix)... so the same software should be good for both.

CVBS is interesting and I have seen some grey-scale examples on the pico. Not seen a color demo as yet. I will raise this as a separate issue as it is of academic interest!

fruit-bat avatar Jul 27 '22 18:07 fruit-bat

proto_keyboard

Waiting on some hookup wires now.

fruit-bat avatar Jul 31 '22 16:07 fruit-bat

proto_keyboard

Waiting on some hookup wires now.

Oh so nice!

wtfrules avatar Aug 01 '22 15:08 wtfrules

I have a circuit, now just(!) need some software :- proto_kbd )

fruit-bat avatar Aug 13 '22 15:08 fruit-bat

Ohhhh yessssssssss! The good is coming!

wtfrules avatar Aug 14 '22 14:08 wtfrules

There is some code on a branch, including an executable: https://github.com/fruit-bat/pico-zxspectrum/tree/feature/zxkeyboard https://github.com/fruit-bat/pico-zxspectrum/blob/feature/zxkeyboard/uf2/ZxSpectrumBreadboardHdmiKbd1PinAudio.uf2

It all works fine, as far as I can tell, but as yet there is no way to open the emulator menu from the Spectrum keyboard... and all of the GPIO pins are used up. This needs a little thought but it's fine to play with as it is and you can always attach a USB keyboard to access the menus.

fruit-bat avatar Aug 14 '22 20:08 fruit-bat

There is some code on a branch, including an executable: https://github.com/fruit-bat/pico-zxspectrum/tree/feature/zxkeyboard https://github.com/fruit-bat/pico-zxspectrum/blob/feature/zxkeyboard/uf2/ZxSpectrumBreadboardHdmiKbd1PinAudio.uf2

It all works fine, as far as I can tell, but as yet there is no way to open the emulator menu from the Spectrum keyboard... and all of the GPIO pins are used up. This needs a little thought but it's fine to play with as it is and you can always attach a USB keyboard to access the menus.

Why not use a sn74hc164 or similar shift register to drive the keyboard row lines? That should free some pin

lortoffi avatar Aug 16 '22 13:08 lortoffi

Yup, could do. I will get some and have a play. Will need diodes on each on the row lines as well.

fruit-bat avatar Aug 16 '22 17:08 fruit-bat

Shift register has arrived....

20220822_214315

...needs some software now.

fruit-bat avatar Aug 22 '22 20:08 fruit-bat

I've pushed some changes and a new uf2 to the main branch. For the example mappings see:

https://github.com/fruit-bat/pico-zxspectrum/blob/main/src/ZxSpectrumKeyMatrix.cpp

It now supports an 8x8 key matrix.

The keyscan routines could do with a PIO program rather than being 'bit-banged', which I will try and get round to at some point.

There is one pin free, which I could use to 2-pin PWM audio? The UART pins are also free which is nice for debug but could be used for something else.

Let me know your thoughts.

fruit-bat avatar Aug 26 '22 22:08 fruit-bat

I've pushed some changes and a new uf2 to the main branch. For the example mappings see:

https://github.com/fruit-bat/pico-zxspectrum/blob/main/src/ZxSpectrumKeyMatrix.cpp

It now supports an 8x8 key matrix.

The keyscan routines could do with a PIO program rather than being 'bit-banged', which I will try and get round to at some point.

There is one pin free, which I could use to 2-pin PWM audio? The UART pins are also free which is nice for debug but could be used for something else.

Let me know your thoughts.

Hi!

Thank you very much for all your time and efforts! I´ll give it a try with my hardware, I need to get a shift register and test this.

Cheers!

wtfrules avatar Aug 27 '22 01:08 wtfrules