|
|
View previous topic :: View next topic |
Author |
Message |
drzxoulis
Joined: 12 Apr 2004 Posts: 14
|
HELP!!a little more!!! |
Posted: Fri Apr 16, 2004 10:08 pm |
|
|
Is any possible way i could really make the expression below look simpler without loosing its functionality.????? Quote: |
if (temp>80)
printf(lcd_putc,"\fPRESSURE:%4.0f mB\nHIGH TEMP",pres);
else if (temp<-20)
printf(lcd_putc,"\fPRESSURE:%4.0f mB\nLOW TEMP",pres);
else if (pres<500)
printf(lcd_putc,"\fLOW PRESSURE\nTEMP:%2.1f %CC",temp,0xDF);
else if (pres>1150)
printf(lcd_putc,"\fHIGH PRESSURE\nTEMP:%2.1f %CC",temp,0xDF);
else if (temp>80 && PRES<500)
lcd_putc("\fLOW PRESSURE\nHIGH TEMP");
else if (temp<-20 && PRES<500)
lcd_putc("\fLOW PRESSURE\nLOW TEMP");
else if (temp<-20 && PRES>1150)
lcd_putc("\fHIGH PRESSURE\nLOW TEMP");
else if (temp>80 && PRES>1150)
lcd_putc("\fHIGH PRESSURE\nHIGH TEMP");
else
printf(lcd_putc,"\fPRESSURE:%4.0f mB\nTEMP:%2.1f %CC",pres,temp,0xDF); |
Any suggestion more than welcomed!!!!!Thanks in advance....... |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Sat Apr 17, 2004 1:53 am |
|
|
Are you sure you want to maintain the functionality of that code? Because I don't think it works properly as it is. You have overlapping conditions but they can't run together. For example if temp=100 and PRES=100, what do you want the code to print? Right now it will execute the line printf(lcd_putc,"\fPRESSURE:%4.0f mB\nHIGH TEMP",pres); but you also have another condition check to execute lcd_putc("\fLOW PRESSURE\nHIGH TEMP");, and this line will never run because the code flow will never get to this point. |
|
|
drzxoulis
Joined: 12 Apr 2004 Posts: 14
|
|
Posted: Sat Apr 17, 2004 7:29 am |
|
|
As you said the whole loop doesn't really work.
what i want to achieve is just a way of presenting the limits on the lcd.
this means having for each limit something writen eg."low temp" and silmutaneously the result from the other.
But for some reason it doesn't work if i want to have both warnings on the lcd.
Any ideas? |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sat Apr 17, 2004 8:06 am |
|
|
drzxoulis,
I suggest the following:
1) Reserve the upper line of the LCD to display PRESURE values,
2) Reserve the lower line to display TEMP values.
Code: |
printf(lcd_putc,"\f"); // Clear the LCD display ONCE
if (pres<500)
printf(lcd_putc,"LOW PRESSURE !");
else if (pres>1150)
printf(lcd_putc,"HIGH PRESSURE !");
else
printf(lcd_putc,"PRESSURE:%4.0f mB",pres);
if (temp>80)
printf(lcd_putc,"\nHIGH TEMP !");
else if (temp<-20)
printf(lcd_putc,"\nLOW TEMP !");
else
printf(lcd_putc,"\nTEMP:%2.1f %CC",temp,0xDF);
|
Easy isnīt ???
Humberto |
|
|
|
|
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
|