@@ -105,7 +105,12 @@ def const(x):
105
105
_TOUCH_CHANNEL_OFFSET = const (0x10 )
106
106
107
107
_SAMD09_HW_ID_CODE = const (0x55 )
108
- _ATTINY8X7_HW_ID_CODE = const (0x87 )
108
+ _ATTINY806_HW_ID_CODE = const (0x84 )
109
+ _ATTINY807_HW_ID_CODE = const (0x85 )
110
+ _ATTINY816_HW_ID_CODE = const (0x86 )
111
+ _ATTINY817_HW_ID_CODE = const (0x87 )
112
+ _ATTINY1616_HW_ID_CODE = const (0x88 )
113
+ _ATTINY1617_HW_ID_CODE = const (0x89 )
109
114
_EEPROM_I2C_ADDR = const (0x3F )
110
115
111
116
_ENCODER_STATUS = const (0x00 )
@@ -145,13 +150,18 @@ def __init__(self, i2c_bus, addr=0x49, drdy=None, reset=True):
145
150
self .sw_reset ()
146
151
147
152
self .chip_id = self .read8 (_STATUS_BASE , _STATUS_HW_ID )
148
-
149
- if self .chip_id not in (_ATTINY8X7_HW_ID_CODE , _SAMD09_HW_ID_CODE ):
153
+ if self .chip_id not in (
154
+ _ATTINY806_HW_ID_CODE ,
155
+ _ATTINY807_HW_ID_CODE ,
156
+ _ATTINY816_HW_ID_CODE ,
157
+ _ATTINY817_HW_ID_CODE ,
158
+ _ATTINY1616_HW_ID_CODE ,
159
+ _ATTINY1617_HW_ID_CODE ,
160
+ _SAMD09_HW_ID_CODE ,
161
+ ):
150
162
raise RuntimeError (
151
- "Seesaw hardware ID returned (0x{:x}) is not "
152
- "correct! Expected 0x{:x} or 0x{:x}. Please check your wiring." .format (
153
- self .chip_id , _SAMD09_HW_ID_CODE , _ATTINY8X7_HW_ID_CODE
154
- )
163
+ f"Seesaw hardware ID returned 0x{ self .chip_id } is not "
164
+ "correct! Please check your wiring."
155
165
)
156
166
157
167
pid = self .get_version () >> 16
@@ -164,15 +174,22 @@ def __init__(self, i2c_bus, addr=0x49, drdy=None, reset=True):
164
174
from adafruit_seesaw .robohat import MM1_Pinmap
165
175
166
176
self .pin_mapping = MM1_Pinmap
167
- elif pid in (_5690_PID , _5681_PID , _5743_PID ):
177
+ elif (pid in (_5690_PID , _5681_PID , _5743_PID )) or (
178
+ self .chip_id
179
+ in (_ATTINY816_HW_ID_CODE , _ATTINY806_HW_ID_CODE , _ATTINY1616_HW_ID_CODE )
180
+ ):
168
181
from adafruit_seesaw .attinyx16 import ATtinyx16_Pinmap
169
182
170
183
self .pin_mapping = ATtinyx16_Pinmap
171
184
elif self .chip_id == _SAMD09_HW_ID_CODE :
172
185
from adafruit_seesaw .samd09 import SAMD09_Pinmap
173
186
174
187
self .pin_mapping = SAMD09_Pinmap
175
- elif self .chip_id == _ATTINY8X7_HW_ID_CODE :
188
+ elif self .chip_id in (
189
+ _ATTINY817_HW_ID_CODE ,
190
+ _ATTINY807_HW_ID_CODE ,
191
+ _ATTINY1617_HW_ID_CODE ,
192
+ ):
176
193
from adafruit_seesaw .attiny8x7 import ATtiny8x7_Pinmap
177
194
178
195
self .pin_mapping = ATtiny8x7_Pinmap
@@ -255,10 +272,10 @@ def analog_read(self, pin, delay=0.008):
255
272
if pin not in self .pin_mapping .analog_pins :
256
273
raise ValueError ("Invalid ADC pin" )
257
274
258
- if self .chip_id == _ATTINY8X7_HW_ID_CODE :
259
- offset = pin
260
- elif self .chip_id == _SAMD09_HW_ID_CODE :
275
+ if self .chip_id == _SAMD09_HW_ID_CODE :
261
276
offset = self .pin_mapping .analog_pins .index (pin )
277
+ else :
278
+ offset = pin
262
279
263
280
self .read (_ADC_BASE , _ADC_CHANNEL_OFFSET + offset , buf , delay )
264
281
ret = struct .unpack (">H" , buf )[0 ]
@@ -351,10 +368,10 @@ def analog_write(self, pin, value):
351
368
if pin not in self .pin_mapping .pwm_pins :
352
369
raise ValueError ("Invalid PWM pin" )
353
370
354
- if self .chip_id == _ATTINY8X7_HW_ID_CODE :
355
- offset = pin
356
- elif self .chip_id == _SAMD09_HW_ID_CODE :
371
+ if self .chip_id == _SAMD09_HW_ID_CODE :
357
372
offset = self .pin_mapping .pwm_pins .index (pin )
373
+ else :
374
+ offset = pin
358
375
359
376
if self .pin_mapping .pwm_width == 16 :
360
377
cmd = bytearray ([offset , (value >> 8 ), value & 0xFF ])
0 commit comments