I tried my Max7219 library and came up with this.
/*******************************************************************************
Scroll example
NoiascaLedControl
Example based on a idea of
https://forum.arduino.cc/t/wanting-to-scroll-messages-on-a-display/924553/50
by noiasca
2021-11-14
*******************************************************************************/
#include "NoiascaLedControl.h" // download from: https://werner.rothschopf.net/201904_arduino_ledcontrol_max7219.htm
//#include <NoiascaLedControlSpi.h> // this is for Hardware SPI
const uint8_t maxCsPin = 8; // 8 LED CS or LOAD - 8 CS
const uint8_t maxClkPin = 52; // 13 CLK on UNO/NANO - 52 MEGA
const uint8_t maxDataPin = 51; // 11 MOSI on UNO/NANO - 51 MEGA
const uint8_t noOfModules = 1;
LedControl lc = LedControl (maxDataPin, maxClkPin, maxCsPin, noOfModules); // Software Bitbang - use this if you can't use Hardware SPI
//LedControlSpi lc = LedControlSpi (maxCsPin, noOfModules); // faster Hardware SPI
const unsigned long delaytime = 500; // speed of scrolling
const byte digits = 8; // used digits on MAX7219
byte myip[4]; // dummy IP
/*
convert the IP into text (char array) and scroll it on the display
*/
void scrollIP()
{
static byte actual = 0;
static uint32_t previousMillis = 0;
const char delimiter[] {"-"};
if (millis() - previousMillis > delaytime)
{
previousMillis = millis();
char scrolltext[42] {""}; // this variable will store the total scroll text
char buffer[4]; // temp buffer for byte convert to char (3 chars in DEC + null terminator)
itoa(myip[0], buffer, 10); // convert the byte into ASCII/text
strcpy(scrolltext, buffer);
strcat(scrolltext, delimiter);
itoa(myip[1], buffer, 10);
strcat(scrolltext, buffer);
strcat(scrolltext, delimiter);
itoa(myip[2], buffer, 10);
strcat(scrolltext, buffer);
strcat(scrolltext, delimiter);
itoa(myip[3], buffer, 10);
strcat(scrolltext, buffer);
const size_t lengthOfScrolltext = strlen(scrolltext);
lc.clearDisplay(0);
byte len = digits;
byte pos = 0;
char out[digits + 1]{""}; // we need one more than digits for the null terminator
if (actual < digits ) // start on right most side of display (position 7)
{
pos = digits - 1 - actual;
len = actual + 1;
lc.setCursor(pos);
strncpy(out, scrolltext, len); // cut text to length
}
else
{
strncpy(out, scrolltext + actual-digits+1, digits); // cut text to length
}
lc.print(out);
Serial.print(len);
Serial.print("\t");
Serial.print(pos);
Serial.print("\t");
Serial.println(out);
actual++;
if (actual >= lengthOfScrolltext+digits) actual = 0;// rollover
}
}
/*
simple print of IP address to display
*/
void dispIP()
{
static byte actual = 0;
static uint32_t previousMillis = 0;
const uint16_t delaytimeSlow = 1000;
if (millis() - previousMillis > delaytimeSlow)
{
previousMillis = millis();
lc.clearDisplay(0);
if (actual == 0)
{
lc.print("IP");
lc.print(myip[0]);
lc.print(".");
lc.print(myip[1]);
lc.print(".");
actual = 1;
}
else
{
lc.print(myip[2]);
lc.print(".");
lc.print(myip[3]);
actual = 0;
}
}
}
void setup() {
Serial.begin(115200);
lc.begin();
lc.shutdown(0, false);
lc.setIntensity(0, 8);
lc.clearDisplay(0);
// just some dummy values for the IP
myip[0] = 192;
myip[1] = 123;
myip[2] = 222;
myip[3] = 255;
}
void loop()
{
scrollIP();
//dispIP();
}
personally I think that scrolling on a 8 digit 7 segment display isn't readable very well.
Therefore there is also an example how to print the IP in two octets.
Library: https://werner.rothschopf.net/201904_arduino_ledcontrol_max7219.htm
it also supports Hardware SPI and should be quite small as it inherits from print class to make printing easier.