Skip to content

Commit 1ede2b6

Browse files
committed
fixed scaling issue in listener, updated readme and examples
1 parent 3e3b931 commit 1ede2b6

File tree

5 files changed

+40
-35
lines changed

5 files changed

+40
-35
lines changed

Plotter/examples/control_points_displayed/control_points_displayed.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ void setup() {
2727
p.addXYGraph("X-Y graph w/ 200 points", 200, "x axis", &x, "y axis", &y);
2828

2929
// Add time graphs. Notice the effect of points displayed on the time scale
30-
p.addTimeGraph("Time graph w/ 100 points", 1000, "x label", &x);
3130
p.addTimeGraph("Time graph w/ 500 points", 500, "x label", &x);
31+
p.addTimeGraph("Time graph w/ 200 points", 200, "x label", &x);
3232

3333
}
3434

Plotter/examples/dynamically_modify_graph_layout/dynamically_modify_graph_layout.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ void setup() {
2929
p = Plotter();
3030

3131
// Add a graph during setup
32-
p.addTimeGraph("x and y against time", 2000, "x label", &x, "y label", &y);
32+
p.addTimeGraph("x and y against time", 1000, "x label", &x, "y label", &y);
3333
}
3434

3535
void loop() {
3636

3737
// After 3 seconds add a 1-variable graph
3838
if (millis() > 3000 && add_first) {
39-
p.addTimeGraph("First dynamic addition", 2000, "z label", &z);
39+
p.addTimeGraph("First dynamic addition", 1000, "z label", &z);
4040
add_first = false;
4141
}
4242

4343
// After 5 seconds, add a 3-variable graph
4444
if (millis() > 5000 && add_second) {
45-
p.addTimeGraph("Second dynamic addition", 2000, "x label", &x, "y label", &y, "z label", &z);
45+
p.addTimeGraph("Second dynamic addition", 1000, "x label", &x, "y label", &y, "z label", &z);
4646
add_second = false;
4747
}
4848

Plotter/library.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=Plotter
2-
version=1.0.0
2+
version=1.0.1
33
author=Devin Conley <devinconley@jhu.edu>
44
maintainer=Devin Conley <devinconley@jhu.edu>
5-
sentence=an Arduino library for easy plotting using Processing via serial communication.
6-
paragraph=Supports multi-variable plots against time as well as 2D plotting of an X vs Y variable. Multiple graphs can be displayed at once, with all formatting and scaling handled automatically. Various listener options are provided, including stand-alone options so that the Processing software does NOT need to be downloaded. The listener requires no modification, just start the program on the host computer.
5+
sentence=An Arduino library for easy plotting on host computer via serial communication.
6+
paragraph=Supports multi-variable plots against time as well as 2D plotting of an X vs Y variable. Multiple graphs can be displayed at once, with all formatting and scaling handled automatically. A stand-alone listener application, written with Processing, is provided.
77
category=Data Processing
88
url=https://github.com/devinconley/ArduinoPlotter
99
architectures=*

README.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
ArduinoPlotter
22
===============
3-
an Arduino library for easy plotting using Processing via serial communication
3+
An Arduino library for easy plotting on host computer via serial communication
44

55
_by: Devin Conley_
66

7-
Types of plots available:
8-
------------------------
9-
- Multivariable plots against time
10-
- 2-variable "x" vs "y" plots
11-
127
Features:
138
----------
9+
- Multi-variable plots against time
10+
- 2-variable "x" vs "y" plots
1411
- Display multiple graphs within single window
15-
- Simply pass a reference to your variables when the graph is added, no need to update the values manually
16-
- Choose desired number of data points to be shown along time scale for each graph
12+
- Simply pass a reference to your variables when the graph is added, no need to update each value directly
13+
- Control number of data points displayed on each graph
1714
- Auto-scaling to fit all data on graph
15+
- Stand-alone listener application, written with Processing, is provided
1816

19-
Processing listener options:
20-
-----------------------------
21-
- Stand-alone Windows application (32-bit, 64-bit)
22-
- Stand-alone Linux application (32-bit, 64-bit)
23-
- Source Processing script (ArduinoPlotter_processingListener.pde)
17+
![Plotter Preview Image](https://www.dropbox.com/s/0471kf89skyo72x/plotter_preview.png?raw=1)
2418

2519
Quickstart:
2620
------------
@@ -30,10 +24,10 @@ Search for "Plotter" in the Arduino Library Manager.
3024

3125
___or___
3226

33-
Install directly with the [ZIP file of Plotter](https://github.com/devinconley/ArduinoPlotter-for-Library-Manager/archive/master.zip)/
27+
Install manually with the [ZIP file of Plotter](https://github.com/devinconley/ArduinoPlotter-for-Library-Manager/archive/master.zip).
3428

3529
#### Setup Listener
36-
Download one of the following stand-alone listener options. Keep the folder intact so the application can access the lib and source folders. These stand-alone applications are dependent on your system having the Java Runtime Engine (JRE) installed.
30+
Download one of the following stand-alone listener options. Keep the folder intact so the application can access the library and source folders.
3731
- [Windows 32-bit](https://www.dropbox.com/s/88wa2nkfzh5j3uz/ArduinoPlotter_listener_windows32.zip?dl=1)
3832
- [Windows 64-bit](https://www.dropbox.com/s/ahy2ppul6v4lybi/ArduinoPlotter_listener_windows64.zip?dl=1)
3933
- [Linux 32-bit](https://www.dropbox.com/s/ilt9n3hkiw74vrf/ArduinoPlotter_listener_linux32.zip?dl=1)
@@ -58,11 +52,10 @@ Plotter p;
5852
```
5953

6054
Create the Plotter object and add graphs as desired. When adding graphs, the first argument is a String with the title of the graph and the second argument is an int with the number of points displayed at any given time. These two arguments are followed by atleast one String and double reference. Include more arguments (in pairs of a String and double reference) to plot multiple variables on a single time graph. If adding an XYGraph, exactly two of these pairs are required.
61-
_Although graphs will usually be added during setup(), they can be added and removed at any time (see example on dynamic modification)._
6255
```arduino
6356
void setup() {
6457
p = Plotter();
65-
58+
6659
p.addTimeGraph("Some title of single variable graph", 500, "label for x", &x);
6760
p.addTimeGraph("Some title of two-variable graph", 500, "label for x", &x, "label for y", &y);
6861
p.addXYGraph("Title of x versus y graph", 500, "x axis", &x, "y axis", &y);
@@ -75,11 +68,15 @@ void loop() {
7568
x = 10*sin(2.0*PI*(millis()/5000.0));
7669
y = 10*cos(2.0*PI*(millis()/5000.0));
7770
78-
p.plot();
71+
p.plot(); // usually called within loop()
7972
}
8073
```
8174

8275
#### Using the Listener
83-
Once the Arduino is running, start the listener application that you chose above.
76+
Once the Arduino is running, start the listener application that you setup above.
77+
78+
![Start Listener Image](https://www.dropbox.com/s/9kyzory64369mjh/start_listener.png?raw=1)
79+
80+
The application will auto-configure itself and your data should be plotted appropriately.
8481

8582
__That's it!__

listener_src/ArduinoPlotter_processingListener/ArduinoPlotter_processingListener.pde

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ final int BG_COL = 75; //
3838
final int PLOT_COL = 115;
3939
final int TICK_LEN = 6;
4040
final int NUM_TICKS = 5;
41+
final float PT_SZ = 1.5;
4142

4243
// Setup and config Globals
4344
int h;
@@ -78,6 +79,7 @@ void setup() {
7879
frameRate(100);
7980
textSize(16);
8081
background(BG_COL);
82+
strokeWeight(PT_SZ);
8183
}
8284

8385
void draw() {
@@ -191,28 +193,34 @@ void drawTicks(int g) {
191193
// Draw ticks along y-axis
192194
float temp_x = pos_graphs[g][0] - TICK_LEN/2;
193195
float tick_offset = 0.5*(1.0 - AXIS_COVERAGE)*sub_height;
196+
float tick_interval = AXIS_COVERAGE * sub_height / (NUM_TICKS - 1);
194197
float val = (float)extremes_graphs[g][3];
195198
float val_interval = (float)(extremes_graphs[g][3] - extremes_graphs[g][2]) / (NUM_TICKS - 1);
196199
for (float temp_y = pos_graphs[g][1] + tick_offset;
197-
temp_y <= pos_graphs[g][1] + sub_height - tick_offset;
198-
temp_y += AXIS_COVERAGE * sub_height / (NUM_TICKS - 1)) {
200+
temp_y <= pos_graphs[g][1] + sub_height - tick_offset; temp_y += tick_interval) {
199201
line(temp_x, temp_y, temp_x + TICK_LEN, temp_y);
200202
text(Float.toString(val), temp_x + TICK_LEN + 5, temp_y);
201203
val -= val_interval;
202204
}
203-
// Draw along x-axis
205+
// Draw along x-axis (will be diff for each type of graph)
204206
float temp_y = pos_graphs[g][1] + sub_height - TICK_LEN/2;
205-
tick_offset = 0.5*(1.0 - AXIS_COVERAGE)*sub_width;
206-
val = (float)extremes_graphs[g][0];
207-
val_interval = (float)(extremes_graphs[g][1] - extremes_graphs[g][0]) / (NUM_TICKS - 1);
207+
// if XvY graph, evenly spaced ticks within coverage
208208
if (xvy[g]) {
209-
val *= AXIS_COVERAGE;
210-
val_interval *= AXIS_COVERAGE;
209+
val = (float)extremes_graphs[g][0];
210+
val_interval = (float)(extremes_graphs[g][1] - extremes_graphs[g][0]) / (NUM_TICKS - 1);
211+
tick_offset = 0.5*(1.0 - AXIS_COVERAGE)*sub_width;
212+
tick_interval = AXIS_COVERAGE * sub_width / (NUM_TICKS - 1);
213+
// if a time graph, evenly spaced ticks across all
214+
} else {
215+
val_interval = (float)(extremes_graphs[g][1] - extremes_graphs[g][0]) / (NUM_TICKS + 1);
216+
val = (float)extremes_graphs[g][0] + val_interval;
217+
tick_offset = sub_width / (NUM_TICKS + 1);
218+
tick_interval = tick_offset;
211219
}
212220
textAlign(CENTER, BOTTOM);
213221
for (temp_x = pos_graphs[g][0] + tick_offset;
214222
temp_x <= pos_graphs[g][0] + sub_width - tick_offset;
215-
temp_x += AXIS_COVERAGE * sub_width / (NUM_TICKS - 1)) {
223+
temp_x += tick_interval) {
216224
line(temp_x, temp_y, temp_x, temp_y + TICK_LEN);
217225
text(Float.toString(val), temp_x, temp_y - 5);
218226
val += val_interval;

0 commit comments

Comments
 (0)