In the given library, SSD_WriteDigitsGrouped()
displays the four hex digits of the val
argument. By first converting your integer to binary-coded decimal (BCD) format where each hex nibble represents a decimal digit value 0 to 9, you can display decimal values.
This can easily be done with a wrapper for SSD_WriteDigitsGrouped()
that does the conversion. Implement the following function, and call it in place of SSD_WriteDigitsGrouped()
:
void SSD_WriteDigitsGroupedBCD( unsigned int val, unsigned char dp )
{
unsigned bcd = 0 ;
int shift = 0 ;
while( val > 0)
{
bcd |= (val % 10) << (shift << 2) ;
shift++ ;
val /= 10;
}
SSD_WriteDigitsGrouped( bcd, dp ) ;
}