Following on from the game prototyping I've started on the hardware.
To display the numbers I wired up a small LCDsmall LCD I had spare from earlier experiments. It's a "Chip on Glass" model so it's very small and has an inbuilt I2C slave chip that's compatible with the ST7032i.
As well as these pins there's a back light on the side of the LCD that needs powering. I added a resistor and drove that from the supply line of the Trinket. The LCD also has an inbuilt voltage booster to allow it to be run from 3v (same as the trinket) but I thought I'd try and keep the component count down and decided to run that from the 5v supply too. I used some 2K2 resistors to pull up the I2C bus to the 3v output on the Trinket and hoped the LCD would be ok with that.
After a few experiments I settled on Visual Studio Code for editing and Putty for diagnostics. I connected to the serial port of the Trinket and it's pretty good at reporting issues with the code, "missing name" was the most frequent error I saw which was an indication my libraries/includes were not quite right.
I tried the example of I2C scan from Adafruit and that did work (once I'd remembered to connect the 0v rail for the LCD), that reported the LCD was present at 0x3E.
I then tried the Adafruit character lcd libraries but those just reported that there was no enough space on the trinket. I looked at the data sheet and some old arduino code and contemplated writing my own library. A bit of googling found me an example from boochowp which was a ESP32 variant with MicroPython. ESP32 + MicroPythonでLCDモジュールに文字を表示させてみた: 楽しくやろう。
The library needed a few tweaks to the includes and a "lock" adding but I eventually had some text appearing. I then spent ages trying to find the right function to turn a character into it's ASCII integer value and eventually stumbled on "ord" which seems to work nicely.
https://github.com/Workshopshed/FizzBuzz/blob/master/st7032i.PY
import board
import busio
from st7032i import ST7032i
i2c = busio.I2C(board.SCL, board.SDA)
lcd = ST7032i(i2c)
#Write ABC
for c in "Hi Workshopshed":
lcd.write_data (ord(c))
Next up, some hardware buttons.



Top Comments