-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVOR13.cpp
More file actions
103 lines (87 loc) · 2.57 KB
/
VOR13.cpp
File metadata and controls
103 lines (87 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Projet VOR-013 Vor Marley the drawing Robots
// Major Lee
// CC-0
// Juillet 2016
//----------------------------------------------------------------------------------------------------------------------
// permet de conserver l'état du robot et d'effectuer les tâches commune.
#include <Arduino.h>
#include "VOR13.h"
#include "debugSerialPort.h"
VOR13::VOR13(): _aEcrire( "VOLAB" ) {}
void VOR13::begin(){
_mode = MODE_ECRIT; // mode par defaut
_etat = ETAT_ATTENTE;
_recState = NOREC;
}
String VOR13::buildStateTrame(){
String trame;
switch (_mode){
case MODE_ECRIT:
trame = "Mode ecrit,";
break;
case MODE_DESSINE:
trame = "Mode dessin,";
break;
}
switch (_etat){
case ETAT_ATTENTE:
trame += "en attente, ";
break;
case ETAT_WORK:
trame += "en cours, ";
break;
case ETAT_FINI:
trame += "fini, ";
break;
}
switch (_recState){
case NOREC:
trame += "rien recu";
break;
case LASTREC_GO:
trame += "recu GO";
break;
case LASTREC_DESSINE: // finalement pas utilise
trame += "recu dessine";
break;
case LASTREC_TEXTE: // finalement pas utilise
trame += "recu : " + _aEcrire ;
break;
case LASTREC_MODEDESSIN:
trame += "recu mode dessin et " + _aEcrire ; // + aDessiner
break;
case LASTREC_MODETEXTE:
trame += "recu mode texte et " + _aEcrire ;
break;
case LASTREC_UNKNOW:
trame += "commande inconnue";
break;
}
return trame;
}
boolean VOR13::go(){
return ( _recState == LASTREC_GO );
}
void VOR13::interpreteTrame( String trame ){
if ( trame == "GO" ){
_recState = LASTREC_GO;
return;
} else if ( trame.indexOf('_') == 1 ){
if ( trame.startsWith("D")){
_mode = MODE_DESSINE;
//aDessinner = trame.substring(2);
_aEcrire = trame.substring(2); // attention on réatulise la variable pour un autre usage
//verifier si le fichier exist
//sinon => unknow file => retour mode ecrit
// dessine reste a implementer
_recState = LASTREC_MODEDESSIN;
} else if ( trame.startsWith("E") ){
_mode = MODE_ECRIT;
_aEcrire = trame.substring(2);
//sp("-");SERIALDEBUG.print( _aEcrire.charAt(_aEcrire.length()-1 ), HEX );spl("-");
_recState = LASTREC_MODETEXTE;
}
} else {
_recState = LASTREC_UNKNOW;
}
}