Skip to content

binary_clock

wolfen351 edited this page Mar 30, 2024 · 2 revisions

The binary_clock module is designed to display the time in a binary format. It loads a UI on a touchscreen.

UI

The UI looks like this:

20240307_164201

The user can tap the screen to show and hide the decimal representation of the time that is shown underneath.

Time source

The time is sourced from the internal clock: localTime = time.localtime(time.time() + self.UTC_OFFSET)

This module relies on the ntptime micropython module to set the internal clock correctly. It syncs time on boot from the "0.nz.pool.ntp.org" ntp server (Hardcoded)

Time Zone Support

The UTC_OFFSET is used to adjust the time to the local time zone. It is currently hardcoded.

UTC_BASE_OFFSET = 12 * 60 * 60
UTC_OFFSET = 12 * 60 * 60

Daylight Savings Time

This module has very primitive (date based) support for daylight savings time. It is currently hardcoded.

    if (doy < 92 or doy > 268): # 2 April, 25 Sept
        self.UTC_OFFSET = self.UTC_BASE_OFFSET + 3600

Hardware / Pinout

The hardware I used when developing this module was this screen, designed for the D1 Mini: https://www.aliexpress.com/item/32919729730.html

"TFT 2.4 Touch Shield V1.0.0 for LOLIN (WEMOS) D1 mini 2.4" inch 320X240 SPI Touch Screen ILI9341 XPT2046"

I used a S2 Mini as the main controller: https://www.wemos.cc/en/latest/s2/s2_mini.html

I 3d printed a case to hold the screen: Thingiverse Link

310735729-ee49e668-32dc-4cbf-a6f7-31d6b1ebdeca

It was difficult to map the pins for the D1 Mini to the S2 mini for this screen display unit!

SPI1 baud rate:

  • 60000000 - High speed for drawing - This worked (unreliably) up to 100000000, but 60M was stable.
  • 2000000 - Low speed for touch

I needed to reset the SPI1 baud rate to slow after drawing to allow the touch to work.

Here is the pin-out for the screen on the S2 Mini (ESP32):

  • GPIO0 -> Display - RST
  • GPIO5 -> Display - CS
  • GPIO7 -> SPI1 - SCK
  • GPIO9 -> SPI1 - MISO
  • GPIO11 -> SPI1 - MOSI
  • GPIO12 -> Display - DC
  • GPIO18 -> Touch - CS

Here is the official pinout for the D1 Mini (ESP8266): (Copied from: https://www.wemos.cc/en/latest/d1_mini_shield/tft_2_4.html)

TFT refers to the display. TS refers to the touchscreen.

D1 mini GPIO Shield
NC*(D1/D2/D3/D4) NC*(5/4/0/2) TFT_LED
RST*(D1/D3/D4)) RST*(5/0/2) TFT_RST
D8 15 TFT_DC
D7 13 MOSI
D6 12 MISO
D5 14 SCK
D0 16 TFT_CS
D3*(D1/D2/D4) 0*(5/4/2) TS_CS

Configuration

At the moment there are no config options for this module. All the pins are hardcoded.

Telemetry provided

This module provides no telemtry data for other modules to use.

Telemetry consumed

This module consumes no telemetry from other modules.

Commands provided

This module does not provide any commands to other modules.

Commands consumed

This module responds to touch commands. If the screen is touched, it toggles the display of the time in decimal format.

Commands:

  • /touch - This command toggles the display of the time in decimal format.
Clone this wiki locally