Skip to content

Commit b4345dc

Browse files
Merge pull request #49 from Peppe21/main
New platformio config : 0_9_X_WT901
2 parents 5660fff + 39485dd commit b4345dc

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

Firmware/LowLevel/lib/JY901_SERIAL/JY901.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#include "JY901.h"
22
#include "string.h"
33

4+
#ifdef WT901_INSTEAD_OF_SOUND
45
CJY901 ::CJY901(HardwareSerial *serial)
6+
#elif WT901
7+
CJY901 ::CJY901(SerialPIO *serial)
8+
#endif
59
{
610
this->serial = serial;
711
}

Firmware/LowLevel/lib/JY901_SERIAL/JY901.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ class CJY901
141141
struct SLonLat stcLonLat;
142142
struct SGPSV stcGPSV;
143143

144-
CJY901 (HardwareSerial *serial);
144+
#ifdef WT901_INSTEAD_OF_SOUND
145+
CJY901 (HardwareSerial *serial);
146+
#elif WT901
147+
CJY901 (SerialPIO *serial);
148+
#endif
145149

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

151155

152156
private:
157+
#ifdef WT901_INSTEAD_OF_SOUND
153158
HardwareSerial *serial;
159+
#elif WT901
160+
SerialPIO *serial;
161+
#endif
154162
unsigned char ucRxBuffer[250];
155163
unsigned char ucRxCnt = 0;
156164

Firmware/LowLevel/platformio.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,12 @@ lib_deps = ${env.lib_deps}
7777
JY901_SERIAL
7878
build_flags =
7979
${env.build_flags} -DWT901_INSTEAD_OF_SOUND -DHW_0_9_X
80+
81+
[env:0_9_X_WT901]
82+
lib_ignore = JY901_I2C
83+
build_src_filter = ${env.build_src_filter} +<imu/WT901_SERIAL/> +<soundsystem.cpp>
84+
lib_deps = ${env.lib_deps}
85+
JY901_SERIAL
86+
powerbroker2/DFPlayerMini_Fast@^1.2.4
87+
build_flags =
88+
${env.build_flags} -DWT901 -DHW_0_9_X -DENABLE_SOUND_MODULE

Firmware/LowLevel/src/imu/WT901_SERIAL/imu.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
#include "pins.h"
33
#include <JY901.h>
44

5+
#ifdef WT901_INSTEAD_OF_SOUND
56
CJY901 IMU(&Serial2);
7+
#elif WT901
8+
SerialPIO imuSerial(PIN_WT901_TX, PIN_WT901_RX, 250); // set hardware pin
9+
CJY901 IMU(&imuSerial);
10+
#endif
611

712
bool init_imu()
813
{
14+
#ifdef WT901_INSTEAD_OF_SOUND
915
Serial2.setRX(PIN_WT901_RX); // set hardware pin
1016
Serial2.setTX(PIN_WT901_TX);
17+
#endif
1118

1219
IMU.begin();
1320

Firmware/LowLevel/src/pins.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@
3232
#define PIN_SOUND_RX 9
3333
#endif
3434

35-
//This is used as a hack to use WT901 on older mainboards.
3635
#ifdef WT901_INSTEAD_OF_SOUND
37-
#ifdef ENABLE_SOUND_MODULE
38-
#error you can not enable sound and have wt901 on sound port at the same time.
39-
#endif
40-
#define PIN_WT901_TX 8
41-
#define PIN_WT901_RX 9
36+
#ifdef ENABLE_SOUND_MODULE
37+
#error you can not enable sound and have wt901 on sound port at the same time.
38+
#endif
39+
#define PIN_WT901_TX 8
40+
#define PIN_WT901_RX 9
41+
#elif WT901 //This is to use WT901 on MPU9250 Slot via Serial.
42+
#define PIN_WT901_TX 17
43+
#define PIN_WT901_RX 16
4244
#endif
4345

4446
#elif HW_0_10_X

0 commit comments

Comments
 (0)