Skip to content

Commit 813ad0e

Browse files
authored
Merge pull request #174 from sparkfun/develop
Merge latest dev into the main branch
2 parents f0b9f46 + 5f20268 commit 813ad0e

File tree

49 files changed

+599
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+599
-151
lines changed

src/core/flux_base/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ flux_sdk_add_source_files(
88
flxCore.h
99
flxCoreDevice.cpp
1010
flxCoreDevice.h
11+
flxDeviceValueTypes.h
1112
flxCoreEvent.h
1213
flxCoreEvent.cpp
1314
flxCoreEventID.h

src/core/flux_base/flxCoreLog.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
#pragma once
1414

1515
// Messaging/logging system for the framework
16-
//#include "flxCoreEvent.h"
16+
// #include "flxCoreEvent.h"
1717
#include <WString.h>
1818
#include <map>
1919
#include <stdarg.h>
20+
#include <stdexcept>
2021
#include <vector>
2122

2223
#include "flxCoreEventID.h"
@@ -143,7 +144,13 @@ class flxLogging
143144

144145
//-------------------------------------------------------------------------
145146
// generic log interface - for flash strings
146-
int logPrintf(const flxLogLevel_t level, bool newline, const __FlashStringHelper *fmt, ...);
147+
int logPrintf(const flxLogLevel_t level, bool newline,
148+
#if defined(ESP32) || defined(ESP8266)
149+
const __FlashStringHelper *fmt,
150+
#else
151+
const arduino::__FlashStringHelper *fmt,
152+
#endif
153+
...);
147154

148155
//-------------------------------------------------------------------------
149156
// generic log interface

src/core/flux_base/flxCoreParam.h

+82-4
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,43 @@
2525
#include "flxCoreTypes.h"
2626
#include "flxUtils.h"
2727

28+
// Define a type used to enumerate parameter value types (not data types, but values, like temp, accel)
29+
30+
typedef uint16_t flxParamValueType_t;
31+
32+
const flxParamValueType_t kParamValueNone = 0;
33+
2834
//----------------------------------------------------------------------------------------
2935
// flxParameter
3036
//
3137
// Base/Core Parameter Class
3238
//
3339
// From an abstract sense, a basic parameter - nothing more
34-
40+
//
3541
class flxParameter : public flxDescriptor
3642
{
3743
bool _isEnabled;
44+
flxParamValueType_t _valueType;
3845

3946
public:
40-
flxParameter() : _isEnabled{true} {};
47+
flxParameter() : _isEnabled{true}, _valueType{kParamValueNone}
48+
{
49+
}
4150

4251
bool enabled(void)
4352
{
4453
return _isEnabled;
4554
}
4655

56+
flxParamValueType_t valueType(void)
57+
{
58+
return _valueType;
59+
}
60+
void setValueType(flxParamValueType_t type)
61+
{
62+
_valueType = type;
63+
}
64+
4765
virtual void setEnabled(bool enabled)
4866
{
4967
_isEnabled = enabled;
@@ -292,6 +310,14 @@ class _flxParameterOut : public _flxDataOut<T>, public flxParameterOutScalar
292310
(*this)(obj, name);
293311
}
294312

313+
void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
314+
{
315+
// Value type
316+
setValueType(vtype);
317+
318+
// cascade to other version of method
319+
(*this)(obj, name, desc);
320+
}
295321
// override to deal with dirty status of object.
296322
void setEnabled(bool bEnabled)
297323
{
@@ -488,6 +514,14 @@ class flxParameterOutString : public flxParameterOutScalar, public _flxDataOutSt
488514
(*this)(obj, name);
489515
}
490516

517+
void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
518+
{
519+
// Value type
520+
setValueType(vtype);
521+
522+
// cascade to other version of method
523+
(*this)(obj, name, desc);
524+
}
491525
// override to deal with dirty status of object.
492526
void setEnabled(bool bEnabled)
493527
{
@@ -641,6 +675,14 @@ class flxParameterOutArrayType : public flxParameterOutArray
641675
(*this)(obj, name);
642676
}
643677

678+
void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
679+
{
680+
// Value type
681+
setValueType(vtype);
682+
683+
// cascade to other version of method
684+
(*this)(obj, name, desc);
685+
}
644686
// override to deal with dirty status of object.
645687
void setEnabled(bool bEnabled)
646688
{
@@ -805,7 +847,14 @@ class flxParameterOutArrayString : public flxParameterOutArray
805847
// cascade to other version of method
806848
(*this)(obj, name);
807849
}
850+
void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
851+
{
852+
// Value type
853+
setValueType(vtype);
808854

855+
// cascade to other version of method
856+
(*this)(obj, name, desc);
857+
}
809858
// override to deal with dirty status of object.
810859
void setEnabled(bool bEnabled)
811860
{
@@ -913,6 +962,14 @@ class _flxParameterIn : public flxParameterIn, public _flxDataIn<T>
913962
(*this)(obj, name);
914963
}
915964

965+
void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
966+
{
967+
// Value type
968+
setValueType(vtype);
969+
970+
// cascade to other version of method
971+
(*this)(obj, name, desc);
972+
}
916973
//---------------------------------------------------------------------------------
917974
void set(T const &value)
918975
{
@@ -1063,6 +1120,14 @@ class flxParameterInString : public flxParameterIn, _flxDataInString
10631120
(*this)(obj, name);
10641121
}
10651122

1123+
void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
1124+
{
1125+
// Value type
1126+
setValueType(vtype);
1127+
1128+
// cascade to other version of method
1129+
(*this)(obj, name, desc);
1130+
}
10661131
//---------------------------------------------------------------------------------
10671132
void set(std::string const &value)
10681133
{
@@ -1188,6 +1253,15 @@ template <class Object, void (Object::*_setter)()> class flxParameterInVoid : pu
11881253
(*this)(obj, name);
11891254
}
11901255

1256+
void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
1257+
{
1258+
// Value type
1259+
setValueType(vtype);
1260+
1261+
// cascade to other version of method
1262+
(*this)(obj, name, desc);
1263+
}
1264+
11911265
//---------------------------------------------------------------------------------
11921266
void set()
11931267
{
@@ -1229,9 +1303,10 @@ template <class Object, void (Object::*_setter)()> class flxParameterInVoid : pu
12291303

12301304
// Use some macro magic to determine which actual call to make based on the number of passed in
12311305
// parameters..
1232-
#define _spGetRegAttributeMacro(_1, _2, _3, _NAME_, ...) _NAME_
1306+
#define _spGetRegAttributeMacro(_1, _2, _3, _4, _NAME_, ...) _NAME_
12331307
#define flxRegister(...) \
1234-
_spGetRegAttributeMacro(__VA_ARGS__, flxRegisterDesc, flxRegisterName, flxRegisterObj)(__VA_ARGS__)
1308+
_spGetRegAttributeMacro(__VA_ARGS__, flxRegisterValueType, flxRegisterDesc, flxRegisterName, \
1309+
flxRegisterObj)(__VA_ARGS__)
12351310

12361311
#define flxRegisterObj(_obj_name_) _obj_name_(this, #_obj_name_)
12371312

@@ -1241,6 +1316,9 @@ template <class Object, void (Object::*_setter)()> class flxParameterInVoid : pu
12411316
// User provided Name and description
12421317
#define flxRegisterDesc(_obj_name_, _name_, _desc_) _obj_name_(this, _name_, _desc_)
12431318

1319+
// For parameters - user provided value type
1320+
#define flxRegisterValueType(_obj_name_, _name_, _desc_, _type_) _obj_name_(this, _name_, _desc_, _type_)
1321+
12441322
// Define a object type that supports parameter lists (input and output)
12451323
class flxOperation : public flxObject, public _flxParameterContainer
12461324
{

0 commit comments

Comments
 (0)