max7221 using SPI library and displaying a character

Ok, I am using a combination of various display drivers. I was trying to stay away from the max7221 series chips because when I cascaded a few of them together they would eventually fail and I have yet to figure out why. I went ahead and started using sparkfun’s openSegment led’s 7-segment displays and they seem much more reliable. However, they only come in 4 digit sections and for one display I need a 2-digit display…so I am still stuck using the max7221 to drive this guy.

I can not use both the SPI library to program the openSegement’s from sparkfun and the ledcontrol lib. for the max7221s. So I am working on using the SPI library to also control the max7221.

example:

void setup() {
  SPI.begin(); // initialize SPI
  pinMode(slaveSelect, OUTPUT);
  digitalWrite(slaveSelect,LOW); // select slave
  // prepare the 7221 to display 7-segment data - see data sheet
  sendCommand(12,1); // normal mode (default is shutdown mode);
  sendCommand(15,0); // Display test off
  sendCommand(10,8); // set medium intensity (range is 0-15)
  sendCommand(11,numberOfDigits); // 7221 digit scan limit command
  sendCommand(9,255); // decode command, use standard 7-segment digits
  digitalWrite(slaveSelect,HIGH); // deselect slave
}

]// function to display up to four digits on a 7-segment display
void displayNumber( int number){
  for (int i = 0; i < numberOfDigits; i++)
  {
      byte character = number % 10; // get the value of the rightmost decade
         // send digit number as command, first digit is command 1
       sendCommand(numberOfDigits-i, character);
     number = number / 10;
   }
}
void sendCommand( int command, int value){
  digitalWrite(slaveSelect,LOW); // chip select is active low
    // 2 byte data transfer to the 7221
    SPI.transfer(command);
    SPI.transfer(value);
    digitalWrite(slaveSelect,HIGH); // release chip, signal end transfer
}

this code displays numbers fine, but I also need to push some characters, can anyone help me with that code that will work in conjunction with SPI.
Thanks.

So you want to work in both Decode mode for the digits, and then No Decode mode for characters other than H E L P from the same MAX7219? I think you need to run in No Decode mode for all 8 digits and just define your own font to display on 7-segment display. 0,1,2,3,4,5,6,7,9 A, b, C, c, d, E, F, G, H, I, J, L, n, O, o, P, S, T, U, u, Y are all pretty recognizable.

However, they only come in 4 digit sections and for one display I need a 2-digit display.

Why? Just use two, cover the other two.

CrossRoads: So you want to work in both Decode mode for the digits, and then No Decode mode for characters other than H E L P from the same MAX7219? I think you need to run in No Decode mode for all 8 digits and just define your own font to display on 7-segment display. 0,1,2,3,4,5,6,7,9 A, b, C, c, d, E, F, G, H, I, J, L, n, O, o, P, S, T, U, u, Y are all pretty recognizable.

Yes, but I currently can not push those characters with my current code even with decode mode off. Has to do with displayNumber function and pushing int's instead of a character or string or something...it just displays junk.

steinie44:

However, they only come in 4 digit sections and for one display I need a 2-digit display.

Why? Just use two, cover the other two.

Yeah, wish that was possible, but it is not, not with the current footprint I have to work with, it won't fit.

Never mind, I think I figured out what I needed. It's a little sloppy, but I should be able to clean it up.