1 Reply Latest reply on Feb 7, 2020 1:37 AM by MoTa_728816

    LCD

    eeEn_4618901

      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

        • 1. Re: LCD
          MoTa_728816

          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

          1 of 1 people found this helpful