Minor fixes to Moon Clock
Read accelerometer 2X on boot to blow out startup residue.
Show "100%" at max instead of "100.0%" (looks nicer).
Force periodic matrix repaint to try to fix situation where splash screen is stuck.
@@ -175,6 +175,8 @@ MATRIX = Matrix(bit_depth=BITPLANES)
DISPLAY = MATRIX.display
ACCEL = adafruit_lis3dh.LIS3DH_I2C(busio.I2C(board.SCL, board.SDA),
address=0x19)
+_ = ACCEL.acceleration # Dummy reading to blow out any startup residue
+time.sleep(0.1)
DISPLAY.rotation = (int(((math.atan2(-ACCEL.acceleration.y,
-ACCEL.acceleration.x) + math.pi) /
(math.pi * 2) + 0.875) * 4) % 4) * 90
@@ -368,7 +370,7 @@ while True:
GROUP[0] = TILE_GRID
# Update percent value (5 labels: GROUP[1-4] for outline, [5] for text)
- if PERCENT >= 100:
+ if PERCENT >= 99.95:
STRING = '100%'
else:
STRING = '{:.1f}'.format(PERCENT + 0.05) + '%'
@@ -421,4 +423,5 @@ while True:
GROUP[7].x = CENTER_X - GROUP[7].bounding_box[2] // 2
GROUP[7].y = TIME_Y + 10
+ DISPLAY.refresh() # Force full repaint (splash screen sometimes sticks)
time.sleep(5)
