HI,
I would like to flip the output of the maxmatrix.h library by 180degrees.
Currently it scrolls text from right to left with the DIN/VCC ports towards the bottom. I would like the ports at the top since planning to build a wearable. I am using one of the 8x8led boards as in image attached.
#include <MaxMatrix.h>
#include <SoftwareSerial.h>
#include <avr/pgmspace.h>
PROGMEM const unsigned char CH[] = {
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A
4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C
4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D
4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E
4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F
4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G
4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H
3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I
4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J
4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K
4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L
5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M
5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O
4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P
4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R
4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S
5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T
4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U
5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V
5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W
5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X
5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z
};
int dIn = 7; // DIN pin of MAX7219 module
int clk = 6; // CLK pin of MAX7219 module
int cs = 5; // CS pin of MAX7219 module
int maxInUse = 2; // Number of MAX7219's connected
MaxMatrix m(dIn, cs, clk, maxInUse);
SoftwareSerial Bluetooth(10, 11); // RX | TX
byte buffer[10];
char incomebyte;
int scrollSpeed = 100;
char text[100] = "TEST MESSAGE "; // Initial text message
int brightness = 1;
int count = 0;
char indicator;
void setup() {
m.init(); // MAX7219 initialization
m.setIntensity(brightness); // initial led matrix intensity, 0-15
// Serial.begin(9600);
Bluetooth.begin(9600); // Default communication rate of the Bluetooth module
Serial.println("The bluetooth gates are open.\n Connect to HC-05 from any other bluetooth device with 1234 as pairing key!.");
}
void loop() {
// Printing the text
printStringWithShift(text, scrollSpeed);
if (Bluetooth.available()) { // Checks whether data is comming from the serial port
indicator = Bluetooth.read();
// Starts reading the serial port, the first byte from the incoming data
// If we have pressed the "Send" button from the Android App, clear the previous text
if (indicator == '1') {
for (int i = 0; i < 100; i++) {
text[i] = 0;
m.clear();
}
// Read the whole data/string comming from the phone and put it into text[] array.
while (Bluetooth.available()) {
incomebyte = Bluetooth.read();
text[count] = incomebyte;
count++;
}
count = 0;
}
// Adjusting the Scrolling Speed
else if (indicator == '2') {
String sS = Bluetooth.readString();
scrollSpeed = 150 - sS.toInt(); // Milliseconds, subtraction because lower value means higher scrolling speed
}
// Adjusting the brightness
else if (indicator == '3') {
String sB = Bluetooth.readString();
brightness = sB.toInt();
m.setIntensity(brightness);
}
}
}
void printCharWithShift(char c, int shift_speed) {
if (c < 32) return;
c -= 32;
memcpy_P(buffer, CH + 7 * c, 7);
m.writeSprite(32, 0, buffer);
m.setColumn(32 + buffer[0], 0);
for (int i = 0; i < buffer[0] + 1; i++)
{
delay(shift_speed);
m.shiftLeft(false, false);
}
}
void printStringWithShift(char* s, int shift_speed) {
while (*s != 0) {
printCharWithShift(*s, shift_speed);
s++;
}
}
void printString(char* s)
{
int col = 0;
while (*s != 0)
{
if (*s < 32) continue;
char c = *s - 32;
memcpy_P(buffer, CH + 7 * c, 7);
m.writeSprite(col, 0, buffer);
m.setColumn(col + buffer[0], 0);
col += buffer[0] + 1;
s++;
}
}
If I use the MD_MAX72xx library, I can define which type of led matrix I am using and also transform the text using (TSR/TSL etc) so its displayed correctly, but I am unable to figure out how to add bluetooth app controls. The attached examples in the library don't work and output a blank screen.
Can anyone help either way?
