DigiClock Unit
UNIT-Digi-Clock is a 2.1 inch 4-digit 7-segment display module. There are decimal points on each digit and an extra wire for colon-dots in the center, which can display Decimals and Clock. This module adopts TM1637 as the driver IC, and STM32F030 as I2C communication. I2C address can be modified per 4-bit dip switch. The red LED supports 8 brightness. And we have reserved 4 fixing holes there.
Support the following products:
Micropython Example:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from hardware import * 9from unit import DigiClockUnit 10import time 11 12 13label0 = None 14i2c0 = None 15digiclock_0 = None 16 17 18now = None 19 20 21def setup(): 22 global label0, i2c0, digiclock_0, now 23 24 M5.begin() 25 Widgets.fillScreen(0x222222) 26 label0 = Widgets.Label("label0", 99, 97, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu40) 27 28 i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000) 29 digiclock_0 = DigiClockUnit(i2c0, 0x30) 30 now = str((str(((time.localtime())[3])) + str(":"))) + str(((time.localtime())[4])) 31 digiclock_0.set_string(now) 32 label0.setText(str(now)) 33 34 35def loop(): 36 global label0, i2c0, digiclock_0, now 37 M5.update() 38 if now != (str((str(((time.localtime())[3])) + str(":"))) + str(((time.localtime())[4]))): 39 now = str((str(((time.localtime())[3])) + str(":"))) + str(((time.localtime())[4])) 40 label0.setText(str(now)) 41 digiclock_0.set_string(now) 42 digiclock_0.set_raw(1, 2) 43 time.sleep(1) 44 digiclock_0.set_raw(0, 2) 45 time.sleep(1) 46 47 48if __name__ == "__main__": 49 try: 50 setup() 51 while True: 52 loop() 53 except (Exception, KeyboardInterrupt) as e: 54 try: 55 from utility import print_error_msg 56 57 print_error_msg(e) 58 except ImportError: 59 print("please update to latest firmware")
UIFLOW2 Example:
cores3_digi_clock_example.m5f2
class DigiClockUnit
Constructors
Methods
- DigiClockUnit.set_brightness(brightness: int) None
Set the brightness of the display.
- 参数:
brightness (int) – The brightness of the display, range from 0 to 8.
UIFLOW2: