I had intended to have the ZX81 keyboard control a Raspberry PI using the serial in, on the PI's GPIO header, and then acting as a PS2 keyboard via that serial connection. While this seems like it should be possible and basic serial communication was easily achievable, I didn't have much luck getting it to work with the PS2 protocol. For anybody with more fortitude than I, inputattach seems to hold they key. In the end I fell back on an easier option, that of using USB.
A LeoStick acting as a ZX81 keyboard controller |
Not being the first person to do something is usually pretty beneficial, and in the case of interfacing ZX81 keyboards, Arduinos and Raspberry PI's doubly so. Not only has the Leonardo been used to do just this previously, there is already a complete 'how to', thanks to Smittytone and The Sinclair ZX81: a Raspberry Pi retro restyle – Part 1 blog entry.
The complete code listing for the Leonardo and instructions are in the Smittytone blog, so I wont reproduce them here. I did have to make one tiny alteration to get things working with the LeoStick, as Pin 11 is linked to an inbuilt piezo on the LeoStick. You simply need to change the following in the code and wiring up accordingly.
Change from: // Define the row and column pins byte colPins[NUM_COLS] = {13, 12, 11, 10, 9}; |
Change to: // Define the row and column pins byte colPins[NUM_COLS] = {13, 12, 10, 9, 8}; |
The keyboard works perfectly with the LeoStick as is, however the functionality of the Arduino code is not complete. There is no emulator mode / layer, and there are a lot of key codes missing that are required for a complete PS2 keyboard replacement. With the limited number of keys available on the ZX81 keyboard it wont be easy, however the manner in which keyboard is used in a ZX81 provides the answer to this problem.
Each Key on the ZX81 keyboard has several modes of operation, you can switch these modes by pressing the Shift key and either a combination of Shift, Function or Shift, Graphics keys. There are a total of 6 possible modes to set the keyboard to, this should give plenty of options for filling out most of the required PS2 keys. Of course it wont be the most efficient of keyboard mappings, but then that was always going to be a problem.
One last thing, proving just how these things go kind of go around in circles, there is a blog entry on the Freetronics site, commenting on the possibility of using a LeoStick to drive a ZX81 keyboard.
No comments:
Post a Comment