Skip to content

Commit 1f5f333

Browse files
authored
Merge pull request #50 from arduino-libraries/led_matrix_multi
Allow to specify I2C address of LED Matrix
2 parents be56b97 + f4e7186 commit 1f5f333

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Modulino_LED_Matrix.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,33 @@
2323
#define DEFAULT_WIRE Wire
2424
#endif
2525

26+
#define DEFAULT_ADDRESS 0x39
27+
2628
class ModulinoLEDMatrix
2729
#ifdef MATRIX_WITH_ARDUINOGRAPHICS
2830
: public ArduinoGraphics
2931
#endif
3032
{
3133

3234
public:
33-
ModulinoLEDMatrix(HardwareI2C& wire = DEFAULT_WIRE)
35+
ModulinoLEDMatrix(uint8_t address = DEFAULT_ADDRESS, HardwareI2C& wire = DEFAULT_WIRE)
3436
#ifdef MATRIX_WITH_ARDUINOGRAPHICS
3537
: ArduinoGraphics(canvasWidth, canvasHeight)
3638
#endif
3739
{
40+
_address = address;
3841
_wire = &wire;
3942
}
43+
44+
ModulinoLEDMatrix(HardwareI2C& wire, uint8_t address = DEFAULT_ADDRESS)
45+
#ifdef MATRIX_WITH_ARDUINOGRAPHICS
46+
: ArduinoGraphics(canvasWidth, canvasHeight)
47+
#endif
48+
{
49+
_address = address;
50+
_wire = &wire;
51+
}
52+
4053
// TODO: find a better name
4154
// autoscroll will be slower than calling next() at precise times
4255
void autoscroll(uint32_t interval_ms) {
@@ -63,7 +76,7 @@ class ModulinoLEDMatrix
6376
}
6477
_sequenceDone = true;
6578
}
66-
_wire->beginTransmission(0x39);
79+
_wire->beginTransmission(_address);
6780
_wire->write((uint8_t*)frame, sizeof(frame));
6881
_wire->endTransmission();
6982
}
@@ -219,4 +232,5 @@ class ModulinoLEDMatrix
219232
bool _sequenceDone = false;
220233
voidFuncPtr _callBack = nullptr;
221234
HardwareI2C* _wire;
235+
uint8_t _address = DEFAULT_ADDRESS;
222236
};

0 commit comments

Comments
 (0)