Adafruit IO Arduino Library
AdafruitIO_Data.h
Go to the documentation of this file.
1 
15 #ifndef ADAFRUITIO_DATA_H
16 #define ADAFRUITIO_DATA_H
17 
18 #include "AdafruitIO_Definitions.h"
19 #include "Arduino.h"
20 
21 // forward decl
22 class AdafruitIO_Feed;
23 
24 /**************************************************************************/
29 /**************************************************************************/
31 
32 public:
35  AdafruitIO_Data(AdafruitIO_Feed *f, char *csv);
36  AdafruitIO_Data(AdafruitIO_Feed *f, const char *csv);
37  AdafruitIO_Data(const char *f);
38  AdafruitIO_Data(const char *f, char *csv);
39 
40  bool setCSV(char *csv);
41  bool setCSV(const char *csv);
42 
43  void setLocation(double lat, double lon, double ele = 0);
44 
45  void setValue(const char *value, double lat = 0, double lon = 0,
46  double ele = 0);
47  void setValue(char *value, double lat = 0, double lon = 0, double ele = 0);
48  void setValue(bool value, double lat = 0, double lon = 0, double ele = 0);
49  void setValue(String value, double lat = 0, double lon = 0, double ele = 0);
50  void setValue(int value, double lat = 0, double lon = 0, double ele = 0);
51  void setValue(unsigned int value, double lat = 0, double lon = 0,
52  double ele = 0);
53  void setValue(long value, double lat = 0, double lon = 0, double ele = 0);
54  void setValue(unsigned long value, double lat = 0, double lon = 0,
55  double ele = 0);
56  void setValue(float value, double lat = 0, double lon = 0, double ele = 0,
57  int precision = 6);
58  void setValue(double value, double lat = 0, double lon = 0, double ele = 0,
59  int precision = 6);
60 
61  char *feedName();
62 
63  char *value();
64  char *toChar();
65  String toString();
66 
67  bool toBool();
68  bool isTrue();
69  bool isFalse();
70 
71  int toInt();
72  int toPinLevel();
73  unsigned int toUnsignedInt();
74 
75  double toDouble();
76  float toFloat();
77 
78  long toLong();
79  unsigned long toUnsignedLong();
80 
81  int toRed();
82  int toGreen();
83  int toBlue();
84  long toNeoPixel();
85 
86  char *toCSV();
87  char *charFromDouble(double d, int precision = 6);
88 
89  double lat();
90  double lon();
91  double ele();
92 
95 private:
96  char _feed[AIO_FEED_NAME_LENGTH];
97 
98  char _csv[AIO_CSV_LENGTH];
99  char _value[AIO_DATA_LENGTH];
100 
101  double _lat, _lon, _ele;
102 
103  bool _parseCSV();
104 };
105 
106 #endif // ADAFRUITIO_DATA_H
int toInt()
Converts provided String value to Integer.
Definition: AdafruitIO_Data.cpp:482
long toLong()
Converts value to to a long value.
Definition: AdafruitIO_Data.cpp:546
char * feedName()
Returns existing Adafruit IO feed name.
Definition: AdafruitIO_Data.cpp:422
#define AIO_DATA_LENGTH
Maximum length of data sent/recieved from Adafruit IO.
Definition: AdafruitIO_Definitions.h:135
char * toChar()
Converts value to char.
Definition: AdafruitIO_Data.cpp:438
AdafruitIO_Data * next_data
Definition: AdafruitIO_Data.h:93
bool isFalse()
Checks if value is False.
Definition: AdafruitIO_Data.cpp:474
unsigned int toUnsignedInt()
Converts value to to an Unsigned Integer value.
Definition: AdafruitIO_Data.cpp:507
String toString()
Converts value to string.
Definition: AdafruitIO_Data.cpp:446
Class that provides methods for interfacing with Adafruit IO feed topics. https://io.adafruit.com/api/docs/mqtt.html#mqtt-topics.
Definition: AdafruitIO_Feed.h:34
#define AIO_CSV_LENGTH
Maximum comma-separated-value length from Adafruit IO.
Definition: AdafruitIO_Definitions.h:137
unsigned long toUnsignedLong()
Converts value to to an unsigned long value.
Definition: AdafruitIO_Data.cpp:557
long toNeoPixel()
Creates a RGB Tuple usable by Adafruit_NeoPixel's setPixelColor method.
Definition: AdafruitIO_Data.cpp:620
bool toBool()
Converts value to Boolean.
Definition: AdafruitIO_Data.cpp:454
AdafruitIO_Data()
Sets up an Adafruit IO Data Record.
Definition: AdafruitIO_Data.cpp:24
double ele()
Returns a data record's elevation value.
Definition: AdafruitIO_Data.cpp:669
double toDouble()
Converts value to to a double value.
Definition: AdafruitIO_Data.cpp:535
double lat()
Returns a data record's latitude value.
Definition: AdafruitIO_Data.cpp:653
bool isTrue()
Checks if value is True.
Definition: AdafruitIO_Data.cpp:466
void setLocation(double lat, double lon, double ele=0)
Sets Adafruit IO Feed location metadata.
Definition: AdafruitIO_Data.cpp:180
char * toCSV()
Creates a list of comma-separated-values for an Adafruit IO data record.
Definition: AdafruitIO_Data.cpp:634
float toFloat()
Converts value to a floating point value.
Definition: AdafruitIO_Data.cpp:524
char * charFromDouble(double d, int precision=6)
Converts from a character to a double.
Definition: AdafruitIO_Data.cpp:683
Class for interacting with Adafruit IO Data Records. https://io.adafruit.com/api/docs/#data.
Definition: AdafruitIO_Data.h:30
double lon()
Returns a data record's longitude value.
Definition: AdafruitIO_Data.cpp:661
#define AIO_FEED_NAME_LENGTH
group, a dot, and actual feed name.
Definition: AdafruitIO_Definitions.h:131
int toBlue()
Returns BB from 0xRRGGBB value.
Definition: AdafruitIO_Data.cpp:604
char * value()
Converts provided value to char.
Definition: AdafruitIO_Data.cpp:430
int toPinLevel()
Checks digital pin level.
Definition: AdafruitIO_Data.cpp:494
int toGreen()
Returns GG from 0xRRGGBB value.
Definition: AdafruitIO_Data.cpp:589
void setValue(const char *value, double lat=0, double lon=0, double ele=0)
Sets Adafruit IO Feed value field.
Definition: AdafruitIO_Data.cpp:203
bool setCSV(char *csv)
Sets data to be returned by AdafruitIO_Feed subCallback.
Definition: AdafruitIO_Data.cpp:152
int toRed()
Returns RR from 0xRRGGBB value.
Definition: AdafruitIO_Data.cpp:574