- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi;
When I use the sensorread function it says 9A on the screen. How do I print the result in decimal?
void sensorRead()
{
int8 sensorRead=(-20-((205 - spi_read(0x26))/ 2));
LCD_Position(0u,4u);
LCD_LCD_LCD_PrintInt8(sensorRead);
CyDelay(300);
// LCD_ClearDisplay();
}
LCD_PrintNumber(spi_read(0x26));==> LCD Output 42
LCD_PrintDecUint16(spi_read(0x26)); ==> LCD Output 42
LCD_PrintHexUint16(spi_read(0x26)); ==> LCD Output 2A
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
From what you wrote both LCD_PrintNumber() and LCD_PrintDecUint16() are printing in decimal.
as 2A in hex is 42 in decimal.
If you want to have control over format, maybe you can try...
#define STR_LEN 32 // choose appropriate number for your usage
char str[STR_LEN] ;
int8 sensorRead ;
...
sensorRead = -20-((205 - spi_read(0x26))/2) ; // I just referenced your formula
snprintf(str, STR_LEN, "%d", sensorRead) ; // you can have something like "value = %d" for the format
LCD_PrintString(str) ;
...
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
From what you wrote both LCD_PrintNumber() and LCD_PrintDecUint16() are printing in decimal.
as 2A in hex is 42 in decimal.
If you want to have control over format, maybe you can try...
#define STR_LEN 32 // choose appropriate number for your usage
char str[STR_LEN] ;
int8 sensorRead ;
...
sensorRead = -20-((205 - spi_read(0x26))/2) ; // I just referenced your formula
snprintf(str, STR_LEN, "%d", sensorRead) ; // you can have something like "value = %d" for the format
LCD_PrintString(str) ;
...
moto