@@ -5,75 +5,99 @@ Plotter::Plotter() {
5
5
head = NULL ;
6
6
total_size = 0 ;
7
7
num_graphs = 0 ;
8
+ max_points_displayed = 0 ;
8
9
last_updated = millis ();
9
10
}
10
11
11
12
Plotter::~Plotter () { }
12
13
13
14
14
- void Plotter::addTimeGraph (String title, String labelA, double * refA) {
15
+ void Plotter::addTimeGraph (String title, int points_displayed, String labelA, double * refA) {
15
16
GraphNode* temp = head;
16
17
String labels[] = {labelA};
17
18
double * refs[] = {refA};
18
- head = new GraphNode (title, labels, refs, 1 , false );
19
+ head = new GraphNode (title, labels, refs, 1 , false , points_displayed );
19
20
head->next = temp;
20
21
total_size++;
21
22
num_graphs++;
23
+ if (points_displayed > max_points_displayed) {
24
+ max_points_displayed = points_displayed;
25
+ }
22
26
last_updated = millis ();
23
27
}
24
28
25
- void Plotter::addTimeGraph (String title, String labelA, double * refA,
29
+ void Plotter::addTimeGraph (String title, int points_displayed, String labelA, double * refA,
26
30
String labelB, double * refB) {
27
31
GraphNode* temp = head;
28
32
String labels[] = {labelA, labelB};
29
33
double * refs[] = {refA, refB};
30
- head = new GraphNode (title, labels, refs, 2 , false );
34
+ head = new GraphNode (title, labels, refs, 2 , false , points_displayed );
31
35
head->next = temp;
32
36
total_size+=2 ;
33
37
num_graphs++;
38
+ if (points_displayed > max_points_displayed) {
39
+ max_points_displayed = points_displayed;
40
+ }
34
41
last_updated = millis ();
35
42
}
36
43
37
- void Plotter::addTimeGraph (String title, String labelA, double * refA,
44
+ void Plotter::addTimeGraph (String title, int points_displayed, String labelA, double * refA,
38
45
String labelB, double * refB, String labelC, double * refC) {
39
46
GraphNode* temp = head;
40
47
String labels[] = {labelA, labelB, labelC};
41
48
double * refs[] = {refA, refB, refC};
42
- head = new GraphNode (title, labels, refs, 3 , false );
49
+ head = new GraphNode (title, labels, refs, 3 , false , points_displayed );
43
50
head->next = temp;
44
51
total_size+=3 ;
45
52
num_graphs++;
53
+ if (points_displayed > max_points_displayed) {
54
+ max_points_displayed = points_displayed;
55
+ }
46
56
last_updated = millis ();
47
57
}
48
58
49
59
50
- void Plotter::addXYGraph (String title, String labelX, double * refX, String labelY, double * refY) {
60
+ void Plotter::addXYGraph (String title, int points_displayed, String labelX, double * refX, String labelY, double * refY) {
61
+ // Code for creating XYgraph...
62
+ GraphNode* temp = head;
63
+ String labels[] = {labelX, labelY};
64
+ double * refs[] = {refX, refY};
65
+ head = new GraphNode (title, labels, refs, 2 , true , points_displayed);
66
+ head->next = temp;
51
67
total_size+=2 ;
52
68
num_graphs++;
69
+ if (points_displayed > max_points_displayed) {
70
+ max_points_displayed = points_displayed;
71
+ }
53
72
last_updated = millis ();
54
73
}
55
74
56
- void Plotter::init () {
57
-
58
- }
59
-
60
75
void Plotter::plot () {
61
76
// Print configuration code
62
- Serial.print (OUTER_KEY);
63
- Serial.print (num_graphs); Serial.print (' @' ); Serial.print (total_size); Serial.print (' @' );
77
+ String code = OUTER_KEY;
78
+ code += (num_graphs + INNER_KEY + total_size + INNER_KEY
79
+ + max_points_displayed + INNER_KEY + last_updated + INNER_KEY);
80
+ Serial.print (code);
81
+ /*
82
+ Serial.print(OUTER_KEY);
83
+ Serial.print(num_graphs); Serial.print('@'); Serial.print(num_time); Serial.print(INNER_KEY);
84
+ Serial.print(total_size); Serial.print('@');
64
85
Serial.print(last_updated); Serial.print('@'); Serial.println();
86
+ */
65
87
GraphNode* temp = head;
66
88
while (temp != NULL ) {
89
+ Serial.println ();
67
90
temp->plot ();
68
91
temp = temp->next ;
69
92
}
70
- Serial.print (OUTER_KEY);
93
+ Serial.println (OUTER_KEY);
71
94
}
72
95
73
96
// Functions for helper class
74
- Plotter::GraphNode::GraphNode (String title, String* _labels, double ** _refs, int size, bool xvy) : title(title), size(size), xvy(xvy) {
97
+ Plotter::GraphNode::GraphNode (String title, String* _labels, double ** _refs, int size, bool xvy,
98
+ int points_displayed) : title(title), size(size), xvy(xvy),
99
+ points_displayed(points_displayed) {
75
100
next = NULL ;
76
- points_displayed = 300 ;
77
101
labels = new String[size];
78
102
refs = new double *[size];
79
103
for (int i = 0 ; i < size; i++) {
@@ -84,12 +108,11 @@ Plotter::GraphNode::GraphNode(String title, String* _labels, double** _refs, int
84
108
85
109
void Plotter::GraphNode::plot () {
86
110
Serial.print (title); Serial.print (' @' );
87
- Serial.print (true ); Serial.print (' @' );
111
+ Serial.print (xvy ); Serial.print (' @' );
88
112
Serial.print (points_displayed); Serial.print (' @' );
89
113
Serial.print (size); Serial.print (' @' );
90
114
for (int i = 0 ; i < size; i++) {
91
115
Serial.print (labels[i]); Serial.print (' @' );
92
116
Serial.print (*refs[i]); Serial.print (' @' );
93
117
}
94
- Serial.println ();
95
118
}
0 commit comments