MAX72XX 7 segment display LedControl

I have a setup with a MAX7221 and 8 digits of 7 segment displays
I use the LedControl library, and it all works.
I have edited the LedControl.h file, so I can use all characters in the alphabet.

I want to have a text scrolling from left to right
I use this code:

char text[] = "hello earth"; //should be world, I know, but W doesn't really work on a 7 segment display

    for (int num = 0; num <= sizeof(text)-1; num++) {
    lc.setChar(0,7,(text[num]),false);
    lc.setChar(0,6,(text[num-1]),false);
    lc.setChar(0,5,(text[num-2]),false);
    lc.setChar(0,4,(text[num-3]),false);
    lc.setChar(0,3,(text[num-4]),false);
    lc.setChar(0,2,(text[num-5]),false);
    lc.setChar(0,1,(text[num-6]),false);
    lc.setChar(0,0,(text[num-7]),false);
    delay(600);
}

It scrolls like I want to, but between each time it scrolls, other characters are added.

don’t pay attention to the minus in stead of pluss (text[num-1])
I must have wired the digits in reverse order, but it just means that digit 0 is to the left

any suggestions?

Cheers

I imagine the data is coming from a larger array somewhere - so wouldn't you want num to be changing where it is starting from? Or allowing for it wrap around?
0-7
1-8
2-10
3-11
4-12
5-13
6-14
7-15
8-15, 0
9-15, 0,1
10-15,0,1,2
etc.

the array is just the line at the top,
char text = "hello earth";

but yes, the characters come from a large array in the LedControl.h file

It seams like its "skipping"
this is what is scrolling : hello earth011103hello earth etc.
I have no idea why it puts in the 011103 between

wrap around sounds like a good idea

do you have a code suggestion for ho that would look?

Cheers

You have to figure out your pointer scheme, that's all.
Right now you go from 0 to (size of the array) + another 7, where random stuff is read from memory & displayed. So you need to from 0 to (size of array less 7) and then wrap around for example.
Think about it some, see what you can come up with.

I have tried lots of things now, and tried to find out about “pointer scheme” and “wrap around”
I just can’t figure it out

do I need another forward loop with another int?

I have changed the code to make it simpler

char text[14] = "_hello_earth_";

void scrollText(){
    for (int i = 0; i <=14; i++) {
    lc.setChar(0,0,(text[i]),false);
    lc.setChar(0,1,(text[i+1]),false);
    lc.setChar(0,2,(text[i+2]),false);
    lc.setChar(0,3,(text[i+3]),false);
    lc.setChar(0,4,(text[i+4]),false);
    lc.setChar(0,5,(text[i+5]),false);
    lc.setChar(0,6,(text[i+6]),false);
    lc.setChar(0,7,(text[i+7]),false);
    delay(delaytime);
}
    lc.clearDisplay(0);
}

I just have no idea about how to “wrap it around”
could you please give me a clue :slight_smile:

Here is how I did it for a largish display, 32 columns. I had 2 variables that kept track of where in a much larger array the data was coming from (like 1000+ columns, experimented to see how big I could go before the program crashed) and where the end of the message being displayed was (because not all 1000+ columns were used all the time).
Altho looking at this now, I probably just used some blank columns at the end to let the message scroll off and then restarted the display Near the first column, I didn't like having at the very beginning as the first letter scrolled off display too quickly.

// e_time_check

// see if time to scroll the display, or change pointer for other move command
// move start pointer within the array

// time check
currentMillis = millis();
if ( (currentMillis - previousMillis) >= holdDuration && (move_control == normal)){ // lets update!
  previousMillis = previousMillis + holdDuration;  // time check for next pass
  updateDisplay = 1;
  // Serial.println("time check");
  // move start of display pointer
  // add some serially-sent control characters to manually move left, right, & hold for testing

  displayStart = displayStart +1;
  // calculate end based on (# of characters * 6), 5 byte font + space 
  if (displayStart == (displayEnd +1)){  
    displayStart = 2; // reset once reach the end
  }
} // end time time check