|
|
View previous topic :: View next topic |
Author |
Message |
matcobra
Joined: 14 Feb 2011 Posts: 8
|
lcd clear |
Posted: Fri Mar 25, 2011 10:06 am |
|
|
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
|
|
Posted: Fri Mar 25, 2011 10:56 am |
|
|
'/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
|
|
Posted: Fri Mar 25, 2011 11:20 am |
|
|
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
|
|
Posted: Fri Mar 25, 2011 11:44 am |
|
|
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
|
|
Posted: Fri Mar 25, 2011 12:17 pm |
|
|
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
|
|
Posted: Fri Mar 25, 2011 12:18 pm |
|
|
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
|
|
Posted: Fri Mar 25, 2011 12:53 pm |
|
|
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 |
|
|
|
|
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
|