File tree Expand file tree Collapse file tree 3 files changed +79
-0
lines changed Expand file tree Collapse file tree 3 files changed +79
-0
lines changed Original file line number Diff line number Diff line change
1
+ class AudioOut :
2
+ def __init__ (self , pin ):
3
+ pass
4
+
5
+ def stop (self ):
6
+ pass
7
+
8
+ def play (self , what ):
9
+ pass
10
+
11
+ class WaveFile :
12
+ def __init__ (self , file , buffer = None ):
13
+ pass
Original file line number Diff line number Diff line change
1
+ ../ stage .py
Original file line number Diff line number Diff line change
1
+ import board
2
+ import stage
3
+ import busio
4
+ import time
5
+ import keypad
6
+
7
+
8
+ K_X = 0x01
9
+ K_O = 0x02
10
+ K_DOWN = 0x04
11
+ K_LEFT = 0x08
12
+ K_RIGHT = 0x10
13
+ K_UP = 0x20
14
+ K_Z = 0x40
15
+
16
+ display = board .DISPLAY
17
+ display .auto_brightness = True
18
+ display .auto_refresh = False
19
+
20
+
21
+ class _Buttons :
22
+ def __init__ (self ):
23
+ self .keys = keypad .Keys ((board .BTNA , board .BTNB , board .DOWN ,
24
+ board .LEFT , board .RIGHT , board .UP ),
25
+ value_when_pressed = False , interval = 0.05 )
26
+ self .last_state = 0
27
+ self .event = keypad .Event (0 , False )
28
+ self .last_z_press = None
29
+
30
+ def get_pressed (self ):
31
+ buttons = self .last_state
32
+ events = self .keys .events
33
+ while events :
34
+ if events .get_into (self .event ):
35
+ bit = 1 << self .event .key_number
36
+ if self .event .pressed :
37
+ buttons |= bit
38
+ self .last_state |= bit
39
+ else :
40
+ self .last_state &= ~ bit
41
+ if buttons & K_Z :
42
+ now = time .monotonic ()
43
+ if self .last_z_press :
44
+ if now - self .last_z_press > 2 :
45
+ supervisor .set_next_code_file (None )
46
+ supervisor .reload ()
47
+ else :
48
+ self .last_z_press = now
49
+ else :
50
+ self .last_z_press = None
51
+ return buttons
52
+
53
+
54
+ class DummyAudio :
55
+ def play (self , f , loop = False ):
56
+ pass
57
+
58
+ def stop (self ):
59
+ pass
60
+
61
+ def mute (self , mute ):
62
+ pass
63
+
64
+ audio = DummyAudio ()
65
+ buttons = _Buttons ()
You can’t perform that action at this time.
0 commit comments