4242__version__ = "0.0.0-auto.0"
4343__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MonsterM4sk.git"
4444
45- SS_LIGHTSENSOR_PIN = 2
45+ # Seesaw pin numbers
46+ SS_LIGHTSENSOR_PIN = 2 # "through-hole" light sensor near left eye
4647SS_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 :)
4952SS_SWITCH1_PIN = 9
5053SS_SWITCH2_PIN = 10
5154SS_SWITCH3_PIN = 11
@@ -60,19 +63,28 @@ class MonsterM4sk:
6063 """
6164
6265 def __init__ (self , i2c = None ):
66+ """
67+ :param i2c: The I2C bus to use, will try board.I2C()
68+ if not supplied
69+
70+ """
6371 displayio .release_displays ()
6472
6573 if i2c is None :
6674 i2c = board .I2C ()
6775
6876 # set up on-board seesaw
6977 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
7283 self ._ss .pin_mode (SS_SWITCH1_PIN , self ._ss .INPUT_PULLUP )
7384 self ._ss .pin_mode (SS_SWITCH2_PIN , self ._ss .INPUT_PULLUP )
7485 self ._ss .pin_mode (SS_SWITCH3_PIN , self ._ss .INPUT_PULLUP )
7586
87+ # light sensor near left eye
7688 self ._ss .pin_mode (SS_LIGHTSENSOR_PIN , self ._ss .INPUT )
7789
7890 # Manual reset for left screen
@@ -92,17 +104,19 @@ def __init__(self, i2c=None):
92104 left_tft_dc = board .LEFT_TFT_DC
93105
94106 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
96108 )
97109
98110 self .left_display = ST7789 (left_display_bus , width = 240 , height = 240 , rowstart = 80 )
99111
112+ # right backlight on board
100113 self .right_backlight = pulseio .PWMOut (
101114 board .RIGHT_TFT_LITE , frequency = 5000 , duty_cycle = 0
102115 )
116+ # full brightness
103117 self .right_backlight .duty_cycle = 65535
104118
105- # right display
119+ # right display spi bus
106120 right_spi = busio .SPI (board .RIGHT_TFT_SCK , MOSI = board .RIGHT_TFT_MOSI )
107121 right_tft_cs = board .RIGHT_TFT_CS
108122 right_tft_dc = board .RIGHT_TFT_DC
@@ -111,13 +125,14 @@ def __init__(self, i2c=None):
111125 right_spi ,
112126 command = right_tft_dc ,
113127 chip_select = right_tft_cs ,
114- reset = board .RIGHT_TFT_RST ,
128+ reset = board .RIGHT_TFT_RST , # reset on board
115129 )
116130
117131 self .right_display = ST7789 (
118132 right_display_bus , width = 240 , height = 240 , rowstart = 80
119133 )
120134
135+ # setup accelerometer
121136 if i2c is not None :
122137 int1 = digitalio .DigitalInOut (board .ACCELEROMETER_INTERRUPT )
123138 try :
@@ -127,12 +142,26 @@ def __init__(self, i2c=None):
127142 except ValueError :
128143 self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (i2c , int1 = int1 )
129144
145+ # touchio on nose
130146 self .nose = touchio .TouchIn (board .NOSE )
147+
148+ # can be iffy, depending on environment and person.
149+ # User code can tweak if needed.
131150 self .nose .threshold = 180
132151
133152 @property
134153 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+ """
136165 return (
137166 self ._accelerometer .acceleration
138167 if self ._accelerometer is not None
@@ -141,12 +170,36 @@ def acceleration(self):
141170
142171 @property
143172 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+ """
145184 return self ._ss .analog_read (SS_LIGHTSENSOR_PIN )
146185
147186 @property
148187 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+ """
150203
151204 return {
152205 "S9" : self ._ss .digital_read (SS_SWITCH1_PIN ) is False ,
@@ -156,5 +209,19 @@ def buttons(self):
156209
157210 @property
158211 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+ """
160227 return self .nose .value
0 commit comments