Skip to content

Commit 8f9d73f

Browse files
authored
Merge pull request #321 from ligenxxxx/low-band
support Low band and (540P60)17Mhz
2 parents 909e54b + fd2ec34 commit 8f9d73f

26 files changed

Lines changed: 757 additions & 231 deletions

mkapp/app/setting.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ power_ana_rx = 1
2222

2323
[source]
2424
analog_format=0
25+
hdzero_band=0
26+
hdzero_bw=0
2527

2628
[record]
2729
mode_manual=false

mkapp/hal/HDZGOGGLE_RX.bin

0 Bytes
Binary file not shown.

mkapp/hal/HDZGOGGLE_VA.bin

0 Bytes
Binary file not shown.

mkapp/hal/ver.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
73-184
1+
74-186

src/core/app_state.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
app_state_t g_app_state = APP_STATE_MAINMENU;
2424

25-
extern int valid_channel_tb[11];
25+
extern int valid_channel_tb[10];
2626
extern int user_select_index;
2727

2828
void app_state_push(app_state_t state) {
@@ -114,11 +114,11 @@ void app_switch_to_hdzero(bool is_default) {
114114
ini_putl("scan", "channel", g_setting.scan.channel, SETTING_INI);
115115
}
116116

117-
HDZero_open((ch >> 7) & 1);
118-
ch &= 0xF;
117+
HDZero_open(g_setting.source.hdzero_bw);
118+
ch &= 0x7f;
119119

120-
LOGI("switch to ch:%x, CAM_MODE=%d 4:3=%d", g_setting.scan.channel, CAM_MODE, cam_4_3);
121-
DM6302_SetChannel(ch);
120+
LOGI("switch to bw:%d, band:%d, ch:%d, CAM_MODE=%d 4:3=%d", g_setting.source.hdzero_bw, g_setting.source.hdzero_band, g_setting.scan.channel, CAM_MODE, cam_4_3);
121+
DM6302_SetChannel(g_setting.source.hdzero_band, ch);
122122
DM5680_clear_vldflg();
123123
DM5680_req_vldflg();
124124
progress_bar.start = 0;

src/core/elrs.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,18 @@ void msp_process_packet() {
211211
if (packet.type == MSP_PACKET_COMMAND) {
212212
switch (packet.function) {
213213
case MSP_GET_BAND_CHAN: {
214-
uint8_t chan, ch;
215-
ch = g_setting.scan.channel & 0xF;
216-
if (ch <= 8) {
217-
chan = ch - 1 + 4 * 8; // Map R1..8
218-
} else {
219-
chan = (ch - 9) * 2 + 3 * 8 + 1; // Map F2/4
214+
uint8_t chan, ch, band;
215+
ch = g_setting.scan.channel;
216+
band = g_setting.source.hdzero_band;
217+
218+
if (band == SETTING_SOURCES_HDZERO_BAND_RACEBAND) {
219+
if (ch <= 8) {
220+
chan = ch - 1 + (4 * 8); // Map R1..8
221+
} else {
222+
chan = ((ch - 9) * 2) + (3 * 8) + 1; // Map F2/4
223+
}
224+
} else { // if (band == SETTING_SOURCES_HDZERO_BAND_LOWBAND)
225+
chan = ch - 1 + 5 * 8; // Map L1..8
220226
}
221227
msp_send_packet(MSP_GET_BAND_CHAN, MSP_PACKET_RESPONSE, 1, &chan);
222228
} break;
@@ -399,15 +405,21 @@ bool elrs_headtracking_enabled() {
399405
}
400406

401407
void msp_channel_update() {
402-
// Channel 1...10 for R1...8, F2 and F4
408+
// Channel 1...18 for R1...8, F2 and F4, L1...8
403409
uint8_t const ch = g_setting.scan.channel;
410+
uint8_t const band = g_setting.source.hdzero_band;
404411
uint8_t chan;
405-
if (ch == 0 || 10 < ch)
412+
413+
if (ch == 0 || ch > CHANNEL_NUM)
406414
return; // Invalid value -> ignore
407-
if (ch <= 8) {
408-
chan = ch - 1 + (4 * 8); // Map R1..8
409-
} else {
410-
chan = ((ch - 9) * 2) + (3 * 8) + 1; // Map F2/4
415+
if (band == SETTING_SOURCES_HDZERO_BAND_RACEBAND) {
416+
if (ch <= 8) {
417+
chan = ch - 1 + (4 * 8); // Map R1..8
418+
} else {
419+
chan = ((ch - 9) * 2) + (3 * 8) + 1; // Map F2/4
420+
}
421+
} else { // if (band == SETTING_SOURCES_HDZERO_BAND_LOWBAND)
422+
chan = ch - 1 + 5 * 8; // Map L1..8
411423
}
412424
msp_send_packet(MSP_SET_BAND_CHAN, MSP_PACKET_COMMAND, sizeof(chan), &chan);
413425
LOGI("MSPv2 MSP_SET_BAND_CHAN %d sent", chan);

src/core/ht.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
#include "bmi270/accel_gyro.h"
1818
#include "core/settings.h"
19-
#include "driver/dm6302.h"
2019
#include "driver/beep.h"
20+
#include "driver/dm6302.h"
2121
#include "driver/hardware.h"
2222
#include "driver/oled.h"
2323
#include "ui/page_common.h"
@@ -103,7 +103,7 @@ static void detect_motion(bool is_moving) {
103103
beep();
104104

105105
OLED_ON(0); // Turn off OLED
106-
if (g_hw_stat.source_mode == HW_SRC_MODE_HDZERO) {
106+
if (g_hw_stat.source_mode == SOURCE_MODE_HDZERO) {
107107
HDZero_Close(); // Turn off RF
108108
}
109109

@@ -125,10 +125,10 @@ static void detect_motion(bool is_moving) {
125125
cnt++;
126126

127127
if (cnt == 2) {
128-
if (g_hw_stat.source_mode == HW_SRC_MODE_HDZERO) {
128+
if (g_hw_stat.source_mode == SOURCE_MODE_HDZERO) {
129129
uint8_t ch = g_setting.scan.channel - 1;
130-
HDZero_open((ch >> 7) & 1);
131-
DM6302_SetChannel(ch & 0xF);
130+
HDZero_open(g_setting.source.hdzero_bw);
131+
DM6302_SetChannel(g_setting.source.hdzero_band, ch & 0x7F);
132132
}
133133
LOGI("OLED ON from protection.");
134134
OLED_Brightness(g_setting.image.oled);

src/core/input_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ void tune_channel(uint8_t action) {
9898

9999
switch (action) {
100100
case DIAL_KEY_UP: // Tune up
101-
if (channel == 10)
101+
if (channel == CHANNEL_NUM)
102102
channel = 1;
103103
else
104104
channel++;
105105
break;
106106

107107
case DIAL_KEY_DOWN: // Tune down
108108
if (channel == 1)
109-
channel = 10;
109+
channel = CHANNEL_NUM;
110110
else
111111
channel--;
112112
break;

src/core/osd.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "driver/nct75.h"
3131
#include "ui/page_common.h"
3232
#include "ui/page_fans.h"
33+
#include "ui/page_scannow.h"
3334
#include "ui/ui_image_setting.h"
3435
#include "ui/ui_porting.h"
3536

@@ -210,16 +211,17 @@ void osd_vlq_show(bool bShow) {
210211
// = 0x00 | Channel Show Time
211212
uint8_t channel_osd_mode;
212213

213-
char *channel2str(uint8_t channel) // channel=1:10
214+
char *channel2str(uint8_t band, uint8_t channel) // channel=[1:18]
214215
{
215-
static char *ChannelName[] = {
216-
"R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8",
217-
"F2", "F4", ""};
216+
static char *ChannelName[2][10] = {
217+
{"R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "F2", "F4"},
218+
{"L1", "L2", "L3", "L4", "L5", "L6", "L7", "L8", " ", " "},
219+
};
218220

219-
if ((channel > 0) && (channel < 11))
220-
return ChannelName[channel - 1];
221+
if ((channel > 0) && (channel <= CHANNEL_NUM))
222+
return ChannelName[band][channel - 1];
221223
else
222-
return ChannelName[0];
224+
return ChannelName[band][0];
223225
}
224226

225227
void osd_channel_show(bool bShow) {
@@ -228,14 +230,14 @@ void osd_channel_show(bool bShow) {
228230
char buf[32];
229231

230232
if (channel_osd_mode & 0x80) {
231-
ch = channel_osd_mode & 0xF;
233+
ch = channel_osd_mode & 0x7F;
232234
color = lv_color_make(0xFF, 0x20, 0x20);
233-
sprintf(buf, " To %s? ", channel2str(ch));
235+
sprintf(buf, " To %s? ", channel2str(g_setting.source.hdzero_band, ch));
234236
lv_obj_set_style_bg_opa(g_osd_hdzero.channel[is_fhd], LV_OPA_100, 0);
235237
} else {
236-
ch = g_setting.scan.channel & 0xF;
238+
ch = g_setting.scan.channel & 0x7F;
237239
color = lv_color_make(0xFF, 0xFF, 0xFF);
238-
sprintf(buf, "CH:%s", channel2str(ch));
240+
sprintf(buf, "CH:%s", channel2str(g_setting.source.hdzero_band, ch));
239241
lv_obj_set_style_bg_opa(g_osd_hdzero.channel[is_fhd], 0, 0);
240242
}
241243

src/core/osd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void osd_hdzero_update(void);
8282
void osd_rec_update(bool enable);
8383
void osd_show(bool show);
8484
void osd_update_element_positions();
85-
char *channel2str(uint8_t channel);
85+
char *channel2str(uint8_t band, uint8_t channel);
8686
void load_fc_osd_font(uint8_t);
8787
void *thread_osd(void *ptr);
8888
void osd_resource_path(char *buf, const char *fmt, osd_resource_t osd_resource_type, ...);

0 commit comments

Comments
 (0)