Ok I am stumped completly Displaying results

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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("      ");

   

}

0 Likes
8 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

... 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

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Oops, sorry, this is the wrong thread. I'll take another try...

   

 

   

Bob

0 Likes
Anonymous
Not applicable

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 */

   

 

   

 

   
    
   
0 Likes
Anonymous
Not applicable

 or you can try 

   

/* a[1] is the higher bute */

   

uint16 uiData = a[1] & 0x3f;

   

uiData <<= 8;

   

uiData += a[0]; 

   

LCD_Char_PrintNumber(uiData);

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Anonymous
Not applicable

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

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes