Skip to content

Commit

Permalink
build(PlatformIO): use defines for repeated configs
Browse files Browse the repository at this point in the history
Close #34
  • Loading branch information
leon0399 committed Mar 28, 2023
1 parent e58b1a6 commit 3f0211f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions firmware/firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <components/serial_plotter.hpp>
#endif // SERIAL_PLOTTER

#ifndef SERIAL_PLOTTER_PORT
#define SERIAL_PLOTTER_PORT Serial
#endif // SERIAL_PLOTTER_PORT

#ifndef PIO_UNIT_TESTING

extern void setupMode();
Expand All @@ -17,12 +21,10 @@ extern void setupMode();
OpenHaptics App;

void setup() {
Serial.begin(115200);

setupMode();

#if defined(SERIAL_PLOTTER) && SERIAL_PLOTTER == true
auto* serialOutputState = new OH::SerialPlotter_OutputStates<HardwareSerial>(Serial, App.getOutput());
auto* serialOutputState = new OH::SerialPlotter_OutputStates<HardwareSerial>(SERIAL_PLOTTER_PORT, App.getOutput());
serialOutputState->begin();
#endif // SERIAL_PLOTTER

Expand Down
6 changes: 5 additions & 1 deletion lib/arduino/components/serial_plotter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include <HardwareSerial.h>

#ifndef SERIAL_PLOTTER_BAUD
#define SERIAL_PLOTTER_BAUD 115200
#endif // SERIAL_PLOTTER_BAUD

namespace OH {
/**
* Component, that prints the current state of the output to the serial port in Arduino's Serial Plotter format
Expand Down Expand Up @@ -42,7 +46,7 @@ namespace OH {
*/
template<>
inline void SerialPlotter_OutputStates<HardwareSerial>::setup() {
this->serial->begin(115200);
this->serial->begin(SERIAL_PLOTTER_BAUD);
}

template class SerialPlotter_OutputStates<HardwareSerial>;
Expand Down
5 changes: 3 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ build_flags =
; -D DEBUG_MODE=0
; -D DEBUG_ESP_PORT=Serial
; -D SERIAL_PLOTTER=true
-D BATTERY_ENABLED=true
-D BLUETOOTH_USE_NIMBLE=true
; -D BATTERY_ENABLED=true
; -D BLUETOOTH_USE_NIMBLE=false

build_unflags =
-std=gnu++11
build_src_filter =
Expand Down

0 comments on commit 3f0211f

Please sign in to comment.