/*
Module Orientation
G F E D C B A DP
+------------------------+
| 7 6 5 4 3 2 1 0 | DIG0
| 1 | DIG1
| 2 | DIG2
| 3 | DIG3
| O 4 | DIG4
| O O 5 | DIG5
| O O O 6 | DIG6
| O O O O 7 | DIG7
+------------------------+
*/
#include <LedControl.h>
#define DATA_PIN 12
#define CS_PIN 11
#define CLK_PIN 10
#define MAX_SEG 0
#define LEN(arr) ((int) (sizeof (arr) / sizeof (arr)[0])) // get number of rows in array
// https://gurgleapps.com/tools/matrix (left, right revesred)
// https://xantorohara.github.io/led-matrix-editor/# ( up , down revesred)
// https://www.instructables.com/LED-Matrix-Editor/
// https://dotmatrixtool.com/#
// 8px by 8px, row major, little endian.
//byte up_arrow[8] = {0x18, 0x3c, 0x7e, 0xdb, 0x99, 0x18, 0x18, 0x18};
byte up_arrow[8] = {B00011000,B00111100,B01111110,B11011011,B10011001,B00011000,B00011000,B00011000};
byte down_arrow[8] = {0x18,0x18,0x18,0x99,0xdb,0x7e,0x3c,0x18};
//byte left_arrow[8] = {0x18, 0x0c, 0x06, 0xff, 0xff, 0x06, 0x0c, 0x18};
byte right_arrow[8] = {B00011000,B00110000,B01100000,B11111111,B11111111,B01100000,B00110000,B00011000};
//byte right_arrow[8] = {0x18,0x30,0x60,0xff,0xff,0x60,0x30,0x18};
byte heart[8]={0x66, 0xa5, 0x99, 0x81, 0x81, 0x42, 0x24, 0x18};
byte smile[8] ={0x3c,0x42,0xa5,0x81,0xa5,0x99,0x42,0x3c};
byte sad[8] ={0x3c, 0x42, 0xa5, 0x81, 0x99, 0xa5, 0x42, 0x3c};
byte cross[2][8]= {{B00011000,B00011000,B00011000,B11111111,B11111111,B00011000,B00011000,B00011000},
{B11000011,B11100111,B01100110,B00111100,B00111100,B01100110,B11100111,B11000011}};
byte scrollingLeftArrow[4][8] = {
{0xc0,0x60,0x30,0xf8,0xf8,0x30,0x60,0xc0},
{0x60,0x30,0x18,0xfc,0xfc,0x18,0x30,0x60},
{0x30,0x18,0x0c,0xfe,0xfe,0x0c,0x18,0x30},
{0x18,0x0c,0x06,0xff,0xff,0x06,0x0c,0x18}
};
byte scrollingRightArrow[4][8] = {
{0x03,0x06,0x0c,0x1f,0x1f,0x0c,0x06,0x03},
{0x06,0x0c,0x18,0x3f,0x3f,0x18,0x0c,0x06},
{0x0c,0x18,0x30,0x7f,0x7f,0x30,0x18,0x0c},
{0x18,0x30,0x60,0xff,0xff,0x60,0x30,0x18}
};
uint16_t displayTime = 500; // Time each frame is shown in milliseconds
int brightnessLevel = 8; // Set brightness level (0 is minimum, 15 is maximum)
// Initialize the LedControl library
LedControl mat = LedControl(DATA_PIN, CLK_PIN, CS_PIN, MAX_SEG);
void setup() {
mat.shutdown(0, false); // Turn on the display
mat.setIntensity(0, brightnessLevel); // Set the brightness (0-15)
mat.clearDisplay(0); // Clear the display
}
void loop() {
//displayFrame(up_arrow);
displayFrame(sad);
//delay(1000);
//playAnimation(scrollingLeftArrow, 4, 2);
//playAnimation(scrollingRightArrow, 4, 2);
//displayFrame(heart);
//playAnimation(cross, LEN(cross), 2);
//displayFrame(smile);
}
void playAnimation(byte animation[][8], int frameCount, int repeat) {
for (int r = 0; r < repeat; r++) {
for (int i = 0; i < frameCount; i++) {
displayFrame(animation[i]);
delay(displayTime); // Wait before showing next frame
}
}
}
void displayFrame(byte frame[8]) {
for (int i = 0; i < 8; i++) {
mat.setRow(0, i, frame[i]); // Display each row of the bitmap
}
//mat.update(); // Ensure the display is updated
}