g0hjq / lcd_nixie_clock

Pseudo Nixie LCD clock in Micropython for the Waveshare kit and Pi Pico

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lcd_nixie_clock

Pseudo Nixie LCD clock in Micropython for the Waveshare kit and Pi Pico

This project contains the MicroPython code for a Raspberry Pi Pico RP2040 to drive the Waveshare Programmable RGB Pseduo Nixie Tube clock. See https://www.waveshare.com/lcd-clock-a.htm

image

Features

  • Shows the time in 12 or 24 hour format
  • Shows time on the LCDs in the style of Nixie tubes. Other types of display may be shown
  • Shows Hours, minutes and seconds, or Hours, Minutes and Alarm status
  • Alarm sounds the buzzer and flashes the LED neopixels
  • Controlable brightness
  • Ten preset RGB lighting patterns. More may be added if desired

Alternative self-setting version with web interface

If you are looking for something a bit "smarter", Michael Margolis has produced a WiFi version of this project which has automatic date and time setting synchronized with NTP, plus a web browser user interface to configure the clock settings. Details can be found here: https://github.com/michaelmargolis/lcd_ntp_nixie_clock

Limitations

  • Due to the lmiited amount of eeprom in the Pi Pico, only one set of font files may be loaded at any one time, however alternative .raw font files may be created and uploaded via Thonny. Additional 7-segment and dot-matrix like fonts are generated by the software.
  • The temperature and humidity from the BME280 sensor are not displayed. The sensor is on the PCB, inside an unventilated case, so is never going to be able to give accurate readings.
  • Due to the way the LCD chip enable pins and DC pins are wired, it is not possible to use the standard Adafruit driver libraries. This uses modified versions of the Waveshare 1.14" python examples to drive all 6 LCDs. As it is written in Micropython, the performance is not optimum, but adequate for this project
  • The time is maintained by a battery backed up DS3231 temperature compensated clock chip. This is reasonably accurate, but could be improved by reading the time over Wifi from an NTP server. Possible future enhancement?
  • I wanted to animate the RGB LED lighting in the RP2040's second core, but was unable to do this reliably. It would often crash after an hour or so. I suspect this may be due to the experimental nature of micropython multi-threading support. Maybe this can be revisited at some time in the future.

Font Files

The ten images for the digits 0 to 9 are stored in .raw files. This is explained here: https://www.penguintutor.com/programming/picodisplayanimations . You can create your own set of font files as follows:

  • Create a set of 10 image files at resolution 240 x 135 pixels.
  • Rotate the images anticlockwise 90 degrees and save as .png files 0.png to 9.png
  • Run the conversion program animation_convert.py. This will produce files 0.raw to 9.raw
  • Use thonny to upload the .raw files to the root directory of the pi pico

Other Fonts

Additional 7-segment and dot-matrix like fonts in various colurs are generated by the Python code in display.py

PXL_20230707_190128832

PXL_20230707_184316827

Files

  • main.py : The main program file in Micropython
  • ds3231.py : Driver for the DS3231 real time clock chip
  • display.py : LCD driver for the Waveshare ST7789 1.14" 240x134 pixel LCD. Also includes a 5x8 ASCII text font which is shown magnified 4x
  • leds.py : Controls the RGB neopixel LEDs behind each digit. Consider adding more effects and/or animations, maybe running as a seperate thread in the second core.
  • setings.py : Saves and retrieves the alarm time, display mode and other setting values in the settings.json file below.
  • settings.json : Contains the setting values. This file is written to every time one of the clock settings is changed. settings.json will be created automatically if it does not exist

Installation

Use Thonny to upload the following files to the root directory of the Raspberry Pi Pico. Do not copy the fonts directory or its contents.

  • display.py
  • ds3231.py
  • leds.py
  • main.py
  • settings.py
  • 0.raw
  • 1.raw
  • 2.raw
  • 3.raw
  • 4.raw
  • 5.raw
  • 6.raw
  • 7.raw
  • 8.raw
  • 9.raw

Open main.py in the Thonny editor and press RUN.

Because the top program file is named "main.py", the clock will start automatically when powered on.

Setting the Clock

  • Press the Mode button to enter the first setting screen (Alarm On/Off).
  • Press the Left and Right buttons to change the value. (The buttons should now be labeled Down and Up). 0 means OFF and 1 means ON
  • Further presses of the mode button cycle through all the various settings before returning to normal time-keeping.
  • If no setting button is pressed for 5 seconds, the clock will automatically return to normal time-keeping.
  • The adjust timing setting allows very slight adjustments to be made to the Quartz oscilator. The default value is 128, which should be a pretty good starting point accurate to a few seconds a month. Lower values speed up the clock, and higher values slow the clock. If you have access to a very accurate frequency counter, the exact 1Hz timing signal can be monitored on Pin 24 (GPIO 18) of the Raspberry Pi Pico.

About

Pseudo Nixie LCD clock in Micropython for the Waveshare kit and Pi Pico

License:MIT License


Languages

Language:Python 100.0%