Skip to content

Commit

Permalink
Merge pull request #174 from sparkfun/develop
Browse files Browse the repository at this point in the history
Merge latest dev into the main branch
  • Loading branch information
gigapod authored Nov 13, 2024
2 parents f0b9f46 + 5f20268 commit 813ad0e
Show file tree
Hide file tree
Showing 49 changed files with 599 additions and 151 deletions.
1 change: 1 addition & 0 deletions src/core/flux_base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ flux_sdk_add_source_files(
flxCore.h
flxCoreDevice.cpp
flxCoreDevice.h
flxDeviceValueTypes.h
flxCoreEvent.h
flxCoreEvent.cpp
flxCoreEventID.h
Expand Down
11 changes: 9 additions & 2 deletions src/core/flux_base/flxCoreLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
#pragma once

// Messaging/logging system for the framework
//#include "flxCoreEvent.h"
// #include "flxCoreEvent.h"
#include <WString.h>
#include <map>
#include <stdarg.h>
#include <stdexcept>
#include <vector>

#include "flxCoreEventID.h"
Expand Down Expand Up @@ -143,7 +144,13 @@ class flxLogging

//-------------------------------------------------------------------------
// generic log interface - for flash strings
int logPrintf(const flxLogLevel_t level, bool newline, const __FlashStringHelper *fmt, ...);
int logPrintf(const flxLogLevel_t level, bool newline,
#if defined(ESP32) || defined(ESP8266)
const __FlashStringHelper *fmt,
#else
const arduino::__FlashStringHelper *fmt,
#endif
...);

//-------------------------------------------------------------------------
// generic log interface
Expand Down
86 changes: 82 additions & 4 deletions src/core/flux_base/flxCoreParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,43 @@
#include "flxCoreTypes.h"
#include "flxUtils.h"

// Define a type used to enumerate parameter value types (not data types, but values, like temp, accel)

typedef uint16_t flxParamValueType_t;

const flxParamValueType_t kParamValueNone = 0;

//----------------------------------------------------------------------------------------
// flxParameter
//
// Base/Core Parameter Class
//
// From an abstract sense, a basic parameter - nothing more

//
class flxParameter : public flxDescriptor
{
bool _isEnabled;
flxParamValueType_t _valueType;

public:
flxParameter() : _isEnabled{true} {};
flxParameter() : _isEnabled{true}, _valueType{kParamValueNone}
{
}

bool enabled(void)
{
return _isEnabled;
}

flxParamValueType_t valueType(void)
{
return _valueType;
}
void setValueType(flxParamValueType_t type)
{
_valueType = type;
}

virtual void setEnabled(bool enabled)
{
_isEnabled = enabled;
Expand Down Expand Up @@ -292,6 +310,14 @@ class _flxParameterOut : public _flxDataOut<T>, public flxParameterOutScalar
(*this)(obj, name);
}

void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
{
// Value type
setValueType(vtype);

// cascade to other version of method
(*this)(obj, name, desc);
}
// override to deal with dirty status of object.
void setEnabled(bool bEnabled)
{
Expand Down Expand Up @@ -488,6 +514,14 @@ class flxParameterOutString : public flxParameterOutScalar, public _flxDataOutSt
(*this)(obj, name);
}

void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
{
// Value type
setValueType(vtype);

// cascade to other version of method
(*this)(obj, name, desc);
}
// override to deal with dirty status of object.
void setEnabled(bool bEnabled)
{
Expand Down Expand Up @@ -641,6 +675,14 @@ class flxParameterOutArrayType : public flxParameterOutArray
(*this)(obj, name);
}

void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
{
// Value type
setValueType(vtype);

// cascade to other version of method
(*this)(obj, name, desc);
}
// override to deal with dirty status of object.
void setEnabled(bool bEnabled)
{
Expand Down Expand Up @@ -805,7 +847,14 @@ class flxParameterOutArrayString : public flxParameterOutArray
// cascade to other version of method
(*this)(obj, name);
}
void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
{
// Value type
setValueType(vtype);

// cascade to other version of method
(*this)(obj, name, desc);
}
// override to deal with dirty status of object.
void setEnabled(bool bEnabled)
{
Expand Down Expand Up @@ -913,6 +962,14 @@ class _flxParameterIn : public flxParameterIn, public _flxDataIn<T>
(*this)(obj, name);
}

void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
{
// Value type
setValueType(vtype);

// cascade to other version of method
(*this)(obj, name, desc);
}
//---------------------------------------------------------------------------------
void set(T const &value)
{
Expand Down Expand Up @@ -1063,6 +1120,14 @@ class flxParameterInString : public flxParameterIn, _flxDataInString
(*this)(obj, name);
}

void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
{
// Value type
setValueType(vtype);

// cascade to other version of method
(*this)(obj, name, desc);
}
//---------------------------------------------------------------------------------
void set(std::string const &value)
{
Expand Down Expand Up @@ -1188,6 +1253,15 @@ template <class Object, void (Object::*_setter)()> class flxParameterInVoid : pu
(*this)(obj, name);
}

void operator()(Object *obj, const char *name, const char *desc, flxParamValueType_t vtype)
{
// Value type
setValueType(vtype);

// cascade to other version of method
(*this)(obj, name, desc);
}

//---------------------------------------------------------------------------------
void set()
{
Expand Down Expand Up @@ -1229,9 +1303,10 @@ template <class Object, void (Object::*_setter)()> class flxParameterInVoid : pu

// Use some macro magic to determine which actual call to make based on the number of passed in
// parameters..
#define _spGetRegAttributeMacro(_1, _2, _3, _NAME_, ...) _NAME_
#define _spGetRegAttributeMacro(_1, _2, _3, _4, _NAME_, ...) _NAME_
#define flxRegister(...) \
_spGetRegAttributeMacro(__VA_ARGS__, flxRegisterDesc, flxRegisterName, flxRegisterObj)(__VA_ARGS__)
_spGetRegAttributeMacro(__VA_ARGS__, flxRegisterValueType, flxRegisterDesc, flxRegisterName, \
flxRegisterObj)(__VA_ARGS__)

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

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

// For parameters - user provided value type
#define flxRegisterValueType(_obj_name_, _name_, _desc_, _type_) _obj_name_(this, _name_, _desc_, _type_)

// Define a object type that supports parameter lists (input and output)
class flxOperation : public flxObject, public _flxParameterContainer
{
Expand Down
Loading

0 comments on commit 813ad0e

Please sign in to comment.