J'essaie de faire une interface Processing pour configurer l'aéroquad.
Lorsque la carte reçoit un caractère, elle renvoie un string, Exemple :
Processing envoi "L", Arduino envoi 0.20,0.20,0.500
Si j'envoie un caractère en solo, pas de problème, par contre si j'envoie une série de caractère différents je devrais avoir ça :
Processing envoi "L", Arduino envoi 0.20,0.20,0.500
processing envoi "Q", Arduino envoi -1,-1,1,-525,-527,-757,0,0,0.00,0.00
Processing envoi "R", Arduino envoi -2,0,2,-426,-467,-679
et ainsi de suite....
Et ce n'est pas ce que j'obtiens... j'ai plutôt ça :
Q 0,0,0,-527,-529,-756,0,0,0.00,0
L .00
L 0.20,0.20,0.50,
Q -1,0,1,-523,-530,-756,0,0,0.00,0.00
L 0.20,0.20,0.50,
Q 0,-1,-1,-522,-531,-759,0,0,0.00,0.00
Q 0.20,0.20,0.50,
Q -1,0,-1,-526,-527,-758,0,0,0.00,0.00
Q 0.20,0.20,0.50,
L -1,-1,-1,-525,-530,-759,0,0,0.00,0.00
L 0.20,0.20,0.50,
L -1,-1,0,-522,-527,-755,0,0,0.00,0.00
L 0.20,0.20,0.50,
Q -1,-1,1,-525,-527,-757,0,0,0.00,0.00
Q 0.20,0.20
avec ce code test :
import processing.serial.*;
Serial myPort;
char send_char;
String portName;
void setup()
{
size(490, 200);
background(51);
frame.setResizable(true);
println(Serial.list());
String portName = Serial.list()[3];
myPort = new Serial(this, portName, 115200);
}
void draw()
{ myPort.clear();
new Serial(this, portName, 115200);
send_char='Q';
myPort.write(send_char); // envoi un caractere a l'arduino
while (myPort.available() > 0) {
String inBuffer = myPort.readString();
if (inBuffer != null) {
print (send_char+" ");
println(inBuffer);
}
myPort.clear();
}
new Serial(this, portName, 115200);
send_char='L';
myPort.write(send_char); // envoi un caractere a l'arduino
while (myPort.available() > 0) {
String inBuffer = myPort.readString();
if (inBuffer != null) {
print (send_char+" ");
println(inBuffer);
}
myPort.clear();
}
}
Comment est ce que je peux faire pour pouvoir changer de caractère et que ça match à chaque fois avec le string entrant ?