Skip to content

Commit

Permalink
allow specifying the i2c_bus on neoKey and neoTrellis (adafruit#63)
Browse files Browse the repository at this point in the history
* updated to allow specifying an i2c_bus on creation

* fix formatting

* made requested changes
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

rltvty authored Jan 26, 2022
1 parent 02382f7 commit fe4b241
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Adafruit_NeoKey_1x4.cpp
Original file line number Diff line number Diff line change
@@ -4,10 +4,12 @@
/*!
@brief Class constructor
@param addr the I2C address this neotrellis object uses
@param i2c_bus the I2C bus connected to this neokey, defaults to "Wire"
*/
/**************************************************************************/
Adafruit_NeoKey_1x4::Adafruit_NeoKey_1x4(uint8_t addr)
: pixels(NEOKEY_1X4_KEYS, NEOKEY_1X4_NEOPIN, NEO_GRB + NEO_KHZ800) {
Adafruit_NeoKey_1x4::Adafruit_NeoKey_1x4(uint8_t addr, TwoWire *i2c_bus)
: Adafruit_seesaw(i2c_bus), pixels(NEOKEY_1X4_KEYS, NEOKEY_1X4_NEOPIN,
NEO_GRB + NEO_KHZ800, i2c_bus) {
for (int i = 0; i < NEOKEY_1X4_KEYS; i++) {
_callbacks[i] = NULL;
}
2 changes: 1 addition & 1 deletion Adafruit_NeoKey_1x4.h
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ typedef void (*NeoKey1x4Callback)(keyEvent evt);
/**************************************************************************/
class Adafruit_NeoKey_1x4 : public Adafruit_seesaw {
public:
Adafruit_NeoKey_1x4(uint8_t addr = NEOKEY_1X4_ADDR);
Adafruit_NeoKey_1x4(uint8_t addr = NEOKEY_1X4_ADDR, TwoWire *i2c_bus = &Wire);
~Adafruit_NeoKey_1x4(){};

bool begin(uint8_t addr = NEOKEY_1X4_ADDR, int8_t flow = -1);
10 changes: 6 additions & 4 deletions Adafruit_NeoTrellis.cpp
Original file line number Diff line number Diff line change
@@ -4,11 +4,13 @@
/*!
@brief Class constructor
@param addr the I2C address this neotrellis object uses
@param i2c_bus the I2C bus connected to this neotrellis, defaults to "Wire"
*/
/**************************************************************************/
Adafruit_NeoTrellis::Adafruit_NeoTrellis(uint8_t addr)
: pixels(NEO_TRELLIS_NUM_KEYS, NEO_TRELLIS_NEOPIX_PIN,
NEO_GRB + NEO_KHZ800) {
Adafruit_NeoTrellis::Adafruit_NeoTrellis(uint8_t addr, TwoWire *i2c_bus)
: Adafruit_seesaw(i2c_bus),
pixels(NEO_TRELLIS_NUM_KEYS, NEO_TRELLIS_NEOPIX_PIN, NEO_GRB + NEO_KHZ800,
i2c_bus) {
for (int i = 0; i < NEO_TRELLIS_NUM_KEYS; i++) {
_callbacks[i] = NULL;
}
@@ -348,4 +350,4 @@ void Adafruit_MultiTrellis::read() {
}
}
}
}
}
3 changes: 2 additions & 1 deletion Adafruit_NeoTrellis.h
Original file line number Diff line number Diff line change
@@ -33,7 +33,8 @@ typedef void (*TrellisCallback)(keyEvent evt);
/**************************************************************************/
class Adafruit_NeoTrellis : public Adafruit_seesaw {
public:
Adafruit_NeoTrellis(uint8_t addr = NEO_TRELLIS_ADDR);
Adafruit_NeoTrellis(uint8_t addr = NEO_TRELLIS_ADDR,
TwoWire *i2c_bus = &Wire);
~Adafruit_NeoTrellis(){};

bool begin(uint8_t addr = NEO_TRELLIS_ADDR, int8_t flow = -1);

0 comments on commit fe4b241

Please sign in to comment.