The following function will return a u32
value composed of four bytes with LED values for the digit display. Note that I don't know what order your display wants the digit in, so you might need to byteswap the return value or something. Also, this function will provide leading zeros for the LED display - you might need to modify things so those show as blanks on the display.
typedef unsigned int u32;
static char led_digits[] = { 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xd8, 0x80, 0x90 };
u32 four_digits( int x)
{
unsigned char c[4];
int i;
for (i = 0; i < 4; ++i)
{
int digit = x % 10;
x = x / 10;
c[i] = led_digits[digit];
}
return (u32)(c[3] << 24) | (u32)(c[2] << 16) | (u32)(c[1] << 8) | (u32)c[0];
}