plotly interface based on ardunio sample code
Library for plotting a simple x/y scatter chart on the plot.ly website.
See plotly_HelloWorld for sample usage.
Diff: plotly.cpp
- Revision:
- 5:fc8eefeb301b
- Parent:
- 4:33006c37c633
- Child:
- 7:9409a72ab6c0
--- a/plotly.cpp Fri Jul 11 10:10:16 2014 +0000 +++ b/plotly.cpp Mon Jul 28 10:56:42 2014 +0000 @@ -302,6 +302,20 @@ sendFormatedText(buffer,len); } +void plotly::plot(float x, float y) +{ + if (!initalised) + return; + + reconnectStream(); + + // need to prefix with the length so print it once to get the content lenght and then a second time with the prefix. + int len = snprintf(buffer,k_bufferSize,"{\"x\": %.3f, \"y\": %.3f}\n", x,y); + len = snprintf(buffer,k_bufferSize,"%x\r\n{\"x\": %.3f, \"y\": %.3f}\n\r\n",len, x,y); + sendFormatedText(buffer,len); +} + + bool plotly::print_(int d) { char smallBuffer[10];