Hi,
I need a Numberfield for entering Numbers, Points and Chars. I use the TButton function for that. This is the function:
int new_waypoint(int n){
noStroke();
fill(255);
rect(73,0,247,240);
stroke(0);
zahl1.Paint();
zahl2.Paint();
zahl3.Paint();
zahl4.Paint();
zahl5.Paint();
zahl6.Paint();
zahl7.Paint();
zahl8.Paint();
zahl9.Paint();
zahl0.Paint();
zp.Paint();
zc.Paint();
zenter.Paint();
zn.Paint();
ze.Paint();
fill(200,200,200);
rect(110,30,190,40);
char input_data[100];
int i = 0;
unsigned long time = millis();
while(1){
if(millis()>time+250){
if(zahl1.GetTouch()){
input_data[i] = '1';
i++;
fill(200,200,200);
rect(110,30,190,40);
fill(200,200,200);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zahl2.GetTouch()){
input_data[i] = '2';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zahl3.GetTouch()){
input_data[i] = '3';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zahl4.GetTouch()){
input_data[i] = '4';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zahl5.GetTouch()){
input_data[i] = '5';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zahl6.GetTouch()){
input_data[i] = '6';
i++;
fill(200,200,200);
rect(110,30,190,40);
fill(200,200,200);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zahl7.GetTouch()){
input_data[i] = '7';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zahl8.GetTouch()){
input_data[i] = '8';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zahl9.GetTouch()){
input_data[i] = '9';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zahl0.GetTouch()){
input_data[i] = '0';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zn.GetTouch()){
input_data[i] = 'N';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(ze.GetTouch()){
input_data[i] = 'E';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zc.GetTouch()){
i--;
input_data[i] = 0;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zp.GetTouch()){
input_data[i] = '.';
i++;
fill(200,200,200);
rect(110,30,190,40);
noFill();
stroke(0);
text(input_data,115,50,10);
time = millis();
}
else if(zenter.GetTouch()){
char lat[10];
char lon[10];
i = 0;
while(input_data[i]!='N'){
lat[i] = input_data[i];
i++;
}
lat[i] = '\0';
i++;
int e=0;
while(input_data[i]!='E'){
lon[e] = input_data[i];
i++;
e++;
}
lon[e] = '\0';
waypoint_lat[n] = atof(lat);
waypoint_lon[n] = atof(lon);
return 1;
}
}
}
}
I have a field with the numbers 0-9, with a point, a clear button, the chars N and E, and a Enter button. I want to add the chars to a char arrayw, when a button with numbers/chars is pressed. With the clear button, I want to clear the last entered char. At the end, the chars will look like that:
50.894238N10.473400E
Only the numbers will change. I want to convert the numbers, before the 'N' to a float and save it in waypoint_lat[n]. The number after 'N' will also be converted to a float a wil be saved in the waypoint_lon array.
In this movie can you see, what happends: Mieten & Vermieten im Mietmarkt auf Kleinanzeigen.com
After doing that, the Autopilot Site will be painted.
void autopilot_seite_paint(){
noStroke();
fill(255);
rect(73,0,247,240);
stroke(0);
direct1.Paint();
direct2.Paint();
direct3.Paint();
direct4.Paint();
direct5.Paint();
direct6.Paint();
fill(200,200,200);
rect(100,1,215,33);
rect(100,41,215,33);
rect(100,81,215,33);
rect(100,121,215,33);
rect(100,161,215,33);
rect(100,201,215,33);
stroke(0,0,0);
fill(255);
int n;
for(int i=0;i<6;i++){
char test[100];
n=sprintf(test,"%f %f",waypoint_lat[i], waypoint_lon[i]);
switch(i){
case 0:
text(test,110,15,10);
break;
case 1:
text(test,110,55,10);
break;
case 2:
text(test,110,95,10);
break;
case 3:
text(test,110,135,10);
break;
case 4:
text(test,110,175,10);
break;
case 5:
text(test,110,215,10);
break;
}
}
}
I use the sprintf function, to generate a char array for the waypoint_lat and _lon arrays. But there happens nothing.
Can you please help me whats wrong?
Greetings
Philipp