This is a library for the Adafruit LED Backpacks. This library works with the Adafruit Mini 8x8 and 16x8.
Dependents: Adafruit_LEDBackpack_16x8_App Adafruit_32x8matrix
Fork of Adafruit_LEDBackpack by
Diff: Adafruit_LEDBackpack.cpp
- Revision:
- 2:529bad55777e
- Parent:
- 1:f066d5347c60
- Child:
- 3:b0ac557b5f0c
--- a/Adafruit_LEDBackpack.cpp Fri Aug 16 15:44:44 2013 +0000 +++ b/Adafruit_LEDBackpack.cpp Thu Dec 15 17:31:22 2016 +0000 @@ -111,4 +111,40 @@ } else { displaybuffer[y] &= ~(1 << x); } +} + + +Adafruit_16x8matrix::Adafruit_16x8matrix(I2C *i2c) : Adafruit_LEDBackpack(i2c), Adafruit_GFX(16, 8) { +} + +void Adafruit_16x8matrix::drawPixel(int16_t x, int16_t y, uint16_t color) { + if ((y < 0) || (y >= 8)) return; + if ((x < 0) || (x >= 16)) return; + + // check rotation, move pixel around if necessary + switch (getRotation()) { + case 1: + swap(x, y); + x = 16 - x - 1; + break; + case 2: + x = 16 - x - 1; + y = 8 - y - 1; + break; + case 3: + swap(x, y); + y = 8 - y - 1; + break; + } + + // wrap around the x + x += 15; + x %= 16; + + + if (color) { + displaybuffer[y] |= 1 << x; + } else { + displaybuffer[y] &= ~(1 << x); + } } \ No newline at end of file