Skip to content

Commit 5eeab17

Browse files
authored
Merge pull request #70 from jonas-koeritz/orqa
Orqa FPV.Connect support
2 parents 394eff5 + bef4aba commit 5eeab17

File tree

8 files changed

+146
-9
lines changed

8 files changed

+146
-9
lines changed

lib/Channels/channels.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "channels.h"
2+
3+
uint16_t GetFrequency(uint8_t index)
4+
{
5+
if (index >= 0 && index < 48)
6+
return frequencyTable[index];
7+
else
8+
return 0;
9+
}
10+
11+
uint8_t GetBand(uint8_t index)
12+
{
13+
return index / 8 + 1;
14+
}
15+
16+
uint8_t GetChannel(uint8_t index)
17+
{
18+
return (index % 8) + 1;
19+
}

lib/Channels/channels.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include <Arduino.h>
4+
5+
const uint16_t frequencyTable[48] = {
6+
5865, 5845, 5825, 5805, 5785, 5765, 5745, 5725, // A
7+
5733, 5752, 5771, 5790, 5809, 5828, 5847, 5866, // B
8+
5705, 5685, 5665, 5645, 5885, 5905, 5925, 5945, // E
9+
5740, 5760, 5780, 5800, 5820, 5840, 5860, 5880, // F
10+
5658, 5695, 5732, 5769, 5806, 5843, 5880, 5917, // R
11+
5333, 5373, 5413, 5453, 5493, 5533, 5573, 5613 // L
12+
};
13+
14+
uint16_t GetFrequency(uint8_t index);
15+
uint8_t GetBand(uint8_t index);
16+
uint8_t GetChannel(uint8_t index);

platformio.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ extra_configs =
1818
targets/dupletx_tx.ini
1919
targets/radiomaster_tx.ini
2020
targets/hdzero.ini
21-
targets/skyzone.ini
21+
targets/skyzone.ini
22+
targets/orqa.ini

src/Vrx_main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "hdzero.h"
3535
#elif defined(SKYZONE_MSP_BACKPACK)
3636
#include "skyzone_msp.h"
37+
#elif defined(ORQA_BACKPACK)
38+
#include "orqa.h"
3739
#endif
3840

3941
/////////// DEFINES ///////////
@@ -102,6 +104,8 @@ VrxBackpackConfig config;
102104
HDZero vrxModule(&Serial);
103105
#elif defined(SKYZONE_MSP_BACKPACK)
104106
SkyzoneMSP vrxModule(&Serial);
107+
#elif defined(ORQA_BACKPACK)
108+
Orqa vrxModule;
105109
#endif
106110

