File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 16
16
board .DISPLAY .show (splash )
17
17
18
18
max_brightness = 2 ** 15
19
+ SENSITIVITY = 5 # reading in Z direction to trigger, adjustable
19
20
20
21
images = list (filter (lambda x : x .endswith ("bmp" ), os .listdir ("/" )))
21
22
22
- i = random .randint (0 , 19 ) # initial image is randomly selected
23
+ i = random .randint (0 , ( len ( images ) - 1 ) ) # initial image is randomly selected
23
24
24
25
# Set up accelerometer on I2C bus, 4G range:
25
26
I2C = busio .I2C (board .SCL , board .SDA )
52
53
# Wait forever
53
54
while not shaken :
54
55
try :
55
- ACCEL_X , ACCEL_Y , ACCEL_Z = ACCEL .acceleration # Read the accelerometer
56
+ ACCEL_Z = ACCEL .acceleration [ 2 ] # Read Z axis acceleration
56
57
except IOError :
57
58
pass
58
59
# print(ACCEL_Z) # uncomment to see the accelerometer z reading
59
- if ACCEL_Z > 5 :
60
+ if ACCEL_Z > SENSITIVITY :
60
61
shaken = True
61
62
62
63
# Fade down the backlight
66
67
67
68
splash .pop ()
68
69
69
- if ACCEL_Z > 5 :
70
- i = random .randint (0 , 19 ) # initial image is randomly selected
71
- print ("shaken" )
72
- faceup = False
70
+ i = random .randint (0 , (len (images )- 1 )) # pick a new random image
71
+ # print("shaken")
72
+ faceup = False
73
73
i %= len (images ) - 1
You can’t perform that action at this time.
0 commit comments