Keyboard map Sinclair Spectrum ZX +2 on Teensy 3.2 - keyboard

I'm converting a Sinclair Spectrum 128 ZX +2 into a Raspberry Pi-powered computer and I'm using a Teensy 3.2 USB Development Board for mapping the original keyboard with the original membrane and get a normal USB keyboard. I'm not planning to maintain the original key mapping, probably I'll buy some stickers and I'll convert it in a UK keyboard.
I've reused the original ribbon connectors in this way:
5 Rows > Teensy Pins 1 to 5
8 Columns > Teensy Pins 6 to 13
(I noticed the disconnected cables after I took the photo, now fixed)
I've found a Teensy code for something similar online (thanks Chad Boughton) and I've tried to adapt it for the Sinclair, the first attempt was to simply check if all the keys were working.
Here the code: https://gist.github.com/federicocappelli/7f61d6bc2095cbc278df12519b721435
Briefly, I've created a fake keys matrix:
const byte ROWS = 5;
const byte COLS = 8;
char keys[ROWS][COLS] = {
{KEY_1,KEY_2,KEY_3,KEY_4,KEY_5,KEY_6,KEY_7,KEY_8},
{KEY_9,KEY_0,KEY_A,KEY_B,KEY_C,KEY_D,KEY_E,KEY_F},
{KEY_G,KEY_H,KEY_I,KEY_J,KEY_K,KEY_L,KEY_M,KEY_N},
{KEY_O,KEY_P,KEY_Q,KEY_R,KEY_S,KEY_T,KEY_U,KEY_V},
{KEY_W,KEY_X,KEY_Y,KEY_Z,KEY_ENTER,KEY_TILDE,KEY_DELETE,KEY_BACKSPACE}
};
byte rowPins[ROWS] = {1,2,3,4,5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6,7,8,9,10,11,12,13}; //connect to the column pinouts of the keypad
But the result is not what I was expecting, for instance, pressing
spacebar the keyboard prints 12345678
u the keyboard prints 5cs
graph the keyboard prints 6d4b
I expected 1 character for one keypress.
What I am doing wrong?
Here the Sinclair service manual with the keyboard membrane explanation
The keyboard as reference:

if you're still interested by this topic,
I wrote a code to handle the ZXSpectrum+ specific Keyboard (compared to Legacy Spectrum) with an Arduino MICRO MCU.
only SYMBOL+A combo does still not work
based on the PDF that you sent...
ZXKeyb with arduino micro

Related

X server 8 bit pseudo color initiating the palette (linux xdoom)

I' looking at the original 1997 32 bit port of xDoom for Linux which I have running on Ubuntu 64 bit.
Sound and input is working and I am getting graphical output but the colors are all wrong.
The code assumes an 8 bit pseudo screen and I have used Xypher (Xserver) to provide a window that is 8 bits deep.
So I get the impression xDoom assumes this 8 256 pseudo color screen has a fixed/default palette of colors which the X window does not have.
So I need to know two things:
what is the color palette for a 256 pseudo color X window
how can I use a script/program to assign colors to the X window prior to xDoom launching.
At this point I'm assuming 8 bit RGB 3x3x2, but I don't really know.
My startup script looks like this:
#!/bin/sh
Xephyr :2 -ac -br -screen 1280x800x8 -reset -terminate -title DOOM &
#DISPLAY=:2 ./setupcolorpalette
DISPLAY=:2 ./linuxxdoom -4 -warp 1 1
I need some ideas regarding doing this in script or code!
I had the same issue. Fixed by adding the following line to i_video.c around line 819 (just before the call to XDefineCursor).
XInstallColormap(X_display, X_cmap);
I found this fix in a closed PullRequest for DOOM here: https://github.com/id-Software/DOOM/pull/2/files#diff-ecac9183c706456b9a28129cc023c038R820

Fastest way to get X/Y position of text or text-based shape in screenshot?

I'm trying to create a script for Linux that will detect where the text cursor is. This should be done in maximum 1 second. In order to implement this, the best solution seems to be to programmatically add some text via xdotool, take a screenshot via some other utility, try to figure out the position of that text, and then remove the text we've inserted using xdotool again.
I tried inserting a random string (like <-- CURSOR HERE). Using Tesseract 4 it takes about 20 seconds to find the position of the string, although it's very precise in terms of pixel coordinates. I was not able to use whitelisting (in version 4 of Tesseract) to narrow result to specific letters or digits only, which I assume would speed up processing.
I don't know what font the user will be using, but every font has dashes and slashes, so I could create some sort of shape (for instance, |/\|/\|/\|/\|), and use some library to detect that shape. What would be a good choice?
I don't care about what's on the rest of the screen: it could be more text, images, etc. I only need o know where my random string is (<-- CURSOR HERE, |/\|/\|/\|/\|, or can you think of anything else), and get its X/Y position in pixels.

Key 42 (USB HID codes)

Can anybody explain what a key with position 42 on AT-101 keyboard is? This key has Usage ID 50 (dec) in USB specification.
On my AT-102 keyboard it looks like Backslash key, but Backslash key is located at position 29 here and has Usage ID 49.
Hut1_12v2.pdf (page 54)
It depends on the region, in the UK it is a key that contains the ~ and the # (if a shift key is pressed).
In the UK the Enter's key shape is different and takes the space of position 29 and position 43.
In the document you linked to on page 54 the line with usage id 50 contains the explanation (Keyboard Non-US # and ~), and there is a reference to footnote 2 on page 59.
below is a 102 key layout
and here is a example from 2 keyboards, one for the US market and one for the UKmarket.
UK market:
US market:
However it appears that this key is used on the 102-key keyboard layout.
You can find more details and examples here:
https://www.w3.org/TR/uievents-code/

Cosmos VGAScreen Clear Colors

I remember finding this online once but I can't seem to find it anywhere now. I'm creating an enumeration for each of the colors (ints) in the vgascreen.clear(int) method. Instead of testing out each number, I was looking for a description online for each number coresponding to it's correct integer value.
for example
VGAScreen.Clear(0); // Black Screen
VGAScreen.Clear(1); // Blue Screen
VGAScreen.Clear(2); // Green
...
...
As you can guess, testing out each number is getting to be tiresome and boring. Anybody know a link for what I'm looking for?
First relevant image hit on google for standard VGA palette search.
Those are the colors set by VGA BIOS entering any 256 colors VGA/VESA video mode. It is designed for better dithering results ...
So it is high likelly you got the same colors.

TMRpcm playback and analogread issue on Arduino

I am working on an Arduino toy (using Uno). When people press the Force Sensitive Resistor, it triggers the .wav audio which is played by the TMPpcm library.
However, I realized once the audio is played the analogread from the FSR got messed up.
(the value on the FSR no longer goes back to 0, instead, it's stuck with some numbers.
I tried to set it back to 0 at the end of the function. didn't work.)
also tried with digitalread with thick buttons, it's fine. But I really would love to use the thin FSR so I can put it in papers.
Any thought?
Thanks a lot!!
Put a resistor from the positive side of the "button" to ground. Should pull the value down to zero.

Resources