understanding timing for an LED matrix

Hello arduino community. I'm trying to take my LED matrix to the next level and make it scroll. the only problem is that i still don't fully understand the timing piece of the code that allows the letters to be displayed statically. In the timing piece of the code a while loop runs like so: while ((start+letdelay)>millis()); where start was defined as millis() and letdelay is a global variable of any number i give it for delay. wouldn't start+letdelay always be greater than millis()? I have no idea why this works, any help would be appreciated. I have posted this question a few times a couple months ago but never received a straight up answer that was understandable.

The specific function that contains the while loop is in the void show function

/* Hopefully the last LED matrix code I ever make

BY: Chris Yambo
*/

int CPR = 8;  // clock pin row
int DPR = 10; // data pin row
int CPC = 11; // clock pin column
int DPC = 12; // data pin column
int LP = 9;   // combined the latch pins so theres only one

byte RA[] = {B10000000, B01000000, B00100000, B00010000, B00001000,}; // way to address rows individually
byte letters[27][5] = {
    
  {B10001000, B10001000, B11111000, B10001000, B11111000}, // A 0          
  {B11111000, B10001000, B11110000, B10001000, B11111000}, // B 1
  {B11111000, B10001000, B10000000, B10001000, B11111000}, // C 2 
  {B11110000, B10001000, B10001000, B10001000, B11110000}, // D 3
  {B11111000, B10000000, B11110000, B10000000, B11111000}, // E 4
  {B10000000, B10000000, B11110000, B10000000, B11111000}, // F 5
  {B11111000, B10001000, B10011000, B10000000, B11111000}, // G 6
  {B10001000, B10001000, B11111000, B10001000, B10001000}, // H 7
  {B01000000, B01000000, B01000000, B01000000, B01000000}, // I 8
  {B11111000, B10001000, B00001000, B00001000, B00001000}, // J 9
  {B10001000, B10010000, B11100000, B10010000, B10001000}, // K 10
  {B11111000, B10000000, B10000000, B10000000, B10000000}, // L 11
  {B10101000, B10101000, B10101000, B10101000, B11011000}, // M 12
  {B10001000, B10011000, B10101000, B11001000, B10001000}, // N 13
  {B11111000, B10001000, B10001000, B10001000, B11111000}, // O 14
  {B10000000, B10000000, B11111000, B10001000, B11111000}, // P 15
  {B11111000, B10011000, B10001000, B10001000, B11111000}, // Q 16
  {B10001000, B10010000, B11111000, B10001000, B11111000}, // R 17
  {B11111000, B00001000, B11111000, B10000000, B11111000}, // S 18 
  {B00100000, B00100000, B00100000, B00100000, B11111000}, // T 19
  {B11111000, B10001000, B10001000, B10001000, B10001000}, // U 20
  {B00100000, B01010000, B10001000, B10001000, B10001000}, // V 21
  {B11011000, B10101000, B10101000, B10101000, B10101000}, // W 22
  {B10001000, B01010000, B00100000, B01010000, B10001000}, // X 23
  {B11111000, B00001000, B11111000, B10001000, B10001000}, // Y 24
  {B11111000, B01000000, B00100000, B00010000, B11111000}, // Z 25
  {B00000000, B00000000, B00000000, B00000000, B00000000}, // Space to shift out use number 91
};

byte scrollarray[1][5] = {
}; 




int letdelay = 650;                             // delay between letters
String message = "YAMBO ";             /////WHATS GOING TO BE DISPLAYED Most important part of code/////
int msglength = message.length();               //stores length of message string
int shiftdelay = 145;                           //int for later

//-----------------------------------------------------------------------------------------------------------------------------------------------
void setup() {
 
  pinMode(CPR, OUTPUT);
  pinMode(DPR, OUTPUT);  
  pinMode(CPC, OUTPUT);                         // setting pins as outputs
  pinMode(DPC, OUTPUT);
  pinMode(LP, OUTPUT);
  

  
Serial.begin(9600);
//-----------------------------------------------------------------------------------------------------------------------------------------------
}
 
void loop() {
  show();


 }
