Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Adafruit_LEDBackpack
Dependents: Adafruit_LEDBackpack_32x8_App RubeGoldberg
Adafruit_32x8matrix.cpp@1:ed6764fbda54, 2017-11-10 (annotated)
- Committer:
- maclobdell
- Date:
- Fri Nov 10 14:08:31 2017 -0600
- Revision:
- 1:ed6764fbda54
- Parent:
- 0:acc3c726ffe3
- Child:
- 2:cdcd2d7d83c3
Don't copy I2C object, just pass in pointer. Fixes error with mbed OS 5.6.x.
Who changed what in which revision?
| User | Revision | Line number | New 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 | 1:ed6764fbda54 | 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 | } |