I\'ve written a small program that uses a button on an STM32 Discovery board to act as a counter in either Binary/Decimal/Hexadecimal mode (screen cycles through the 3 optio
Probably lcd_putint
takes a lot of time to refresh the display. It probably convert each number to string and then put it to the screen.
format_int()
In binary case it loops 4 times, then 4 times more than Hex and Dec cases.
If you change the code as below, It will, I guess, be faster:
char bin[5];
sprintf(bin, "%d%d%d%d", ((n&0x08)>>3), ((n&0x04)>>2), ((n&0x02)>>1), (n&0x01));
lcd_putstring(bin);
I know there are a lot of solutions to convert number to binary string, but the key point is to use lcd_putstring
that is surely faster then call 4 times lcd_putint