- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How do I convert the hex to a decimal base 0 to 9.
void Display_Result(void)
{
LCD_Char_Position(0,6);
LCD_Char_PrintInt8(HYT221_Read_Buff[0] & 0x3f); //Mask HYT humidity the highest two status bits
LCD_Char_PrintInt8(HYT221_Read_Buff[1]);
LCD_Char_PrintNumber(unit8,HYT221_Read_Buff);
temp = astio(temp, HYT221_Read_Buff[1], 16);
LCD_Char_PrintString(" ");
LCD_Char_Position(1,6);
LCD_Char_PrintInt8(HYT221_Read_Buff[2]);
LCD_Char_PrintInt8(HYT221_Read_Buff[3] & 0xfc); //Mask HYT temperature the lowest two status bits
LCD_Char_PrintString(" ");
}
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My original email was wrong. below is the corrected version
void Display_Result(void)
{
LCD_Char_Position(0,6);
LCD_Char_PrintInt8(HYT221_Read_Buff[0] & 0x3f); //Mask HYT humidity the highest two status bits
LCD_Char_PrintInt8(HYT221_Read_Buff[1]);
LCD_Char_PrintString(" ");
LCD_Char_Position(1,6);
LCD_Char_PrintInt8(HYT221_Read_Buff[2]);
LCD_Char_PrintInt8(HYT221_Read_Buff[3] & 0xfc); //Mask HYT temperature the lowest two status bits
LCD_Char_PrintString(" ");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How about LCD_Char_PrintNumber()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe I tried it. I received an email that I needed to use UNIT16. THere is the long and hard way. But I was hoping Kiel software had a function to convert the the number. I have a hex value ex: 3fad. This needs to be converted to a decimal value.
Thanks for the reply.
Philip
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
when you #include <stdio.h> you may use sprintf() to convert any number to a string which you may print on LCD.
Parameters for sprintf() are here http://publications.gbdirect.co.uk/c_book/chapter9/formatted_io.html
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the feedback,
My code Is as follows. I get the the hex vale in 4 digits. With the sprintf(0 can I get the complete decimal value?
void Display_Result(void)
{
LCD_Char_Position(0,6);
LCD_Char_PrintInt8(HYT221_Read_Buff[0] & 0x3f); //Mask HYT humidity the highest two status bits
LCD_Char_PrintInt8(HYT221_Read_Buff[1]);
LCD_Char_PrintString(" ");
///////////////////////////////////////////////////////////
// sprintf() insert conversion here ?
/////////////////////////////////////////////////////////
LCD_Char_Position(1,6);
LCD_Char_PrintInt8(HYT221_Read_Buff[2]);
LCD_Char_PrintInt8(HYT221_Read_Buff[3] & 0xfc); //Mask HYT temperature the lowest two status bits
LCD_Char_PrintString(" ");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob,
Thanks for the help. My Cypress compiler at work will compile my software fine. But the same software on my home PC will not compile. I am uninstall Creator 2.1 and 2.2 CP5 from my work PC now. Then I will do a clean install? That did not occur to me to check the copilers.
Thanks Bob,
Phi