by esmetaman » Sun Sep 16, 2007 6:30 pm
Thanks Lawrie,
if you test the following example, LCD.drawString doesnt forget any byte.
- Code: Select all
import lejos.nxt.*;
public class BLCDDrawString2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String message;
message = "Esmeta Labs";
LCD.drawString(message,0,0);
message = "Bug detected";
LCD.drawString(message,0,1);
message = "LCD.drawString()";
while(true)
{
try{
LCD.drawString(message,0,2);
int battery = (int)(Battery.getVoltageMilliVolt() );
LCD.drawInt(battery,0,3);
int memory = (int)(Runtime.getRuntime().freeMemory());
LCD.drawInt(memory,0,4);
LCD.refresh();
}catch(Exception e){
}
}
}
}
but if you create a string in a loop, The program will forget memory:
- Code: Select all
import lejos.nxt.*;
public class BLCDDrawString3 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String message;
message = "Esmeta Labs";
LCD.drawString(message,0,0);
message = "Bug detected";
LCD.drawString(message,0,1);
while(true)
{
try{
message = "LCD.drawString()";
LCD.drawString(message,0,2);
int battery = (int)(Battery.getVoltageMilliVolt() );
LCD.drawInt(battery,0,3);
int memory = (int)(Runtime.getRuntime().freeMemory());
LCD.drawInt(memory,0,4);
LCD.refresh();
}catch(Exception e){
}
}
}
}
Conclussions: It is neccesary to define the messages.
Thanks Lawrie
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
http://www.roboticaenlaescuela.es