Skip to content

Commit 3d4e875

Browse files
authored
Merge pull request #162 from sparkfun/release/v01.02.01-prior-sdk-refactor
Move the latest release branch into main. This contains int32 changes, int naming and smart(er) type codes
2 parents 5989586 + 2e17f71 commit 3d4e875

Some content is hidden

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

72 files changed

+671
-701
lines changed

src/Flux/flxClock.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ std::string _flxClock::get_ref_clock(void)
103103
{
104104
return _nameRefClock;
105105
}
106-
void _flxClock::set_ref_interval(uint val)
106+
void _flxClock::set_ref_interval(uint32_t val)
107107
{
108108
if (val == _refCheck)
109109
return;
@@ -124,12 +124,12 @@ void _flxClock::set_ref_interval(uint val)
124124
flxUpdateJobInQueue(_jobRefCheck);
125125
}
126126
}
127-
uint _flxClock::get_ref_interval(void)
127+
uint32_t _flxClock::get_ref_interval(void)
128128
{
129129
return _refCheck;
130130
}
131131

132-
void _flxClock::set_conn_interval(uint val)
132+
void _flxClock::set_conn_interval(uint32_t val)
133133
{
134134
if (val == _connCheck)
135135
return;
@@ -145,7 +145,7 @@ void _flxClock::set_conn_interval(uint val)
145145
flxUpdateJobInQueue(_jobConnCheck);
146146
}
147147
}
148-
uint _flxClock::get_conn_interval(void)
148+
uint32_t _flxClock::get_conn_interval(void)
149149
{
150150
return _connCheck;
151151
}

src/Flux/flxClock.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
class flxIClock
2727
{
2828
public:
29-
virtual uint get_epoch(void) = 0;
30-
virtual void set_epoch(const uint &) = 0;
29+
virtual uint32_t get_epoch(void) = 0;
30+
virtual void set_epoch(const uint32_t &) = 0;
3131
virtual bool valid_epoch(void) = 0;
3232
};
3333

