diff --git a/mkapp/app/setting.ini b/mkapp/app/setting.ini index eb81333a..410d47a2 100644 --- a/mkapp/app/setting.ini +++ b/mkapp/app/setting.ini @@ -22,6 +22,8 @@ power_ana_rx = 1 [source] analog_format=0 +hdzero_band=0 +hdzero_bw=0 [record] mode_manual=false diff --git a/mkapp/hal/HDZGOGGLE_RX.bin b/mkapp/hal/HDZGOGGLE_RX.bin index 06150cdf..d1cf62a2 100644 Binary files a/mkapp/hal/HDZGOGGLE_RX.bin and b/mkapp/hal/HDZGOGGLE_RX.bin differ diff --git a/mkapp/hal/HDZGOGGLE_VA.bin b/mkapp/hal/HDZGOGGLE_VA.bin index 2f2f4ade..dc5eb184 100644 Binary files a/mkapp/hal/HDZGOGGLE_VA.bin and b/mkapp/hal/HDZGOGGLE_VA.bin differ diff --git a/mkapp/hal/ver.txt b/mkapp/hal/ver.txt index 53866a1a..268dbeea 100644 --- a/mkapp/hal/ver.txt +++ b/mkapp/hal/ver.txt @@ -1 +1 @@ -73-184 +74-186 diff --git a/src/core/app_state.c b/src/core/app_state.c index 488da5c1..d3c41cc8 100644 --- a/src/core/app_state.c +++ b/src/core/app_state.c @@ -22,7 +22,7 @@ app_state_t g_app_state = APP_STATE_MAINMENU; -extern int valid_channel_tb[11]; +extern int valid_channel_tb[10]; extern int user_select_index; void app_state_push(app_state_t state) { @@ -114,11 +114,11 @@ void app_switch_to_hdzero(bool is_default) { ini_putl("scan", "channel", g_setting.scan.channel, SETTING_INI); } - HDZero_open((ch >> 7) & 1); - ch &= 0xF; + HDZero_open(g_setting.source.hdzero_bw); + ch &= 0x7f; - LOGI("switch to ch:%x, CAM_MODE=%d 4:3=%d", g_setting.scan.channel, CAM_MODE, cam_4_3); - DM6302_SetChannel(ch); + 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); + DM6302_SetChannel(g_setting.source.hdzero_band, ch); DM5680_clear_vldflg(); DM5680_req_vldflg(); progress_bar.start = 0; diff --git a/src/core/elrs.c b/src/core/elrs.c index ee8c6476..852f09eb 100644 --- a/src/core/elrs.c +++ b/src/core/elrs.c @@ -211,12 +211,18 @@ void msp_process_packet() { if (packet.type == MSP_PACKET_COMMAND) { switch (packet.function) { case MSP_GET_BAND_CHAN: { - uint8_t chan, ch; - ch = g_setting.scan.channel & 0xF; - if (ch <= 8) { - chan = ch - 1 + 4 * 8; // Map R1..8 - } else { - chan = (ch - 9) * 2 + 3 * 8 + 1; // Map F2/4 + uint8_t chan, ch, band; + ch = g_setting.scan.channel; + band = g_setting.source.hdzero_band; + + if (band == SETTING_SOURCES_HDZERO_BAND_RACEBAND) { + if (ch <= 8) { + chan = ch - 1 + (4 * 8); // Map R1..8 + } else { + chan = ((ch - 9) * 2) + (3 * 8) + 1; // Map F2/4 + } + } else { // if (band == SETTING_SOURCES_HDZERO_BAND_LOWBAND) + chan = ch - 1 + 5 * 8; // Map L1..8 } msp_send_packet(MSP_GET_BAND_CHAN, MSP_PACKET_RESPONSE, 1, &chan); } break; @@ -399,15 +405,21 @@ bool elrs_headtracking_enabled() { } void msp_channel_update() { - // Channel 1...10 for R1...8, F2 and F4 + // Channel 1...18 for R1...8, F2 and F4, L1...8 uint8_t const ch = g_setting.scan.channel; + uint8_t const band = g_setting.source.hdzero_band; uint8_t chan; - if (ch == 0 || 10 < ch) + + if (ch == 0 || ch > CHANNEL_NUM) return; // Invalid value -> ignore - if (ch <= 8) { - chan = ch - 1 + (4 * 8); // Map R1..8 - } else { - chan = ((ch - 9) * 2) + (3 * 8) + 1; // Map F2/4 + if (band == SETTING_SOURCES_HDZERO_BAND_RACEBAND) { + if (ch <= 8) { + chan = ch - 1 + (4 * 8); // Map R1..8 + } else { + chan = ((ch - 9) * 2) + (3 * 8) + 1; // Map F2/4 + } + } else { // if (band == SETTING_SOURCES_HDZERO_BAND_LOWBAND) + chan = ch - 1 + 5 * 8; // Map L1..8 } msp_send_packet(MSP_SET_BAND_CHAN, MSP_PACKET_COMMAND, sizeof(chan), &chan); LOGI("MSPv2 MSP_SET_BAND_CHAN %d sent", chan); diff --git a/src/core/ht.c b/src/core/ht.c index 98d7bd48..8b25533d 100644 --- a/src/core/ht.c +++ b/src/core/ht.c @@ -16,8 +16,8 @@ #include "bmi270/accel_gyro.h" #include "core/settings.h" -#include "driver/dm6302.h" #include "driver/beep.h" +#include "driver/dm6302.h" #include "driver/hardware.h" #include "driver/oled.h" #include "ui/page_common.h" @@ -103,7 +103,7 @@ static void detect_motion(bool is_moving) { beep(); OLED_ON(0); // Turn off OLED - if (g_hw_stat.source_mode == HW_SRC_MODE_HDZERO) { + if (g_hw_stat.source_mode == SOURCE_MODE_HDZERO) { HDZero_Close(); // Turn off RF } @@ -125,10 +125,10 @@ static void detect_motion(bool is_moving) { cnt++; if (cnt == 2) { - if (g_hw_stat.source_mode == HW_SRC_MODE_HDZERO) { + if (g_hw_stat.source_mode == SOURCE_MODE_HDZERO) { uint8_t ch = g_setting.scan.channel - 1; - HDZero_open((ch >> 7) & 1); - DM6302_SetChannel(ch & 0xF); + HDZero_open(g_setting.source.hdzero_bw); + DM6302_SetChannel(g_setting.source.hdzero_band, ch & 0x7F); } LOGI("OLED ON from protection."); OLED_Brightness(g_setting.image.oled); diff --git a/src/core/input_device.c b/src/core/input_device.c index 21f8ab3f..322088f5 100644 --- a/src/core/input_device.c +++ b/src/core/input_device.c @@ -98,7 +98,7 @@ void tune_channel(uint8_t action) { switch (action) { case DIAL_KEY_UP: // Tune up - if (channel == 10) + if (channel == CHANNEL_NUM) channel = 1; else channel++; @@ -106,7 +106,7 @@ void tune_channel(uint8_t action) { case DIAL_KEY_DOWN: // Tune down if (channel == 1) - channel = 10; + channel = CHANNEL_NUM; else channel--; break; diff --git a/src/core/osd.c b/src/core/osd.c index ae61216f..08126d8b 100644 --- a/src/core/osd.c +++ b/src/core/osd.c @@ -30,6 +30,7 @@ #include "driver/nct75.h" #include "ui/page_common.h" #include "ui/page_fans.h" +#include "ui/page_scannow.h" #include "ui/ui_image_setting.h" #include "ui/ui_porting.h" @@ -210,16 +211,17 @@ void osd_vlq_show(bool bShow) { // = 0x00 | Channel Show Time uint8_t channel_osd_mode; -char *channel2str(uint8_t channel) // channel=1:10 +char *channel2str(uint8_t band, uint8_t channel) // channel=[1:18] { - static char *ChannelName[] = { - "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", - "F2", "F4", ""}; + static char *ChannelName[2][10] = { + {"R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "F2", "F4"}, + {"L1", "L2", "L3", "L4", "L5", "L6", "L7", "L8", " ", " "}, + }; - if ((channel > 0) && (channel < 11)) - return ChannelName[channel - 1]; + if ((channel > 0) && (channel <= CHANNEL_NUM)) + return ChannelName[band][channel - 1]; else - return ChannelName[0]; + return ChannelName[band][0]; } void osd_channel_show(bool bShow) { @@ -228,14 +230,14 @@ void osd_channel_show(bool bShow) { char buf[32]; if (channel_osd_mode & 0x80) { - ch = channel_osd_mode & 0xF; + ch = channel_osd_mode & 0x7F; color = lv_color_make(0xFF, 0x20, 0x20); - sprintf(buf, " To %s? ", channel2str(ch)); + sprintf(buf, " To %s? ", channel2str(g_setting.source.hdzero_band, ch)); lv_obj_set_style_bg_opa(g_osd_hdzero.channel[is_fhd], LV_OPA_100, 0); } else { - ch = g_setting.scan.channel & 0xF; + ch = g_setting.scan.channel & 0x7F; color = lv_color_make(0xFF, 0xFF, 0xFF); - sprintf(buf, "CH:%s", channel2str(ch)); + sprintf(buf, "CH:%s", channel2str(g_setting.source.hdzero_band, ch)); lv_obj_set_style_bg_opa(g_osd_hdzero.channel[is_fhd], 0, 0); } diff --git a/src/core/osd.h b/src/core/osd.h index e3e44dda..d9610452 100644 --- a/src/core/osd.h +++ b/src/core/osd.h @@ -82,7 +82,7 @@ void osd_hdzero_update(void); void osd_rec_update(bool enable); void osd_show(bool show); void osd_update_element_positions(); -char *channel2str(uint8_t channel); +char *channel2str(uint8_t band, uint8_t channel); void load_fc_osd_font(uint8_t); void *thread_osd(void *ptr); void osd_resource_path(char *buf, const char *fmt, osd_resource_t osd_resource_type, ...); diff --git a/src/core/settings.c b/src/core/settings.c index ef3f8108..ed0ebd93 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -185,6 +185,11 @@ const setting_t g_setting_defaults = { .logging = false, .selftest = false, }, + .source = { + .analog_format = SETTING_SOURCES_ANALOG_FORMAT_NTSC, + .hdzero_band = SETTING_SOURCES_HDZERO_BAND_RACEBAND, + .hdzero_bw = SETTING_SOURCES_HDZERO_BW_WIDE, + }, }; int settings_put_osd_element_shown(bool show, char *config_name) { @@ -296,6 +301,8 @@ void settings_load(void) { // source g_setting.source.analog_format = ini_getl("source", "analog_format", g_setting_defaults.source.analog_format, SETTING_INI); + g_setting.source.hdzero_band = ini_getl("source", "hdzero_band", g_setting_defaults.source.hdzero_band, SETTING_INI); + g_setting.source.hdzero_bw = ini_getl("source", "hdzero_bw", g_setting_defaults.source.hdzero_bw, SETTING_INI); // autoscan g_setting.autoscan.status = ini_getl("autoscan", "status", g_setting_defaults.autoscan.status, SETTING_INI); diff --git a/src/core/settings.h b/src/core/settings.h index 42a6daa4..e961d8f0 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -197,9 +197,19 @@ typedef enum { SETTING_SOURCES_ANALOG_FORMAT_NTSC = 0, SETTING_SOURCES_ANALOG_FORMAT_PAL = 1 } setting_sources_analog_format_t; +typedef enum { + SETTING_SOURCES_HDZERO_BAND_RACEBAND = 0, + SETTING_SOURCES_HDZERO_BAND_LOWBAND = 1 +} setting_sources_hdzero_band_t; +typedef enum { + SETTING_SOURCES_HDZERO_BW_WIDE = 0, + SETTING_SOURCES_HDZERO_BW_NARROW = 1 +} setting_sources_hdzero_bw_t; typedef struct { setting_sources_analog_format_t analog_format; // 0=NTSC, 1= PAL + setting_sources_hdzero_band_t hdzero_band; + setting_sources_hdzero_bw_t hdzero_bw; } setting_sources_t; typedef struct { diff --git a/src/driver/dm6302.c b/src/driver/dm6302.c index 6ad8a059..cb3e70b5 100644 --- a/src/driver/dm6302.c +++ b/src/driver/dm6302.c @@ -135,29 +135,117 @@ void SPI_Write(uint8_t sel, uint8_t page, uint16_t addr, uint32_t dat) { } // ����Ƶ�� -uint32_t tab[3][FREQ_NUM] = { - {0x3741, 0x379D, 0x37FA, 0x3856, 0x38B3, 0x390F, 0x396C, 0x39C8, 0x3840, 0x38A4}, - {0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x96, 0x97}, - {0xB00000, 0x9D5555, 0x8AAAAB, 0x780000, 0x655555, 0x52AAAB, 0x400000, 0x2D5555, 0x000000, 0x155555}}; - -void DM6302_SetChannel(uint8_t ch) { +uint32_t tab[3][18] = { + { + // race band + 0x3741, + 0x379D, + 0x37FA, + 0x3856, + 0x38B3, + 0x390F, + 0x396C, + 0x39C8, + // fatshark band + 0x3840, + 0x38A4, + // low band + 0x3574, + 0x35D2, + 0x3631, + 0x368F, + 0x36ED, + 0x374C, + 0x37AA, + 0x3809, + }, + { + // race band + 0x93, + 0x94, + 0x95, + 0x96, + 0x97, + 0x98, + 0x99, + 0x9A, + // fatshark band + 0x96, + 0x97, + // low band + 0x8B, + 0x8C, + 0x8D, + 0x8E, + 0x8F, + 0x90, + 0x91, + 0x92, + }, + { + // race band + 0xB00000, + 0x9D5555, + 0x8AAAAB, + 0x780000, + 0x655555, + 0x52AAAB, + 0x400000, + 0x2D5555, + // fatshark band + 0x000000, + 0x155555, + // low band + 0x1455555, + 0x132AAAB, + 0x1200000, + 0x10D5555, + 0xFAAAAB, + 0xE80000, + 0xD55555, + 0xC2AAAB, + }, +}; + +void DM6302_SetChannel(uint8_t band, uint8_t ch) { + if (band == 1) + ch = ch + 10; 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); - SPI_Write(0, 0x3, 0x144, 0x0D640735); + if (band == 1) { + SPI_Write(0, 0x3, 0x144, 0x15240735); + } else { + SPI_Write(0, 0x3, 0x144, 0x0D640735); + } + SPI_Write(0, 0x3, 0x148, 0x01017F03); - SPI_Write(0, 0x3, 0x14C, 0x022288A2); + if (band == 1) { + SPI_Write(0, 0x3, 0x14C, 0x021288A2); + } else { + SPI_Write(0, 0x3, 0x14C, 0x022288A2); + } SPI_Write(0, 0x3, 0x150, 0x00FFCF33); - SPI_Write(0, 0x3, 0x154, 0x1F0C3440); - SPI_Write(0, 0x3, 0x128, 0x00008030); + if (band == 1) { + SPI_Write(0, 0x3, 0x154, 0x1F2C3840); + SPI_Write(0, 0x3, 0x128, 0x00008031); + } else { + SPI_Write(0, 0x3, 0x154, 0x1F0C3440); + SPI_Write(0, 0x3, 0x128, 0x00008030); + } SPI_Write(0, 0x3, 0x120, tab[0][ch]); // ch + SPI_Write(0, 0x3, 0x11C, 0x00000002); SPI_Write(0, 0x3, 0x118, 0x00000001); SPI_Write(0, 0x3, 0x118, 0x00000000); - SPI_Write(0, 0x3, 0x128, 0x00008030); + if (band == 1) { + SPI_Write(0, 0x3, 0x128, 0x00008031); + } else { + SPI_Write(0, 0x3, 0x128, 0x00008030); + } SPI_Write(0, 0x3, 0x120, tab[0][ch]); // ch SPI_Write(0, 0x3, 0x11C, 0x00000003); SPI_Write(0, 0x3, 0x118, 0x00000001); @@ -168,7 +256,11 @@ void DM6302_SetChannel(uint8_t ch) { SPI_Write(0, 0x3, 0x100, 0x00000000); SPI_Write(0, 0x3, 0x100, 0x00000003); SPI_Write(0, 0x3, 0x150, 0x000333B3); - SPI_Write(0, 0x3, 0x140, 0x07070000); + if (band == 1) { + SPI_Write(0, 0x3, 0x140, 0x07070002); + } else { + SPI_Write(0, 0x3, 0x140, 0x07070000); + } SPI_Write(0, 0x3, 0x130, 0x00000010); } @@ -1080,8 +1172,8 @@ void DM6302_Init14(uint8_t sel, uint8_t bw) { SPI_Write(sel, 0x3, 0xB4C, 0x10001000); if (bw) { - SPI_Write(sel, 0x3, 0x90C, 0x9EA3C008); - SPI_Write(sel, 0x3, 0xB0C, 0x9EA3C008); + SPI_Write(sel, 0x3, 0x90C, 0x9EA2C008); + SPI_Write(sel, 0x3, 0xB0C, 0x9EA2C008); } else { SPI_Write(sel, 0x3, 0x90C, 0x9E22E0F0); SPI_Write(sel, 0x3, 0xB0C, 0x9E22E0F0); diff --git a/src/driver/dm6302.h b/src/driver/dm6302.h index 6ac74292..915f0006 100644 --- a/src/driver/dm6302.h +++ b/src/driver/dm6302.h @@ -6,7 +6,7 @@ // #define _DEBUG_DM6300 -#define FREQ_NUM 10 +#define FREQ_NUM 18 typedef enum { DM5680_L = 0, DM5680_R, @@ -29,7 +29,7 @@ typedef enum { } cmd_5680_t; int DM6302_init(uint8_t freq, uint8_t bw); -void DM6302_SetChannel(uint8_t ch); +void DM6302_SetChannel(uint8_t band, uint8_t ch); void DM6302_openM0(uint32_t open); void DM6302_get_gain(uint8_t *gain); diff --git a/src/driver/hardware.c b/src/driver/hardware.c index 6c261598..138e0cac 100644 --- a/src/driver/hardware.c +++ b/src/driver/hardware.c @@ -36,8 +36,8 @@ int fhd_req = 0; pthread_mutex_t hardware_mutex; void hw_stat_init() { - g_hw_stat.source_mode = HW_SRC_MODE_UI; - g_hw_stat.vdpo_tmg = HW_VDPO_1080P50; + g_hw_stat.source_mode = SOURCE_MODE_UI; + g_hw_stat.vdpo_tmg = VDPO_TMG_1080P50; g_hw_stat.hdz_bw = 0; g_hw_stat.hdzero_open = 0; @@ -48,7 +48,7 @@ void hw_stat_init() { g_hw_stat.av_valid[0] = g_hw_stat.av_valid[1] = 0; g_hw_stat.hdmiin_valid = 0; - g_hw_stat.hdmiin_vtmg = 0; + g_hw_stat.hdmiin_vtmg = HDMIIN_VTMG_UNKNOW; g_hw_stat.IS_TP2825_L = 0; pthread_mutex_init(&hardware_mutex, NULL); @@ -58,7 +58,7 @@ void Display_VO_SWITCH(uint8_t sel) // 0 = UI; 1 = HDZERO or AV_in or HDMI_in { I2C_Write(ADDR_FPGA, 0x20, sel); - if (sel && g_hw_stat.hdzero_open && (g_hw_stat.source_mode == HW_SRC_MODE_HDZERO)) + if (sel && g_hw_stat.hdzero_open && (g_hw_stat.source_mode == SOURCE_MODE_HDZERO)) DM6302_openM0(1); else DM6302_openM0(0); @@ -73,11 +73,11 @@ void OLED_ON(int bON) { } void Display_UI_init() { - g_hw_stat.source_mode = HW_SRC_MODE_UI; + g_hw_stat.source_mode = SOURCE_MODE_UI; I2C_Write(ADDR_FPGA, 0x8C, 0x00); system_exec("dispw -s vdpo 1080p50"); - g_hw_stat.vdpo_tmg = HW_VDPO_1080P50; + g_hw_stat.vdpo_tmg = VDPO_TMG_1080P50; Display_VO_SWITCH(0); I2C_Write(ADDR_FPGA, 0x8d, 0x10); @@ -106,7 +106,7 @@ void Display_720P60_50_t(int mode, uint8_t is_43) // fps: 0=50, 1=60 I2C_Write(ADDR_FPGA, 0x8C, 0x00); system_exec("dispw -s vdpo 720p60"); - g_hw_stat.vdpo_tmg = HW_VDPO_720P60; + g_hw_stat.vdpo_tmg = VDPO_TMG_720P60; I2C_Write(ADDR_FPGA, 0x8d, 0x14); I2C_Write(ADDR_FPGA, 0x8e, 0x04); I2C_Write(ADDR_AL, 0x14, 0x00); @@ -121,7 +121,7 @@ void Display_720P60_50_t(int mode, uint8_t is_43) // fps: 0=50, 1=60 I2C_Write(ADDR_FPGA, 0x8C, 0x01); - g_hw_stat.source_mode = HW_SRC_MODE_HDZERO; + g_hw_stat.source_mode = SOURCE_MODE_HDZERO; Display_VO_SWITCH(1); OLED_display(1); system_exec("aww 0x06542018 0x00000044"); // disable horizontal chroma FIR filter. @@ -132,7 +132,7 @@ void Display_720P90_t(int mode) { I2C_Write(ADDR_FPGA, 0x8C, 0x00); system_exec("dispw -s vdpo 720p90"); - g_hw_stat.vdpo_tmg = HW_VDPO_720P90; + g_hw_stat.vdpo_tmg = VDPO_TMG_720P90; I2C_Write(ADDR_FPGA, 0x8d, 0x10); I2C_Write(ADDR_FPGA, 0x8e, 0x04); I2C_Write(ADDR_AL, 0x14, 0x00); @@ -144,7 +144,7 @@ void Display_720P90_t(int mode) { I2C_Write(ADDR_FPGA, 0x8C, 0x01); - g_hw_stat.source_mode = HW_SRC_MODE_HDZERO; + g_hw_stat.source_mode = SOURCE_MODE_HDZERO; Display_VO_SWITCH(1); OLED_display(1); system_exec("aww 0x06542018 0x00000044"); // disable horizontal chroma FIR filter. @@ -155,7 +155,7 @@ void Display_1080P30_t(int mode) { I2C_Write(ADDR_FPGA, 0x8C, 0x00); system_exec("dispw -s vdpo 1080p60"); - g_hw_stat.vdpo_tmg = HW_VDPO_1080P60; + g_hw_stat.vdpo_tmg = VDPO_TMG_1080P60; I2C_Write(ADDR_FPGA, 0x8d, 0x10); I2C_Write(ADDR_FPGA, 0x8e, 0x04); I2C_Write(ADDR_AL, 0x14, 0x00); @@ -168,7 +168,7 @@ void Display_1080P30_t(int mode) { I2C_Write(ADDR_FPGA, 0x8C, 0x01); - g_hw_stat.source_mode = HW_SRC_MODE_HDZERO; + g_hw_stat.source_mode = SOURCE_MODE_HDZERO; Display_VO_SWITCH(1); OLED_display(1); system_exec("aww 0x06542018 0x00000044"); // disable horizontal chroma FIR filter. @@ -222,11 +222,11 @@ void HDZero_Close() { void AV_Mode_Switch_fpga(int is_pal) { if (is_pal) { system_exec("dispw -s vdpo 720p50"); - g_hw_stat.vdpo_tmg = HW_VDPO_720P50; + g_hw_stat.vdpo_tmg = VDPO_TMG_720P50; I2C_Write(ADDR_FPGA, 0x80, 0x10); } else { system_exec("dispw -s vdpo 720p60"); - g_hw_stat.vdpo_tmg = HW_VDPO_720P60; + g_hw_stat.vdpo_tmg = VDPO_TMG_720P60; I2C_Write(ADDR_FPGA, 0x80, 0x00); } I2C_Write(ADDR_FPGA, 0x06, 0x0F); @@ -234,7 +234,7 @@ void AV_Mode_Switch_fpga(int is_pal) { } void AV_Mode_Switch(int is_pal) { - int tmg = is_pal ? HW_VDPO_720P50 : HW_VDPO_720P60; + int tmg = is_pal ? VDPO_TMG_720P50 : VDPO_TMG_720P60; if (g_hw_stat.vdpo_tmg != tmg) { OLED_display(0); @@ -271,7 +271,7 @@ void Source_AV(uint8_t sel) // 0=AV in, 1=AV module I2C_Write(ADDR_FPGA, 0x8C, 0x02); - g_hw_stat.source_mode = HW_SRC_MODE_AV; + g_hw_stat.source_mode = SOURCE_MODE_AV; Display_VO_SWITCH(1); OLED_display(1); @@ -293,7 +293,7 @@ void Source_HDMI_in() { I2C_Write(ADDR_FPGA, 0x8C, 0x04); I2C_Write(ADDR_FPGA, 0x84, 0x00); - g_hw_stat.source_mode = HW_SRC_MODE_HDMIIN; + g_hw_stat.source_mode = SOURCE_MODE_HDMIIN; Display_VO_SWITCH(1); // OLED_display(1); @@ -308,7 +308,7 @@ int HDZERO_detect() // return = 1: vtmg to V536 changed pthread_mutex_lock(&hardware_mutex); - if (g_hw_stat.source_mode == HW_SRC_MODE_HDZERO) { + if (g_hw_stat.source_mode == SOURCE_MODE_HDZERO) { if (cam_mode_last != CAM_MODE) { // Camera mode changed LOGI("CAM_mode: %d->%d", cam_mode_last, CAM_MODE); @@ -375,7 +375,7 @@ int AV_in_detect() // return = 1: vtmg to V536 changed rdat = I2C_Read(ADDR_TP2825, 0x01); - if (g_hw_stat.source_mode == HW_SRC_MODE_UI) { // detect in UI mode + if (g_hw_stat.source_mode == SOURCE_MODE_UI) { // detect in UI mode TP2825_Set_Clamp(0); det = (rdat & 0x80) ? 0 : 1; @@ -391,7 +391,7 @@ int AV_in_detect() // return = 1: vtmg to V536 changed } det_cnt = det2_cnt = 0; - } else if (g_hw_stat.source_mode == HW_SRC_MODE_AV) { // detect in AV_in/Module_bay mode + } else if (g_hw_stat.source_mode == SOURCE_MODE_AV) { // detect in AV_in/Module_bay mode det = ((rdat & 0xAE) == (g_hw_stat.av_pal_w ? 0x28 : 0x2C)) ? 1 : 0; if (det_last != det) { @@ -481,18 +481,18 @@ void HDMI_in_detect() { static int vtmg_last = -1; static int cs_last = -1; static int last_vld = 0; - int vtmg, cs; + int vtmg, cs, freq_ref; pthread_mutex_lock(&hardware_mutex); - if ((g_hw_stat.source_mode == HW_SRC_MODE_UI) || (g_hw_stat.source_mode == HW_SRC_MODE_HDMIIN)) { + if ((g_hw_stat.source_mode == SOURCE_MODE_UI) || (g_hw_stat.source_mode == SOURCE_MODE_HDMIIN)) { last_vld = g_hw_stat.hdmiin_valid; g_hw_stat.hdmiin_valid = IT66021_Sig_det(); - if (g_hw_stat.source_mode == HW_SRC_MODE_HDMIIN) { + if (g_hw_stat.source_mode == SOURCE_MODE_HDMIIN) { if (g_hw_stat.hdmiin_valid) { - vtmg = IT66021_Get_VTMG(); + vtmg = IT66021_Get_VTMG(&freq_ref); if (vtmg_last != vtmg) { vtmg_last = vtmg; LOGI("IT66021: VTMG change: %d", vtmg); @@ -500,9 +500,13 @@ void HDMI_in_detect() { OLED_display(0); I2C_Write(ADDR_FPGA, 0x8C, 0x00); - if (vtmg == 1) { + switch (vtmg) { + case HDMIIN_VTMG_UNKNOW: + break; + + case HDMIIN_VTMG_1080P: system_exec("dispw -s vdpo 1080p50"); - g_hw_stat.vdpo_tmg = HW_VDPO_1080P50; + g_hw_stat.vdpo_tmg = VDPO_TMG_1080P50; // I2C_Write(ADDR_FPGA, 0x8d, 0x10); I2C_Write(ADDR_FPGA, 0x8e, 0x04); I2C_Write(ADDR_AL, 0x14, 0x00); @@ -513,30 +517,63 @@ void HDMI_in_detect() { I2C_Write(ADDR_FPGA, 0x8C, 0x04); I2C_Write(ADDR_FPGA, 0x06, 0x0F); OLED_display(1); - g_hw_stat.hdmiin_vtmg = 1; - } else if (vtmg == 2) { + g_hw_stat.hdmiin_vtmg = HDMIIN_VTMG_1080P; + break; + + case HDMIIN_VTMG_720P50: + system_exec("dispw -s vdpo 720p50"); + g_hw_stat.vdpo_tmg = VDPO_TMG_720P50; + // I2C_Write(ADDR_FPGA, 0x8d, 0x10); + I2C_Write(ADDR_FPGA, 0x8e, 0x04); + I2C_Write(ADDR_AL, 0x14, 0x00); + I2C_Write(ADDR_FPGA, 0x80, 0x40); + + OLED_SetTMG(1); + + I2C_Write(ADDR_FPGA, 0x8C, 0x04); + I2C_Write(ADDR_FPGA, 0x06, 0x0F); + OLED_display(1); + g_hw_stat.hdmiin_vtmg = HDMIIN_VTMG_720P50; + break; + + case HDMIIN_VTMG_720P60: + system_exec("dispw -s vdpo 720p60"); + g_hw_stat.vdpo_tmg = VDPO_TMG_720P60; + // I2C_Write(ADDR_FPGA, 0x8d, 0x10); + I2C_Write(ADDR_FPGA, 0x8e, 0x04); + I2C_Write(ADDR_AL, 0x14, 0x00); + I2C_Write(ADDR_FPGA, 0x80, 0x80); + + OLED_SetTMG(1); + + I2C_Write(ADDR_FPGA, 0x8C, 0x04); + I2C_Write(ADDR_FPGA, 0x06, 0x0F); + OLED_display(1); + g_hw_stat.hdmiin_vtmg = HDMIIN_VTMG_720P60; + break; + + case HDMIIN_VTMG_720P100: system_exec("dispw -s vdpo 720p30"); // 100fps actually - g_hw_stat.vdpo_tmg = HW_VDPO_720P100; + g_hw_stat.vdpo_tmg = VDPO_TMG_720P100; // I2C_Write(ADDR_FPGA, 0x8d, 0x04); I2C_Write(ADDR_FPGA, 0x8e, 0x04); I2C_Write(ADDR_AL, 0x14, 0x00); - I2C_Write(ADDR_FPGA, 0x80, 0x80); + I2C_Write(ADDR_FPGA, 0x80, 0xc0); OLED_SetTMG(1); I2C_Write(ADDR_FPGA, 0x8C, 0x04); I2C_Write(ADDR_FPGA, 0x06, 0x0F); OLED_display(1); - g_hw_stat.hdmiin_vtmg = 2; + g_hw_stat.hdmiin_vtmg = HDMIIN_VTMG_720P100; + break; } } - cs = IT66021_Get_PCLKFREQ(); - if (cs > 0) { - if (cs < 63) // pclk_h - I2C_Write(ADDR_FPGA, 0x8d, 0x14); - else // pclk_l - I2C_Write(ADDR_FPGA, 0x8d, 0x04); + if (freq_ref < 63) { + I2C_Write(ADDR_FPGA, 0x8d, 0x14); + } else { // pclk_l + I2C_Write(ADDR_FPGA, 0x8d, 0x04); } cs = IT66021_Get_CS(); @@ -598,21 +635,21 @@ void Set_HT_dat(uint16_t ch0, uint16_t ch1, uint16_t ch2) { void Analog_Module_Power(bool ForceSet) { // Batch 2 goggles only if (getHwRevision() >= HW_REV_2) { - static bool Analog_Module_Power_State = 0; - static bool Analog_Module_Power_State_Last = 0; + static bool Analog_Module_Power_State = 0; + static bool Analog_Module_Power_State_Last = 0; if (g_setting.power.power_ana == 0) { - Analog_Module_Power_State = 0; + Analog_Module_Power_State = 0; } else { if (g_source_info.source != SOURCE_EXPANSION) { - Analog_Module_Power_State = 1; + Analog_Module_Power_State = 1; } else { - Analog_Module_Power_State = 0; + Analog_Module_Power_State = 0; } - } + } if ((Analog_Module_Power_State_Last != Analog_Module_Power_State) || (ForceSet == 1)) { - beep(); - Analog_Module_Power_State_Last = Analog_Module_Power_State; - DM5680_Power_AnalogModule(Analog_Module_Power_State); + beep(); + Analog_Module_Power_State_Last = Analog_Module_Power_State; + DM5680_Power_AnalogModule(Analog_Module_Power_State); } } } @@ -621,7 +658,7 @@ int Get_VideoLatancy_status() // ret: 0=unlocked, 1=locked { uint8_t rdat = 0; - if (g_hw_stat.source_mode == HW_SRC_MODE_AV || g_hw_stat.source_mode == HW_SRC_MODE_HDZERO) { + if (g_hw_stat.source_mode == SOURCE_MODE_AV || g_hw_stat.source_mode == SOURCE_MODE_HDZERO) { rdat = I2C_Read(ADDR_FPGA, 0x11); rdat = (rdat < 0x04) ? 1 : 0; } diff --git a/src/driver/hardware.h b/src/driver/hardware.h index f17eac4b..80ff47d6 100644 --- a/src/driver/hardware.h +++ b/src/driver/hardware.h @@ -4,21 +4,33 @@ #include #include -#define HW_SRC_MODE_UI 0 -#define HW_SRC_MODE_HDZERO 1 -#define HW_SRC_MODE_AV 2 -#define HW_SRC_MODE_HDMIIN 3 - -#define HW_VDPO_720P50 0 -#define HW_VDPO_720P60 1 -#define HW_VDPO_720P90 2 -#define HW_VDPO_1080P50 3 -#define HW_VDPO_720P100 4 -#define HW_VDPO_1080P60 5 +typedef enum { + SOURCE_MODE_UI = 0, + SOURCE_MODE_HDZERO = 1, + SOURCE_MODE_AV = 2, + SOURCE_MODE_HDMIIN = 3, +} source_mode_t; + +typedef enum { + HDMIIN_VTMG_UNKNOW = 0, + HDMIIN_VTMG_1080P = 1, + HDMIIN_VTMG_720P50 = 2, + HDMIIN_VTMG_720P60 = 3, + HDMIIN_VTMG_720P100 = 4, +} hdmiin_vtmg_t; + +typedef enum { + VDPO_TMG_720P50 = 0, + VDPO_TMG_720P60 = 1, + VDPO_TMG_720P90 = 2, + VDPO_TMG_1080P50 = 3, + VDPO_TMG_720P100 = 4, + VDPO_TMG_1080P60 = 5, +} vdpo_tmg_t; typedef struct { - int source_mode; // 0=UI; 1=HDZERO; 2=AV_in/Module_bay; 3=HDMI in - int vdpo_tmg; // 0=720p50; 1=720P60; 2=720P90; 3=1080P50; + source_mode_t source_mode; + vdpo_tmg_t vdpo_tmg; // hdzero int hdz_bw; // 0=27MHz; 1=17MHz @@ -33,7 +45,7 @@ typedef struct { // hdmi in int hdmiin_valid; - int hdmiin_vtmg; // 1=1080p,2=720p + hdmiin_vtmg_t hdmiin_vtmg; int IS_TP2825_L; diff --git a/src/driver/it66021.c b/src/driver/it66021.c index 09f41c81..73871594 100644 --- a/src/driver/it66021.c +++ b/src/driver/it66021.c @@ -10,6 +10,7 @@ #include "../core/common.hh" #include "defines.h" #include "dm5680.h" +#include "hardware.h" #include "i2c.h" #include "oled.h" @@ -201,6 +202,9 @@ void IT66021_init() { IT66021_Mask_WR(1, 0x66, 0x03, 0x01); IT66021_Mask_WR(1, 0x2a, 0x07, 0x01); IT66021_Mask_WR(1, 0x0f, 0x10, 0x00); + + usleep(1000); + IT66121_EDID(); } int IT66021_Sig_det() { @@ -213,25 +217,59 @@ int IT66021_Sig_det() { return st; } -// return: 1 = 1920x1080, 2= 1280x720 -int IT66021_Get_VTMG() { - int r9e, r9f, ra5, ra4; - int width, height; +#define IT66121_9A_READ_N 5 +int IT66021_Get_VTMG(int *freq_ref) { + int r9a[IT66121_9A_READ_N], r9c, r9d, r9e, r9f, ra3, ra4, ra5; + int hmax, vmax, hact, vact; + int i, j; + double fps; int ret = 0; IT66021_Mask_WR(0, 0x0f, 0x03, 0x00); + + for (i = 0; i < IT66121_9A_READ_N; i++) { + r9a[i] = I2C_L_Read(ADDR_IT66021, 0x9a); + } + + for (i = 0; i < IT66121_9A_READ_N; i++) { + for (j = IT66121_9A_READ_N - 1; j >= i; j--) { + if (r9a[j] > r9a[j + 1]) { + int temp = r9a[j]; + r9a[j] = r9a[j + 1]; + r9a[j + 1] = temp; + } + } + } + + r9c = I2C_L_Read(ADDR_IT66021, 0x9c); + r9d = I2C_L_Read(ADDR_IT66021, 0x9d); r9e = I2C_L_Read(ADDR_IT66021, 0x9e); r9f = I2C_L_Read(ADDR_IT66021, 0x9f); - ra5 = I2C_L_Read(ADDR_IT66021, 0xa5); + ra3 = I2C_L_Read(ADDR_IT66021, 0xa3); ra4 = I2C_L_Read(ADDR_IT66021, 0xa4); + ra5 = I2C_L_Read(ADDR_IT66021, 0xa5); + + hmax = ((r9d & 0x3f) << 8) | (r9c & 0xff); + vmax = ((ra4 & 0x0f) << 8) | (ra3 & 0xff); + + hact = ((r9f & 0x3f) << 8) | (r9e & 0xff); + vact = ((ra4 & 0xf0) << 4) | (ra5 & 0xff); + + *freq_ref = r9a[1]; - width = ((r9f & 0x3f) << 8) | (r9e & 0xff); - height = ((ra4 & 0xf0) << 4) | (ra5 & 0xff); + fps = 6831.0 / r9a[1]; + fps = fps * 1000000 / hmax / vmax; - if (width == 1920 && height == 1080) - ret = 1; - if (width == 1280 && height == 720) - ret = 2; + if (hact == 1920 && vact == 1080) + ret = HDMIIN_VTMG_1080P; + else if (hact == 1280 && vact == 720) { + if (fps < 55) + ret = HDMIIN_VTMG_720P50; + else if (fps > 80) + ret = HDMIIN_VTMG_720P100; + else + ret = HDMIIN_VTMG_720P60; + } return ret; } @@ -256,12 +294,271 @@ void IT66021_Set_CSMatrix(int cs) { } } -int IT66021_Get_PCLKFREQ() { - int rdat; - - rdat = I2C_L_Read(ADDR_IT66021, 0x9A); - if (rdat != I2C_L_Read(ADDR_IT66021, 0x9A)) - rdat = 0; - - return rdat; -} \ No newline at end of file +void IT66121_EDID() { + // 0x49->0xc4 must set same data with 0x54->0x7f + // 0x49->0xc5 must set same data with 0x54->0xff + I2C_L_Write(0x49, 0xc0, 0x40); + I2C_L_Write(0x49, 0xc4, 0xBB); + I2C_L_Write(0x49, 0xc5, 0xEE); + + I2C_L_Write(0x54, 0x00, 0x00); + I2C_L_Write(0x54, 0x01, 0xFF); + I2C_L_Write(0x54, 0x02, 0xFF); + I2C_L_Write(0x54, 0x03, 0xFF); + I2C_L_Write(0x54, 0x04, 0xFF); + I2C_L_Write(0x54, 0x05, 0xFF); + I2C_L_Write(0x54, 0x06, 0xFF); + I2C_L_Write(0x54, 0x07, 0x00); + I2C_L_Write(0x54, 0x08, 0x26); + I2C_L_Write(0x54, 0x09, 0x85); + I2C_L_Write(0x54, 0x0a, 0x02); + I2C_L_Write(0x54, 0x0b, 0x66); + I2C_L_Write(0x54, 0x0c, 0x01); + I2C_L_Write(0x54, 0x0d, 0x68); + I2C_L_Write(0x54, 0x0e, 0x00); + I2C_L_Write(0x54, 0x0f, 0x00); + I2C_L_Write(0x54, 0x10, 0x00); + I2C_L_Write(0x54, 0x11, 0x17); + I2C_L_Write(0x54, 0x12, 0x01); + I2C_L_Write(0x54, 0x13, 0x03); + I2C_L_Write(0x54, 0x14, 0x80); + I2C_L_Write(0x54, 0x15, 0x73); + I2C_L_Write(0x54, 0x16, 0x41); + I2C_L_Write(0x54, 0x17, 0x78); + I2C_L_Write(0x54, 0x18, 0x2A); + I2C_L_Write(0x54, 0x19, 0x7C); + I2C_L_Write(0x54, 0x1a, 0x11); + I2C_L_Write(0x54, 0x1b, 0x9E); + I2C_L_Write(0x54, 0x1c, 0x59); + I2C_L_Write(0x54, 0x1d, 0x47); + I2C_L_Write(0x54, 0x1e, 0x9B); + I2C_L_Write(0x54, 0x1f, 0x27); + I2C_L_Write(0x54, 0x20, 0x10); + I2C_L_Write(0x54, 0x21, 0x50); + I2C_L_Write(0x54, 0x22, 0x54); + I2C_L_Write(0x54, 0x23, 0x00); + I2C_L_Write(0x54, 0x24, 0x00); + I2C_L_Write(0x54, 0x25, 0x00); + I2C_L_Write(0x54, 0x26, 0x81); + I2C_L_Write(0x54, 0x27, 0xC0); + I2C_L_Write(0x54, 0x28, 0x81); + I2C_L_Write(0x54, 0x29, 0xE8); + I2C_L_Write(0x54, 0x2a, 0x01); + I2C_L_Write(0x54, 0x2b, 0x01); + I2C_L_Write(0x54, 0x2c, 0x01); + I2C_L_Write(0x54, 0x2d, 0x01); + I2C_L_Write(0x54, 0x2e, 0x01); + I2C_L_Write(0x54, 0x2f, 0x01); + I2C_L_Write(0x54, 0x30, 0x01); + I2C_L_Write(0x54, 0x31, 0x01); + I2C_L_Write(0x54, 0x32, 0x01); + I2C_L_Write(0x54, 0x33, 0x01); + I2C_L_Write(0x54, 0x34, 0x01); + I2C_L_Write(0x54, 0x35, 0x01); + I2C_L_Write(0x54, 0x36, 0x02); + I2C_L_Write(0x54, 0x37, 0x3A); + I2C_L_Write(0x54, 0x38, 0x80); + I2C_L_Write(0x54, 0x39, 0xD0); + I2C_L_Write(0x54, 0x3a, 0x72); + I2C_L_Write(0x54, 0x3b, 0x38); + I2C_L_Write(0x54, 0x3c, 0x2D); + I2C_L_Write(0x54, 0x3d, 0x40); + I2C_L_Write(0x54, 0x3e, 0x58); + I2C_L_Write(0x54, 0x3f, 0x2C); + I2C_L_Write(0x54, 0x40, 0x45); + I2C_L_Write(0x54, 0x41, 0x00); + I2C_L_Write(0x54, 0x42, 0x10); + I2C_L_Write(0x54, 0x43, 0x09); + I2C_L_Write(0x54, 0x44, 0x00); + I2C_L_Write(0x54, 0x45, 0x00); + I2C_L_Write(0x54, 0x46, 0x00); + I2C_L_Write(0x54, 0x47, 0x1E); + I2C_L_Write(0x54, 0x48, 0x01); + I2C_L_Write(0x54, 0x49, 0x1D); + I2C_L_Write(0x54, 0x4a, 0x00); + I2C_L_Write(0x54, 0x4b, 0x72); + I2C_L_Write(0x54, 0x4c, 0x51); + I2C_L_Write(0x54, 0x4d, 0xD0); + I2C_L_Write(0x54, 0x4e, 0x1E); + I2C_L_Write(0x54, 0x4f, 0x20); + I2C_L_Write(0x54, 0x50, 0x6E); + I2C_L_Write(0x54, 0x51, 0x28); + I2C_L_Write(0x54, 0x52, 0x55); + I2C_L_Write(0x54, 0x53, 0x00); + I2C_L_Write(0x54, 0x54, 0x10); + I2C_L_Write(0x54, 0x55, 0x09); + I2C_L_Write(0x54, 0x56, 0x00); + I2C_L_Write(0x54, 0x57, 0x00); + I2C_L_Write(0x54, 0x58, 0x00); + I2C_L_Write(0x54, 0x59, 0x18); + I2C_L_Write(0x54, 0x5a, 0x00); + I2C_L_Write(0x54, 0x5b, 0x00); + I2C_L_Write(0x54, 0x5c, 0x00); + I2C_L_Write(0x54, 0x5d, 0xFC); + I2C_L_Write(0x54, 0x5e, 0x00); + I2C_L_Write(0x54, 0x5f, 0x49); + I2C_L_Write(0x54, 0x60, 0x54); + I2C_L_Write(0x54, 0x61, 0x45); + I2C_L_Write(0x54, 0x62, 0x36); + I2C_L_Write(0x54, 0x63, 0x38); + I2C_L_Write(0x54, 0x64, 0x30); + I2C_L_Write(0x54, 0x65, 0x32); + I2C_L_Write(0x54, 0x66, 0x0A); + I2C_L_Write(0x54, 0x67, 0x20); + I2C_L_Write(0x54, 0x68, 0x20); + I2C_L_Write(0x54, 0x69, 0x20); + I2C_L_Write(0x54, 0x6a, 0x20); + I2C_L_Write(0x54, 0x6b, 0x20); + I2C_L_Write(0x54, 0x6c, 0x00); + I2C_L_Write(0x54, 0x6d, 0x00); + I2C_L_Write(0x54, 0x6e, 0x00); + I2C_L_Write(0x54, 0x6f, 0xFD); + I2C_L_Write(0x54, 0x70, 0x00); + I2C_L_Write(0x54, 0x71, 0x30); + I2C_L_Write(0x54, 0x72, 0x7A); + I2C_L_Write(0x54, 0x73, 0x0F); + I2C_L_Write(0x54, 0x74, 0x50); + I2C_L_Write(0x54, 0x75, 0x10); + I2C_L_Write(0x54, 0x76, 0x00); + I2C_L_Write(0x54, 0x77, 0x0A); + I2C_L_Write(0x54, 0x78, 0x20); + I2C_L_Write(0x54, 0x79, 0x20); + I2C_L_Write(0x54, 0x7a, 0x20); + I2C_L_Write(0x54, 0x7b, 0x20); + I2C_L_Write(0x54, 0x7c, 0x20); + I2C_L_Write(0x54, 0x7d, 0x20); + I2C_L_Write(0x54, 0x7e, 0x01); + I2C_L_Write(0x54, 0x7f, 0xBB); + I2C_L_Write(0x54, 0x80, 0x02); + I2C_L_Write(0x54, 0x81, 0x03); + I2C_L_Write(0x54, 0x82, 0x16); + I2C_L_Write(0x54, 0x83, 0x72); + I2C_L_Write(0x54, 0x84, 0x43); + I2C_L_Write(0x54, 0x85, 0x84); + I2C_L_Write(0x54, 0x86, 0x9F); + I2C_L_Write(0x54, 0x87, 0x29); + I2C_L_Write(0x54, 0x88, 0x23); + I2C_L_Write(0x54, 0x89, 0x09); + I2C_L_Write(0x54, 0x8a, 0x07); + I2C_L_Write(0x54, 0x8b, 0x07); + I2C_L_Write(0x54, 0x8c, 0x83); + I2C_L_Write(0x54, 0x8d, 0x01); + I2C_L_Write(0x54, 0x8e, 0x00); + I2C_L_Write(0x54, 0x8f, 0x00); + I2C_L_Write(0x54, 0x90, 0x65); + I2C_L_Write(0x54, 0x91, 0x03); + I2C_L_Write(0x54, 0x92, 0x0C); + I2C_L_Write(0x54, 0x93, 0x00); + I2C_L_Write(0x54, 0x94, 0x10); + I2C_L_Write(0x54, 0x95, 0x00); + I2C_L_Write(0x54, 0x96, 0x01); + I2C_L_Write(0x54, 0x97, 0x1D); + I2C_L_Write(0x54, 0x98, 0x00); + I2C_L_Write(0x54, 0x99, 0x72); + I2C_L_Write(0x54, 0x9a, 0x51); + I2C_L_Write(0x54, 0x9b, 0xD0); + I2C_L_Write(0x54, 0x9c, 0x1E); + I2C_L_Write(0x54, 0x9d, 0x20); + I2C_L_Write(0x54, 0x9e, 0x6E); + I2C_L_Write(0x54, 0x9f, 0x28); + I2C_L_Write(0x54, 0xa0, 0x55); + I2C_L_Write(0x54, 0xa1, 0x00); + I2C_L_Write(0x54, 0xa2, 0x10); + I2C_L_Write(0x54, 0xa3, 0x09); + I2C_L_Write(0x54, 0xa4, 0x00); + I2C_L_Write(0x54, 0xa5, 0x00); + I2C_L_Write(0x54, 0xa6, 0x00); + I2C_L_Write(0x54, 0xa7, 0x1E); + I2C_L_Write(0x54, 0xa8, 0x02); + I2C_L_Write(0x54, 0xa9, 0x3A); + I2C_L_Write(0x54, 0xaa, 0x80); + I2C_L_Write(0x54, 0xab, 0xD0); + I2C_L_Write(0x54, 0xac, 0x72); + I2C_L_Write(0x54, 0xad, 0x38); + I2C_L_Write(0x54, 0xae, 0x2D); + I2C_L_Write(0x54, 0xaf, 0x40); + I2C_L_Write(0x54, 0xb0, 0x58); + I2C_L_Write(0x54, 0xb1, 0x2C); + I2C_L_Write(0x54, 0xb2, 0x45); + I2C_L_Write(0x54, 0xb3, 0x00); + I2C_L_Write(0x54, 0xb4, 0x10); + I2C_L_Write(0x54, 0xb5, 0x09); + I2C_L_Write(0x54, 0xb6, 0x00); + I2C_L_Write(0x54, 0xb7, 0x00); + I2C_L_Write(0x54, 0xb8, 0x00); + I2C_L_Write(0x54, 0xb9, 0x1E); + I2C_L_Write(0x54, 0xba, 0x00); + I2C_L_Write(0x54, 0xbb, 0x00); + I2C_L_Write(0x54, 0xbc, 0x00); + I2C_L_Write(0x54, 0xbd, 0x00); + I2C_L_Write(0x54, 0xbe, 0x00); + I2C_L_Write(0x54, 0xbf, 0x00); + I2C_L_Write(0x54, 0xc0, 0x00); + I2C_L_Write(0x54, 0xc1, 0x00); + I2C_L_Write(0x54, 0xc2, 0x00); + I2C_L_Write(0x54, 0xc3, 0x00); + I2C_L_Write(0x54, 0xc4, 0x00); + I2C_L_Write(0x54, 0xc5, 0x00); + I2C_L_Write(0x54, 0xc6, 0x00); + I2C_L_Write(0x54, 0xc7, 0x00); + I2C_L_Write(0x54, 0xc8, 0x00); + I2C_L_Write(0x54, 0xc9, 0x00); + I2C_L_Write(0x54, 0xca, 0x00); + I2C_L_Write(0x54, 0xcb, 0x00); + I2C_L_Write(0x54, 0xcc, 0x00); + I2C_L_Write(0x54, 0xcd, 0x00); + I2C_L_Write(0x54, 0xce, 0x00); + I2C_L_Write(0x54, 0xcf, 0x00); + I2C_L_Write(0x54, 0xd0, 0x00); + I2C_L_Write(0x54, 0xd1, 0x00); + I2C_L_Write(0x54, 0xd2, 0x00); + I2C_L_Write(0x54, 0xd3, 0x00); + I2C_L_Write(0x54, 0xd4, 0x00); + I2C_L_Write(0x54, 0xd5, 0x00); + I2C_L_Write(0x54, 0xd6, 0x00); + I2C_L_Write(0x54, 0xd7, 0x00); + I2C_L_Write(0x54, 0xd8, 0x00); + I2C_L_Write(0x54, 0xd9, 0x00); + I2C_L_Write(0x54, 0xda, 0x00); + I2C_L_Write(0x54, 0xdb, 0x00); + I2C_L_Write(0x54, 0xdc, 0x00); + I2C_L_Write(0x54, 0xdd, 0x00); + I2C_L_Write(0x54, 0xde, 0x00); + I2C_L_Write(0x54, 0xdf, 0x00); + I2C_L_Write(0x54, 0xe0, 0x00); + I2C_L_Write(0x54, 0xe1, 0x00); + I2C_L_Write(0x54, 0xe2, 0x00); + I2C_L_Write(0x54, 0xe3, 0x00); + I2C_L_Write(0x54, 0xe4, 0x00); + I2C_L_Write(0x54, 0xe5, 0x00); + I2C_L_Write(0x54, 0xe6, 0x00); + I2C_L_Write(0x54, 0xe7, 0x00); + I2C_L_Write(0x54, 0xe8, 0x00); + I2C_L_Write(0x54, 0xe9, 0x00); + I2C_L_Write(0x54, 0xea, 0x00); + I2C_L_Write(0x54, 0xeb, 0x00); + I2C_L_Write(0x54, 0xec, 0x00); + I2C_L_Write(0x54, 0xed, 0x00); + I2C_L_Write(0x54, 0xee, 0x00); + I2C_L_Write(0x54, 0xef, 0x00); + I2C_L_Write(0x54, 0xf0, 0x00); + I2C_L_Write(0x54, 0xf1, 0x00); + I2C_L_Write(0x54, 0xf2, 0x00); + I2C_L_Write(0x54, 0xf3, 0x00); + I2C_L_Write(0x54, 0xf4, 0x00); + I2C_L_Write(0x54, 0xf5, 0x00); + I2C_L_Write(0x54, 0xf6, 0x00); + I2C_L_Write(0x54, 0xf7, 0x00); + I2C_L_Write(0x54, 0xf8, 0x00); + I2C_L_Write(0x54, 0xf9, 0x00); + I2C_L_Write(0x54, 0xfa, 0x00); + I2C_L_Write(0x54, 0xfb, 0x00); + I2C_L_Write(0x54, 0xfc, 0x00); + I2C_L_Write(0x54, 0xfd, 0x00); + I2C_L_Write(0x54, 0xfe, 0x00); + I2C_L_Write(0x54, 0xff, 0xEE); + + I2C_L_Write(0x49, 0xc0, 0x24); + usleep(2000); + I2C_L_Write(0x49, 0xc0, 0x04); +} diff --git a/src/driver/it66021.h b/src/driver/it66021.h index fc8969bf..d5847fc8 100644 --- a/src/driver/it66021.h +++ b/src/driver/it66021.h @@ -5,9 +5,9 @@ void IT66021_srst(); void IT66021_close(); void IT66021_init(); int IT66021_Sig_det(); -int IT66021_Get_VTMG(); +int IT66021_Get_VTMG(int *freq_ref); int IT66021_Get_CS(); void IT66021_Set_CSMatrix(int cs); int IT66021_Get_PCLKFREQ(); - +void IT66121_EDID(); #endif \ No newline at end of file diff --git a/src/driver/oled.c b/src/driver/oled.c index ca9efc95..1e7e8918 100644 --- a/src/driver/oled.c +++ b/src/driver/oled.c @@ -66,7 +66,7 @@ uint16_t OLED_read(uint16_t addr, uint8_t sel) { val = (sel << 4) | 0x02; I2C_Write(ADDR_AL, 0xa0, val); - usleep(250); + usleep(500); val = I2C_Read(ADDR_AL, 0xa6); rdat = val; diff --git a/src/ui/page_common.h b/src/ui/page_common.h index 07a26289..6ec6f283 100644 --- a/src/ui/page_common.h +++ b/src/ui/page_common.h @@ -9,19 +9,19 @@ #define AUDIO_SEL_SH "/mnt/app/script/audio_sel.sh" #define SETTING_INI_VERSION 1 #ifndef EMULATOR_BUILD -#define SETTING_INI "/mnt/app/setting.ini" +#define SETTING_INI "/mnt/app/setting.ini" #else -#define SETTING_INI "setting.ini" +#define SETTING_INI "setting.ini" #endif -#define TEST_INI "/mnt/extsd/test.ini" -#define REC_START "/mnt/app/app/record/gogglecmd -rec start" -#define REC_STOP "/mnt/app/app/record/gogglecmd -rec stop" -#define REC_STOP_LIVE "/mnt/app/app/record/gogglecmd -rec stopl" -#define REC_CONF "/mnt/app/app/record/confs/record.conf" -#define WIFI_OFF "/mnt/app/script/wlan_stop.sh" -#define WIFI_AP_ON "/tmp/wlan_start_ap.sh" -#define WIFI_STA_ON "/tmp/wlan_start_sta.sh" -#define ROOT_PW_SET "/tmp/root_pw_set.sh" +#define TEST_INI "/mnt/extsd/test.ini" +#define REC_START "/mnt/app/app/record/gogglecmd -rec start" +#define REC_STOP "/mnt/app/app/record/gogglecmd -rec stop" +#define REC_STOP_LIVE "/mnt/app/app/record/gogglecmd -rec stopl" +#define REC_CONF "/mnt/app/app/record/confs/record.conf" +#define WIFI_OFF "/mnt/app/script/wlan_stop.sh" +#define WIFI_AP_ON "/tmp/wlan_start_ap.sh" +#define WIFI_STA_ON "/tmp/wlan_start_sta.sh" +#define ROOT_PW_SET "/tmp/root_pw_set.sh" #define FC_OSD_LOCAL_PATH "/mnt/app/resource/OSD/FC/" #define FC_OSD_SDCARD_PATH "/mnt/extsd/resource/OSD/FC/" diff --git a/src/ui/page_imagesettings.c b/src/ui/page_imagesettings.c index 6dd4010d..14e9854c 100644 --- a/src/ui/page_imagesettings.c +++ b/src/ui/page_imagesettings.c @@ -107,7 +107,7 @@ static void page_imagesettings_enter() { switch (g_source_info.source) { case SOURCE_HDZERO: progress_bar.start = 1; - HDZero_open(g_hw_stat.hdz_bw); + HDZero_open(g_setting.source.hdzero_bw); app_switch_to_hdzero(true); g_bShowIMS = true; break; diff --git a/src/ui/page_osd.c b/src/ui/page_osd.c index ce9e5fda..82ea2b7b 100644 --- a/src/ui/page_osd.c +++ b/src/ui/page_osd.c @@ -90,7 +90,7 @@ static void open_element_pos_preview() { switch (g_source_info.source) { case SOURCE_HDZERO: progress_bar.start = 1; - HDZero_open(g_hw_stat.hdz_bw); + HDZero_open(g_setting.source.hdzero_bw); app_switch_to_hdzero(true); break; diff --git a/src/ui/page_scannow.c b/src/ui/page_scannow.c index cd407c8a..bf10899c 100644 --- a/src/ui/page_scannow.c +++ b/src/ui/page_scannow.c @@ -70,8 +70,8 @@ int user_select_index = 0; static int auto_scaned_cnt = 0; static lv_obj_t *progressbar; static lv_obj_t *label; -static lv_coord_t col_dsc[] = {500, 20, 1164 - 520, LV_GRID_TEMPLATE_LAST}; -static lv_coord_t row_dsc[] = {60, 60, 80, LV_GRID_TEMPLATE_LAST}; +static lv_coord_t col_dsc1[] = {500, 20, 1164 - 520, LV_GRID_TEMPLATE_LAST}; +static lv_coord_t row_dsc1[] = {60, 60, 80, LV_GRID_TEMPLATE_LAST}; static lv_coord_t col_dsc2[] = {120, 80, 80, 180, 100, 80, 80, 180, LV_GRID_TEMPLATE_LAST}; static lv_coord_t row_dsc2[] = {60, 60, 60, 60, 60, 60, 60, 60, 60, 60, LV_GRID_TEMPLATE_LAST}; @@ -87,7 +87,7 @@ static void select_signal(channel_t *channel) { lv_img_set_src(channel->img0, &img_signal_status3); } -static void set_signal(channel_t *channel, bool is_valid, int gain) { +static void set_signal_bar(channel_t *channel, bool is_valid, int gain) { if (!is_valid) { lv_img_set_src(channel->img0, &img_signal_status); @@ -131,7 +131,7 @@ static void set_signal(channel_t *channel, bool is_valid, int gain) { } } // gain, 0-60 -static void draw_signal(lv_obj_t *parent, const char *name, int col, int row, channel_t *channel) { +static void create_channel_switch(lv_obj_t *parent, int col, int row, channel_t *channel) { channel->img0 = lv_img_create(parent); lv_img_set_src(channel->img0, &img_signal_status); @@ -140,7 +140,6 @@ static void draw_signal(lv_obj_t *parent, const char *name, int col, int row, ch LV_GRID_ALIGN_CENTER, row, 1); channel->label = lv_label_create(parent); - lv_label_set_text(channel->label, name); lv_obj_set_style_text_font(channel->label, &lv_font_montserrat_40, 0); lv_obj_set_style_text_align(channel->label, LV_TEXT_ALIGN_LEFT, 0); lv_obj_set_style_text_color(channel->label, lv_color_make(255, 255, 255), 0); @@ -156,6 +155,39 @@ static void draw_signal(lv_obj_t *parent, const char *name, int col, int row, ch LV_GRID_ALIGN_CENTER, row, 1); } +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 *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++) { + 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); + } else { + 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); + } +} + // 1920-500 // 1420 // 1420*0.18 @@ -169,16 +201,16 @@ static lv_obj_t *page_scannow_create(lv_obj_t *parent, panel_arr_t *arr) { lv_obj_add_style(page, &style_scan, LV_PART_MAIN); lv_obj_set_style_pad_top(page, 60, 0); - lv_obj_t *cont = lv_obj_create(page); - lv_obj_set_size(cont, 1158, 250); - lv_obj_set_layout(cont, LV_LAYOUT_GRID); - lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_add_style(cont, &style_scan, LV_PART_MAIN); - lv_obj_set_style_bg_opa(cont, 0, 0); - lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0); - lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0); + lv_obj_t *cont1 = lv_obj_create(page); + lv_obj_set_size(cont1, 1158, 250); + lv_obj_set_layout(cont1, LV_LAYOUT_GRID); + lv_obj_clear_flag(cont1, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_add_style(cont1, &style_scan, LV_PART_MAIN); + lv_obj_set_style_bg_opa(cont1, 0, 0); + lv_obj_set_style_grid_column_dsc_array(cont1, col_dsc1, 0); + lv_obj_set_style_grid_row_dsc_array(cont1, row_dsc1, 0); - progressbar = lv_bar_create(cont); + progressbar = lv_bar_create(cont1); lv_obj_set_size(progressbar, 500, 50); lv_obj_center(progressbar); lv_bar_set_value(progressbar, 0, LV_ANIM_OFF); @@ -190,9 +222,9 @@ static lv_obj_t *page_scannow_create(lv_obj_t *parent, panel_arr_t *arr) { lv_obj_set_grid_cell(progressbar, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_CENTER, 1, 1); - lv_bar_set_range(progressbar, 0, 14 * (INC_17MHZ_MODE + 1)); + lv_bar_set_range(progressbar, 0, 14); - label = lv_label_create(cont); + label = lv_label_create(cont1); lv_label_set_text(label, "Scan Ready"); lv_obj_set_style_text_font(label, &lv_font_montserrat_26, 0); lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_LEFT, 0); @@ -202,7 +234,7 @@ static lv_obj_t *page_scannow_create(lv_obj_t *parent, panel_arr_t *arr) { lv_obj_set_grid_cell(label, LV_GRID_ALIGN_START, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1); - lv_obj_t *label2 = lv_label_create(cont); + lv_obj_t *label2 = lv_label_create(cont1); lv_label_set_text(label2, "When scanning is complete,use the\n dial to select a channel and press\n the Enter button to choose"); lv_obj_set_style_text_font(label2, &lv_font_montserrat_26, 0); lv_obj_set_style_text_align(label2, LV_TEXT_ALIGN_LEFT, 0); @@ -221,16 +253,16 @@ static lv_obj_t *page_scannow_create(lv_obj_t *parent, panel_arr_t *arr) { lv_obj_set_style_grid_column_dsc_array(cont2, col_dsc2, 0); lv_obj_set_style_grid_row_dsc_array(cont2, row_dsc2, 0); - draw_signal(cont2, "R1", 1, 0, &channel_tb[0]); - draw_signal(cont2, "R2", 1, 1, &channel_tb[1]); - draw_signal(cont2, "R3", 1, 2, &channel_tb[2]); - draw_signal(cont2, "R4", 1, 3, &channel_tb[3]); - draw_signal(cont2, "R5", 1, 4, &channel_tb[4]); - draw_signal(cont2, "R6", 5, 0, &channel_tb[5]); - draw_signal(cont2, "R7", 5, 1, &channel_tb[6]); - draw_signal(cont2, "R8", 5, 2, &channel_tb[7]); - draw_signal(cont2, "F2", 5, 3, &channel_tb[8]); - draw_signal(cont2, "F4", 5, 4, &channel_tb[9]); + // create channel + uint8_t i; + for (int i = 0; i < 8; i++) { + create_channel_switch(cont2, ((i >> 2) << 2) + 1, i & 0x03, &channel_tb[i]); + } + for (int i = 0; i < 2; i++) { + create_channel_switch(cont2, (i << 2) + 1, 4, &channel_tb[8 + i]); + } + page_scannow_set_channel_label(); + return page; } @@ -244,7 +276,6 @@ static void user_select_signal(void) { static void user_clear_signal(void) { user_select_index = 0; - for (int i = 0; i < 10; i++) { lv_img_set_src(channel_tb[i].img0, &img_signal_status); lv_img_set_src(channel_tb[i].img1, &img_ant1); @@ -257,11 +288,11 @@ uint8_t max4(uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4) { return (b1 > b2) ? b1 : b2; } -void scan_channel(uint8_t channel, uint8_t *gain_ret, bool *valid) { +void scan_channel(band_t band, uint8_t channel, uint8_t *gain_ret, bool *valid) { uint8_t vld0, vld1; uint8_t gain[4]; - DM6302_SetChannel(channel); + DM6302_SetChannel(band, channel); usleep(100000); DM5680_clear_vldflg(); @@ -274,13 +305,12 @@ void scan_channel(uint8_t channel, uint8_t *gain_ret, bool *valid) { vld1 = rx_status[1].rx_valid; *valid = vld0 | vld1; - LOGI("Scan channel%d: valid:%d, gain:%d", channel, *valid, *gain_ret); + LOGI("Scan band:%d, channel%d: valid:%d, gain:%d", band, channel, *valid, *gain_ret); } int8_t scan_now(void) { uint8_t ch, gain; bool valid; - uint8_t bw; uint8_t valid_index; lv_label_set_text(label, "Scanning..."); @@ -290,37 +320,33 @@ int8_t scan_now(void) { lv_timer_handler(); // clear - for (ch = 0; ch < FREQ_NUM; ch++) { + for (ch = 0; ch < 10; ch++) { valid_channel_tb[ch] = -1; channel_status_tb[ch].is_valid = 0; } - for (bw = 0; bw < (INC_17MHZ_MODE + 1); bw++) { - HDZero_open(bw); - lv_bar_set_value(progressbar, bw * 14 + 4, LV_ANIM_OFF); - lv_timer_handler(); + HDZero_open(g_setting.source.hdzero_bw); + lv_bar_set_value(progressbar, 4, LV_ANIM_OFF); + lv_timer_handler(); - for (ch = 0; ch < FREQ_NUM; ch++) { - if (!channel_status_tb[ch].is_valid) { - scan_channel(ch, &gain, &valid); - if (valid) { - channel_status_tb[ch].is_valid = 1; - channel_status_tb[ch].gain = gain; - channel_status_tb[ch].bw = bw; - set_signal(&channel_tb[ch], channel_status_tb[ch].is_valid, channel_status_tb[ch].gain); - } - } - lv_bar_set_value(progressbar, bw * 14 + ch + 5, LV_ANIM_OFF); - lv_timer_handler(); + for (ch = 0; ch < CHANNEL_NUM; ch++) { + scan_channel(g_setting.source.hdzero_band, ch, &gain, &valid); + if (valid) { + channel_status_tb[ch].is_valid = 1; + channel_status_tb[ch].gain = gain; + set_signal_bar(&channel_tb[ch], channel_status_tb[ch].is_valid, channel_status_tb[ch].gain); } + lv_bar_set_value(progressbar, ch + 5, LV_ANIM_OFF); + lv_timer_handler(); } + lv_bar_set_value(progressbar, 14, LV_ANIM_OFF); valid_index = 0; - for (ch = 0; ch < FREQ_NUM; ch++) { - if (channel_status_tb[ch].is_valid) - valid_channel_tb[valid_index++] = ch | (channel_status_tb[ch].bw << 7); + for (ch = 0; ch < CHANNEL_NUM; ch++) { + if (channel_status_tb[ch].is_valid) { + valid_channel_tb[valid_index++] = ch; + } - // set_signal(&channel_tb[ch], channel_status_tb[ch].is_valid, channel_status_tb[ch].gain); lv_timer_handler(); } @@ -390,7 +416,7 @@ static void page_scannow_on_roller(uint8_t key) { if (user_select_index > 0) user_select_index--; } - select_signal(&channel_tb[valid_channel_tb[user_select_index] & 0x0F]); + select_signal(&channel_tb[valid_channel_tb[user_select_index] & 0x07F]); } static void page_scannow_on_click(uint8_t key, int sel) { diff --git a/src/ui/page_scannow.h b/src/ui/page_scannow.h index e9d18e26..83bc1ba9 100644 --- a/src/ui/page_scannow.h +++ b/src/ui/page_scannow.h @@ -1,17 +1,20 @@ #ifndef _PAGE_SCANNOW_H #define _PAGE_SCANNOW_H -#include - #include "ui/ui_main_menu.h" +#include -#define INC_17MHZ_MODE 0 // 0 or 1 +#define CHANNEL_NUM (g_setting.source.hdzero_band == RACE_BAND ? 10 : 8) -extern page_pack_t pp_scannow; +typedef enum { + RACE_BAND = 0, + LOW_BAND = 1, +} band_t; int scan(void); int scan_reinit(void); - void autoscan_exit(void); +void page_scannow_set_channel_label(void); +extern page_pack_t pp_scannow; #endif diff --git a/src/ui/page_source.c b/src/ui/page_source.c index 5c71bcea..5c2a53f1 100644 --- a/src/ui/page_source.c +++ b/src/ui/page_source.c @@ -21,13 +21,13 @@ #include "ui/ui_style.h" // local -static lv_coord_t col_dsc[] = {160, 160, 160, 160, 160, 160, LV_GRID_TEMPLATE_LAST}; +static lv_coord_t col_dsc[] = {160, 160, 200, 160, 160, 160, LV_GRID_TEMPLATE_LAST}; static lv_coord_t row_dsc[] = {60, 60, 60, 60, 60, 60, 60, 60, 60, 60, LV_GRID_TEMPLATE_LAST}; static lv_obj_t *label[5]; static uint8_t oled_tst_mode = 0; // 0=Normal,1=CB; 2-Grid; 3=All Black; 4=All White,5=Boot logo static bool in_sourcepage = false; -static btn_group_t btn_group0; +static btn_group_t btn_group0, btn_group1, btn_group2; static lv_obj_t *page_source_create(lv_obj_t *parent, panel_arr_t *arr) { lv_obj_t *page = lv_menu_page_create(parent, NULL); @@ -62,14 +62,20 @@ static lv_obj_t *page_source_create(lv_obj_t *parent, panel_arr_t *arr) { create_btn_group_item(&btn_group0, cont, 2, "Analog Video", "NTSC", "PAL", "", "", 4); btn_group_set_sel(&btn_group0, g_setting.source.analog_format); + create_btn_group_item(&btn_group1, cont, 2, "HDZero Band", "Raceband", "Lowband", "", "", 5); + btn_group_set_sel(&btn_group1, g_setting.source.hdzero_band); + + create_btn_group_item(&btn_group2, cont, 2, "HDZero BW", "Wide", "Narrow", "", "", 6); + btn_group_set_sel(&btn_group2, g_setting.source.hdzero_bw); + if (g_setting.storage.selftest) { - pp_source.p_arr.max = 7; - label[4] = create_label_item(cont, "OLED Pattern: Normal", 1, 5, 3); - create_label_item(cont, "< Back", 1, 6, 3); + pp_source.p_arr.max = 9; + label[4] = create_label_item(cont, "OLED Pattern: Normal", 1, 7, 3); + create_label_item(cont, "< Back", 1, 8, 3); } else { - pp_source.p_arr.max = 6; + pp_source.p_arr.max = 8; label[4] = NULL; - create_label_item(cont, "< Back", 1, 5, 3); + create_label_item(cont, "< Back", 1, 7, 3); } return page; } @@ -85,11 +91,19 @@ void source_status_timer() { if (!in_sourcepage) return; - ch = g_setting.scan.channel & 0xF; - if (ch > 8) - sprintf(buf, "HDZero: F%d", (ch - 8) * 2); - else - sprintf(buf, "HDZero: R%d", ch); + ch = g_setting.scan.channel & 0x7F; + if (g_setting.source.hdzero_band == SETTING_SOURCES_HDZERO_BAND_RACEBAND) { + if (ch <= 8) { + sprintf(buf, "HDZero: R%d", ch); + } else { + sprintf(buf, "HDZero: F%d", (ch - 8) * 2); + } + } else { + if (ch > 8) { + g_setting.scan.channel = 1; + } + sprintf(buf, "HDZero: L%d", ch); + } lv_label_set_text(label[0], buf); sprintf(buf, "HDMI In: %s", state2string(g_source_info.hdmi_in_status)); @@ -148,7 +162,20 @@ static void page_source_on_click(uint8_t key, int sel) { ini_putl("source", "analog_format", g_setting.source.analog_format, SETTING_INI); break; - case 5: + case 5: // HDZero band format + btn_group_toggle_sel(&btn_group1); + g_setting.source.hdzero_band = btn_group_get_sel(&btn_group1); + page_scannow_set_channel_label(); + ini_putl("source", "hdzero_band", g_setting.source.hdzero_band, SETTING_INI); + break; + + case 6: // HDZero bw format + btn_group_toggle_sel(&btn_group2); + g_setting.source.hdzero_bw = btn_group_get_sel(&btn_group2); + ini_putl("source", "hdzero_bw", g_setting.source.hdzero_bw, SETTING_INI); + break; + + case 7: if (g_setting.storage.selftest && label[4]) { uint8_t oled_te = (oled_tst_mode != 0); uint8_t oled_tm = (oled_tst_mode & 0x0F) - 1; @@ -179,7 +206,7 @@ static void page_source_exit() { page_pack_t pp_source = { .p_arr = { .cur = 0, - .max = 4, + .max = 6, }, .name = "Source", diff --git a/src/ui/ui_statusbar.c b/src/ui/ui_statusbar.c index ca739a97..d3abb323 100644 --- a/src/ui/ui_statusbar.c +++ b/src/ui/ui_statusbar.c @@ -118,7 +118,7 @@ int statusbar_init(void) { lv_label_set_text(label[STS_SDCARD], "SD Card "); lv_label_set_recolor(label[STS_SDCARD], true); - sprintf(buf, "RF: HDZero %s", channel2str(g_setting.scan.channel & 0xF)); + sprintf(buf, "RF: HDZero %s", channel2str(g_setting.source.hdzero_band, g_setting.scan.channel & 0x7F)); lv_label_set_text(label[STS_SOURCE], buf); lv_label_set_text(label[STS_ELRS], "ELRS: Off"); @@ -181,15 +181,13 @@ void statubar_update(void) { } static int channel_last = 0; - static int source_last = 0; - if ((channel_last != g_setting.scan.channel) || (source_last != g_source_info.source)) { + static source_t source_last = SOURCE_HDZERO; + static setting_sources_hdzero_band_t hdzero_band_last = SETTING_SOURCES_HDZERO_BAND_RACEBAND; + if ((channel_last != g_setting.scan.channel) || (source_last != g_source_info.source) || (hdzero_band_last != g_setting.source.hdzero_band)) { memset(buf, 0, sizeof(buf)); if (g_source_info.source == SOURCE_HDZERO) { // HDZero - int ch = g_setting.scan.channel & 0xF; - if (ch > 8) - sprintf(buf, "RF: HDZero F%d", (ch - 8) * 2); - else - sprintf(buf, "RF: HDZero R%d", ch); + int ch = g_setting.scan.channel & 0x7F; + sprintf(buf, "RF: HDZero %s", channel2str(g_setting.source.hdzero_band, g_setting.scan.channel & 0x7F)); } else if (g_source_info.source == SOURCE_HDMI_IN) sprintf(buf, "HDMI In"); else if (g_source_info.source == SOURCE_AV_IN) @@ -201,6 +199,7 @@ void statubar_update(void) { } channel_last = g_setting.scan.channel; source_last = g_source_info.source; + hdzero_band_last = g_setting.source.hdzero_band; if (page_storage_is_sd_repair_active()) { lv_img_set_src(img_sdc, &img_sdcard);