#include <SPI.h>
#include <Adafruit_GFX.h>
#include "Max72xxPanel.h"
int pinCS = 5; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 1; // Количество матриц по горизонтали
int numberOfVerticalDisplays = 8; // Количество матриц по-вертикали
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
unsigned long ticker_next;
String tape = "z";
int spacer = 1;
int width = 5 + spacer;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
tape = utf8rus("This Text TEst texttt");
matrix.setIntensity(7); // яркость матрицы от 0 до 15
matrix.setRotation(matrix.getRotation()+1); // направление движения. 1 - 90 2 - 180 3 - 270
// matrix.setRotation(3); // направление движения. 1 - 90 2 - 180 3 - 270
}
String utf8rus(String source){
int i, k;
String target;
unsigned char n;
char m[2] = { '0', '\0' };
k = source.length(); i = 0;
while (i < k) {
n = source[i]; i++;
if (n >= 0xC0) {
switch (n) {
case 0xD0: {
n = source[i]; i++;
if (n == 0x81) {
n = 0xA8;
break;
}
if (n >= 0x90 && n <= 0xBF) n = n + 0x2F;
break;
}
case 0xD1: {
n = source[i]; i++;
if (n == 0x91) {
n = 0xB7;
break;
}
if (n >= 0x80 && n <= 0x8F) n = n + 0x6F;
break;
}
}
}
m[0] = n; target = target + String(m);
}
return target;
}
void handleTicker() {
Serial.println("matrix.width()");
Serial.println(matrix.width());
Serial.println("matrix.height()");
Serial.println(matrix.height());
for ( int i = 0 ; i < width * tape.length() + matrix.width() - 1 - spacer; i++ ) {
matrix.fillScreen(LOW);
int letter = i / width;
int x = (matrix.width() - 1) - i % width;
int y = (matrix.height() - 8) / 2;
while ( x + width - spacer >= 0 && letter >= 0 ) {
if ( letter < tape.length() ) {
matrix.drawChar(x, y, tape[letter], HIGH, LOW, 1);
}
letter--;
x -= width;
}
matrix.write();
delay(1000);
}
}
void loop() {
handleTicker();
}