adafruit / Adafruit_Seesaw

Arduino library driver for seesaw multi-use chip
93 stars 64 forks source link

servo frequency NOT set properly for ATtiny1616 #98

Closed tracton closed 5 months ago

tracton commented 7 months ago

BUG: Adafruit_seesaw.cpp appears to have a bug in that the chip is not identified in the Adafruit_seesaw::setPWMFreq function, and so legit pins can not have their PWM frequency set; the call is prematurely returned.

SOLUTION: The setPWMFreqfunction should look like the analogWrite function which tests each Hardware ID Code to determine which pins support PWM per chip. I think it should look a bit like this:


  int8_t p = -1;
  if (_hardwaretype == SEESAW_HW_ID_CODE_SAMD09) {
    switch (pin) {
    case PWM_0_PIN:
      p = 0;
      break;
    case PWM_1_PIN:
      p = 1;
      break;
    case PWM_2_PIN:
      p = 2;
      break;
    case PWM_3_PIN:
      p = 3;
      break;
    default:
#ifdef SEESAW_I2C_DEBUG
      Serial.printf("SEESAW: PWM not supported on Pin %d for hardware %d\n", pin, _hardwaretype);
#endif
      break;
    }
  } else {
    p = pin;
  }
caternuson commented 7 months ago

Hmm. Agree. Looks like that logic needs updating for the ATtiny variants, like you mention - similar to what's in analogWrite.

Thanks for changing the issue title.

caternuson commented 5 months ago

Closing. Should be fixed with #99.