I am trying to display unicode characters on Max7219 module, 4 x (8x8) matrix. Those letters are arabic/urdu. I am using MD_MX72xx and MD_Parola library.
Using MD_MX72xx its working fine and displaying the characters, but its not able to scroll it, Please let me know if I can scroll those characters as well as if I want to join them (removing space), how can it be done. here is the code I am trying, it also include the scrolling code but its not working as expected, Infact If I only use scrolling code it display nothing.
Please guide me on this.
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define delay_t 50
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CLK_PIN D6
#define DATA_PIN D8
#define CS_PIN D7
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
MD_Parola parola = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
byte toaay[8] = {0, 64, 64, 126, 80, 80, 32, 0,};
byte fay[8] = {112, 64, 64, 64, 112, 106, 112, 0, };
byte AinAlif[8] = {
0, 62, 64, 64, 112, 72, 72, 72,
};
void setup() {
// Serial.begin(57600);
mx.begin();
mx.control(MD_MAX72XX::INTENSITY, 0);
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
parola.begin();
mx.clear();
}
bool isScroll = true;
void loop() {
if(!isScroll){
drawShape();
isScroll = true;
}
else{
scrollCharacter();
isScroll = false;
}
}
void scrollCharacter() {
byte rotatedAinAlif[8];
byte rotatedToaay[8];
byte rotatedFay[8];
// Transpose characters
for (int i = 0; i < 8; i++) {
byte val = 0;
for (int j = 0; j < 8; j++) {
val |= ((AinAlif[j] >> i) & 0x01) << (7 - j);
}
rotatedAinAlif[i] = val;
}
for (int i = 0; i < 8; i++) {
byte val = 0;
for (int j = 0; j < 8; j++) {
val |= ((toaay[j] >> i) & 0x01) << (7 - j);
}
rotatedToaay[i] = val;
}
for (int i = 0; i < 8; i++) {
byte val = 0;
for (int j = 0; j < 8; j++) {
val |= ((fay[j] >> i) & 0x01) << (7 - j);
}
rotatedFay[i] = val;
}
// Scroll characters
for (int j = 0; j < 8; j++) {
for (int i = 0; i < 8; i++) {
mx.setColumn(i, 0, mx.getColumn(i, 1));
mx.setColumn(i, 1, mx.getColumn(i, 2));
mx.setColumn(i, 2, mx.getColumn(i, 3));
}
mx.setColumn(7, 0, rotatedToaay[j]);
mx.setColumn(7, 1, rotatedAinAlif[j]);
mx.setColumn(7, 2, rotatedFay[j]);
delay(delay_t);
}
}
void drawShape() {
byte rotatedAinAlif[8];
byte rotatedToaay[8];
byte rotatedFay[8];
for (int i = 0; i < 8; i++) {
byte val = 0;
for (int j = 0; j < 8; j++) {
val |= ((AinAlif[j] >> i) & 0x01) << (7 - j);
}
rotatedAinAlif[i] = val;
}
for (int i = 0; i < 8; i++) {
byte val = 0;
for (int j = 0; j < 8; j++) {
val |= ((toaay[j] >> i) & 0x01) << (7 - j);
}
rotatedToaay[i] = val;
}
for (int i = 0; i < 8; i++) {
byte val = 0;
for (int j = 0; j < 8; j++) {
val |= ((fay[j] >> i) & 0x01) << (7 - j);
}
rotatedFay[i] = val;
}
for (int i = 0; i <= 7; i++) {
mx.setRow(0, i, rotatedAinAlif[i]);
}
delay(delay_t);
for (int i = 0; i <= 7; i++) {
mx.setRow(1, i, rotatedToaay[i]);
}
delay(delay_t);
for (int i = 0; i <= 7; i++) {
mx.setRow(2, i, rotatedFay[i]);
}
}