Library to drive a pair of Adafruit 16x8 led matrices (powered by Adafruit LED Backpack) rotated end to end and stuck together to make a larger matrix.

Dependencies:   Adafruit_LEDBackpack

Dependents:   Adafruit_LEDBackpack_32x8_App RubeGoldberg

/media/uploads/maclobdell/austin_iot_lab.jpg

Committer:
maclobdell
Date:
Wed Jun 28 19:32:40 2017 +0000
Revision:
0:acc3c726ffe3
Child:
1:ed6764fbda54
initial version of library for class that combines two 16x8 led matrices

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maclobdell 0:acc3c726ffe3 1 #include "mbed.h"
maclobdell 0:acc3c726ffe3 2
maclobdell 0:acc3c726ffe3 3 #include "Adafruit_32x8matrix.h"
maclobdell 0:acc3c726ffe3 4
maclobdell 0:acc3c726ffe3 5 Adafruit_32x8matrix::Adafruit_32x8matrix(I2C *i2c, uint8_t i2c_addr, uint8_t i2c_addr2, uint8_t rotation, uint8_t rotation2, uint8_t brightness)
maclobdell 0:acc3c726ffe3 6
maclobdell 0:acc3c726ffe3 7 : _i2c(*i2c), _matrix(&_i2c), _matrix2(&_i2c), _i2c_addr(i2c_addr), _i2c_addr2(i2c_addr2), _rotation(rotation), _rotation2(rotation2), _brightness(brightness)
maclobdell 0:acc3c726ffe3 8
maclobdell 0:acc3c726ffe3 9 {
maclobdell 0:acc3c726ffe3 10
maclobdell 0:acc3c726ffe3 11 _matrix2.begin(_i2c_addr2);
maclobdell 0:acc3c726ffe3 12 _matrix2.setBrightness(_brightness);
maclobdell 0:acc3c726ffe3 13 _matrix2.setRotation(_rotation2);
maclobdell 0:acc3c726ffe3 14 _matrix2.clear();
maclobdell 0:acc3c726ffe3 15 _matrix2.writeDisplay();
maclobdell 0:acc3c726ffe3 16
maclobdell 0:acc3c726ffe3 17 _matrix.begin(_i2c_addr);
maclobdell 0:acc3c726ffe3 18 _matrix.setBrightness(_brightness);
maclobdell 0:acc3c726ffe3 19 _matrix.setRotation(_rotation);
maclobdell 0:acc3c726ffe3 20 _matrix.clear();
maclobdell 0:acc3c726ffe3 21 _matrix.writeDisplay();
maclobdell 0:acc3c726ffe3 22
maclobdell 0:acc3c726ffe3 23
maclobdell 0:acc3c726ffe3 24 }
maclobdell 0:acc3c726ffe3 25
maclobdell 0:acc3c726ffe3 26 void Adafruit_32x8matrix::scrollText(char * buffer, uint8_t buf_len, uint8_t speed)
maclobdell 0:acc3c726ffe3 27 {
maclobdell 0:acc3c726ffe3 28
maclobdell 0:acc3c726ffe3 29
maclobdell 0:acc3c726ffe3 30 // code inspired by LOLShield library
maclobdell 0:acc3c726ffe3 31 int xoff=31;// set offset to the right end of the screen - must be signed
maclobdell 0:acc3c726ffe3 32 for(int i=0; i< (31 + buf_len*6 +10); i++){ //scrolling loop
maclobdell 0:acc3c726ffe3 33 for(int j=0; j<buf_len; j++){ //loop over all of the chars in the text
maclobdell 0:acc3c726ffe3 34 if(xoff > 15){
maclobdell 0:acc3c726ffe3 35 _matrix2.drawChar(xoff + j*6 - 16, 0, buffer[j], 1, 0, 1);
maclobdell 0:acc3c726ffe3 36 }else
maclobdell 0:acc3c726ffe3 37 {
maclobdell 0:acc3c726ffe3 38 _matrix.drawChar(xoff + j*6, 0, buffer[j], 1, 0, 1);
maclobdell 0:acc3c726ffe3 39 _matrix2.drawChar(xoff + j*6 - 16, 0, buffer[j], 1, 0, 1);
maclobdell 0:acc3c726ffe3 40 }
maclobdell 0:acc3c726ffe3 41 }
maclobdell 0:acc3c726ffe3 42 xoff--; // decrement x offset
maclobdell 0:acc3c726ffe3 43
maclobdell 0:acc3c726ffe3 44 _matrix.writeDisplay();
maclobdell 0:acc3c726ffe3 45 _matrix2.writeDisplay();
maclobdell 0:acc3c726ffe3 46 Thread::wait(1000/speed);
maclobdell 0:acc3c726ffe3 47 _matrix.clear();
maclobdell 0:acc3c726ffe3 48 _matrix2.clear();
maclobdell 0:acc3c726ffe3 49 }
maclobdell 0:acc3c726ffe3 50 }
maclobdell 0:acc3c726ffe3 51
maclobdell 0:acc3c726ffe3 52
maclobdell 0:acc3c726ffe3 53 void Adafruit_32x8matrix::showText(char * buffer, uint8_t buf_len, uint8_t speed)
maclobdell 0:acc3c726ffe3 54 {
maclobdell 0:acc3c726ffe3 55 for(int j=0; j<buf_len; j++){ //loop over all of the chars in the text
maclobdell 0:acc3c726ffe3 56 _matrix.drawChar(j*6, 0, buffer[j], 1, 0, 1);
maclobdell 0:acc3c726ffe3 57 _matrix2.drawChar(j*6 - 16, 0, buffer[j], 1, 0, 1);
maclobdell 0:acc3c726ffe3 58 }
maclobdell 0:acc3c726ffe3 59 _matrix.writeDisplay();
maclobdell 0:acc3c726ffe3 60 _matrix2.writeDisplay();
maclobdell 0:acc3c726ffe3 61 Thread::wait(1000/speed);
maclobdell 0:acc3c726ffe3 62 _matrix.clear();
maclobdell 0:acc3c726ffe3 63 _matrix2.clear();
maclobdell 0:acc3c726ffe3 64
maclobdell 0:acc3c726ffe3 65 }
maclobdell 0:acc3c726ffe3 66