Skip to content

Commit

Permalink
New config 0_9_X_WT901 : IMU Connected on the MPU9250 Slot using Seri…
Browse files Browse the repository at this point in the history
…alPIO
  • Loading branch information
Peppe21 committed Jan 3, 2023
1 parent 5660fff commit 39485dd
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Firmware/LowLevel/lib/JY901_SERIAL/JY901.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include "JY901.h"
#include "string.h"

#ifdef WT901_INSTEAD_OF_SOUND
CJY901 ::CJY901(HardwareSerial *serial)
#elif WT901
CJY901 ::CJY901(SerialPIO *serial)
#endif
{
this->serial = serial;
}
Expand Down
10 changes: 9 additions & 1 deletion Firmware/LowLevel/lib/JY901_SERIAL/JY901.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ class CJY901
struct SLonLat stcLonLat;
struct SGPSV stcGPSV;

CJY901 (HardwareSerial *serial);
#ifdef WT901_INSTEAD_OF_SOUND
CJY901 (HardwareSerial *serial);
#elif WT901
CJY901 (SerialPIO *serial);
#endif

void begin(int baudrate = 9600);
// Call as often as possible to fetch data from serial
Expand All @@ -150,7 +154,11 @@ class CJY901


private:
#ifdef WT901_INSTEAD_OF_SOUND
HardwareSerial *serial;
#elif WT901
SerialPIO *serial;
#endif
unsigned char ucRxBuffer[250];
unsigned char ucRxCnt = 0;

Expand Down
9 changes: 9 additions & 0 deletions Firmware/LowLevel/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,12 @@ lib_deps = ${env.lib_deps}
JY901_SERIAL
build_flags =
${env.build_flags} -DWT901_INSTEAD_OF_SOUND -DHW_0_9_X

[env:0_9_X_WT901]
lib_ignore = JY901_I2C
build_src_filter = ${env.build_src_filter} +<imu/WT901_SERIAL/> +<soundsystem.cpp>
lib_deps = ${env.lib_deps}
JY901_SERIAL
powerbroker2/DFPlayerMini_Fast@^1.2.4
build_flags =
${env.build_flags} -DWT901 -DHW_0_9_X -DENABLE_SOUND_MODULE
7 changes: 7 additions & 0 deletions Firmware/LowLevel/src/imu/WT901_SERIAL/imu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
#include "pins.h"
#include <JY901.h>

#ifdef WT901_INSTEAD_OF_SOUND
CJY901 IMU(&Serial2);
#elif WT901
SerialPIO imuSerial(PIN_WT901_TX, PIN_WT901_RX, 250); // set hardware pin
CJY901 IMU(&imuSerial);
#endif

bool init_imu()
{
#ifdef WT901_INSTEAD_OF_SOUND
Serial2.setRX(PIN_WT901_RX); // set hardware pin
Serial2.setTX(PIN_WT901_TX);
#endif

IMU.begin();

Expand Down
14 changes: 8 additions & 6 deletions Firmware/LowLevel/src/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
#define PIN_SOUND_RX 9
#endif

//This is used as a hack to use WT901 on older mainboards.
#ifdef WT901_INSTEAD_OF_SOUND
#ifdef ENABLE_SOUND_MODULE
#error you can not enable sound and have wt901 on sound port at the same time.
#endif
#define PIN_WT901_TX 8
#define PIN_WT901_RX 9
#ifdef ENABLE_SOUND_MODULE
#error you can not enable sound and have wt901 on sound port at the same time.
#endif
#define PIN_WT901_TX 8
#define PIN_WT901_RX 9
#elif WT901 //This is to use WT901 on MPU9250 Slot via Serial.
#define PIN_WT901_TX 17
#define PIN_WT901_RX 16
#endif

#elif HW_0_10_X
Expand Down

0 comments on commit 39485dd

Please sign in to comment.