LCD display

View: New views
4 Messages — Rating Filter:   Alert me  

LCD display

by sid_s_us :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi all,

I have a project in which i have to dynamically display numbers on
LCD by taking input from the user, i have done it for integers, can any
one guide me how do i implement the same for decimal numbers
Thanx



     

Re: LCD display

by Gabriel Calin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just use fixed point notation and plot a "." in the right place. For
example, a decimal number 10.123 will be stored as 10123. All math will
work exactly the same way you know (you will only have to check you
variable limits to avoid overflows).

Calin

sid_s_us@... wrote:
>
> hi all,
>
> I have a project in which i have to dynamically display numbers on
> LCD by taking input from the user, i have done it for integers, can any
> one guide me how do i implement the same for decimal numbers
> Thanx
>
>  



[Non-text portions of this message have been removed]


Parent Message unknown Re: LCD display

by sid_s_us :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

ya dats true but hw do i scan if a decimal point is present or not;

this is the code for integers as per my requirements:
#include "LCD.h"
#include "msp430xG46x.h"
#include "stdio.h"

const int charseg[]=
{
  LCD_A+LCD_B+LCD_C+LCD_D+LCD_E+LCD_F,        // '0' or 'O'
  LCD_B+LCD_C,                                // '1' or 'I'
  LCD_A+LCD_B+LCD_D+LCD_E+LCD_G,              // '2' or 'Z'
  LCD_A+LCD_B+LCD_C+LCD_D+LCD_G,              // '3'
  LCD_B+LCD_C+LCD_F+LCD_G,                    // '4' or 'y'
  LCD_A+LCD_C+LCD_D+LCD_F+LCD_G,              // '5' or 'S'
  LCD_A+LCD_C+LCD_D+LCD_E+LCD_F+LCD_G,        // '6' or 'b'
  LCD_A+LCD_B+LCD_C,                          // '7'
  LCD_A+LCD_B+LCD_C+LCD_D+LCD_E+LCD_F+LCD_G,  // '8' or 'B'
  LCD_A+LCD_B+LCD_C+LCD_F+LCD_G              // '9' or 'g'
     
                 
};

void disp(long int num)
{
  int pos=0, index;
  long int x;
 
 
  if(num>18888888)
  {
     LCDM7=LCD_A+LCD_D+LCD_E+LCD_F+LCD_G;
     LCDM6=LCD_E+LCD_G;
     LCDM5=LCD_E+LCD_G;
  }
  else if(num>9999999)
  {
   
    LCDMEM[12]|=LCD_D;
   
    x=num-10000000;
     
    do
    {
      index=x%10;
      LCDMEM[pos+LCD_MEM_OFFSET]=charseg[index];
      pos++;
      x=x/10;
    }while(x!=0);
  }
 
  else
  {
   
    x=num;
     
    do
    {
      index=x%10;
      LCDMEM[pos+LCD_MEM_OFFSET]=charseg[index];
      pos++;
      x=x/10;
    }while(x!=0);
   
  }  
   
 
   
 
}
void main(void)
{
  int i;
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 
  FLL_CTL0 |= XCAP14PF;                     // Configure load caps
 
         
 
  P5SEL = 0x1C;                             // P5.2/3/4 = LCD COM lines
  for (i = 19; i > 0; i--) LCDMEM[i] = 0;   // Clear LCD
   LCDACTL = LCDON + LCD4MUX + LCDFREQ_128;  // 4mux LCD, ACLK/128
   LCDAPCTL0 = 0x7E;                         // Segments 4-27
 

 disp(18283848);
 

}



----- Original Message ----
From: Gabriel Calin <gcalin@...>
To: msp430@...
Sent: Monday, July 14, 2008 5:24:14 PM
Subject: Re: [msp430] LCD display


Just use fixed point notation and plot a "." in the right place. For
example, a decimal number 10.123 will be stored as 10123. All math will
work exactly the same way you know (you will only have to check you
variable limits to avoid overflows).

Calin

sid_s_us@yahoo. com wrote:
>
> hi all,
>
> I have a project in which i have to dynamically display numbers on
> LCD by taking input from the user, i have done it for integers, can any
> one guide me how do i implement the same for decimal numbers
> Thanx
>
>

[Non-text portions of this message have been removed]

   


     

[Non-text portions of this message have been removed]


Re: LCD display

by leon Heller-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

----- Original Message -----
From: <sid_s_us@...>
To: <msp430@...>
Sent: Monday, July 14, 2008 10:27 PM
Subject: Re: [msp430] LCD display


> ya dats true but hw do i scan if a decimal point is present or not;
>

With fixed-point arithmetic you know where it is.

Leon

LightInTheBox - Buy quality products at wholesale price!