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.
plotly.h
- Committer:
- AndyA
- Date:
- 2014-07-02
- Revision:
- 1:d532e96fca12
- Parent:
- 0:96532c59670f
- Child:
- 2:d53d74ed68ac
File content as of revision 1:d532e96fca12:
#ifndef plotly_streaming_ethernet_h #define plotly_streaming_ethernet_h #include <EthernetInterface.h> #include <TCPSocketConnection.h> /********************************* in main.cpp EthernetInterface eth; #define num_traces 1 // Sign up to plotly here: https://plot.ly // View your API key and stream tokens in your settings: https://plot.ly/settings char *streaming_tokens[num_traces] = {"leofdu7cun"}; plotly graph = plotly("AndyA", "acchq52p7j", streaming_tokens, "test1", num_traces); void plotSetup() { // eth.init(); // eth.connect(); // Initialize a streaming graph in your plotly account pc.printf("plot init..\n"); graph.init(); pc.printf("Open stream..\n"); // Initialize plotly's streaming service graph.openStream(); } void plotGenerateData() { static int counter = 0; graph.plot(counter, counter*counter, streaming_tokens[0]); counter++; } ********************************************/ class plotly { public: plotly(char *username, char *api_key, char* stream_tokens[], char *filename, int nTraces); ~plotly(); bool init(); void openStream(); void closeStream(); void reconnectStream(); void jsonStart(int i); void jsonMiddle(); void jsonEnd(char *token); void plot(unsigned long x, int y, char *token); void plot(unsigned long x, float y, char *token); int log_level; bool dry_run; int maxpoints; bool world_readable; bool convertTimestamp; char *timezone; char *fileopt; private: bool print_(int d); bool print_(unsigned long d); bool print_(float d); bool print_(char *d); bool printHex_(uint16_t d); int len_(int i); int len_(unsigned long i); int len_(char *i); char txBuffer[128]; char rxBuffer[128]; TCPSocketConnection socket; unsigned long fibonacci_; char *username_; char *api_key_; char** stream_tokens_; char *filename_; int nTraces_; bool initalised; }; #endif