With that out of the way, you can write a fairly simple display routine:
volatile unsigned char led_buffer[DIGS_MAX]; //display buffer. DIGS_MAX defines the max number of led digits allowed
void led_display(void) {
static unsigned char dig=0; //digital counter
dig += 1; //increment the digit
if (dig == DIGS_MAX) dig = 0; //reset dig if max digit has been reached
//turn off all digits
DIG_OFF(DIG0); DIG_OFF(DIG1); ...
SEGs_OUT(led_buffer[dig]); //send out segment information
//turn on the digit
//can be implemented more cleanly with an array
switch (dig) {
case 0: DIG_ON(DIG0); break;
case 1: DIG_ON(DIG1); break;
...
}
}
So each time, led_display() is called, it displays a number on the led.