![](/media/cache/group/Download_mxxYCWN.jpg.50x50_q85.jpg)
Plotly Cloud Dienst mit Sensorwerten
Dependencies: EthernetInterface mbed-rtos mbed plotly
Fork of Plotly_HelloWorld by
Diff: main.cpp
- Revision:
- 1:5e7145bb2184
- Parent:
- 0:c7329ea5d8d5
- Child:
- 2:99852a7499da
--- a/main.cpp Fri Jul 11 10:11:00 2014 +0000 +++ b/main.cpp Tue Jul 29 13:55:43 2014 +0000 @@ -8,30 +8,35 @@ EthernetInterface eth; // plotly account details -char PlotlyUsername[] = "YoutUsername"; -char PlotlyAPIToken[] = "YourAPIKey"; -char streaming_token[] = "YourStreamToken"; -char fileName[] = "Mbed Test Chart"; +const int numberOfTraces = 3; +const char PlotlyUsername[] = "YoutUsername"; +const char PlotlyAPIToken[] = "YourAPIKey"; +const char *PlotlyStreamingTokens[numberOfTraces] = {"YourStreamToken","YourSecondStreamToken"}; // or {"YourStreamToken"} for a single line. Must match numberOfTraces +const char PlotlyFileName[] = "Mbed Test Chart"; -plotly graph = plotly(PlotlyUsername, PlotlyAPIToken, streaming_token, fileName); +plotly graph = plotly(PlotlyUsername,PlotlyAPIToken, PlotlyStreamingTokens, PlotlyFileName, numberOfTraces); void plotSetup() { - graph.log_level = 2; // turn on status output + graph.log_level = 1; // turn on status output graph.maxpoints = 72; if (graph.init()) { - graph.openStream(); + graph.openStreams(); } } -// Generate a sample chart +// Generate some simple sample data points void plotGenerateDataPoint() { - static int counter = 0; - float yValue = sin(counter*3.14159/180); - graph.plot(counter, yValue); - counter+=5; + static float counter = 0; + + // generate a series of sine waves with slightly different frequencies. + for (int i = 0; i < numberOfTraces; i++) { + graph.plot(counter, (float)sin(counter * (1-i*0.1)), i); + } + + counter+=0.2; } @@ -57,7 +62,7 @@ plotGenerateDataPoint(); wait(0.5); } - graph.closeStream(); + graph.closeStreams(); } else pc.printf("No IP Address\n");