pimoroni / unicorn-hat

Python library for Unicorn pHAT and HAT. 32 or 64 blinding ws2812 pixels for your Raspberry Pi
https://shop.pimoroni.com/products/unicorn-hat
MIT License
370 stars 131 forks source link

Binary clock date is wrong #127

Closed datruck closed 5 years ago

datruck commented 5 years ago

In the example binary_clock.py the implementation of day is incorrect. How can 31 days be represented by only 4 bits? 5 bits would be needed. However that would interfere with the 4 bits currently used for month. Not sure how this can be fixed.

Gadgetoid commented 5 years ago

You're right- and the comments actually explicitly state "day will not go past 31 so only needs 4 bits." Clearly a minor error that informed the design of the whole clock and, uh, well painted it into this unfortunate corner.

I'm going to try a small hack:

draw_time_string(now.day >> 1, 4, 0, 0, lightblue if now.day & 16 else blue)

Which encodes the 5th bit into the colour of the day counter.

Pyroseza commented 3 years ago

oof how did I not see this issue, thanks for fixing it guys.

I'm actually working on this again doing a rewrite with things I've learnt over the last 2 years