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

Fix date display in binary clock #134

Closed hughsaunders closed 4 years ago

hughsaunders commented 4 years ago

The date (day-of-month) field has 4 lights/bits so it can display values from 0-15, this isn't sufficient for dates which can go up to 31. This was recognised previously (#127) and colour was used to encode the 5th bit. However the previous solution was incorrect because it encodes the most significant bit in colour but discards the least significant bit with a right shift. This commit fixes that by only removing the most significant bit and encoding it as colour.

Gadgetoid commented 4 years ago

Looks good to me. For posterity I'd probably have avoided conflating bitwise values and regular maths operators and been more explicit about what we want to happen by using now.day & 0b10000 instead of now.day > 0b1111, but it's not a problem.

Thanks for spotting this and taking the time to PR a fix!