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