Skip to content

Commit

Permalink
Merge branch 'master' into more-baros
Browse files Browse the repository at this point in the history
  • Loading branch information
CapnBry committed Apr 3, 2024
2 parents 6bc003f + 57cf9d7 commit cb01292
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/html/hardware.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@@require(PLATFORM, VERSION, isTX, sx127x)
@@require(PLATFORM, VERSION, isTX)
<!DOCTYPE HTML>
<html lang="en">

Expand Down
4 changes: 2 additions & 2 deletions src/html/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@@require(PLATFORM, VERSION, isTX, sx127x)
@@require(PLATFORM, VERSION, isTX, hasSubGHz)
<!DOCTYPE HTML>
<html lang="en">

Expand Down Expand Up @@ -53,7 +53,7 @@ <h2>Runtime Options</h2>
<br/><br/>
<form id='upload_options' method='POST' action="/options">
@@end
@@if sx127x:
@@if hasSubGHz:
<div class="mui-select">
<select id='domain' name='domain'>
<option value='0'>AU915</option>
Expand Down
8 changes: 7 additions & 1 deletion src/html/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let colorTimer = undefined;
let colorUpdated = false;
let storedModelId = 255;
let buttonActions = [];
let modeSelectionInit = true;
let originalUID = undefined;
let originalUIDType = undefined;

Expand Down Expand Up @@ -156,6 +157,9 @@ function updatePwmSettings(arPwm) {
if (other != index) {
document.querySelectorAll(`#pwm_${other}_mode option`).forEach(opt => {
if (opt.value == value) {
if (modeSelectionInit)
opt.disabled = true;
else
opt.disabled = enable;
}
});
Expand Down Expand Up @@ -184,6 +188,8 @@ function updatePwmSettings(arPwm) {
};
failsafeMode.onchange();
});

modeSelectionInit = false;

// put some contraints on pinRx/Tx mode selects
if (pinRxIndex !== undefined && pinTxIndex !== undefined) {
Expand Down Expand Up @@ -271,7 +277,7 @@ function updateUIDType(uidtype) {
bg = '#1976D2'; // blue/white
desc = 'The binding UID was generated from a binding phrase set at flash time';
}
if (uidtype === 'Overridden') // TX
else if (uidtype === 'Overridden') // TX
{
bg = '#689F38'; // green/black
fg = 'black';
Expand Down
1 change: 1 addition & 0 deletions src/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ extern SX127xDriver Radio;
#elif defined(RADIO_LR1121)
#define RATE_MAX 14
#define RATE_BINDING RATE_LORA_50HZ
#define RATE_DUALBAND_BINDING 9 // 2.4GHz 50Hz

extern LR1121Driver Radio;

Expand Down
20 changes: 10 additions & 10 deletions src/python/build_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def dequote(str):
return str

def process_json_flag(define):
parts = re.search("-D(.*)\s*=\s*(.*)$", define)
parts = re.search(r"-D(.*)\s*=\s*(.*)$", define)
if parts and define.startswith("-D"):
if parts.group(1) == "MY_BINDING_PHRASE":
json_flags['uid'] = [x for x in hashlib.md5(define.encode()).digest()[0:6]]
Expand All @@ -45,19 +45,19 @@ def process_json_flag(define):
if parts.group(1) == "HOME_WIFI_PASSWORD":
json_flags['wifi-password'] = dequote(parts.group(2))
if parts.group(1) == "AUTO_WIFI_ON_INTERVAL":
parts = re.search("-D(.*)\s*=\s*\"?([0-9]+).*\"?$", define)
parts = re.search(r"-D(.*)\s*=\s*\"?([0-9]+).*\"?$", define)
json_flags['wifi-on-interval'] = int(dequote(parts.group(2)))
if parts.group(1) == "TLM_REPORT_INTERVAL_MS" and not isRX:
parts = re.search("-D(.*)\s*=\s*\"?([0-9]+).*\"?$", define)
parts = re.search(r"-D(.*)\s*=\s*\"?([0-9]+).*\"?$", define)
json_flags['tlm-interval'] = int(dequote(parts.group(2)))
if parts.group(1) == "FAN_MIN_RUNTIME" and not isRX:
parts = re.search("-D(.*)\s*=\s*\"?([0-9]+).*\"?$", define)
parts = re.search(r"-D(.*)\s*=\s*\"?([0-9]+).*\"?$", define)
json_flags['fan-runtime'] = int(dequote(parts.group(2)))
if parts.group(1) == "RCVR_UART_BAUD" and isRX:
parts = re.search("-D(.*)\s*=\s*\"?([0-9]+).*\"?$", define)
parts = re.search(r"-D(.*)\s*=\s*\"?([0-9]+).*\"?$", define)
json_flags['rcvr-uart-baud'] = int(dequote(parts.group(2)))
if parts.group(1) == "USE_AIRPORT_AT_BAUD":
parts = re.search("-D(.*)\s*=\s*\"?([0-9]+).*\"?$", define)
parts = re.search(r"-D(.*)\s*=\s*\"?([0-9]+).*\"?$", define)
json_flags['is-airport'] = True
if isRX:
json_flags['rcvr-uart-baud'] = int(dequote(parts.group(2)))
Expand All @@ -81,15 +81,15 @@ def process_build_flag(define):
parsedMelody = melodyparser.parse(define.split('"')[1::2][0])
define = "-DMY_STARTUP_MELODY_ARR=\"" + parsedMelody + "\""
if "HOME_WIFI_SSID=" in define:
parts = re.search("(.*)=\w*\"(.*)\"$", define)
parts = re.search(r"(.*)=\w*\"(.*)\"$", define)
if parts and parts.group(2):
define = "-DHOME_WIFI_SSID=" + string_to_ascii(parts.group(2))
if "HOME_WIFI_PASSWORD=" in define:
parts = re.search("(.*)=\w*\"(.*)\"$", define)
parts = re.search(r"(.*)=\w*\"(.*)\"$", define)
if parts and parts.group(2):
define = "-DHOME_WIFI_PASSWORD=" + string_to_ascii(parts.group(2))
if "DEVICE_NAME=" in define:
parts = re.search("(.*)=\w*'?\"(.*)\"'?$", define)
parts = re.search(r"(.*)=\w*'?\"(.*)\"'?$", define)
if parts and parts.group(2):
env['DEVICE_NAME'] = parts.group(2)
if not define in build_flags:
Expand Down Expand Up @@ -118,7 +118,7 @@ def condense_flags():
global build_flags
for line in build_flags:
# Some lines have multiple flags so this will split them and remove them all
for flag in re.findall("!-D\s*[^\s]+", line):
for flag in re.findall(r"!-D\s*[^\s]+", line):
build_flags = [x.replace(flag,"") for x in build_flags] # remove the removal flag
build_flags = [x.replace(flag[1:],"") for x in build_flags] # remove the flag if it matches the removal flag
build_flags = [x for x in build_flags if (x.strip() != "")] # remove any blank items
Expand Down
3 changes: 2 additions & 1 deletion src/python/build_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ def build_html(mainfile, var, out, env, isTX=False):
extensions=[CoreExtension("@@")]
)
template = engine.get_template(mainfile)
has_sub_ghz = '-DRADIO_SX127X=1' in env['BUILD_FLAGS'] or '-DRADIO_LR1121=1' in env['BUILD_FLAGS']
data = template.render({
'VERSION': get_version(env),
'PLATFORM': re.sub("_via_.*", "", env['PIOENV']),
'isTX': isTX,
'sx127x': '-DRADIO_SX127X=1' in env['BUILD_FLAGS']
'hasSubGHz': has_sub_ghz
})
if mainfile.endswith('.html'):
data = html_minifier.html_minify(data)
Expand Down
12 changes: 6 additions & 6 deletions src/python/serve_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
open http://localhost:8080/
add the following query params for TX and/or 900Mhz testing
isTX
sx127x
hasSubGHz
"""

from external.bottle import route, run, response, request
Expand All @@ -17,7 +17,7 @@

net_counter = 0
isTX = False
sx127x = False
hasSubGHz = False

config = {
"options": {
Expand Down Expand Up @@ -111,7 +111,7 @@
}

def apply_template(mainfile):
global isTX, sx127x
global isTX, hasSubGHz
engine = Engine(
loader=FileLoader(["html"]),
extensions=[CoreExtension("@@")]
Expand All @@ -121,16 +121,16 @@ def apply_template(mainfile):
'VERSION': 'testing (xxxxxx)',
'PLATFORM': '',
'isTX': isTX,
'sx127x': sx127x
'hasSubGHz': hasSubGHz
})
return data

@route('/')
def index():
global net_counter, isTX, sx127x
global net_counter, isTX, hasSubGHz
net_counter = 0
isTX = 'isTX' in request.query
sx127x = 'sx127x' in request.query
hasSubGHz = 'hasSubGHz' in request.query
response.content_type = 'text/html; charset=latin9'
return apply_template('index.html')

Expand Down
7 changes: 1 addition & 6 deletions src/src/rx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,6 @@ static uint8_t minLqForChaos()

void ICACHE_RAM_ATTR getRFlinkInfo()
{
if (GPIO_PIN_NSS_2 != UNDEF_PIN)
{
antenna = (Radio.GetProcessingPacketRadio() == SX12XX_Radio_1) ? 0 : 1;
}

int32_t rssiDBM = Radio.LastPacketRSSI;

if (GPIO_PIN_NSS_2 != UNDEF_PIN)
Expand All @@ -272,7 +267,7 @@ void ICACHE_RAM_ATTR getRFlinkInfo()
// BetaFlight/iNav expect positive values for -dBm (e.g. -80dBm -> sent as 80)
CRSF::LinkStatistics.uplink_RSSI_1 = -rssiDBM;
CRSF::LinkStatistics.uplink_RSSI_2 = -rssiDBM2;
antenna = (rssiDBM > rssiDBM2)? 0 : 1; // report a better antenna for the reception
antenna = (Radio.GetProcessingPacketRadio() == SX12XX_Radio_1) ? 0 : 1;
}
else if (antenna == 0)
{
Expand Down
8 changes: 8 additions & 0 deletions src/src/tx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,14 @@ static void EnterBindingMode()
// Start attempting to bind
// Lock the RF rate and freq while binding
SetRFLinkRate(enumRatetoIndex(RATE_BINDING));

#if defined(RADIO_LR1121)
FHSSuseDualBand = true;
expresslrs_mod_settings_s *const dualBandBindingModParams = get_elrs_airRateConfig(RATE_DUALBAND_BINDING); // 2.4GHz 50Hz
Radio.Config(dualBandBindingModParams->bw2, dualBandBindingModParams->sf2, dualBandBindingModParams->cr2, FHSSgetInitialGeminiFreq(),
dualBandBindingModParams->PreambleLen2, true, dualBandBindingModParams->PayloadLength, dualBandBindingModParams->interval, SX12XX_Radio_2);
#endif

Radio.SetFrequencyReg(FHSSgetInitialFreq());
if (isDualRadio() && config.GetAntennaMode() == TX_RADIO_MODE_GEMINI) // Gemini mode
{
Expand Down

0 comments on commit cb01292

Please sign in to comment.