Skip to content

Commit d0d481e

Browse files
committed
Make Adafruit-requested changes
1 parent 5f494e0 commit d0d481e

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

examples/circuitplayground_acceleration_mapping_neopixels.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
This video walks you through the code: https://youtu.be/eNpPLbYx-iA
1414
"""
1515

16-
from time import sleep
16+
import time
1717
from adafruit_circuitplayground.express import cpx
1818

1919
cpx.pixels.brightness = 0.2 # Adjust overall brightness as desired, between 0 and 1
@@ -28,25 +28,21 @@ def color_amount(accel_component):
2828
return round(normalized_accel * 255) # Convert to 0–255
2929

3030

31-
def fmt_accel(acceleration):
31+
def format_acceleration():
3232
return ', '.join(('{:>6.2f}'.format(axis_value) for axis_value in acceleration))
3333

3434

35-
def fmt_rgb(rgb_amounts):
35+
def format_rgb():
3636
return ', '.join(('{:>3d}'.format(rgb_amount) for rgb_amount in rgb_amounts))
3737

3838

39-
def log_values(acceleration, rgb_amounts):
40-
print('({}) ==> ({})'.format(fmt_accel(acceleration), fmt_rgb(rgb_amounts)))
39+
def log_values():
40+
print('({}) ==> ({})'.format(format_acceleration(), format_rgb()))
4141

4242

43-
def process():
43+
while True:
4444
acceleration = cpx.acceleration
4545
rgb_amounts = [color_amount(axis_value) for axis_value in acceleration]
4646
cpx.pixels.fill(rgb_amounts)
47-
log_values(acceleration, rgb_amounts)
48-
49-
50-
while True:
51-
process()
52-
sleep(0.1)
47+
log_values()
48+
time.sleep(0.1)

0 commit comments

Comments
 (0)