File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change 13
13
This video walks you through the code: https://youtu.be/eNpPLbYx-iA
14
14
"""
15
15
16
- from time import sleep
16
+ import time
17
17
from adafruit_circuitplayground .express import cpx
18
18
19
19
cpx .pixels .brightness = 0.2 # Adjust overall brightness as desired, between 0 and 1
@@ -28,25 +28,21 @@ def color_amount(accel_component):
28
28
return round (normalized_accel * 255 ) # Convert to 0–255
29
29
30
30
31
- def fmt_accel ( acceleration ):
31
+ def format_acceleration ( ):
32
32
return ', ' .join (('{:>6.2f}' .format (axis_value ) for axis_value in acceleration ))
33
33
34
34
35
- def fmt_rgb ( rgb_amounts ):
35
+ def format_rgb ( ):
36
36
return ', ' .join (('{:>3d}' .format (rgb_amount ) for rgb_amount in rgb_amounts ))
37
37
38
38
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 ( )))
41
41
42
42
43
- def process () :
43
+ while True :
44
44
acceleration = cpx .acceleration
45
45
rgb_amounts = [color_amount (axis_value ) for axis_value in acceleration ]
46
46
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 )
You can’t perform that action at this time.
0 commit comments