@@ -46,14 +46,14 @@ class flxISystemClock : public flxIClock
4646
class flxClockESP32 : public flxISystemClock
4747
{
4848
public:
49-
uint get_epoch(void)
49+
uint32_t get_epoch(void)
5050
{
5151
time_t now;
5252
time(&now);
5353
return now;
5454
}
5555

56-
void set_epoch(const uint &refEpoch)
56+
void set_epoch(const uint32_t &refEpoch)
5757
{
5858
timeval epoch = {(time_t)refEpoch, 0};
5959
const timeval *tv = &epoch;
@@ -111,11 +111,11 @@ class _flxClock : public flxActionType<_flxClock>
111111
void set_timezone(std::string tz);
112112
std::string get_timezone(void);
113113

114-
void set_ref_interval(uint);
115-
uint get_ref_interval(void);
114+
void set_ref_interval(uint32_t);
115+
uint32_t get_ref_interval(void);
116116

117-
void set_conn_interval(uint);
118-
uint get_conn_interval(void);
117+
void set_conn_interval(uint32_t);
118+
uint32_t get_conn_interval(void);
119119

120120
public:
121121
// flxClock is a singleton
@@ -150,13 +150,14 @@ class _flxClock : public flxActionType<_flxClock>
150150

151151
flxPropertyRWString<_flxClock, &_flxClock::get_ref_clock, &_flxClock::set_ref_clock> referenceClock;
152152

153-
flxPropertyRWUint<_flxClock, &_flxClock::get_ref_interval, &_flxClock::set_ref_interval> updateClockInterval = {60};
153+
flxPropertyRWUInt32<_flxClock, &_flxClock::get_ref_interval, &_flxClock::set_ref_interval> updateClockInterval = {
154+
60};
154155

155156
// Use alternative clock if primary isn't available?
156157
flxPropertyBool<_flxClock> useAlternativeClock = {true};
157158

158-
flxPropertyRWUint<_flxClock, &_flxClock::get_conn_interval, &_flxClock::set_conn_interval> connectedClockInterval =
159-
{60};
159+
flxPropertyRWUInt32<_flxClock, &_flxClock::get_conn_interval, &_flxClock::set_conn_interval>
160+
connectedClockInterval = {60};
160161
flxPropertyBool<_flxClock> updateConnectedOnUpdate = {true};
161162

162163
// TimeZone string

src/Flux/flxCore.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,35 @@
1212

1313
#include "flxCore.h"
1414

15-
static const char *typeNames[] = {"none", "bool", "int8", "int16",
16-
"integer", "unsigned int8", "unsigned int16", "unsigned integer",
17-
"float", "double", "string"};
15+
static const struct
16+
{
17+
flxDataType_t type;
18+
const char *name;
19+
} typeNames[] = {
20+
{flxTypeNone, "none"},
21+
{flxTypeBool, "bool"},
22+
{flxTypeInt8, "int8"},
23+
{flxTypeInt16, "int16"},
24+
{flxTypeInt32, "int32"},
25+
{flxTypeUInt8, "unsigned int8"},
26+
{flxTypeUInt16, "unsigned int16"},
27+
{flxTypeUInt32, "unsigned int32"},
28+
{flxTypeFloat, "float"},
29+
{flxTypeDouble, "double"},
30+
{flxTypeString, "string"},
31+
};
1832

1933
//-------------------------------------------------------------------------
2034
// flxTypeName()
2135
//
2236
// Return a human type give the framework type
2337
const char *flxGetTypeName(flxDataType_t type)
2438
{
25-
if (type < sizeof(typeNames))
26-
return typeNames[type];
39+
for (size_t i = 0; i < sizeof(typeNames) / sizeof(typeNames[0]); i++)
40+
{
41+
if (typeNames[i].type == type)
42+
return typeNames[i].name;
43+
}
2744

2845
return "Invalid Type";
2946
}

src/Flux/flxCoreEvent.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ template <typename TB, typename... ArgT> class flxSignal : public flxSignalBase
9696
typedef flxSignal<bool, bool> flxSignalBool;
9797
typedef flxSignal<int8_t, int8_t> flxSignalInt8;
9898
typedef flxSignal<int16_t, int16_t> flxSignalInt16;
99-
typedef flxSignal<int, int> flxSignalInt;
99+
typedef flxSignal<int32_t, int32_t> flxSignalInt32;
100100
typedef flxSignal<uint8_t, uint8_t> flxSignalUInt8;
101101
typedef flxSignal<uint16_t, uint16_t> flxSignalUInt16;
102-
typedef flxSignal<uint, uint> flxSignalUInt;
102+
typedef flxSignal<uint32_t, uint32_t> flxSignalUInt32;
103103
typedef flxSignal<float, float> flxSignalFloat;
104104
typedef flxSignal<double, double> flxSignalDouble;
105105
typedef flxSignal<const char *, const char *> flxSignalString;

src/Flux/flxCoreParam.h

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -335,21 +335,21 @@ class _flxParameterOut : public _flxDataOut<T>, public flxParameterOutScalar
335335
{
336336
return _flxDataOut<T>::getInt16();
337337
};
338-
int getInt()
338+
int32_t getInt32()
339339
{
340-
return _flxDataOut<T>::getInt();
340+
return _flxDataOut<T>::getInt32();
341341
};
342-
uint8_t getUint8()
342+
uint8_t getUInt8()
343343
{
344-
return _flxDataOut<T>::getUint8();
344+
return _flxDataOut<T>::getUInt8();
345345
};
346-
uint16_t getUint16()
346+
uint16_t getUInt16()
347347
{
348-
return _flxDataOut<T>::getUint16();
348+
return _flxDataOut<T>::getUInt16();
349349
};
350-
uint getUint()
350+
uint32_t getUInt32()
351351
{
352-
return _flxDataOut<T>::getUint();
352+
return _flxDataOut<T>::getUInt32();
353353
};
354354
float getFloat()
355355
{
@@ -374,15 +374,17 @@ using flxParameterOutInt8 = _flxParameterOut<int8_t, Object, _getter>;
374374
template <class Object, int16_t (Object::*_getter)()>
375375
using flxParameterOutInt16 = _flxParameterOut<int16_t, Object, _getter>;
376376

377-
template <class Object, int (Object::*_getter)()> using flxParameterOutInt = _flxParameterOut<int, Object, _getter>;
377+
template <class Object, int32_t (Object::*_getter)()>
378+
using flxParameterOutInt32 = _flxParameterOut<int32_t, Object, _getter>;
378379

379380
template <class Object, uint8_t (Object::*_getter)()>
380-
using flxParameterOutUint8 = _flxParameterOut<uint8_t, Object, _getter>;
381+
using flxParameterOutUInt8 = _flxParameterOut<uint8_t, Object, _getter>;
381382

382383
template <class Object, uint16_t (Object::*_getter)()>
383-
using flxParameterOutUint16 = _flxParameterOut<uint16_t, Object, _getter>;
384+
using flxParameterOutUInt16 = _flxParameterOut<uint16_t, Object, _getter>;
384385

385-
template <class Object, uint (Object::*_getter)()> using flxParameterOutUint = _flxParameterOut<uint, Object, _getter>;
386+
template <class Object, uint32_t (Object::*_getter)()>
387+
using flxParameterOutUInt32 = _flxParameterOut<uint32_t, Object, _getter>;
386388

387389
template <class Object, float (Object::*_getter)()>
388390
class flxParameterOutFloat : public _flxParameterOut<float, Object, _getter>
@@ -530,21 +532,21 @@ class flxParameterOutString : public flxParameterOutScalar, public _flxDataOutSt
530532
{
531533
return _flxDataOutString::getInt16();
532534
};
533-
int getInt()
535+
int32_t getInt32()
534536
{
535-
return _flxDataOutString::getInt();
537+
return _flxDataOutString::getInt32();
536538
};
537-
uint8_t getUint8()
539+
uint8_t getUInt8()
538540
{
539-
return _flxDataOutString::getUint8();
541+
return _flxDataOutString::getUInt8();
540542
};
541-
uint16_t getUint16()
543+
uint16_t getUInt16()
542544
{
543-
return _flxDataOutString::getUint16();
545+
return _flxDataOutString::getUInt16();
544546
};
545-
uint getUint()
547+
uint32_t getUInt32()
546548
{
547-
return _flxDataOutString::getUint();
549+
return _flxDataOutString::getUInt32();
548550
};
549551
float getFloat()
550552
{
@@ -595,8 +597,7 @@ class flxParameterOutArrayType : public flxParameterOutArray
595597
// return our data type
596598
flxDataType_t type()
597599
{
598-
T c;
599-
return flxDataTyper::type(c);
600+
return flxGetTypeOf<T>();
600601
};
601602

602603
//---------------------------------------------------------------------------------
@@ -694,17 +695,17 @@ using flxParameterOutArrayInt8 = flxParameterOutArrayType<int8_t, Object, _gette
694695
template <class Object, bool (Object::*_getter)(flxDataArrayType<int16_t> *)>
695696
using flxParameterOutArrayInt16 = flxParameterOutArrayType<int16_t, Object, _getter>;
696697

697-
template <class Object, bool (Object::*_getter)(flxDataArrayType<int> *)>
698-
using flxParameterOutArrayInt = flxParameterOutArrayType<int, Object, _getter>;
698+
template <class Object, bool (Object::*_getter)(flxDataArrayType<int32_t> *)>
699+
using flxParameterOutArrayInt32 = flxParameterOutArrayType<int32_t, Object, _getter>;
699700

700701
template <class Object, bool (Object::*_getter)(flxDataArrayType<uint8_t> *)>
701-
using flxParameterOutArrayUint8 = flxParameterOutArrayType<uint8_t, Object, _getter>;
702+
using flxParameterOutArrayUInt8 = flxParameterOutArrayType<uint8_t, Object, _getter>;
702703

703704
template <class Object, bool (Object::*_getter)(flxDataArrayType<uint16_t> *)>
704-
using flxParameterOutArrayUint16 = flxParameterOutArrayType<uint16_t, Object, _getter>;
705+
using flxParameterOutArrayUInt16 = flxParameterOutArrayType<uint16_t, Object, _getter>;
705706

706-
template <class Object, bool (Object::*_getter)(flxDataArrayType<uint> *)>
707-
using flxParameterOutArrayUint = flxParameterOutArrayType<uint, Object, _getter>;
707+
template <class Object, bool (Object::*_getter)(flxDataArrayType<uint32_t> *)>
708+
using flxParameterOutArrayUInt32 = flxParameterOutArrayType<uint32_t, Object, _getter>;
708709

709710
template <class Object, bool (Object::*_getter)(flxDataArrayType<float> *)>
710711
class flxParameterOutArrayFloat : public flxParameterOutArrayType<float, Object, _getter>
@@ -983,17 +984,17 @@ using flxParameterInInt8 = _flxParameterIn<int8_t, Object, _setter>;
983984
template <class Object, void (Object::*_setter)(int16_t const &)>
984985
using flxParameterInInt16 = _flxParameterIn<int16_t, Object, _setter>;
985986

986-
template <class Object, void (Object::*_setter)(int const &)>
987-
using flxParameterInInt = _flxParameterIn<int, Object, _setter>;
987+
template <class Object, void (Object::*_setter)(int32_t const &)>
988+
using flxParameterInInt32 = _flxParameterIn<int32_t, Object, _setter>;
988989

989990
template <class Object, void (Object::*_setter)(uint8_t const &)>
990-
using flxParameterInUint8 = _flxParameterIn<uint8_t, Object, _setter>;
991+
using flxParameterInUInt8 = _flxParameterIn<uint8_t, Object, _setter>;
991992

992993
template <class Object, void (Object::*_setter)(uint16_t const &)>
993-
using flxParameterInUint16 = _flxParameterIn<uint16_t, Object, _setter>;
994+
using flxParameterInUInt16 = _flxParameterIn<uint16_t, Object, _setter>;
994995

995-
template <class Object, void (Object::*_setter)(uint const &)>
996-
using flxParameterInUint = _flxParameterIn<uint, Object, _setter>;
996+
template <class Object, void (Object::*_setter)(uint32_t const &)>
997+
using flxParameterInUInt32 = _flxParameterIn<uint32_t, Object, _setter>;
997998

998999
template <class Object, void (Object::*_setter)(float const &)>
9991000
using flxParameterInFloat = _flxParameterIn<float, Object, _setter>;

0 commit comments

Comments
 (0)