FYI 4 digit bubble display

Just got some QDSP-6064 (common cathode) HERE bubble displays from Sparkfun.
Brings back memories of the old days.
I am going to add it to my Logic Probe to count transitions (using a pre-scalar), Frequency Counter and Pulse Width.

If anyone needs a small form factor display for a project these are great.
Not bad for $3.20 ea. I got 10.

Data Sheet:

#include <SPI.h>

// Thanks Nick Gammon

/*
 Arduino       MAX7219
 SS     10     LOAD  12 
 MOSI   11     DIN   1
 MISO   12     No Connection
 SCK    13     CLK   13
*/

unsigned long i= 00000000ul;
//unsigned long i= 99990000ul;

const byte MAX7219_REG_NOOP        = 0x0;
// codes 1 to 8 are digit positions 1 to 8
const byte MAX7219_REG_DECODEMODE  = 0x9;
const byte MAX7219_REG_INTENSITY   = 0xA;
const byte MAX7219_REG_SCANLIMIT   = 0xB;
const byte MAX7219_REG_SHUTDOWN    = 0xC;
const byte MAX7219_REG_DISPLAYTEST = 0xF;

void sendByte (const byte reg, const byte data)
  {    
  digitalWrite (SS, LOW);
  SPI.transfer (reg);
  SPI.transfer (data);
  digitalWrite (SS, HIGH); 
  }  // end of sendByte
 
void setup () 
  {
  SPI.begin ();
  sendByte (MAX7219_REG_SCANLIMIT, 7);      // show 8 digits
  sendByte (MAX7219_REG_DECODEMODE, 0xFF);  // use digits (not bit patterns)
  sendByte (MAX7219_REG_DISPLAYTEST, 0);    // no display test
  sendByte (MAX7219_REG_INTENSITY, 7);      // character intensity: range: 0 to 15
  sendByte (MAX7219_REG_SHUTDOWN, 1);       // not in shutdown mode (ie. start it up)
}   // end of setup
 
void number (const unsigned long num)
  {
 
 char buf [9]; //buf[0] is MSD, buf[7] is LSD
 
  sprintf (buf, "%8ld", min (max (num, 0), 99999999));  // no leading 0s
// sprintf (buf, "%08ld", min (max (num, 0), 99999999));  // add leading 0s
 
// send all 8 digits
 for (int digit = 0; digit < 8; digit++)
   {
   byte c = buf [digit];
   if (c == ' ' )
     c = 0xF;  // code for a blank
   else
     c -= '0';
     if (digit == 1 & i > 999999 || digit == 4 & i > 999)
     {
       c |= 0b10000000;  //turn on the decimal point to act as a comma
                         //at 1,000 and 1,000,000
     }
     
     if (i >=99999999)   //have we overflowed the maximum count?
     {
       c |= 0b10000000;  //turn on all the decimal points
                         //to indicate overflow condition
     }
       
   sendByte (8 - digit, c);  
   }   
  }  // end of number
  

void loop () 
 {
number (i++);
//number (12345678);

delay(10);
 }  // end of loop

Schematic.pdf (15.8 KB)