Data Classes
API Reference
This is a list of all data classes used by the LaRoomy Api.
BarData
class BarData {
public:
BarData(){}
BarData(const BarData& bData );
BarData(const String& bar_name , float bar_value );
BarData(const char* bar_name , float bar_value );
BarData(float bar_value );
String barName = "_";
float barValue = 0;
};
Description:
The BarData class is used to provide the dataset(s) for the bar(s) in a BarGraph property and can be added to the BarGraphState class which is part of a BarGraph property.
Usage:
In the following example some BarData objects are created in different ways and added to a BarGraph:
// create a BarGraph property
BarGraph barGraph ;
barGraph .barGraphID = MY_BAR_GRAPH ;
barGraph .barGraphDescription = "My BarGraph";
barGraph .imageID = LaRoomyImages::BAR_GRAPH_162 ;
// create some BarData objects and add it:
BarData bar_data_one ("Bar 1", 67.0f);
barGraph .barGraphState .addBar(bar_data_one );
BarData bar_data_two ;
bar_data_two .barName = "Bar 2";
bar_data_two .barValue = 26.0f;
barGraph .barGraphState .addBar(bar_data_two );
// if the barGraph should not display bar-names the parameter can be omitted
BarData bar_data_three (98.0f);
barGraph .barGraphState .addBar(bar_data_three );
// add the BarGraph to the LaRoomy Api
LaRoomyApi .addDeviceProperty(barGraph );
LineGraphDataPoints
class LineGraphDataPoints {
public:
LineGraphDataPoints(){}
LineGraphDataPoints(const LineGraphDataPoints& dataPoints );
void addPoint(const POINT& p );
void clear();
unsigned int count();
};
Description:
The LineGraphDataPoints class provides the data for a line in a LineGraph property. A LineGraphDataPoints object is included in the LineGraphState member of a LineGraph property. The line definition must be added to this object by defining POINT objects which will be connected to a line in the LineGraph property.
Usage:
The line-data could be added when a LineGraph property is created:
// create a LineGraph property
LineGraph lineGraph ;
lineGraph .imageID = LaRoomyImages::LINE_GRAPH_163 ;
lineGraph .lineGraphDescription = "My LineGraph";
lineGraph .lineGraphID = MY_LINE_GRAPH ;
// add 25 points in a loop for demonstration
for (uint8_t i = 0; i <= 24; i ++)
{
lineGraph .lineGraphState .lineGraphPoints .addPoint(
POINT(i , -0.2 * ((i - 12) * (i - 12)) + 23)
);
}
// add the LineGraph property
LaRoomyApi .addDeviceProperty(lineGraph );
Or updated within a property state update:
// create LineGraphPoints object
LineGraphDataPoints points ;
// add 25 points in a loop for demonstration
for (uint8_t i = 0; i <= 24; i ++)
{
points .addPoint(
POINT(i , -0.2 * ((i - 12) * (i - 12)) + 23)
);
}
// get current state
auto currentLineGraphState = LaRoomyApi .getLineGraphState(MY_LINE_GRAPH );
// set new line data source
currentLineGraphState .lineGraphPoints = points ;
// update the state (and set the new source)
LaRoomyApi .updateLineGraphState(MY_LINE_GRAPH , currentLineGraphState );
Colors
class Colors {
public:
static COLOR Red ;
static COLOR Green ;
static COLOR Blue ;
static COLOR Cyan ;
static COLOR Magenta ;
static COLOR Orange ;
static COLOR Yellow ;
static COLOR White ;
static COLOR GreenYellow ;
static COLOR YellowGreen ;
static COLOR Purple ;
static COLOR Pink ;
static COLOR Mint ;
static COLOR Turquoise ;
static COLOR OrangeRed ;
static COLOR SeaGreen ;
static COLOR Gold ;
static COLOR PaleRed ;
static COLOR LightRed ;
static COLOR LightGreen ;
static COLOR LightBlue ;
static COLOR LightYellow ;
static COLOR LightPink ;
static COLOR LightCyan ;
static COLOR LightPurple ;
static COLOR DarkRed ;
static COLOR DarkGreen ;
static COLOR DarkBlue ;
static COLOR DarkYellow ;
static COLOR DarkPink ;
static COLOR DarkCyan ;
static COLOR DarkPurple ;
};
Description:
The Colors class can be used to access predefined colors. The colors are provided as COLOR structs. They could be used to work with the RGBSelectorState, the RGBControl and other color member of device properties.
Usage:
Setting the text color of a LevelIndicator property:
auto level = /* measure the level */
/* lets assume the level is critical */
// create a level indicator
LevelIndicator levelIndicator ;
levelIndicator .imageID = LaRoomyImages::BATTERY_EMPTY_036 ;
levelIndicator .levelIndicatorDescription = "Battery Level";
levelIndicator .levelIndicatorID = MY_LEVEL_INDICATOR ;
// set the level
levelIndicator .level = level ;
// set the value color
levelIndicator .valueColor = Colors::Red ;