Hello, i have two "MAX7219 dot matrix 4 in 1 module", but i have a problem, i am trying that in one module i put the score and in the other the time, so for now i only do a simulation with counters that are x and y, but i notice a problem and is that when score had a 1 it is more small that the other numbers, so the module with the time will be more to the left for every 1 that score had.
So i am thinking in two solutions, the first one that i think is to change the font of the 1 because is the only number that create problems to me, i really tried, i modify the excel files and the documents of text that contain the number 1 but nothing work, i believe that i am doing something wrong so if someone know how to change the font it will be of so much help.
The other solution that i think is to know a function in the library that let me change the size of every character or that let me set the position in the modules that i want that the time begin
So this is my code, if someone could help me i would thank you so much.
#include <MD_MAX72xx.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 8
#define CLK_PIN 13 // or SCK
#define DATA_PIN 11 // or MOSI
#define CS_PIN 10 // or SS
// SPI hardware interface
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Arbitrary pins
//MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
// Text parameters
#define CHAR_SPACING 1 // pixels between characters
// Global message buffers shared by Serial and Scrolling functions
#define BUF_SIZE 75
char message[BUF_SIZE] = "P: 000 00:30";
int x=60;
int y=0;
void printText(uint8_t modStart, uint8_t modEnd, char *pMsg)
// Print the text string to the LED matrix modules specified.
// Message area is padded with blank columns after printing.
{
uint8_t state = 0;
uint8_t curLen;
uint16_t showLen;
uint8_t cBuf[8];
int16_t col = ((modEnd + 1) * COL_SIZE) - 1;
mx.control(modStart, modEnd, MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
do // finite state machine to print the characters in the space available
{
switch(state)
{
case 0: // Load the next character from the font table
// if we reached end of message, reset the message pointer
if (*pMsg == '\0')
{
showLen = col - (modEnd * COL_SIZE); // padding characters
state = 2;
break;
}
// retrieve the next character form the font file
showLen = mx.getChar(*pMsg++, sizeof(cBuf)/sizeof(cBuf[0]), cBuf);
curLen = 0;
state++;
// !! deliberately fall through to next state to start displaying
case 1: // display the next part of the character
mx.setColumn(col--, cBuf[curLen++]);
// done with font character, now display the space between chars
if (curLen == showLen)
{
showLen = CHAR_SPACING;
state = 2;
}
break;
case 2: // initialize state for displaying empty columns
curLen = 0;
state++;
// fall through
case 3: // display inter-character spacing or end of message padding (blank columns)
mx.setColumn(col--, 0);
curLen++;
if (curLen == showLen)
state = 0;
break;
default:
col = -1; // this definitely ends the do loop
}
} while (col >= (modStart * COL_SIZE));
mx.control(modStart, modEnd, MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
}
void setup() {
// put your setup code here, to run once:
mx.begin();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
printText(0, MAX_DEVICES-1, message);
delay(1000);
x--;
y++;
sprintf_P(message, (PGM_P)F("P: %03d %02d:%02d"),y, 0, x);
}