2525
2626// Plotter
2727
28- Plotter::Plotter () {
28+ Plotter::Plotter ()
29+ {
2930 Serial.begin (115200 );
3031 head = NULL ;
3132 tail = NULL ;
32- total_size = 0 ;
33- num_graphs = 0 ;
34- max_points_displayed = 0 ;
35- last_updated = millis ();
33+ totalSize = 0 ;
34+ numGraphs = 0 ;
35+ maxPointsDisplayed = 0 ;
36+ lastUpdated = millis ();
3637}
3738
3839Plotter::~Plotter ()
3940{
4041 Graph * temp = head;
41- Graph * temp_next ;
42- while (temp->next )
42+ Graph * tempNext ;
43+ while ( temp->next )
4344 {
44- temp_next = temp->next ;
45+ tempNext = temp->next ;
4546 delete temp;
46- temp = temp_next ;
47+ temp = tempNext ;
4748 }
4849 delete temp;
4950}
5051
51- void Plotter::addGraphHelper (String title, VarWrapper * wrappers, int sz, bool xvy, int points_displayed) {
52- Graph * temp = new Graph ( title, wrappers, sz, xvy, points_displayed );
53- if (head)
52+ void Plotter::AddGraphHelper ( String title, VariableWrapper * wrappers, int sz, bool xvy, int pointsDisplayed )
53+ {
54+ Graph * temp = new Graph ( title, wrappers, sz, xvy, pointsDisplayed );
55+ if ( head )
5456 {
5557 tail->next = temp;
5658 tail = temp;
@@ -61,70 +63,72 @@ void Plotter::addGraphHelper(String title, VarWrapper * wrappers, int sz, bool x
6163 tail = temp;
6264 }
6365
64- total_size += sz;
65- num_graphs ++;
66- if (points_displayed > max_points_displayed )
66+ totalSize += sz;
67+ numGraphs ++;
68+ if ( pointsDisplayed > maxPointsDisplayed )
6769 {
68- max_points_displayed = points_displayed ;
70+ maxPointsDisplayed = pointsDisplayed ;
6971 }
7072
71- last_updated = millis ();
73+ lastUpdated = millis ();
7274}
7375
74- bool Plotter::remove (int index) {
75- if (num_graphs == 0 || index < 0 || num_graphs <= index)
76+ bool Plotter::remove (int index)
77+ {
78+ if ( numGraphs == 0 || index < 0 || numGraphs <= index )
7679 {
7780 return false ;
7881 }
7982 else
8083 {
8184 Graph * temp = head;
82- if (index == 0 )
85+ if ( index == 0 )
8386 {
8487 head = head->next ;
8588 delete temp;
8689 }
8790 else
8891 {
8992 Graph * last = temp;
90- for (int i = 0 ; i < index; i++)
93+ for ( int i = 0 ; i < index; i++ )
9194 {
9295 last = temp;
9396 temp = temp->next ;
9497 }
9598 last->next = temp->next ;
96- num_graphs --;
97- total_size -= temp->size ;
99+ numGraphs --;
100+ totalSize -= temp->size ;
98101 delete temp;
99102 }
100- last_updated = millis ();
103+ lastUpdated = millis ();
101104 return true ;
102105 }
103106}
104107
105- void Plotter::plot () {
108+ void Plotter::Plot ()
109+ {
106110 String code = OUTER_KEY;
107- code += (num_graphs + INNER_KEY + total_size + INNER_KEY
108- + max_points_displayed + INNER_KEY + last_updated + INNER_KEY);
109- Serial.print (code);
111+ code += ( numGraphs + INNER_KEY + totalSize + INNER_KEY
112+ + maxPointsDisplayed + INNER_KEY + lastUpdated + INNER_KEY );
113+ Serial.print ( code );
110114 Graph * temp = head;
111- while (temp != NULL )
115+ while ( temp != NULL )
112116 {
113117 Serial.println ();
114- temp->plot ();
118+ temp->Plot ();
115119 temp = temp->next ;
116120 }
117- Serial.println (OUTER_KEY);
121+ Serial.println ( OUTER_KEY );
118122}
119123
120124// Graph
121125
122- Plotter::Graph::Graph (String title, VarWrapper * wrappers, int size, bool xvy, int points_displayed ) :
126+ Plotter::Graph::Graph ( String title, VariableWrapper * wrappers, int size, bool xvy, int pointsDisplayed ) :
123127 title( title ),
124128 wrappers( wrappers ),
125129 size( size ),
126130 xvy( xvy ),
127- points_displayed( points_displayed ),
131+ pointsDisplayed( pointsDisplayed ),
128132 next( NULL )
129133{}
130134
@@ -133,37 +137,38 @@ Plotter::Graph::~Graph()
133137 delete[] wrappers;
134138}
135139
136- void Plotter::Graph::plot () {
137- Serial.print (title); Serial.print (INNER_KEY);
138- Serial.print (xvy); Serial.print (INNER_KEY);
139- Serial.print (points_displayed); Serial.print (INNER_KEY);
140- Serial.print (size); Serial.print (INNER_KEY);
140+ void Plotter::Graph::Plot ()
141+ {
142+ Serial.print ( title ); Serial.print ( INNER_KEY );
143+ Serial.print ( xvy ); Serial.print ( INNER_KEY );
144+ Serial.print ( pointsDisplayed ); Serial.print ( INNER_KEY );
145+ Serial.print ( size ); Serial.print ( INNER_KEY );
141146 for (int i = 0 ; i < size; i++)
142147 {
143- Serial.print ( wrappers[i].GetLabel () ); Serial.print (INNER_KEY);
144- Serial.print ( wrappers[i].GetValue () ); Serial.print (INNER_KEY);
148+ Serial.print ( wrappers[i].GetLabel () ); Serial.print ( INNER_KEY );
149+ Serial.print ( wrappers[i].GetValue () ); Serial.print ( INNER_KEY );
145150 }
146151}
147152
148153// VariableWrapper
149154
150- Plotter::VarWrapper::VarWrapper () :
155+ Plotter::VariableWrapper::VariableWrapper () :
151156 ref( NULL ),
152157 deref( NULL )
153158{}
154159
155- Plotter::VarWrapper::VarWrapper ( String label, void * ref, double ( * deref )( void * ) ) :
160+ Plotter::VariableWrapper::VariableWrapper ( String label, void * ref, double ( * deref )( void * ) ) :
156161 label( label ),
157162 ref ( ref ),
158163 deref ( deref )
159164{}
160165
161- String Plotter::VarWrapper ::GetLabel ()
166+ String Plotter::VariableWrapper ::GetLabel ()
162167{
163168 return label;
164169}
165170
166- double Plotter::VarWrapper ::GetValue ()
171+ double Plotter::VariableWrapper ::GetValue ()
167172{
168173 return deref ( ref );
169174}
0 commit comments