Props to prop no plural

This commit is contained in:
fauresystems
2020-04-15 10:55:37 +02:00
parent 142ff52329
commit 6cff784cc6
30 changed files with 532 additions and 528 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
Editor: https://github.com/fauresystems
License: MIT License (c) Marie Faure <dev at faure dot systems>
Library to make props sketch for Escape Room 2.0 (connected props).
Library to make prop sketch for Escape Room 2.0 (connected prop).
*/
#include "ArduinoProps.h"
+6 -6
View File
@@ -5,7 +5,7 @@
Editor: https://github.com/fauresystems
License: MIT License (c) Marie Faure <dev at faure dot systems>
Library to make props sketch for Escape Room 2.0 (connected props).
Library to make prop sketch for Escape Room 2.0 (connected prop).
*/
#ifndef _ArduinoProps_h
@@ -17,10 +17,10 @@
#include "WProgram.h"
#endif
#include "BridgeProps.h"
#include "EthernetProps.h"
#include "WifiProps.h"
#include "PropsAction.h"
#include "PropsData.h"
#include "BridgeProp.h"
#include "EthernetProp.h"
#include "WifiProp.h"
#include "PropAction.h"
#include "PropData.h"
#endif
+5 -5
View File
@@ -1,5 +1,5 @@
/*
Name: BridgeProps.cpp
Name: BridgeProp.cpp
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
@@ -8,20 +8,20 @@
Class Props for Arduino Yun and Dragino Yun shield.
*/
#include "BridgeProps.h"
#include "BridgeProp.h"
BridgeProps::BridgeProps(const char* client_id, const char* in_box, const char* out_box, const char* broker, const int port)
BridgeProp::BridgeProp(const char* client_id, const char* in_box, const char* out_box, const char* broker, const int port)
: Props(client_id, in_box, out_box, broker, port)
{
_client.setClient(_bridgeClient);
}
void BridgeProps::begin(void(*on_message)(String))
void BridgeProp::begin(void(*on_message)(String))
{
if (on_message) onInboxMessageReceived = on_message;
}
void BridgeProps::setBrokerIpAddress(IPAddress ip, uint16_t port)
void BridgeProp::setBrokerIpAddress(IPAddress ip, uint16_t port)
{
_brokerIpAddress = ip;
_client.setServer(_brokerIpAddress, port);
+6 -6
View File
@@ -1,5 +1,5 @@
/*
Name: BridgeProps.h
Name: BridgeProp.h
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
@@ -7,17 +7,17 @@
Class Props for Arduino Yun and Dragino Yun shield.
*/
#ifndef BRIDGEPROPS_H
#define BRIDGEPROPS_H
#ifndef BRIDGEPROP_H
#define BRIDGEPROP_H
#include <BridgeClient.h>
#include <IPAddress.h>
#include "Props.h"
#include "Prop.h"
class BridgeProps : public Props
class BridgeProp : public Props
{
public:
BridgeProps(const char*, const char*, const char*, const char*, const int);
BridgeProp(const char*, const char*, const char*, const char*, const int);
void begin(void(*)(String) = NULL);
void setBrokerIpAddress(IPAddress, uint16_t port = 1883);
@@ -1,5 +1,5 @@
/*
Name: EthernetProps.cpp
Name: EthernetProp.cpp
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
@@ -8,15 +8,15 @@
Class Props for Arduino with Ethernet shield.
*/
#include "EthernetProps.h"
#include "EthernetProp.h"
EthernetProps::EthernetProps(const char* client_id, const char* in_box, const char* out_box, const char* broker, const int port)
EthernetProp::EthernetProp(const char* client_id, const char* in_box, const char* out_box, const char* broker, const int port)
: Props(client_id, in_box, out_box, broker, port)
{
_client.setClient(_ethernetClient);
}
void EthernetProps::begin(void(*on_message)(String))
void EthernetProp::begin(void(*on_message)(String))
{
if (on_message) onInboxMessageReceived = on_message;
}
+6 -6
View File
@@ -1,5 +1,5 @@
/*
Name: EthernetProps.h
Name: EthernetProp.h
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
@@ -7,19 +7,19 @@
Class Props for Arduino with Ethernet shield.
*/
#ifndef ETHERNETPROPS_H
#define ETHERNETPROPS_H
#ifndef ETHERNETPROP_H
#define ETHERNETPROP_H
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include "Props.h"
#include "Prop.h"
class EthernetProps : public Props
class EthernetProp : public Props
{
public:
EthernetProps(const char*, const char*, const char*, const char*, const int);
EthernetProp(const char*, const char*, const char*, const char*, const int);
void begin(void(*)(String) = NULL);
private:
+3 -3
View File
@@ -5,10 +5,10 @@
Editor: https://github.com/fauresystems
License: MIT License (c) Marie Faure <dev at faure dot systems>
Base class to make props sketch for Escape Room 2.0 (connected).
Base class to make prop sketch for Escape Room 2.0 (connected).
*/
#include "Props.h"
#include "Prop.h"
#include <Process.h>
#if defined(__AVR__)
#include <avr/wdt.h>
@@ -58,7 +58,7 @@ Props::Props(const char* client_id, const char* in_box, const char* out_box, con
_sendDataAction.reset(400); // check data changes every 400 milliseconds
}
void Props::addData(PropsData* d)
void Props::addData(PropData* d)
{
_dataTable.Add(d);
}
+9 -9
View File
@@ -1,14 +1,14 @@
/*
Name: Props.h
Name: Prop.h
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
License: MIT License (c) Marie Faure <dev at faure dot systems>
Base class to make props sketch for Escape Room 2.0 (connected).
Base class to make prop sketch for Escape Room 2.0 (connected).
*/
#ifndef PROPS_H
#define PROPS_H
#ifndef PROP_H
#define PROP_H
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
@@ -19,8 +19,8 @@
#include <BridgeClient.h>
#include <PubSubClient.h>
#include <ListLib.h>
#include "PropsAction.h"
#include "PropsData.h"
#include "PropAction.h"
#include "PropData.h"
#ifndef MQTT_MAX_PACKET_SIZE
#define MQTT_MAX_PACKET_SIZE 128 // Bridge tranfer stuff (see PubSubClient)
@@ -53,7 +53,7 @@ class Props
public:
Props(const char*, const char*, const char*, const char*, const int=1883);
virtual void begin(void(*)(String) = NULL) = 0;
void addData(PropsData*);
void addData(PropData*);
void loop();
void resetIntervals(const int changes, const int silent);
void resetMcu();
@@ -86,8 +86,8 @@ class Props
uint8_t _maximumSilentPeriod;
unsigned long _nextReconAttempt;
uint8_t _payloadMax;
PropsAction _sendDataAction;
List<PropsData*> _dataTable;
PropAction _sendDataAction;
List<PropData*> _dataTable;
};
#endif
+10 -10
View File
@@ -1,5 +1,5 @@
/*
Name: PropsAction.h
Name: PropAction.h
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
@@ -8,9 +8,9 @@
Provide an easy way of triggering functions at a set _interval.
*/
#include "PropsAction.h"
#include "PropAction.h"
PropsAction::PropsAction()
PropAction::PropAction()
{
_active = true;
_previous = 0;
@@ -18,7 +18,7 @@ PropsAction::PropsAction()
_execute = NULL;
}
PropsAction::PropsAction(unsigned long intervl, void (*function)())
PropAction::PropAction(unsigned long intervl, void (*function)())
{
_active = true;
_previous = 0;
@@ -26,24 +26,24 @@ PropsAction::PropsAction(unsigned long intervl, void (*function)())
_execute = function;
}
void PropsAction::reset(unsigned long intervl)
void PropAction::reset(unsigned long intervl)
{
_active = true;
_previous = 0;
_interval = intervl;
}
void PropsAction::disable()
void PropAction::disable()
{
_active = false;
}
void PropsAction::enable()
void PropAction::enable()
{
_active = true;
}
void PropsAction::check() {
void PropAction::check() {
if (_active && (millis() - _previous >= _interval))
{
_previous = millis();
@@ -51,7 +51,7 @@ void PropsAction::check() {
}
}
bool PropsAction::tick() {
bool PropAction::tick() {
if (_active && (millis() - _previous >= _interval))
{
_previous = millis();
@@ -60,7 +60,7 @@ bool PropsAction::tick() {
return false;
}
unsigned long PropsAction::getInterval()
unsigned long PropAction::getInterval()
{
return _interval;
}
+4 -4
View File
@@ -1,5 +1,5 @@
/*
Name: PropsAction.h
Name: PropAction.h
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
@@ -19,11 +19,11 @@
class Props;
class PropsAction {
class PropAction {
public:
PropsAction();
PropsAction(unsigned long interval, void (*function)());
PropAction();
PropAction(unsigned long interval, void (*function)());
void reset(unsigned long interval);
void disable();
+23 -23
View File
@@ -1,18 +1,18 @@
/*
Name: PropsData.cpp
Name: PropData.cpp
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
License: MIT License (c) Marie Faure <dev at faure dot systems>
Variable wrapper for connected props.
Variable wrapper for connected prop.
*/
#include "PropsData.h"
#include "PropData.h"
#include <String.h>
// ---- Decimal
PropsDataDecimal::PropsDataDecimal(const char * id, uint8_t digits, double precision, double initial) {
PropDataDecimal::PropDataDecimal(const char * id, uint8_t digits, double precision, double initial) {
_id = id;
_current = initial;
_previous = _current;
@@ -20,12 +20,12 @@ PropsDataDecimal::PropsDataDecimal(const char * id, uint8_t digits, double preci
_digits = digits;
}
String PropsDataDecimal::fetch() {
String PropDataDecimal::fetch() {
_previous = _current;
return String(_id) + "=" + String(_current, _digits) + " ";
}
String PropsDataDecimal::fetchChange() {
String PropDataDecimal::fetchChange() {
if (_current != _previous && _current && abs(_current - _previous) / _current >= _precision) {
return fetch();
}
@@ -35,28 +35,28 @@ String PropsDataDecimal::fetchChange() {
return String();
}
void PropsDataDecimal::setValue(const double v) {
void PropDataDecimal::setValue(const double v) {
_current = v;
}
double PropsDataDecimal::value() const {
double PropDataDecimal::value() const {
return _current;
}
// ---- Integer
PropsDataInteger::PropsDataInteger(const char * id, double precision, long initial) {
PropDataInteger::PropDataInteger(const char * id, double precision, long initial) {
_id = id;
_current = initial;
_previous = _current;
_precision = precision;
}
String PropsDataInteger::fetch() {
String PropDataInteger::fetch() {
_previous = _current;
return String(_id) + "=" + String(_current) + " ";
}
String PropsDataInteger::fetchChange() {
String PropDataInteger::fetchChange() {
if (_current != _previous && _current && abs(_current - _previous) / _current >= _precision) {
return fetch();
}
@@ -66,16 +66,16 @@ String PropsDataInteger::fetchChange() {
return String();
}
void PropsDataInteger::setValue(const long v) {
void PropDataInteger::setValue(const long v) {
_current = v;
}
long PropsDataInteger::value() const {
long PropDataInteger::value() const {
return _current;
}
// ---- Logical
PropsDataLogical::PropsDataLogical(const char * id, const char *trueval, const char *falseval, bool initial) {
PropDataLogical::PropDataLogical(const char * id, const char *trueval, const char *falseval, bool initial) {
_id = id;
_current = initial;
_previous = _current;
@@ -83,7 +83,7 @@ PropsDataLogical::PropsDataLogical(const char * id, const char *trueval, const c
_falseString = falseval;
}
String PropsDataLogical::fetch() {
String PropDataLogical::fetch() {
String str(String(_id) + "=");
if (_current) {
str += _trueString ? _trueString : "1";
@@ -95,42 +95,42 @@ String PropsDataLogical::fetch() {
return str;
}
String PropsDataLogical::fetchChange() {
String PropDataLogical::fetchChange() {
if (_current != _previous) {
return fetch();
}
return String();
}
void PropsDataLogical::setValue(const bool v) {
void PropDataLogical::setValue(const bool v) {
_current = v;
}
bool PropsDataLogical::value() const {
bool PropDataLogical::value() const {
return _current;
}
// ---- Text
PropsDataText::PropsDataText(const char * id) {
PropDataText::PropDataText(const char * id) {
_id = id;
}
String PropsDataText::fetch() {
String PropDataText::fetch() {
_previous = _current;
return String(_id) + "=" + _current + " ";
}
String PropsDataText::fetchChange() {
String PropDataText::fetchChange() {
if (_current != _previous) {
return fetch();
}
return String();
}
void PropsDataText::setValue(String v) {
void PropDataText::setValue(String v) {
_current = v;
}
String PropsDataText::value() const {
String PropDataText::value() const {
return _current;
}
+11 -11
View File
@@ -1,11 +1,11 @@
/*
Name: PropsData.h
Name: PropData.h
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
License: MIT License (c) Marie Faure <dev at faure dot systems>
Variable wrapper for connected props.
Variable wrapper for connected prop.
*/
#ifndef PROPSDATA_H
#define PROPSDATA_H
@@ -19,17 +19,17 @@
#include <inttypes.h>
#include <WString.h>
class PropsData
class PropData
{
public:
virtual String fetch() = 0;
virtual String fetchChange() = 0;
};
class PropsDataDecimal : public PropsData
class PropDataDecimal : public PropData
{
public:
PropsDataDecimal(const char *, uint8_t digits = 2, double precision = 0.1, double initial = 0);
PropDataDecimal(const char *, uint8_t digits = 2, double precision = 0.1, double initial = 0);
String fetch();
String fetchChange();
void setValue(const double);
@@ -42,10 +42,10 @@ class PropsDataDecimal : public PropsData
uint8_t _digits;
};
class PropsDataInteger : public PropsData
class PropDataInteger : public PropData
{
public:
PropsDataInteger(const char *, double precision = 0.1, long initial = 0);
PropDataInteger(const char *, double precision = 0.1, long initial = 0);
String fetch();
String fetchChange();
void setValue(const long);
@@ -57,10 +57,10 @@ class PropsDataInteger : public PropsData
double _precision;
};
class PropsDataLogical : public PropsData
class PropDataLogical : public PropData
{
public:
PropsDataLogical(const char *, const char *trueval = NULL, const char *falseval = NULL, bool initial = false);
PropDataLogical(const char *, const char *trueval = NULL, const char *falseval = NULL, bool initial = false);
String fetch();
String fetchChange();
void setValue(const bool);
@@ -73,10 +73,10 @@ class PropsDataLogical : public PropsData
const char *_falseString;
};
class PropsDataText : public PropsData
class PropDataText : public PropData
{
public:
PropsDataText(const char *);
PropDataText(const char *);
String fetch();
String fetchChange();
void setValue(String);
+4 -4
View File
@@ -1,5 +1,5 @@
/*
Name: WifiProps.cpp
Name: WifiProp.cpp
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
@@ -8,19 +8,19 @@
Class Props for Arduino with WiFiNINA.
*/
#include "WifiProps.h"
#include "WifiProp.h"
#if defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRVIDOR4000)
WifiProps::WifiProps(const char* client_id, const char* in_box, const char* out_box, const char* broker, const int port)
WifiProp::WifiProp(const char* client_id, const char* in_box, const char* out_box, const char* broker, const int port)
: Props(client_id, in_box, out_box, broker, port)
{
_client.setClient(_wifiClient);
}
void WifiProps::begin(void(*on_message)(String))
void WifiProp::begin(void(*on_message)(String))
{
if (on_message) onInboxMessageReceived = on_message;
}
+6 -6
View File
@@ -1,5 +1,5 @@
/*
Name: WifiProps.h
Name: WifiProp.h
Created: 29/10/2019 09:20:31
Author: Marie Faure <dev at faure dot systems>
Editor: https://github.com/fauresystems
@@ -7,8 +7,8 @@
Class Props for Arduino with WiFiNINA.
*/
#ifndef WIFIPROPS_H
#define WIFIPROPS_H
#ifndef WIFIPROP_H
#define WIFIPROP_H
#if defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRVIDOR4000)
@@ -18,12 +18,12 @@
#include <SPI.h>
#include <WiFiClient.h>
#include "Props.h"
#include "Prop.h"
class WifiProps : public Props
class WifiProp : public Props
{
public:
WifiProps(const char*, const char*, const char*, const char*, const int);
WifiProp(const char*, const char*, const char*, const char*, const int);
void begin(void(*)(String) = NULL);
private: