diff --git a/core/MyHwLinuxGeneric.cpp b/core/MyHwLinuxGeneric.cpp index 272fe29..e288bd6 100644 --- a/core/MyHwLinuxGeneric.cpp +++ b/core/MyHwLinuxGeneric.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/core/MyHwLinuxGeneric.h b/core/MyHwLinuxGeneric.h index cb01c78..c44d912 100644 --- a/core/MyHwLinuxGeneric.h +++ b/core/MyHwLinuxGeneric.h @@ -21,8 +21,7 @@ #define MyHwLinuxGeneric_h #include "MyHw.h" -#include -#include +#include #include #define MY_SERIALDEVICE Serial @@ -32,8 +31,6 @@ #define hwWatchdogReset() #define hwReboot() -using namespace std; - void hwInit(); void hwReadConfigBlock(void* buf, void* adr, size_t length); void hwWriteConfigBlock(void* buf, void* adr, size_t length); @@ -73,7 +70,7 @@ static __inline__ void __hwLock() { #endif /* DOXYGEN */ #ifndef DOXYGEN - #define MY_CRITICAL_SECTION ATOMIC_BLOCK -#endif /* DOXYGEN */ + #define MY_CRITICAL_SECTION ATOMIC_BLOCK +#endif /* DOXYGEN */ #endif diff --git a/core/MyMessage.cpp b/core/MyMessage.cpp index fc945ed..d95977e 100644 --- a/core/MyMessage.cpp +++ b/core/MyMessage.cpp @@ -23,10 +23,6 @@ #include #include -#ifndef ARDUINO - #define min(a,b) ((a)<(b)?(a):(b)) -#endif - MyMessage::MyMessage() { clear(); @@ -121,7 +117,7 @@ char* MyMessage::getString(char *buffer) const { } else if (payloadType == P_ULONG32) { ultoa(ulValue, buffer, 10); } else if (payloadType == P_FLOAT32) { - dtostrf(fValue,2,min(fPrecision, 8),buffer); + dtostrf(fValue,2,min(fPrecision, (uint8_t)8),buffer); } else if (payloadType == P_CUSTOM) { return getCustomString(buffer); } @@ -216,12 +212,12 @@ MyMessage& MyMessage::setDestination(uint8_t _destination) { MyMessage& MyMessage::set(void* value, uint8_t length) { miSetPayloadType(P_CUSTOM); miSetLength(length); - memcpy(data, value, min(length, MAX_PAYLOAD)); + memcpy(data, value, min(length, (uint8_t)MAX_PAYLOAD)); return *this; } MyMessage& MyMessage::set(const char* value) { - uint8_t length = value == NULL ? 0 : min(strlen(value), MAX_PAYLOAD); + uint8_t length = value == NULL ? 0 : min(strlen(value), (size_t)MAX_PAYLOAD); miSetLength(length); miSetPayloadType(P_STRING); if (length) { diff --git a/drivers/Linux/Arduino.h b/drivers/Linux/Arduino.h index 7ae8162..e352dd1 100644 --- a/drivers/Linux/Arduino.h +++ b/drivers/Linux/Arduino.h @@ -3,17 +3,31 @@ #include -#ifndef LSBFIRST - #define LSBFIRST 0 +#ifdef __cplusplus + #include + + using namespace std; + + extern "C" { #endif -#ifndef MSBFIRST - #define MSBFIRST 1 +void yield(void); + +#define PI 3.1415926535897932384626433832795 +#define HALF_PI 1.5707963267948966192313216916398 +#define TWO_PI 6.283185307179586476925286766559 +#define DEG_TO_RAD 0.017453292519943295769236907684886 +#define RAD_TO_DEG 57.295779513082320876798154814105 +#define EULER 2.718281828459045235360287471352 + +#ifndef __cplusplus + #define min(a,b) ((a)<(b)?(a):(b)) + #define max(a,b) ((a)>(b)?(a):(b)) + #define abs(x) ((x)>0?(x):-(x)) + #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) #endif -#define abs(x) ((x)>0?(x):-(x)) #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) #define radians(deg) ((deg)*DEG_TO_RAD) #define degrees(rad) ((rad)*RAD_TO_DEG) #define sq(x) ((x)*(x)) @@ -21,15 +35,16 @@ #define lowByte(w) ((uint8_t) ((w) & 0xff)) #define highByte(w) ((uint8_t) ((w) >> 8)) +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + #define bit(b) (1UL << (b)) typedef bool boolean; typedef uint8_t byte; -#ifdef __cplusplus - extern "C" { -#endif - /** * C++ version 0.4 char* style "itoa": * Written by Lukás Chmela diff --git a/examples_RPi/MySGateway.cpp b/examples_RPi/MySGateway.cpp index 014d12a..dc61f85 100644 --- a/examples_RPi/MySGateway.cpp +++ b/examples_RPi/MySGateway.cpp @@ -79,8 +79,6 @@ #include -using namespace std; - void setup() { }