CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

lcd clear

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
matcobra



Joined: 14 Feb 2011
Posts: 8

View user's profile Send private message

lcd clear
PostPosted: Fri Mar 25, 2011 10:06 am     Reply with quote

Hi, can anyone help me how to clear text on lcd then after the next text will show. Example, my coding
Code:

#include <16F877A.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)

#include <lcd.c>

#define x input (pin_b0) // ph output
#define y input (pin_b1) // voltage output
//#define z input (pin_b2) // glucose output

void main()
{
int16 adc_value;
float value1;
float value2;
float volt;


lcd_init();

setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);

while(1)

{
value1=read_adc();
value2=(value1*5)/1023;
volt=value2*2 ;
 

   lcd_putc("\f----:FRUITi:----\n");
   delay_ms(100);
 
   
if(x==1)
   {   
     if((volt>5.00)&&(volt<=10.00))
     {printf(lcd_putc,"T:SWEET",);
      printf(lcd_putc,"G:MANY)",);delay_ms(100);}
     else if((volt>3.00)&&(volt<=5.00))
     {printf(lcd_putc,"T:SWEETSOUR",);delay_ms(3100);}
     else if((volt>0.00)&&(volt<=3.00))
     {printf(lcd_putc,"T:SOUR",);delay_ms(3100);}
   }

if(y==1)
   {

   {printf(lcd_putc,"VOLTAGE:%3.2f",volt);delay_ms(3100);}

   }


 }
}

Based on my coding example...I want to show text "SWEET" 1st then after that LCD screen need to clear then it will showing "MANY". The problem is I dunno how to clear text "SWEET" 1st before showing "MANY". Anyone can help me out for my problem ?
I'm sorry bcause my english vocabulary no so good.
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Fri Mar 25, 2011 10:56 am     Reply with quote

'/f'

If you send this to the LCD, using either 'lcd_putc', or a printf to lcd_putc, it clears the screen.
It is the character for a terminal 'form feed'.

Best Wishes
matcobra



Joined: 14 Feb 2011
Posts: 8

View user's profile Send private message

PostPosted: Fri Mar 25, 2011 11:20 am     Reply with quote

oh ok...then how how i must suposed add that inside my coding....can u show how?
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Fri Mar 25, 2011 11:44 am     Reply with quote

matcobra wrote:
oh ok...then how how i must suposed add that inside my coding....can u show how?


Code:
#include <16F877A.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)

#include <lcd.c>

#define x input (pin_b0) // ph output
#define y input (pin_b1) // voltage output
//#define z input (pin_b2) // glucose output

void main()
{
int16 adc_value;
float value1;
float value2;
float volt;


lcd_init();

setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);

while(1)

{
value1=read_adc();
value2=(value1*5)/1023;
volt=value2*2 ;
 
   lcd_putc("\f----:FRUITi:----\n");
   delay_ms(100);
 
   
if(x==1)
   {   
     if((volt>5.00)&&(volt<=10.00))
     {printf(lcd_putc,"T:SWEET \f",);
      printf(lcd_putc,"G:MANY \f)",);delay_ms(100);}
     else if((volt>3.00)&&(volt<=5.00))
     {printf(lcd_putc,"T:SWEETSOUR \f",);delay_ms(3100);}
     else if((volt>0.00)&&(volt<=3.00))
     {printf(lcd_putc,"T:SOUR \f",);delay_ms(3100);}
   }

if(y==1)
   {

   {
      printf(lcd_putc,"VOLTAGE:%3.2f \f",volt);delay_ms(3100);}

   }


 }
}


lcd_putc('\f');

Your LCD should be clearing on your first putc() line. What LCD are you using?
_________________
Vinnie Ryan
matcobra



Joined: 14 Feb 2011
Posts: 8

View user's profile Send private message

PostPosted: Fri Mar 25, 2011 12:17 pm     Reply with quote

i used 16x2 lcd,oh okay..i just tried test coding based on ur new post...it's worked...but it clear 1st row also..hmm i just want to clear second row only
matcobra



Joined: 14 Feb 2011
Posts: 8

View user's profile Send private message

PostPosted: Fri Mar 25, 2011 12:18 pm     Reply with quote

i used 16x2 lcd,oh okay..i just tried test coding based on ur new post...it's worked...but it clear 1st row also..hmm i just want to clear second row only
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Fri Mar 25, 2011 12:53 pm     Reply with quote

just remove all of the "\f" that you dont want. If you only want it to clear the second row, then remove the \f from the first row.

Cheers

Code:
#include <16F877A.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)

#include <lcd.c>

#define x input (pin_b0) // ph output
#define y input (pin_b1) // voltage output
//#define z input (pin_b2) // glucose output

void main()
{
int16 adc_value;
float value1;
float value2;
float volt;


lcd_init();

setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);

while(1)

{
value1=read_adc();
value2=(value1*5)/1023;
volt=value2*2 ;
 
   lcd_putc("----:FRUITi:----\n");
   delay_ms(100);
 
   
if(x==1)
   {   
     if((volt>5.00)&&(volt<=10.00))
     {printf(lcd_putc,"T:SWEET \f",);
      printf(lcd_putc,"G:MANY \f)",);delay_ms(100);}
     else if((volt>3.00)&&(volt<=5.00))
     {printf(lcd_putc,"T:SWEETSOUR \f",);delay_ms(3100);}
     else if((volt>0.00)&&(volt<=3.00))
     {printf(lcd_putc,"T:SOUR \f",);delay_ms(3100);}
   }

if(y==1)
   {

   {
      printf(lcd_putc,"VOLTAGE:%3.2f \f",volt);delay_ms(3100);}

   }


 }
}


Notice how each row has "\f" at the end. Remove this for each line you 'DON'T' want to clear.

Code:
     printf(lcd_putc,"T:SWEET \f",);
     printf(lcd_putc,"G:MANY \f)",);
     printf(lcd_putc,"T:SWEETSOUR \f",);
     printf(lcd_putc,"T:SOUR \f",);
     printf(lcd_putc,"VOLTAGE:%3.2f \f",volt);

_________________
Vinnie Ryan
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group