This is a library for the Adafruit LED Backpacks. This library works with the Adafruit Mini 8x8 and the Adafruit 16x8 LED Matrix backpacks.

Fork of Adafruit_LEDBackpack by Luiz Hespanha

Files at this revision

API Documentation at this revision

Comitter:
sknn
Date:
Tue Mar 24 17:35:22 2015 +0000
Parent:
1:f066d5347c60
Commit message:
Now this library works with the Adafruit 16x8 LED Matrix backpacks, too.

Changed in this revision

Adafruit_LEDBackpack.cpp Show annotated file Show diff for this revision Revisions of this file
Adafruit_LEDBackpack.h Show annotated file Show diff for this revision Revisions of this file
diff -r f066d5347c60 -r caaae61819a4 Adafruit_LEDBackpack.cpp
--- a/Adafruit_LEDBackpack.cpp	Fri Aug 16 15:44:44 2013 +0000
+++ b/Adafruit_LEDBackpack.cpp	Tue Mar 24 17:35:22 2015 +0000
@@ -78,6 +78,36 @@
   }
 }
 
+Adafruit_8x16matrix::Adafruit_8x16matrix(I2C *i2c) : Adafruit_LEDBackpack(i2c), Adafruit_GFX(8, 16) {
+}
+
+void Adafruit_8x16matrix::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 2:
+    swap(x, y);
+    x = 16 - x - 1;
+    break;
+  case 3:
+    x = 16 - x - 1;
+    y = 8 - y - 1;
+    break;
+  case 0:
+    swap(x, y);
+    y = 8 - y - 1;
+    break;
+  }
+
+  if (color) {
+    displaybuffer[y] |= 1 << x;
+  } else {
+    displaybuffer[y] &= ~(1 << x);
+  }
+}
+
 Adafruit_8x8matrix::Adafruit_8x8matrix(I2C *i2c) : Adafruit_LEDBackpack(i2c), Adafruit_GFX(8, 8) {
 }
 
diff -r f066d5347c60 -r caaae61819a4 Adafruit_LEDBackpack.h
--- a/Adafruit_LEDBackpack.h	Fri Aug 16 15:44:44 2013 +0000
+++ b/Adafruit_LEDBackpack.h	Tue Mar 24 17:35:22 2015 +0000
@@ -64,11 +64,20 @@
   uint8_t i2c_addr;
 };
 
+class Adafruit_8x16matrix : public Adafruit_LEDBackpack, public Adafruit_GFX {
+ public:
+  Adafruit_8x16matrix(I2C *i2c);
+
+  virtual void drawPixel(int16_t x, int16_t y, uint16_t color);
+
+ private:
+};
+
 class Adafruit_8x8matrix : public Adafruit_LEDBackpack, public Adafruit_GFX {
  public:
   Adafruit_8x8matrix(I2C *i2c);
 
-  void drawPixel(int16_t x, int16_t y, uint16_t color);
+  virtual void drawPixel(int16_t x, int16_t y, uint16_t color);
 
  private:
 };
\ No newline at end of file