Skip to content

Commit

Permalink
suppoer E1 and F1 channel
Browse files Browse the repository at this point in the history
  • Loading branch information
ligenxxxx committed Nov 4, 2023
1 parent aaaa6be commit 96af9ed
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 48 deletions.
6 changes: 3 additions & 3 deletions src/core/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ uint8_t channel_osd_mode;

char *channel2str(uint8_t band, uint8_t channel) // channel=[1:18]
{
static char *ChannelName[2][10] = {
{"R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "F2", "F4"},
{"L1", "L2", "L3", "L4", "L5", "L6", "L7", "L8", " ", " "},
static char *ChannelName[2][12] = {
{"R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "E1", "F1", "F2", "F4"},
{"L1", "L2", "L3", "L4", "L5", "L6", "L7", "L8", " ", " ", " ", " "},
};

if ((channel > 0) && (channel <= CHANNEL_NUM))
Expand Down
54 changes: 39 additions & 15 deletions src/driver/dm6302.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "i2c.h"
#include "uart.h"

#define WAIT(ms) usleep((ms)*1000)
#define WAIT(ms) usleep((ms) * 1000)

// DM6302: RF receiver
/* �����ź�:
Expand Down Expand Up @@ -135,7 +135,8 @@ void SPI_Write(uint8_t sel, uint8_t page, uint16_t addr, uint32_t dat) {
}

// ����Ƶ��
uint32_t tab[3][18] = {
uint32_t tab[3][20] = {
// 0x120
{
// race band
0x3741,
Expand All @@ -146,9 +147,15 @@ uint32_t tab[3][18] = {
0x390F,
0x396C,
0x39C8,
// fatshark band
0x3840,
0x38A4,

// e band
0x38DF, // E1

// fatshark band
0x3938, // F1
0x3840, // F2
0x38A4, // F4

// low band
0x3574,
0x35D2,
Expand All @@ -159,6 +166,7 @@ uint32_t tab[3][18] = {
0x37AA,
0x3809,
},
// 0x104
{
// race band
0x93,
Expand All @@ -169,9 +177,15 @@ uint32_t tab[3][18] = {
0x98,
0x99,
0x9A,

// e band
0x94, // E1

// fatshark band
0x96,
0x97,
0x95, // F1
0x96, // F2
0x97, // F4

// low band
0x8B,
0x8C,
Expand All @@ -182,6 +196,7 @@ uint32_t tab[3][18] = {
0x91,
0x92,
},
// 0x108
{
// race band
0xB00000,
Expand All @@ -192,9 +207,15 @@ uint32_t tab[3][18] = {
0x52AAAB,
0x400000,
0x2D5555,

// e band
0X122AAAB, // E1

// fatshark band
0x000000,
0x155555,
0XF55555, // F1
0x000000, // F2
0x155555, // F4

// low band
0x1455555,
0x132AAAB,
Expand All @@ -208,28 +229,31 @@ uint32_t tab[3][18] = {
};

void DM6302_SetChannel(uint8_t band, uint8_t ch) {
// band
// 1: lowband
// 0: race band
if (band == 1)
ch = ch + 10;
ch = ch + 12;
SPI_Write(0, 0x6, 0xFF0, 0x00000018);
SPI_Write(0, 0x3, 0x130, 0x00000013);
SPI_Write(0, 0x3, 0x134, 0x00000013);
SPI_Write(0, 0x3, 0x138, 0x00000370);
SPI_Write(0, 0x3, 0x13C, 0x00000410);
SPI_Write(0, 0x3, 0x140, 0x00000000);
if (band == 1) {
if (band == 1 || ch == 8 || ch == 9) {
SPI_Write(0, 0x3, 0x144, 0x15240735);
} else {
SPI_Write(0, 0x3, 0x144, 0x0D640735);
}

SPI_Write(0, 0x3, 0x148, 0x01017F03);
if (band == 1) {
if (band == 1 || ch == 8 || ch == 9) {
SPI_Write(0, 0x3, 0x14C, 0x021288A2);
} else {
SPI_Write(0, 0x3, 0x14C, 0x022288A2);
}
SPI_Write(0, 0x3, 0x150, 0x00FFCF33);
if (band == 1) {
if (band == 1 || ch == 8 || ch == 9) {
SPI_Write(0, 0x3, 0x154, 0x1F2C3840);
SPI_Write(0, 0x3, 0x128, 0x00008031);
} else {
Expand All @@ -241,7 +265,7 @@ void DM6302_SetChannel(uint8_t band, uint8_t ch) {
SPI_Write(0, 0x3, 0x11C, 0x00000002);
SPI_Write(0, 0x3, 0x118, 0x00000001);
SPI_Write(0, 0x3, 0x118, 0x00000000);
if (band == 1) {
if (band == 1 || ch == 8 || ch == 9) {
SPI_Write(0, 0x3, 0x128, 0x00008031);
} else {
SPI_Write(0, 0x3, 0x128, 0x00008030);
Expand All @@ -256,7 +280,7 @@ void DM6302_SetChannel(uint8_t band, uint8_t ch) {
SPI_Write(0, 0x3, 0x100, 0x00000000);
SPI_Write(0, 0x3, 0x100, 0x00000003);
SPI_Write(0, 0x3, 0x150, 0x000333B3);
if (band == 1) {
if (band == 1 || ch == 8 || ch == 9) {
SPI_Write(0, 0x3, 0x140, 0x07070002);
} else {
SPI_Write(0, 0x3, 0x140, 0x07070000);
Expand Down
1 change: 0 additions & 1 deletion src/driver/dm6302.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

// #define _DEBUG_DM6300

#define FREQ_NUM 18
typedef enum {
DM5680_L = 0,
DM5680_R,
Expand Down
58 changes: 30 additions & 28 deletions src/ui/page_scannow.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ typedef struct {
lv_obj_t *img1;
} channel_t;

channel_t channel_tb[10];
channel_status_t channel_status_tb[10];
#define SCAN_CH_NUM 12
channel_t channel_tb[SCAN_CH_NUM];
channel_status_t channel_status_tb[SCAN_CH_NUM];

////////////////////////////////////////////////////////////////////////////////////////////////////
int valid_channel_tb[10];
int valid_channel_tb[SCAN_CH_NUM];
int user_select_index = 0;

// local
Expand All @@ -77,7 +78,7 @@ static lv_coord_t col_dsc2[] = {120, 80, 80, 180, 100, 80, 80, 180, LV_GRID_TEMP
static lv_coord_t row_dsc2[] = {60, 60, 60, 60, 60, 60, 60, 60, 60, 60, LV_GRID_TEMPLATE_LAST};

static void select_signal(channel_t *channel) {
for (int i = 0; i < 10; i++) {
for (int i = 0; i < SCAN_CH_NUM; i++) {
if (channel_status_tb[i].is_valid) {
lv_img_set_src(channel_tb[i].img0, &img_signal_status2);
} else {
Expand Down Expand Up @@ -156,35 +157,32 @@ static void create_channel_switch(lv_obj_t *parent, int col, int row, channel_t
}

void page_scannow_set_channel_label(void) {
static const char *race_band_channel_str[] = {"R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8"};
static const char *fatshark_band_channel_str[] = {"F2", "F4"};
static const char *race_band_channel_str[] = {"R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "E1", "F1", "F2", "F4"};
static const char *low_band_channel_str[] = {"L1", "L2", "L3", "L4", "L5", "L6", "L7", "L8"};
uint8_t i;

// set channel label
if (g_setting.source.hdzero_band == RACE_BAND) {
for (i = 0; i < 8; i++) {
// race band
for (i = 0; i < SCAN_CH_NUM; i++) {
lv_label_set_text(channel_tb[i].label, race_band_channel_str[i]);
}
lv_label_set_text(channel_tb[8].label, fatshark_band_channel_str[0]);
lv_label_set_text(channel_tb[9].label, fatshark_band_channel_str[1]);

lv_obj_clear_flag(channel_tb[8].img0, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(channel_tb[8].label, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(channel_tb[8].img1, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(channel_tb[9].img0, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(channel_tb[9].label, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(channel_tb[9].img1, LV_OBJ_FLAG_HIDDEN);

for (i = 8; i < SCAN_CH_NUM; i++) {
lv_obj_clear_flag(channel_tb[i].img0, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(channel_tb[i].label, LV_OBJ_FLAG_HIDDEN);
lv_obj_clear_flag(channel_tb[i].img1, LV_OBJ_FLAG_HIDDEN);
}
} else {
// lowband
for (i = 0; i < 8; i++) {
lv_label_set_text(channel_tb[i].label, low_band_channel_str[i]);
}
lv_obj_add_flag(channel_tb[8].img0, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(channel_tb[8].label, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(channel_tb[8].img1, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(channel_tb[9].img0, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(channel_tb[9].label, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(channel_tb[9].img1, LV_OBJ_FLAG_HIDDEN);
for (i = 8; i < SCAN_CH_NUM; i++) {
lv_obj_add_flag(channel_tb[i].img0, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(channel_tb[i].label, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(channel_tb[i].img1, LV_OBJ_FLAG_HIDDEN);
}
}
}

Expand Down Expand Up @@ -254,12 +252,16 @@ static lv_obj_t *page_scannow_create(lv_obj_t *parent, panel_arr_t *arr) {
lv_obj_set_style_grid_row_dsc_array(cont2, row_dsc2, 0);

// create channel
uint8_t i;
uint8_t col_offset = 1;
uint8_t row_offset = 0;

for (int i = 0; i < 8; i++) {
create_channel_switch(cont2, ((i >> 2) << 2) + 1, i & 0x03, &channel_tb[i]);
create_channel_switch(cont2, ((i >> 2) << 2) + col_offset, i & 0x03, &channel_tb[i]);
}
for (int i = 0; i < 2; i++) {
create_channel_switch(cont2, (i << 2) + 1, 4, &channel_tb[8 + i]);

row_offset = 4;
for (int i = 0; i < 4; i++) {
create_channel_switch(cont2, ((i >> 1) << 2) + col_offset, row_offset + (i & 0x01), &channel_tb[8 + i]);
}
page_scannow_set_channel_label();

Expand All @@ -276,7 +278,7 @@ static void user_select_signal(void) {

static void user_clear_signal(void) {
user_select_index = 0;
for (int i = 0; i < 10; i++) {
for (int i = 0; i < SCAN_CH_NUM; i++) {
lv_img_set_src(channel_tb[i].img0, &img_signal_status);
lv_img_set_src(channel_tb[i].img1, &img_ant1);
}
Expand Down Expand Up @@ -320,7 +322,7 @@ int8_t scan_now(void) {
lv_timer_handler();

// clear
for (ch = 0; ch < 10; ch++) {
for (ch = 0; ch < SCAN_CH_NUM; ch++) {
valid_channel_tb[ch] = -1;
channel_status_tb[ch].is_valid = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/page_scannow.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "ui/ui_main_menu.h"
#include <lvgl/lvgl.h>

#define CHANNEL_NUM (g_setting.source.hdzero_band == RACE_BAND ? 10 : 8)
#define CHANNEL_NUM (g_setting.source.hdzero_band == RACE_BAND ? 12 : 8)

typedef enum {
RACE_BAND = 0,
Expand Down

0 comments on commit 96af9ed

Please sign in to comment.