Mac Lobdell / Mbed OS Adafruit_LEDBackpack_32x8_App

Dependencies:   Adafruit_32x8matrix

Fork of Adafruit_LEDBackpack_16x8_App by Mac Lobdell

Committer:
maclobdell
Date:
Wed Jun 28 19:27:51 2017 +0000
Revision:
6:8d2eb79a4baf
create class for combined matrix with two 16 x 8 matrices stuck together

Who changed what in which revision?

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