#include <Arduino.h>
#include <GyverMAX7219.h>
#include "E7Symbol.h"
#define E7M_MATRIX_SIZE 4
MAX7219< E7M_MATRIX_SIZE, 1, 6, 7, 5 > _matrix;
E7Symbol _e7s;
void printText(String text = "1234") {
_matrix.clear();
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
uint8_t glyph[8];
_e7s.convertBigGlyphTo8x8(_e7s.getBigSymbolGlyph(text.charAt(seg)), glyph);
for (uint8_t i = 0; i < 8; i++) {
_matrix.setCursor(seg * 8 + i, 0);
_matrix.drawByte(glyph[i]);
}
}
_matrix.update();
}
void setup() {
_matrix.begin();
_matrix.setBright(8);
_matrix.setRotation(3);
printText("1234");
delay(3000);
}
void plusMinus(uint8_t count = 3) {
for (int i = 0; i < count; i++) {
printText("++++");
delay(1000);
printText("----");
delay(1000);
}
}
void dotBlink(uint8_t count = 2) {
for (int i = 0; i < count; i++) {
_matrix.clear();
for (int i = 0; i < 2; i++) {
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
int shift = seg * 8;
_matrix.dot(0 + shift, 0, 1);
_matrix.update();
}
delay(300);
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
int shift = seg * 8;
_matrix.dot(0 + shift, 0, 0);
_matrix.update();
}
delay(300);
}
for (int row = 0; row < 2; row++) {
for (int col = 0; col < 2; col++) {
_matrix.clear();
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
int shift = seg * 8;
_matrix.dot(col + shift, row, 1);
_matrix.update();
}
delay(300);
}
}
}
}
void fillColsByDots() {
_matrix.clear();
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 8; col++) {
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
int shift = seg * 8;
_matrix.dot(col + shift, row, 1);
}
_matrix.update();
delay(300);
}
}
}
void digits() {
for (int num = 0; num < 10; num++) {
String s;
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
s.concat(num);
}
printText(s);
delay(1000);
}
}
void fillByCols() {
_matrix.clear();
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 8; col++) {
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
int shift = seg * 8;
_matrix.dot(col + shift, row, 1);
}
}
_matrix.update();
delay(1000);
}
}
void fillByRows() {
_matrix.clear();
for (int col = 0; col < 8; col++) {
for (int row = 0; row < 8; row++) {
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
int shift = seg * 8;
_matrix.dot(col + shift, row, 1);
}
}
_matrix.update();
delay(1000);
}
}
void colByCol() {
for (int row = 0; row < 8; row++) {
_matrix.clear();
for (int col = 0; col < 8; col++) {
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
int shift = seg * 8;
_matrix.dot(col + shift, row, 1);
}
}
_matrix.update();
delay(1000);
}
}
void rowByRow() {
for (int col = 0; col < 8; col++) {
_matrix.clear();
for (int row = 0; row < 8; row++) {
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
int shift = seg * 8;
_matrix.dot(col + shift, row, 1);
}
}
_matrix.update();
delay(1000);
}
}
void flyingDot() {
for (int col = 0; col < 8; col++) {
for (int row = 0; row < 8; row++) {
_matrix.clear();
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
int shift = seg * 8;
_matrix.dot(col + shift, row, 1);
}
_matrix.update();
delay(300);
}
}
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 8; col++) {
_matrix.clear();
for (uint8_t seg = 0; seg < E7M_MATRIX_SIZE; seg++) {
int shift = seg * 8;
_matrix.dot(col + shift, row, 1);
}
_matrix.update();
delay(300);
}
}
}
void loop() {
dotBlink(5);
fillColsByDots();
digits();
plusMinus();
fillByCols();
fillByRows();
colByCol();
rowByRow();
flyingDot();
}