The popular Mahjong game (4 players using ivory bricks) uses a points reckoning system that balances the individuals' scores in a certain way so that the net result always equals zero. This process is rather tedious and requires the person who is calculating to be "decoupled" from the ongoing social conversations, which degrades one of the nice aspects of the game. Therefore it is a good candidate for automation. My oldest son Joost and I undertook the project of implementing such a calculator in ZBasic hardware using a ZX-328L microcontroller and a simple matrix keyboard and an LCD display. Joost had already made a Java applet for the calculator as a web-app; he translated it to a first rough version of a ZBasic program for the controller, I subsequently refined it and designed the electronics and the box. This project was a nice opportunity for both of us to jointly learn object-oriented programming.
The project is a nice example of the flexibility and power of the ZBasic platform, as shown for example by:
- The use of the FirstTime command to show a welcome text only a few times,
- The use of the AN105 code for interfacing the matrix keyboard, providing for a very fluid behavior of the keyboard in practice,
- Object-oriented programming as a useful way to easily include functionality (for example: LCD display routines are used through the mix-in concept).
The true fun is with the functionality as provided by the software (V5.1 as a zipped ZBASIC project) and the project casing. The QR-code on the box links to a page in Dutch where I explain how the calculator works and how scores per individual are calculated first, which are then used as input for the calculator.
The calculator became somewhat of a visual attraction point and since the Mahyong game is quite a thing in my family I ended up making several units, including the following for my three sons:
From an electrical perspective this project is rather straightforward: a ZX-328L microcontroller with keypad and LCD display interfaces as shown here:

