Go Down

Topic: LCD: erasing printed data? clearing specific fields? (Read 1 time) previous topic - next topic

nym

howdy. thank you in advance for reading.

i have a 16x2 LCD screen that i have configured to print values being read from a pixart infrared sensor.
the code prints the x and y values as read by the sensor. the resolution of this sensor is 1024 by 780.

let's say i do the following:
read/print X values from the sensor starting at 0, then moving up to 10, then 100, and finally 1000.
now, i move in reverse - back down to 0.
problem: the numbers printed from the upper ranges (1000, etc) are not cleared when printing lower values.

i am unfamiliar with how to handle this, as this is my first experiment with an LCD screen. i don't want to clear the whole screen, i just want to print ONLY the digits being read from the sensor.

i hope this is clear. thank you for your time.
nym

nym

here is an example of what i am doing, with a commented out portion where i was trying to print blanks where otherwise there would be leftover numbers.

Quote
Code: [Select]
  int calibration[4];
  int X1 = ircam.Blob1.X;
  int Y1 = ircam.Blob1.Y;
  if (result & BLOB1)
  {
    lcd.setCursor(9,0);   
    lcd.print("X: ");       
    lcd.setCursor(0,1);         
    lcd.print("Left: ");   
    lcd.setCursor(9,1);   
    lcd.print("Y: ");     
    lcd.setCursor(11,0);
//    lcd.rightToLeft();
//    if(X1 < 1000){lcd.print(" ");}
//    if(X1 <  100){lcd.print("  ");}
//    if(X1 <   10){lcd.print("   ");}
    lcd.print(X1);   
//    lcd.leftToRight();
    lcd.setCursor(11,1);
    lcd.print(Y1);   

nym

#2
May 10, 2012, 11:14 pm Last Edit: May 10, 2012, 11:15 pm by nym Reason: 1
started figuring it out, but it seems like overkill to have to do if lesser thans for every degree.

Code: [Select]
 if (result & BLOB1)
 {
   lcd.setCursor(9,0);  
   lcd.print("X: ");      
   lcd.setCursor(9,1);  
   lcd.print("Y: ");    
   if(X1 < 1000){
     lcd.setCursor(13,0);
     lcd.print(" ");
   }
   else{
     lcd.setCursor(12,0);
   }
   lcd.print(X1);  
   lcd.setCursor(13,1);
   lcd.print(Y1);    
   lcd.leftToRight();

liudr

http://arduino.cc/forum/index.php/topic,105187.msg789058.html

nym

thanks! i had searched, but didn't know how to phrase what i was looking for. apparently neither did the other guy.

liudr

If the search worked so well we would have had a lot less repeat questions. Simply asking a question is a learning process itself so you're welcome.

Go Up