Skip to content

Instantly share code, notes, and snippets.

@valkheim
Last active April 12, 2020 15:46
Show Gist options
  • Save valkheim/52b4685f6656cde8146b31c5905d2582 to your computer and use it in GitHub Desktop.
Save valkheim/52b4685f6656cde8146b31c5905d2582 to your computer and use it in GitHub Desktop.
Yellow dots, tracking dots decoder
# 0 1 2 3 4 5 6 7 8 9 A B C D E
# X X X X X X X X X X (parity row)
# +---------------------------
# 64 X| X X
# |
# 32 X|X X X X
# |
# 16 X|X X X X X X
# |
# 8 | X X X X X
# |
# 4 | X X X X X X X X X
# |
# 2 |X X X
# |
# 1 X| X X X X X X
#
# | | | | | | | | | | | |
# | | | | | | | | | | | +-- 64+32+8+4=108
# | | | | | | | | | | +-- 16+4+1=21
# | | | | | | | | | +-- 4+1=5
# | | | | | | | | +-- 18+8+4=28
# | | | | | | | +-- 32+16+8+1=57
# | | | | | | |
# | | | | | | +-- 4+1=5
# | | | | | +-- 4+2=6
# | | | | +-- 16+4+1=21
# | | | +--8+4=12
# | | +-- 0
# | +-- 0
# +-- 32+16+2=50
#
# Columns:
# 0: parity column
# 1: minute
# 2: unused
# 3: unused
# 4: hour
# 5: day
# 6: month
# 7: year (without century)
# 8: unused
# 9: separator (typically all ones)
# A-D: serial number
# E: unknow
#
# In this example: 2005-06-21 12:50 serial 21052857
ROW_VALUES = [0, 64, 32, 16, 8, 4, 2, 1]
LAST_COLUMN = 0x0E
SEPARATOR_COLUMN = 0x09
def get_colmun_value(matrix, column):
row = 0
value = 0
if column == SEPARATOR_COLUMN:
return 0
for c, e in enumerate(matrix):
if c % (LAST_COLUMN + 1) == column:
if e == 'X':
value += ROW_VALUES[row]
row += 1
return value
def print_columns(matrix):
for column in range(LAST_COLUMN + 1):
print(column, get_colmun_value(matrix, column))
def decode(matrix):
year = get_colmun_value(matrix, 0x07)
month = get_colmun_value(matrix, 0x06)
day = get_colmun_value(matrix, 0x05)
print(f"Date:\t20{year:02d}-{month:02d}-{day:02d}")
hour = get_colmun_value(matrix, 0x04)
minute = get_colmun_value(matrix, 0x01)
print(f"Time:\t{hour:02d}:{minute:02d}")
print(
"Serial:\t"
f"{get_colmun_value(matrix, 0x0D):02d}"
f"{get_colmun_value(matrix, 0x0C):02d}"
f"{get_colmun_value(matrix, 0x0B):02d}"
f"{get_colmun_value(matrix, 0x0A):02d}"
)
dots = """
X0XXX0XXX0X0X0X
X00000000X0000X
XX0000000XX000X
XX000X000XXX0X0
0000X0000XXX00X
0000XXXX0X0XXXX
0X0000X00X00000
X0000X0X0XX0XX0
""".replace('\n', '')
decode(dots)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment