Skip to content

Commit

Permalink
Merge branch 'master' into skyzone-custom-osd
Browse files Browse the repository at this point in the history
# Conflicts:
#	platformio.ini
#	src/Vrx_main.cpp
#	src/module_base.cpp
#	src/module_base.h
#	src/skyzone_msp.cpp
#	src/skyzone_msp.h
#	targets/common.ini
#	targets/skyzone.ini
  • Loading branch information
pkendall64 committed Jan 10, 2023
2 parents 778e1f6 + 5eeab17 commit e899c45
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 22 deletions.
19 changes: 19 additions & 0 deletions lib/Channels/channels.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "channels.h"

uint16_t GetFrequency(uint8_t index)
{
if (index >= 0 && index < 48)
return frequencyTable[index];
else
return 0;
}

uint8_t GetBand(uint8_t index)
{
return index / 8 + 1;
}

uint8_t GetChannel(uint8_t index)
{
return (index % 8) + 1;
}
16 changes: 16 additions & 0 deletions lib/Channels/channels.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <Arduino.h>

const uint16_t frequencyTable[48] = {
5865, 5845, 5825, 5805, 5785, 5765, 5745, 5725, // A
5733, 5752, 5771, 5790, 5809, 5828, 5847, 5866, // B
5705, 5685, 5665, 5645, 5885, 5905, 5925, 5945, // E
5740, 5760, 5780, 5800, 5820, 5840, 5860, 5880, // F
5658, 5695, 5732, 5769, 5806, 5843, 5880, 5917, // R
5333, 5373, 5413, 5453, 5493, 5533, 5573, 5613 // L
};

uint16_t GetFrequency(uint8_t index);
uint8_t GetBand(uint8_t index);
uint8_t GetChannel(uint8_t index);
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ extra_configs =
targets/dupletx_tx.ini
targets/radiomaster_tx.ini
targets/hdzero.ini
targets/skyzone.ini
targets/skyzone.ini
targets/orqa.ini
6 changes: 5 additions & 1 deletion src/Vrx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "hdzero.h"
#elif defined(SKYZONE_MSP_BACKPACK)
#include "skyzone_msp.h"
#elif defined(ORQA_BACKPACK)
#include "orqa.h"
#endif

/////////// DEFINES ///////////
Expand Down Expand Up @@ -102,6 +104,8 @@ VrxBackpackConfig config;
HDZero vrxModule(&Serial);
#elif defined(SKYZONE_MSP_BACKPACK)
SkyzoneMSP vrxModule(&Serial);
#elif defined(ORQA_BACKPACK)
Orqa vrxModule;
#endif

/////////// FUNCTION DEFS ///////////
Expand Down Expand Up @@ -435,7 +439,7 @@ void loop()
sendChangesToVrx = false;
vrxModule.SendIndexCmd(cachedIndex);
}

// spam out a bunch of requests for the desired band/channel for the first 5s
if (!gotInitialPacket && now - VRX_BOOT_DELAY < 5000 && now - lastSentRequest > 1000 && connectionState != binding)
{
Expand Down
2 changes: 2 additions & 0 deletions src/fusion.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include "module_base.h"
#include <Arduino.h>

#undef VRX_BOOT_DELAY
#define VRX_BOOT_DELAY 1000

#define VRX_UART_BAUD 500000 // fusion uses 500k baud between the ESP8266 and the STM32

const uint16_t frequencyTable[48] = {
Expand Down
2 changes: 2 additions & 0 deletions src/hdzero.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "module_base.h"
#include <Arduino.h>

#undef VRX_BOOT_DELAY
#define VRX_BOOT_DELAY 7000

#define VRX_RESPONSE_TIMEOUT 500
#define VRX_UART_BAUD 115200 // hdzero uses 115k baud between the ESP8285 and the STM32

Expand Down
62 changes: 62 additions & 0 deletions src/orqa.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "orqa.h"

GENERIC_CRC8 ghst_crc(GHST_CRC_POLY);

void Orqa::SendIndexCmd(uint8_t index)
{
uint8_t band = GetBand(index);
uint8_t channel = GetChannel(index);
uint8_t currentGHSTChannel = GHSTChannel(band, channel);
uint16_t currentFrequency = GetFrequency(index);
SendGHSTUpdate(currentFrequency, currentGHSTChannel);
}


void Orqa::SendGHSTUpdate(uint16_t freq, uint8_t ghstChannel)
{
uint8_t packet[] = {
0x82, 0x0C, 0x20, // Header
0x00, (uint8_t)(freq & 0xFF), (uint8_t)(freq >> 8), // Frequency
0x01, 0x00, ghstChannel, // Band & Channel
0x00, 0x00, 0x00, 0x00, // Power Level?
0x00 }; // CRC
uint8_t crc = ghst_crc.calc(&packet[2], 11);
packet[13] = crc;

for(uint8_t i = 0; i < 14; i++)
{
Serial.write(packet[i]);
}
}

uint8_t Orqa::GHSTChannel(uint8_t band, uint8_t channel)
{
// ELRS Bands: A, B, E, I/F, R, L
// Orqa/Rapidfire Bands: I/F, R, E, B, A, L, X
uint8_t ghstChannel = 0x00;

switch(band)
{
case 0x01:
ghstChannel |= 0x50;
break;
case 0x02:
ghstChannel |= 0x40;
break;
case 0x03:
ghstChannel |= 0x30;
break;
case 0x04:
ghstChannel |= 0x10;
break;
case 0x05:
ghstChannel |= 0x20;
break;
case 0x06:
ghstChannel |= 0x60;
break;
}
ghstChannel |= channel;

return ghstChannel;
}
18 changes: 18 additions & 0 deletions src/orqa.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include "module_base.h"
#include <channels.h>
#include <crc.h>

#define VRX_UART_BAUD 100000
#define VRX_BOOT_DELAY 7000
#define GHST_CRC_POLY 0xD5

class Orqa : public ModuleBase
{
public:
void SendIndexCmd(uint8_t index);
private:
uint8_t GHSTChannel(uint8_t band, uint8_t channel);
void SendGHSTUpdate(uint16_t freq, uint8_t ghstChannel);
};
1 change: 1 addition & 0 deletions src/rapidfire.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "module_base.h"
#include <Arduino.h>

#undef VRX_BOOT_DELAY
#define VRX_BOOT_DELAY 2000

#define BIT_BANG_FREQ 1000
Expand Down
2 changes: 2 additions & 0 deletions src/skyzone_msp.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "module_base.h"
#include <Arduino.h>

#undef VRX_BOOT_DELAY
#define VRX_BOOT_DELAY 2000

#define VRX_RESPONSE_TIMEOUT 500
#define VRX_UART_BAUD 115200 // skyzone uses 115k baud between the ESP32-PICO and their MCU

Expand Down
22 changes: 15 additions & 7 deletions targets/common.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,52 +50,60 @@ build_flags =
build_flags =
${common_env_data.build_flags}
-D TARGET_TX_BACKPACK
build_src_filter = ${common_env_data.build_src_filter} -<Vrx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*>
build_src_filter = ${common_env_data.build_src_filter} -<Vrx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*> -<orqa.*>

# ------------------------- COMMON RAPIDFIRE-BACKPACK DEFINITIONS -----------------
[rapidfire_vrx_backpack_common]
build_flags =
${common_env_data.build_flags}
-D TARGET_VRX_BACKPACK
-D RAPIDFIRE_BACKPACK
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*>
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*> -<orqa.*>

# ------------------------- COMMON RX5808-BACKPACK DEFINITIONS -----------------
[rx5808_vrx_backpack_common]
build_flags =
${common_env_data.build_flags}
-D TARGET_VRX_BACKPACK
-D RX5808_BACKPACK
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*>
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*> -<orqa.*>

# ------------------------- COMMON STEADYVIEW-BACKPACK DEFINITIONS -----------------
[steadyview_vrx_backpack_common]
build_flags =
${common_env_data.build_flags}
-D TARGET_VRX_BACKPACK
-D STEADYVIEW_BACKPACK
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*>
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<fusion.*> -<hdzero.*> -<skyzone_msp.*> -<orqa.*>

# ------------------------- COMMON FUSION-BACKPACK DEFINITIONS -----------------
[fusion_vrx_backpack_common]
build_flags =
${common_env_data.build_flags}
-D TARGET_VRX_BACKPACK
-D FUSION_BACKPACK
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<hdzero.*> -<skyzone_msp.*>
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<hdzero.*> -<skyzone_msp.*> -<orqa.*>

# ------------------------- COMMON HDZERO-BACKPACK DEFINITIONS -----------------
[hdzero_vrx_backpack_common]
build_flags =
${common_env_data.build_flags}
-D TARGET_VRX_BACKPACK
-D HDZERO_BACKPACK
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<stmUpdateClass.*> -<skyzone_msp.*>
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<stmUpdateClass.*> -<skyzone_msp.*> -<orqa.*>

# ------------------------- COMMON SKYZONE-MSP-BACKPACK DEFINITIONS -----------------
[skyzone_msp_vrx_backpack_common]
build_flags =
${common_env_data.build_flags}
-D TARGET_VRX_BACKPACK
-D SKYZONE_MSP_BACKPACK
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<stmUpdateClass.*>
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<hdzero.*> -<stmUpdateClass.*> -<orqa.*>

# ------------------------- COMMON ORQA-BACKPACK DEFINITIONS -------------------
[orqa_backpack_common]
build_flags =
${common_env_data.build_flags}
-D TARGET_VRX_BACKPACK
-D ORQA_BACKPACK
build_src_filter = ${common_env_data.build_src_filter} -<Tx_main.cpp> -<rapidfire.*> -<rx5808.*> -<steadyview.*> -<fusion.*> -<stmUpdateClass.*> -<hdzero.*> -<skyzone_msp.*>
13 changes: 0 additions & 13 deletions targets/generic_esp_rx.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,3 @@ build_flags =

[env:RX5808_ESP_RX_Backpack_via_WIFI]
extends = env:RX5808_ESP_RX_Backpack_via_UART

[env:SteadyView_ESP_RX_Backpack_via_UART]
extends = env_common_esp8285, steadyview_vrx_backpack_common
build_flags =
${env_common_esp8285.build_flags}
${steadyview_vrx_backpack_common.build_flags}
-D PIN_LED=16
-D PIN_MOSI=3 ;RX pad
-D PIN_CLK=0 ;Boot pad
-D PIN_CS=1 ;TX pad

[env:SteadyView_ESP_RX_Backpack_via_WIFI]
extends = env:SteadyView_ESP_RX_Backpack_via_UART
9 changes: 9 additions & 0 deletions targets/orqa.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[env:Orqa_ESP_RX_Backpack_via_UART]
extends = env_common_esp8285, orqa_backpack_common
build_flags =
${env_common_esp8285.build_flags}
${orqa_backpack_common.build_flags}
-D PIN_LED=16

[env:Orqa_ESP_RX_Backpack_via_WIFI]
extends = env:Orqa_ESP_RX_Backpack_via_UART
13 changes: 13 additions & 0 deletions targets/skyzone.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
# VRX backpack targets
# ********************************

[env:Skyzone_DIY_SteadyView_Backpack_via_UART]
extends = env_common_esp8285, steadyview_vrx_backpack_common
build_flags =
${env_common_esp8285.build_flags}
${steadyview_vrx_backpack_common.build_flags}
-D PIN_LED=16
-D PIN_MOSI=3 ;RX pad
-D PIN_CLK=0 ;Boot pad
-D PIN_CS=1 ;TX pad

[env:Skyzone_DIY_SteadyView_Backpack_via_WIFI]
extends = env:Skyzone_DIY_SteadyView_Backpack_via_UART

[env:Skyzone_Onboard_ESP32_Backpack_via_UART]
extends = env_common_esp32, skyzone_msp_vrx_backpack_common
monitor_speed = 115200
Expand Down

0 comments on commit e899c45

Please sign in to comment.