Portable (non-paying) Raspberry Pi Video Poker with a character LCD and controlled with GPIO buttons
VidPokerTerm is a prototype for a Raspberry Pi based handheld variant of the classic electronic casino game, although this one doesn’t pay any money. It was originally envisioned to be used in a larger tabletop / bartop style case and screen and coded with a full Qt-based graphical interface (it can still be built this way!), however the project turned into making it a smaller handheld-like device. That change in requirement meant making a new interface to use very low powered hardware like a 128x64 pixel ST7920 monochrome graphic LCD.
Eventually this will be built into some kind of 3D printed case with cutouts for buttons, the LCD, and inner mounting points for all the wires and brackets to hold it all together. It is very much a hobby project and is still being tinkered with!
The LCD-based game requires:
The Raspberry Pi communicates with 3.3 volt logic levels, but the CFAG12864S needs 5 volt logic. To overcome this, a logic level translator was used, the low-voltage (LV) side connected to the Pi's 3.3 volt connection and the high-voltage (HV) side connected to the Pi's 5 volt connector. Additionally, the Crystalfontz LCD requires 10K ohm potentiometers (one each for contrast and brightness), 5 volt inputs, ground connections, and the SPI connections. The amount of wires needed to hook up a screen quickly overwhelms a simple breadboard, so I built a bracket with a solderable breadboard to make screen and translator connections much easier.
Normally the CFAG12864S communicates over an 8-bit parallel interface, and this would require far more wires than I care to connect. Desoldering the J3 jumper and connecting J4 tells the display to receive instructions over SPI, requiring far fewer connections! To connect the LCD to the breadboard, I soldered male headers to pins 1-6 and 18-20.
The bracket the LCD connects to handles all connections and logic level translations, requiring only 6 wires to connect to the Raspberry Pi (note you will have to configure the Pi to use SPI):
TODO: connection diagram
Upon startup, you can interact with a keyboard emulating the buttons (use -k, this was done to expedite testing and not having wires sprawling over my desk, the keymap is dumped to the console at the start of the game) or with no arguments so the GPIO buttons will be watched for presses.
When starting the game, you are presented with the common VidPokerTerm UI, with softkey actions at the bottom, the number of credits in your account (starts with 0), and a game selection. 'Game' (softkey 3) cycles through the available games (only Jacks or Better is actually coded for now), 'Cred 0' (softkey 2) resets the account balance to 0, and 'Cr+100' (softkey 1) adds 100 credits to the account.
The '>' (softkey 4) shows that more features are available and you can see them by pressing that
key. In the case of the game selection window, only the 'Exit' feature lives there. The softkey
system is unified throughout the game, so new displays can be created and take advantage of it,
adding features as needed.
Pressing the 'select' button starts the game under 'Game Selection:'.
While not playing a hand, you can view the pay table for the current bet amount with 'PayTbl', and cycle through the bet amount with 'Bet +1' / 'BetMax'. Your current bet amount is displayed in the lower left, and the number of credits you have available is shown on the lower right. To deal cards, press the select button.
You see your credit count decreased by the bet amount and 5 cards were dealt. Each time a hand is rendered, the game back-end analyzes the hand and tells you, in this case, the two queens have given you 'Jacks or Better', but you haven’t won anything yet!
You need to hold the Queen of Spades and Queen of Hearts using the Hold 4 and Hold 5 buttons. The cards are underlined indicating that they will not be redrawn when pressing the select button.
Upon drawing the 3 replacement cards, the hand is reanalyzed but nothing better than the 'Jacks or Better' was given, so the game shows you won +5 credits and the hand is done. Pressing the select button at this point will deal a new hand and start again!
Here is an example of the Jacks or Better pay table. You return to the game by pressing 'Return' (softkey 3).