Skip to content

Commit

Permalink
ifdef
Browse files Browse the repository at this point in the history
  • Loading branch information
bmellink committed Apr 7, 2019
1 parent bafc6ff commit 0347bc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions examples/Ibus_sensor/Ibus_sensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ void loop() {
IBus.setSensorMeasurement(1,speed);
speed += 10; // increase motor speed by 10 RPM
IBus.setSensorMeasurement(2,temp++); // increase temperature by 0.1 'C every loop
Serial.print("Speed=");
Serial.print(speed);
Serial.print(" Temp=");
Serial.println((temp-TEMPBASE)/10.);
delay(500);
}

8 changes: 4 additions & 4 deletions src/IBusBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ void onTimer() {


void IBusBM::begin(HardwareSerial& serial, int8_t timerid, int8_t rxPin, int8_t txPin) {
#ifdef ARDUINO_ARCH_AVR
serial.begin(115200, SERIAL_8N1);
#else
#ifdef ARDUINO_ARCH_ESP32
serial.begin(115200, SERIAL_8N1, rxPin, txPin);
#else
serial.begin(115200, SERIAL_8N1);
#endif

this->stream = &serial;
Expand All @@ -93,7 +93,7 @@ void IBusBM::begin(HardwareSerial& serial, int8_t timerid, int8_t rxPin, int8_t
TIMSK0 |= _BV(OCIE0A);
#else
// on other architectures we need to use a time
#ifdef ARDUINO_ARCH_ESP32
#if defined(ARDUINO_ARCH_ESP32)
hw_timer_t * timer = NULL;
timer = timerBegin(timerid, F_CPU / 1000000L, true); // defaults to timer_id = 0; divider=80 (1 ms); countUp = true;
timerAttachInterrupt(timer, &onTimer, true); // edge = true
Expand Down

0 comments on commit 0347bc3

Please sign in to comment.