I have 4 dot matrix displays, every one of them connected to an i2c and accessible with 0x70
, 0x71
, 0x72
and 0x73
. All these work just fine when I address them apart. What I want to achieve is a scrolling text throughout all 4 displays. How can I do this? Are there any libraries around that already do this? (I did not find any).
Basically, this is my code:
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_8x8matrix matrix[4];
void setup() {
Serial.begin(9600);
Serial.println("4x(8x8) LED Matrix Test");
matrix[0].begin(0x70);
matrix[1].begin(0x71);
matrix[2].begin(0x72);
matrix[3].begin(0x73);
}
-
1Google is your friend; forums.adafruit.com/viewtopic.php?f=8&p=386183, for instance "nihil sub sole novum"Mikael Patel– Mikael Patel2016年02月01日 21:09:19 +00:00Commented Feb 1, 2016 at 21:09
1 Answer 1
This is what I found behind the link @mikael-patel posted, and with a little configuration it does exactly what I want. Basically the scroll()
-method handles anything neccessary.
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#define NUM_MATRICES 2
Adafruit_8x8matrix matrix[NUM_MATRICES];
void setup() {
Serial.begin(9600);
Serial.println("8x8 LED Matrix Test");
for(uint8_t m=0; m<NUM_MATRICES; m++) {
matrix[m].begin(0x70 + m);
matrix[m].clear();
matrix[m].setTextSize(1);
matrix[m].setTextWrap(false); // we dont want text to wrap so it scrolls nicely
matrix[m].setTextColor(LED_GREEN);
}
}
void loop() {
scroll("Hello World!");
}
void scroll(char* text) {
int scrollPositions = (strlen(text) * 8) + 32;
for (int x=(8 * NUM_MATRICES); x>=-scrollPositions; x--) {
for(uint8_t m=0; m<NUM_MATRICES; m++) {
matrix[m].clear();
matrix[m].setCursor((x - (m * 8)), 0);
matrix[m].print(text);
matrix[m].writeDisplay();
}
delay(80);
}
}