42
42
__version__ = "0.0.0-auto.0"
43
43
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MonsterM4sk.git"
44
44
45
- SS_LIGHTSENSOR_PIN = 2
45
+ # Seesaw pin numbers
46
+ SS_LIGHTSENSOR_PIN = 2 # "through-hole" light sensor near left eye
46
47
SS_VCCSENSOR_PIN = 3
47
- SS_BACKLIGHT_PIN = 5
48
- SS_TFTRESET_PIN = 8
48
+ SS_BACKLIGHT_PIN = 5 # left screen backlight
49
+ SS_TFTRESET_PIN = 8 # left screen reset
50
+
51
+ # buttons above left eye. Match silkscreen :)
49
52
SS_SWITCH1_PIN = 9
50
53
SS_SWITCH2_PIN = 10
51
54
SS_SWITCH3_PIN = 11
@@ -60,19 +63,27 @@ class MonsterM4sk:
60
63
"""
61
64
62
65
def __init__ (self , i2c = None ):
66
+ """
67
+ :param i2c: The I2C bus to use, will try board.I2C()
68
+ if not supplied
69
+ """
63
70
displayio .release_displays ()
64
71
65
72
if i2c is None :
66
73
i2c = board .I2C ()
67
74
68
75
# set up on-board seesaw
69
76
self ._ss = Seesaw (i2c )
70
- # left screen
71
- self ._ss .pin_mode (SS_TFTRESET_PIN , self ._ss .OUTPUT )
77
+
78
+ # set up seesaw pins
79
+ self ._ss .pin_mode (SS_TFTRESET_PIN , self ._ss .OUTPUT ) # left sceen reset
80
+
81
+ # buttons abolve left eye
72
82
self ._ss .pin_mode (SS_SWITCH1_PIN , self ._ss .INPUT_PULLUP )
73
83
self ._ss .pin_mode (SS_SWITCH2_PIN , self ._ss .INPUT_PULLUP )
74
84
self ._ss .pin_mode (SS_SWITCH3_PIN , self ._ss .INPUT_PULLUP )
75
85
86
+ # light sensor near left eye
76
87
self ._ss .pin_mode (SS_LIGHTSENSOR_PIN , self ._ss .INPUT )
77
88
78
89
# Manual reset for left screen
@@ -92,17 +103,19 @@ def __init__(self, i2c=None):
92
103
left_tft_dc = board .LEFT_TFT_DC
93
104
94
105
left_display_bus = displayio .FourWire (
95
- left_spi , command = left_tft_dc , chip_select = left_tft_cs
106
+ left_spi , command = left_tft_dc , chip_select = left_tft_cs # Reset on Seesaw
96
107
)
97
108
98
109
self .left_display = ST7789 (left_display_bus , width = 240 , height = 240 , rowstart = 80 )
99
110
111
+ # right backlight on board
100
112
self .right_backlight = pulseio .PWMOut (
101
113
board .RIGHT_TFT_LITE , frequency = 5000 , duty_cycle = 0
102
114
)
115
+ # full brightness
103
116
self .right_backlight .duty_cycle = 65535
104
117
105
- # right display
118
+ # right display spi bus
106
119
right_spi = busio .SPI (board .RIGHT_TFT_SCK , MOSI = board .RIGHT_TFT_MOSI )
107
120
right_tft_cs = board .RIGHT_TFT_CS
108
121
right_tft_dc = board .RIGHT_TFT_DC
@@ -111,13 +124,14 @@ def __init__(self, i2c=None):
111
124
right_spi ,
112
125
command = right_tft_dc ,
113
126
chip_select = right_tft_cs ,
114
- reset = board .RIGHT_TFT_RST ,
127
+ reset = board .RIGHT_TFT_RST , # reset on board
115
128
)
116
129
117
130
self .right_display = ST7789 (
118
131
right_display_bus , width = 240 , height = 240 , rowstart = 80
119
132
)
120
133
134
+ # setup accelerometer
121
135
if i2c is not None :
122
136
int1 = digitalio .DigitalInOut (board .ACCELEROMETER_INTERRUPT )
123
137
try :
@@ -127,12 +141,25 @@ def __init__(self, i2c=None):
127
141
except ValueError :
128
142
self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (i2c , int1 = int1 )
129
143
144
+ # touchio on nose
130
145
self .nose = touchio .TouchIn (board .NOSE )
146
+
147
+ # can be iffy, depending on environment and person.
148
+ # User code can tweak if needed.
131
149
self .nose .threshold = 180
132
150
133
151
@property
134
152
def acceleration (self ):
135
- """Accelerometer data, +/- 2G sensitivity."""
153
+ """Accelerometer data, +/- 2G sensitivity.
154
+
155
+ This example initializes the mask and prints the accelerometer data.
156
+
157
+ .. code-block:: python
158
+ import adafruit_monsterm4sk
159
+ mask = adafruit_monsterm4sk.MonsterM4sk(i2c=board.I2C())
160
+ print(mask.acceleration)
161
+
162
+ """
136
163
return (
137
164
self ._accelerometer .acceleration
138
165
if self ._accelerometer is not None
@@ -141,12 +168,34 @@ def acceleration(self):
141
168
142
169
@property
143
170
def light (self ):
144
- """Light sensor data."""
171
+ """Light sensor data.
172
+
173
+ This example initializes the mask and prints the light sensor data.
174
+
175
+ .. code-block:: python
176
+ import adafruit_monsterm4sk
177
+ mask = adafruit_monsterm4sk.MonsterM4sk(i2c=board.I2C())
178
+ print(mask.light)
179
+
180
+ """
145
181
return self ._ss .analog_read (SS_LIGHTSENSOR_PIN )
146
182
147
183
@property
148
184
def buttons (self ):
149
- """Buttons dictionary."""
185
+ """Buttons dictionary.
186
+
187
+ This example initializes the mask and prints when the S9 button
188
+ is pressed down.
189
+
190
+ .. code-block:: python
191
+ import adafruit_monsterm4sk
192
+ mask = adafruit_monsterm4sk.MonsterM4sk(i2c=board.I2C())
193
+
194
+ while True:
195
+ if mask.buttons["S9"]:
196
+ print("Button S9 pressed!")
197
+
198
+ """
150
199
151
200
return {
152
201
"S9" : self ._ss .digital_read (SS_SWITCH1_PIN ) is False ,
@@ -156,5 +205,18 @@ def buttons(self):
156
205
157
206
@property
158
207
def boop (self ):
159
- """Nose touch sense."""
208
+ """Nose touch sense.
209
+
210
+ This example initializes the mask and prints when the nose touch pad
211
+ is being touched.
212
+
213
+ .. code-block:: python
214
+ import adafruit_monsterm4sk
215
+ mask = adafruit_monsterm4sk.MonsterM4sk(i2c=board.I2C())
216
+
217
+ while True:
218
+ if mask.boop:
219
+ print("Nose touched!")
220
+
221
+ """
160
222
return self .nose .value
0 commit comments