Skip to content

Commit 4caacb6

Browse files
committed
[TerkinData] Add separate PlatformIO environment native-radiohead
Fixes compilation on Linux. __unix__ is defined on Linux, while __APPLE__ is defined on macOS [1]. In the default configuration, we don't want to specialize for any of both. It is probably a leftover from where we explored simulating RadioHead- based code. [1] https://www.airspayce.com/mikem/arduino/RadioHead/RadioHead_8h_source.html
1 parent 888363c commit 4caacb6

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

libraries/TerkinData/examples/platformio.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ build_flags =
5959
# -Wextra
6060

6161

62+
[env:native-radiohead]
63+
# Native build with RadioHead, for simulation purposes.
64+
# http://www.airspayce.com/mikem/arduino/RadioHead/classRH__TCP.html
65+
platform = native
66+
lib_deps =
67+
${env:native.lib_deps}
68+
mikem/RadioHead@^1.120
69+
lib_extra_dirs =
70+
${env:native.lib_extra_dirs}
71+
build_flags =
72+
${env:native.build_flags}
73+
# FIXME: Why is that needed? What overwrites it?
74+
-I ${platformio.libdeps_dir}/${this.__env__}/RadioHead
75+
-D RH_SIMULATOR=true
76+
-D SERIAL_PORT_HARDWARE=
77+
78+
6279
[env:avr328]
6380
platform = atmelavr
6481
board = pro8MHzatmega328

libraries/Terrine/Terrine.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2727

2828
#if ARDUINO && !ESP32
2929
#include <MemoryFree.h>
30-
#elif defined(__unix__)
31-
#else
30+
#endif
31+
#if defined(__unix__) || defined(__APPLE__)
3232
#include <iostream>
3333
#endif
3434

@@ -87,7 +87,7 @@ void Terrine::log(int value) {
8787
#ifdef ARDUINO
8888
SERIAL_PORT_HARDWARE.println(value);
8989
delay(TERRINE_SERIAL_DELAY);
90-
#elif defined(__unix__)
90+
#elif defined(RH_SIMULATOR_DEFUNCT)
9191
SERIAL_PORT_HARDWARE.println(std::to_string(value).c_str());
9292
#else
9393
std::cout << value << std::endl;
@@ -112,7 +112,7 @@ void Terrine::logmem() {
112112
SERIAL_PORT_HARDWARE.print("free: ");
113113
SERIAL_PORT_HARDWARE.println(memfree());
114114
delay(TERRINE_SERIAL_DELAY);
115-
#elif defined(__unix__)
115+
#elif defined(RH_SIMULATOR_DEFUNCT)
116116
SERIAL_PORT_HARDWARE.println(std::to_string(memfree()).c_str());
117117
#else
118118
log("free: ", false);

libraries/Terrine/Terrine.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2929
#include <Arduino.h>
3030
#elif defined SIMULAVR
3131
#include <simulavr.h>
32-
#elif defined __unix__
32+
#elif defined RH_SIMULATOR
3333
#include <RHutil/simulator.h>
3434
#endif
3535

@@ -45,7 +45,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4545

4646
#define TERRINE_SERIAL_DELAY 100
4747

48-
#if defined(__unix__)
48+
#if defined(RH_SIMULATOR_DEFUNCT)
4949
#include <sstream>
5050
namespace std {
5151
std::string to_string(size_t n) {
@@ -55,7 +55,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
5555
}
5656
}
5757
#endif
58-
#if defined(__unix__)
58+
#if defined(RH_SIMULATOR_DEFUNCT)
5959
extern char *ultoa(unsigned long int __val, char *__s, int __radix) {
6060
snprintf(__s, __radix, "%d", __val);
6161
return __s;

0 commit comments

Comments
 (0)