adafruit / Adafruit_Seesaw

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

Fix setting I2C address on ATtinys #94

Closed caternuson closed 1 year ago

caternuson commented 1 year ago

For #93.

Tested on a PID 5743 (gamepad) using following sketch to change I2C address:

#include "Adafruit_seesaw.h"

#define OLD_ADDR 0x50
#define NEW_ADDR 0x55

Adafruit_seesaw ss;

void setup() {
  Serial.begin(9600);
  while (!Serial);

  Serial.println("EEPROM I2C address change test.");

  if (!ss.begin(OLD_ADDR)) {
    Serial.println("seesaw not found.");
    while(1);
  }

  Serial.println("seesaw started.");

  Serial.println("Changing I2C address...");
  ss.setI2CAddr(NEW_ADDR);
  Serial.println("Done.");
}

void loop() {
}

NOTE - I2C breaks after the address change (after call to setI2CAddr())and the attempt to restart it doesn't seem to work. But power cycling works and the device comes up at the newly set I2C address.

caternuson commented 1 year ago

@ladyada for review

ladyada commented 1 year ago

thank you!