方法很简单,只需要修改一行代码即可。
https://github.com/spoonysonny/SAKS-tutorials/blob/master/digital-clock/entities/digital_display_tm1637.py
里面这一行:
__number_code = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x00, 0x40]
这些十六进制代表了数码管1位中数字0-9的编码。根据自己需要的形状调整即可。
例如:
#
# __2_
# | | | 0 -> 011 1111 -> 0x3f
# 1 | | 3 | 1 -> 010 0001 -> 0x21
# |__7__| | 2 -> 111 0110 -> 0x76
# | | | 4 -> ...
# 6 | | 4 | ...
# |__5__| | 9 -> ... -> 0x5f
#
pins = [27, 17, 22, 10, 25, 24, 11] #GPIO ports
sels = [14, 15, 18, 23] #GPIO ports to select led, there are four led lights
nums = [0x3f, 0x21, 0x76, 0x5e, 0x4d, 0x5b, 0x7b, 0x0e, 0x7f, 0x5f]
参考:
http://shumeipai.nxez.com/2014/10/12/raspberry-pi-drive-four-digital-tube-display-time.html