//-----------------------------------------------------------------------------------------------------------------------------------------------
void shiftout(int letter, int shiftamt){                                    //function to shift out any letter in the letters array
  for(int j=0; j<5; j++)
  {
    byte x = letters[letter - 'A'][j];
    byte y = x << shiftamt;
    digitalWrite(LP, LOW);                                      //latch pin low
    shiftOut(DPR, CPR, LSBFIRST, RA[j]);                        //wries row activator to the rows
    shiftOut(DPC, CPC, LSBFIRST, y);         //goes to the yarray letter of the array and shifts out each byte one at a time using j
    digitalWrite(LP, HIGH);                                     //latch pin high sshifting everything into registers
  }
}
//-----------------------------------------------------------------------------------------------------------------------------------------------
void shiftoutscroll(){                                //function to shift out any lettr in the scroll array
  for(int j=0; j<5; j++)
  {
    digitalWrite(LP, LOW);                                      //latch pin low
    shiftOut(DPR, CPR, LSBFIRST, RA[j]);                        //wries row activator to the rows
    shiftOut(DPC, CPC, LSBFIRST, scrollarray[0][j]);           //goes to the yarray letter of the array and shifts out each byte one at a time using j
    digitalWrite(LP, HIGH);                                     //latch pin high sshifting everything into registers
  }
}

  
//-----------------------------------------------------------------------------------------------------------------------------------------------
 
void show(){                                        // function to display letters statically one after the other
  for(int j=0; j<msglength; j++)                    // counts up to the number of characters in the message
  {
    int character = message.charAt(j);              // puts the letter of the whatever character the counter is on into an integer called character
    unsigned long start = millis();                 //Begin timing the animation
    while(start + letdelay > millis())              // display each letter for duraton period
    {
      if(character == 32)                           // if the character is a space display a zero. If you dont do this it glitches on spaces
      {
        shiftout(91, 0);                               // 91 - 'A'or65 is 26 which is the space on the letters array
      }
      
      else                                          // this displays letters
      { 
        shiftout(character, 0);                        //shifts out the letter from the array
      }
    }
    
    
    if(message.charAt(j + 1) == character)          //for words with two of the same letter next to eachother, it puts a space between them
    {
        
      digitalWrite(LP, LOW);
      shiftOut(DPR, CPR, LSBFIRST, 0);                             
      shiftOut(DPC, CPC, LSBFIRST, 0);                           
      digitalWrite(LP, HIGH);                       //100 ms delay between two of the same letter
      delay(100);
    }
    
  }
}
//-----------------------------------------------------------------------------------------------------------------------------------------------
void scroll(){
  byte test = {B00001000};
  byte x;
  int q;
  int j = message.charAt(q);
  int k = message.charAt(q+1);
  shiftout(j, 0);
  
  
/*
  for(int z=0; z<5; z++)
  {
    int q = message.charAt(z);
    int y = bitRead(letters[6][z], 7);
    byte t = (letters[0][z] << 2);
    byte x = bitWrite(t, 3, y); 
    scrollarray[0][z] = x;
    
  }
 *
  
  shiftoutscroll();
// use | to combine bytes MAYBE!
*/



}

Your code shows while(start + letdelay > millis()) yet you talk about while((start + letdelay) > millis())

The two are not the same.

I just tried it and if i put the parenthesis the code still works. i just don't understand how because start plus letdelay will always be greater than millis and since it will always be greater why doesnt the code just get stuck on displaying the first letter?.

Not it will not always be greater. The number returned by the millis function keeps on increasing where as your value of start is fixed in the line above it.

cabyambo:
I just tried it and if i put the parenthesis the code still works. i just don't understand how because start plus letdelay will always be greater than millis and since it will always be greater why doesnt the code just get stuck on displaying the first letter?.

for start + letdelay > millis() letdelay > millis() is evaluated first
letdelay > millis() eventually will turn TRUE
start + TRUE ... I have no idea what this evaluates to

for (start + letdelay) > millis() (start + letdelay) is evaluated first
eventually (start + letdelay) will be greater than in value than millis()

millis() Returns the number of milliseconds since the Arduino board began running the current program
which means it is always incrementing whenever you call the function

ieee488:
for start + letdelay > millis() letdelay > millis() is evaluated first

No, I don't think that's right. The "+" will be evaluated before the ">", because "+" has the higher operator precedence. See this link.

Paul

PaulRB:
No, I don't think that's right. The "+" will be evaluated before the ">", because "+" has the higher operator precedence. See this link.

Paul

Yep, you are right.

I was misremembering my operator precedence.