107111
/////////// FUNCTION DEFS ///////////
@@ -432,7 +436,7 @@ void loop()
432436
sendChangesToVrx = false;
433437
vrxModule.SendIndexCmd(cachedIndex);
434438
}
435-
439+
436440
// spam out a bunch of requests for the desired band/channel for the first 5s
437441
if (!gotInitialPacket && now - VRX_BOOT_DELAY < 5000 && now - lastSentRequest > 1000 && connectionState != binding)
438442
{

src/orqa.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include "orqa.h"
2+
3+
GENERIC_CRC8 ghst_crc(GHST_CRC_POLY);
4+
5+
void Orqa::SendIndexCmd(uint8_t index)
6+
{
7+
uint8_t band = GetBand(index);
8+
uint8_t channel = GetChannel(index);
9+
uint8_t currentGHSTChannel = GHSTChannel(band, channel);
10+
uint16_t currentFrequency = GetFrequency(index);
11+
SendGHSTUpdate(currentFrequency, currentGHSTChannel);
12+
}
13+
14+
15+
void Orqa::SendGHSTUpdate(uint16_t freq, uint8_t ghstChannel)
16+
{
17+
uint8_t packet[] = {
18+
0x82, 0x0C, 0x20, // Header
19+
0x00, (uint8_t)(freq & 0xFF), (uint8_t)(freq >> 8), // Frequency
20+
0x01, 0x00, ghstChannel, // Band & Channel
21+
0x00, 0x00, 0x00, 0x00, // Power Level?
22+
0x00 }; // CRC
23+
uint8_t crc = ghst_crc.calc(&packet[2], 11);
24+
packet[13] = crc;
25+
26+
for(uint8_t i = 0; i < 14; i++)
27+
{
28+
Serial.write(packet[i]);
29+
}
30+
}
31+
32+
uint8_t Orqa::GHSTChannel(uint8_t band, uint8_t channel)
33+
{
34+
// ELRS Bands: A, B, E, I/F, R, L
35+
// Orqa/Rapidfire Bands: I/F, R, E, B, A, L, X
36+
uint8_t ghstChannel = 0x00;
37+
38+
switch(band)
39+
{
40+
case 0x01:
41+
ghstChannel |= 0x50;
42+
break;
43+
case 0x02:
44+
ghstChannel |= 0x40;
45+
break;
46+
case 0x03:
47+
ghstChannel |= 0x30;
48+
break;
49+
case 0x04:
50+
ghstChannel |= 0x10;
51+
break;
52+
case 0x05:
53+
ghstChannel |= 0x20;
54+
break;
55+
case 0x06:
56+
ghstChannel |= 0x60;
57+
break;
58+
}
59+
ghstChannel |= channel;
60+
61+
return ghstChannel;
62+
}

src/orqa.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
3+
#include "module_base.h"
4+
#include <channels.h>
5+
#include <crc.h>
6+
7+
#define VRX_UART_BAUD 100000
8+
#define VRX_BOOT_DELAY 7000
9+
#define GHST_CRC_POLY 0xD5
10+
11+
class Orqa : public ModuleBase
12+
{
13+
public:
14+
void SendIndexCmd(uint8_t index);
15+
private:
16+
uint8_t GHSTChannel(uint8_t band, uint8_t channel);
17+
void SendGHSTUpdate(uint16_t freq, uint8_t ghstChannel);
18+
};

targets/common.ini

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,52 +50,60 @@ build_flags =
5050
build_flags =
5151
${common_env_data.build_flags}
5252
-D TARGET_TX_BACKPACK
53-
build_src_filter = ${common_env_data.build_src_filter} -<Vrx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*>
53+
build_src_filter = ${common_env_data.build_src_filter} -<Vrx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*> -<orqa.*>
5454

5555
# ------------------------- COMMON RAPIDFIRE-BACKPACK DEFINITIONS -----------------
5656
[rapidfire_vrx_backpack_common]
5757
build_flags =
5858
${common_env_data.build_flags}
5959
-D TARGET_VRX_BACKPACK
6060
-D RAPIDFIRE_BACKPACK
61-
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*>
61+
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*> -<orqa.*>
6262

6363
# ------------------------- COMMON RX5808-BACKPACK DEFINITIONS -----------------
6464
[rx5808_vrx_backpack_common]
6565
build_flags =
6666
${common_env_data.build_flags}
6767
-D TARGET_VRX_BACKPACK
6868
-D RX5808_BACKPACK
69-
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*>
69+
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*> -<orqa.*>
7070

7171
# ------------------------- COMMON STEADYVIEW-BACKPACK DEFINITIONS -----------------
7272
[steadyview_vrx_backpack_common]
7373
build_flags =
7474
${common_env_data.build_flags}
7575
-D TARGET_VRX_BACKPACK
7676
-D STEADYVIEW_BACKPACK
77-
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*>
77+
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*> -<orqa.*>
7878

7979
# ------------------------- COMMON FUSION-BACKPACK DEFINITIONS -----------------
8080
[fusion_vrx_backpack_common]
8181
build_flags =
8282
${common_env_data.build_flags}
8383
-D TARGET_VRX_BACKPACK
8484
-D FUSION_BACKPACK
85-
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<hdzero.*> -<skyzone_msp.*>
85+
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<hdzero.*> -<skyzone_msp.*> -<orqa.*>
8686

8787
# ------------------------- COMMON HDZERO-BACKPACK DEFINITIONS -----------------
8888
[hdzero_vrx_backpack_common]
8989
build_flags =
9090
${common_env_data.build_flags}
9191
-D TARGET_VRX_BACKPACK
9292
-D HDZERO_BACKPACK
93-
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<stmUpdateClass.*> -<skyzone_msp.*>
93+
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<stmUpdateClass.*> -<skyzone_msp.*> -<orqa.*>
9494

9595
# ------------------------- COMMON SKYZONE-MSP-BACKPACK DEFINITIONS -----------------
9696
[skyzone_msp_vrx_backpack_common]
9797
build_flags =
9898
${common_env_data.build_flags}
9999
-D TARGET_VRX_BACKPACK
100100
-D SKYZONE_MSP_BACKPACK
101-
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<stmUpdateClass.*>
101+
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<stmUpdateClass.*> -<orqa.*>
102+
103+
# ------------------------- COMMON ORQA-BACKPACK DEFINITIONS -------------------
104+
[orqa_backpack_common]
105+
build_flags =
106+
${common_env_data.build_flags}
107+
-D TARGET_VRX_BACKPACK
108+
-D ORQA_BACKPACK
109+
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<stmUpdateClass.*> -<hdzero.*> -<skyzone_msp.*>

targets/orqa.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[env:Orqa_ESP_RX_Backpack_via_UART]
2+
extends = env_common_esp8285, orqa_backpack_common
3+
build_flags =
4+
${env_common_esp8285.build_flags}
5+
${orqa_backpack_common.build_flags}
6+
-D PIN_LED=16
7+
8+
[env:Orqa_ESP_RX_Backpack_via_WIFI]
9+
extends = env:Orqa_ESP_RX_Backpack_via_UART

0 commit comments

Comments
 (0)