- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code below will print numbers like 3BB1, 120F. I can't get the diplay to read decimal value like 5051 with no letters. I think I tried everything. I used LCD_Char_PrintNumber(HYT221_Read_Buff[1]); I tried sprintf. What is it that I am missing?
Philip
uint8 HYT221_Read_Buff[4] = {0};
uint8 HYT221_Write_Buff[4] = {0};
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( HYT221_Read_Buff[1]);
// void LCD_Char_PrintNumber(uint16 value) ;
// duty1_string=(HYT221_Read_Buff);
sprintf(HYT221_Read_Buff,CharLCD_PrintNumber(HYT221_Read_Buff);
// sprintf (duty1_string, "%2.2f", duty1);
// LCD_Char_Position(0,6);
// CharLCD_1_PrintString(duty1_string);
// LCD_Char_PrintNumber(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(" ");
}
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sprintf() should have worked, PrintInt8() or 16 are printing Hex-numbers, have a look into datasheet.
Best would be to use LCD_PrintNumber(), but this expects an int16, so better cast your value into an int16
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
... and as I just see, you enabled in the UART> the command buffer which you cut off with the LJMP to your ISR. Disable the buffer to save some space in flash and ram.
Mean Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oops, sorry, this is the wrong thread. I'll take another try...
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you want to print 256 on the screen if the value of the higher byte is 0x01 and the lower byte is 0x00?
If that is the case, try this
uchar ucData1digit;
uchar ucData10digit,
uchar ucData100digit,
uchar ucData1000digit,
uchar ucData10000digit,
uint uiData = (a[1] << 😎 + a[0];
ucData1digit = uiData %10;
ucData= uiData / 10;
ucData10digit = uiData %10;
ucData= uiData / 10;
.....
/* after getting the 5 number, print the on the LCD starting with ucData10000digit first .......*/
/* you can do leading 0 blanking as well */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
or you can try
/* a[1] is the higher bute */
uint16 uiData = a[1] & 0x3f;
uiData <<= 8;
uiData += a[0];
LCD_Char_PrintNumber(uiData);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sprintf() has many formatting capabilities that may be useful. Its only
downside is the library code added is significant.
Attached some formatting strings that make sprintf() really nice way of
converting numbers into text strings to print with LCD print string API.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob,
I just recast my unit8 to unit16. I will see if this will work. Do you know if there is any book or notes about C from Cypress for the PSOC3 and PSOC5 family. The Designer included a help tab with a compiler section. This was great. I moved two years ago and lost mt C code book.
Thanks Bob I will give it a try.
Philip
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The few special things for PSoCs are to be found in the corresponding compiler manuals, the System Reference Guide (under Help-tab of Creator) and the datasheets of the user-modules.
For a C-redference I use http://publications.gbdirect.co.uk/c_book/
Bob