@@ -172,9 +172,9 @@ def next_moon_data(datetime, utc_offset):
172
172
DISPLAY = MATRIX .display
173
173
ACCEL = adafruit_lis3dh .LIS3DH_I2C (busio .I2C (board .SCL , board .SDA ),
174
174
address = 0x19 )
175
- ROTATE = (int (((math .atan2 (- ACCEL .acceleration .y , - ACCEL . acceleration . x ) +
176
- math . pi ) / ( math . pi * 2 ) - 0.125 ) * 4 ) % 4 ) * 90
177
- DISPLAY . rotation = ROTATE
175
+ DISPLAY . rotation = (int (((math .atan2 (- ACCEL .acceleration .y ,
176
+ - ACCEL . acceleration . x ) + math . pi ) /
177
+ ( math . pi * 2 ) + 0.875 ) * 4 ) % 4 ) * 90
178
178
179
179
LARGE_FONT = bitmap_font .load_font ('/fonts/helvB12.bdf' )
180
180
SMALL_FONT = bitmap_font .load_font ('/fonts/helvR10.bdf' )
@@ -189,7 +189,7 @@ def next_moon_data(datetime, utc_offset):
189
189
# Element 0 is a stand-in item, later replaced with the moon phase bitmap
190
190
# pylint: disable=bare-except
191
191
try :
192
- FILENAME = 'moon/splash-' + str (ROTATE ) + '.bmp'
192
+ FILENAME = 'moon/splash-' + str (DISPLAY . rotation ) + '.bmp'
193
193
BITMAP = displayio .OnDiskBitmap (open (FILENAME , 'rb' ))
194
194
TILE_GRID = displayio .TileGrid (BITMAP ,
195
195
pixel_shader = displayio .ColorConverter (),)
@@ -339,7 +339,7 @@ def next_moon_data(datetime, utc_offset):
339
339
else :
340
340
NEXT_EVENT = NEXT_PERIOD .set
341
341
342
- if ROTATE in (0 , 180 ): # Horizontal 'landscape' orientation
342
+ if DISPLAY . rotation in (0 , 180 ): # Horizontal 'landscape' orientation
343
343
CENTER_X = 48 # Text along right
344
344
MOON_Y = 0 # Moon at left
345
345
TIME_Y = 6 # Time at top right
0 commit comments