diff --git a/adafruit_seesaw/attiny8x7.py b/adafruit_seesaw/attiny8x7.py index d8e59b4..bdddf54 100644 --- a/adafruit_seesaw/attiny8x7.py +++ b/adafruit_seesaw/attiny8x7.py @@ -26,7 +26,8 @@ class ATtiny8x7_Pinmap: pwm_width = 16 # we dont actually use all 16 bits but whatever """The pins capable of PWM output""" - pwm_pins = (0, 1, 9, 12, 13) + pwm_pins = (0, 1, 9, 12, 13) # 8 bit PWM mode + pwm_pins += (6, 7, 8) # 16 bit PWM mode """No pins on this board are capable of touch input""" touch_pins = () diff --git a/adafruit_seesaw/attinyx16.py b/adafruit_seesaw/attinyx16.py index 3ff5de3..874ccd5 100644 --- a/adafruit_seesaw/attinyx16.py +++ b/adafruit_seesaw/attinyx16.py @@ -25,7 +25,8 @@ class ATtinyx16_Pinmap: pwm_width = 16 # we dont actually use all 16 bits but whatever """The pins capable of PWM output""" - pwm_pins = (0, 1, 7, 11, 16) + pwm_pins = (0, 1, 7, 11, 16) # 8 bit PWM mode + pwm_pins += (4, 5, 6) # 16 bit PWM mode """No pins on this board are capable of touch input""" touch_pins = () diff --git a/adafruit_seesaw/seesaw.py b/adafruit_seesaw/seesaw.py index 4857300..67e1d75 100644 --- a/adafruit_seesaw/seesaw.py +++ b/adafruit_seesaw/seesaw.py @@ -390,14 +390,17 @@ def get_temp(self): def set_pwm_freq(self, pin, freq): """Set the PWM frequency of a pin by number""" - if pin in self.pin_mapping.pwm_pins: - cmd = bytearray( - [self.pin_mapping.pwm_pins.index(pin), (freq >> 8), freq & 0xFF] - ) - self.write(_TIMER_BASE, _TIMER_FREQ, cmd) - else: + if pin not in self.pin_mapping.pwm_pins: raise ValueError("Invalid PWM pin") + if self.chip_id == _SAMD09_HW_ID_CODE: + offset = self.pin_mapping.pwm_pins.index(pin) + else: + offset = pin + + cmd = bytearray([offset, (freq >> 8), freq & 0xFF]) + self.write(_TIMER_BASE, _TIMER_FREQ, cmd) + def encoder_position(self, encoder=0): """The current position of the encoder""" buf = bytearray(4)