Skip to content

Commit 0ce9854

Browse files
committed
Fix some linter complaints
1 parent e0be54a commit 0ce9854

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

examples/gravity/main.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
# as used in https://learn.adafruit.com/animated-led-sand
33
# Explainatory comments are used verbatim from that code.
44

5-
import board
6-
import busio
75
import math
86
import random
97

8+
import board
9+
import busio
10+
1011
import adafruit_lsm303
1112
import adafruit_dotstar
1213

@@ -18,10 +19,10 @@
1819
GRAIN_COLOR = (64, 64, 64)
1920
MAX_X = WIDTH * 256 - 1
2021
MAX_Y = HEIGHT * 256 - 1
21-
22+
2223
class Grain:
2324
def __init__(self):
24-
x = 0
25+
x = 0
2526
y = 0
2627
vx = 0
2728
vy = 0
@@ -42,9 +43,9 @@ def __init__(self):
4243

4344
def index_of_xy(x, y):
4445
return (y >> 8) * WIDTH + (x >> 8)
45-
46-
def already_present(i, x, y):
47-
for j in range(i):
46+
47+
def already_present(limit, x, y):
48+
for j in range(limit):
4849
if x == grains[j].x or y == grains[j].y:
4950
return True
5051
return False
@@ -58,13 +59,13 @@ def already_present(i, x, y):
5859
occupied_bits[index_of_xy(g.x, g.y)] = True
5960
g.vx = 0
6061
g.vy = 0
61-
62+
6263
while True:
6364
# Display frame rendered on prior pass. It's done immediately after the
6465
# FPS sync (rather than after rendering) for consistent animation timing.
6566

6667
for i in range(NUMBER_PIXELS):
67-
wing[i] = GRAIN_COLOR if occupied_bits[i] else (0,0,0)
68+
wing[i] = GRAIN_COLOR if occupied_bits[i] else (0, 0, 0)
6869
wing.show()
6970

7071
# Read accelerometer...
@@ -125,7 +126,8 @@ def already_present(i, x, y):
125126

126127
oldidx = index_of_xy(g.x, g.y) # prior pixel
127128
newidx = index_of_xy(newx, newy) # new pixel
128-
if oldidx != newidx and occupied_bits[newidx]: # If grain is moving to a new pixel... but if that pixel is already occupied...
129+
if oldidx != newidx and occupied_bits[newidx]: # If grain is moving to a new pixel...
130+
# but if that pixel is already occupied...
129131
delta = abs(newidx - oldidx) # What direction when blocked?
130132
if delta == 1: # 1 pixel left or right
131133
newx = g.x # cancel x motion

0 commit comments

Comments
 (0)