Issue casting an integer type to char type/string
Here is the method defined in the .h file:
void ILI9341_DrawText(const char* str, const uint8_t font[], uint16_t X, uint16_t Y, uint16_t color, uint16_t bgcolor);
the method defined in the .c file:
void ILI9341_DrawText(const char* str, const uint8_t font[], uint16_t X, uint16_t Y, uint16_t color, uint16_t bgcolor)
{
uint8_t charWidth; /* Width of character */
uint8_t fOffset = font[0]; /* Offset of character */
uint8_t fWidth = font[1]; /* Width of font */
while (*str)
{
ILI9341_DrawChar(*str, font, X, Y, color, bgcolor);
/* Check character width and calculate proper position */
uint8_t *tempChar = (uint8_t*)&font[((*str - 0x20) * fOffset) + 4];
charWidth = tempChar[0];
if(charWidth + 2 < fWidth)
{
/* If character width is smaller than font width */
X += (charWidth + 2);
}
else
{
X += fWidth;
}
str++;
}
}
If in the main.c file I invoke the following command:
v
The TFT LCD display, displays 99 correctly.
My issue is that if I want to pass an integer into the method it fails to complile.
A simple example would be that I declare and int, (int number =1;)
then invoke:ILI9341_DrawText(number, FONT4, 4, 2, WHITE, BLACK);
Moving from Arduino has been difficult as coding in Arduino allows for use of a simple cast.
Can someone advise how to get over this issue? Thanks in advance
