Skip to content

Commit 3255c6b

Browse files
committed
Reduced preprocessors for boxpro and fixed analog RSSI
1 parent 7603a5f commit 3255c6b

16 files changed

Lines changed: 98 additions & 103 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"page_imagesettings.h": "c",
1414
"page_record.h": "c",
1515
"typeindex": "c",
16-
"typeinfo": "c"
16+
"typeinfo": "c",
17+
"targets.h": "c"
1718
}
1819
}

src/core/app_state.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ void app_switch_to_menu() {
6060

6161
system_script(REC_STOP_LIVE);
6262

63-
#if HDZBOXPRO
64-
// Restore image settings from av module
65-
Screen_Brightness(g_setting.image.oled);
66-
Set_Contrast(g_setting.image.contrast);
67-
#endif
63+
if (TARGET_BOXPRO == getTargetType()) {
64+
// Restore image settings from av module
65+
Screen_Brightness(g_setting.image.oled);
66+
Set_Contrast(g_setting.image.contrast);
67+
}
6868
}
6969

7070
void app_exit_menu() {
@@ -81,13 +81,13 @@ void app_exit_menu() {
8181
void app_switch_to_analog(source_t source) {
8282
Source_AV(source);
8383

84-
#if HDZBOXPRO
85-
// Solve LCD residual image
86-
if (SOURCE_AV_MODULE == source) {
87-
Screen_Brightness(7);
88-
Set_Contrast(14);
84+
if (TARGET_BOXPRO == getTargetType()) {
85+
// Solve LCD residual image
86+
if (SOURCE_AV_MODULE == source) {
87+
Screen_Brightness(7);
88+
Set_Contrast(14);
89+
}
8990
}
90-
#endif
9191

9292
dvr_update_vi_conf(VR_720P50);
9393
osd_fhd(0);
@@ -106,11 +106,11 @@ void app_switch_to_analog(source_t source) {
106106
}
107107

108108
void app_switch_to_hdmi_in() {
109-
#if HDZBOXPRO
110-
// Restore image settings from av module
111-
Screen_Brightness(g_setting.image.oled);
112-
Set_Contrast(g_setting.image.contrast);
113-
#endif
109+
if (TARGET_BOXPRO == getTargetType()) {
110+
// Restore image settings from av module
111+
Screen_Brightness(g_setting.image.oled);
112+
Set_Contrast(g_setting.image.contrast);
113+
}
114114

115115
Source_HDMI_in();
116116
IT66121_close();
@@ -146,11 +146,11 @@ void app_switch_to_hdmi_in() {
146146
void app_switch_to_hdzero(bool is_default) {
147147
int ch;
148148

149-
#ifdef HDZBOXPRO
150-
// Restore image settings from av module
151-
Screen_Brightness(g_setting.image.oled);
152-
Set_Contrast(g_setting.image.contrast);
153-
#endif
149+
if (TARGET_BOXPRO == getTargetType()) {
150+
// Restore image settings from av module
151+
Screen_Brightness(g_setting.image.oled);
152+
Set_Contrast(g_setting.image.contrast);
153+
}
154154

155155
if (is_default) {
156156
ch = g_setting.scan.channel - 1;

src/core/dvr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <log/log.h>
99
#include <minIni.h>
1010

11+
#include "../conf/targets.h"
12+
1113
#include "core/msp_displayport.h"
1214
#include "core/settings.h"
1315
#include "driver/hardware.h"

src/core/elrs.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ void msp_process_packet() {
268268
app_state_push(APP_STATE_VIDEO);
269269
pthread_mutex_unlock(&lvgl_mutex);
270270
}
271-
}
272-
#if HDZBOXPRO
273-
else if (g_source_info.source == SOURCE_AV_MODULE) {
271+
} else if (TARGET_BOXPRO == getTargetType() && g_source_info.source == SOURCE_AV_MODULE) {
274272
ch = g_setting.source.analog_channel - 1;
275273
if (chan != ch || g_app_state != APP_STATE_VIDEO) {
276274
g_setting.source.analog_channel = chan + 1;
@@ -282,7 +280,6 @@ void msp_process_packet() {
282280
pthread_mutex_unlock(&lvgl_mutex);
283281
}
284282
}
285-
#endif
286283
} break;
287284
case MSP_GET_FREQ: {
288285
uint8_t ch;

src/core/ht.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,10 @@ static void detect_motion(bool is_moving) {
150150
uint8_t ch = g_setting.scan.channel - 1;
151151
HDZero_open(g_setting.source.hdzero_bw);
152152
DM6302_SetChannel(g_setting.source.hdzero_band, ch & 0x7F);
153-
}
154-
#if HDZBOXPRO
155-
else if (g_hw_stat.source_mode == SOURCE_MODE_AV) {
153+
} else if (TARGET_BOXPRO == getTargetType() && g_hw_stat.source_mode == SOURCE_MODE_AV) {
156154
RTC6715_Open(1);
157155
}
158-
#endif
156+
159157
LOGI("OLED ON from protection.");
160158
if (TARGET_GOGGLE == getTargetType()) {
161159
Screen_Brightness(g_setting.image.oled);

src/core/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ int main(int argc, char *argv[]) {
168168
gpio_init();
169169
uart_init();
170170

171-
#if HDZBOXPRO
172-
gpadc_init();
173-
#endif
171+
if (TARGET_BOXPRO == getTargetType()) {
172+
gpadc_init();
173+
}
174174

175175
// 3. Initialize core devices.
176176
mcp3021_init();

src/core/osd.c

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,7 @@ static uint32_t osdFont_hd[OSD_VNUM][OSD_HNUM][OSD_HEIGHT_HD][OSD_WIDTH_HD];
114114
static uint32_t osdFont_fhd[OSD_VNUM][OSD_HNUM][OSD_HEIGHT_FHD][OSD_WIDTH_FHD]; // 0x00bbggrr
115115
static osd_font_t osd_font_hd;
116116
static osd_font_t osd_font_fhd;
117-
118-
#if HDZBOXPRO
119117
static lv_obj_t *analog_rssi_bar;
120-
#endif
121118

122119
void osd_llock_show(bool bShow) {
123120
char buf[128];
@@ -269,7 +266,13 @@ void osd_vlq_show(bool bShow) {
269266
lv_obj_clear_flag(g_osd_hdzero.vlq[is_fhd], LV_OBJ_FLAG_HIDDEN);
270267
}
271268

272-
#if HDZBOXPRO
269+
void osd_analog_rssi_update_location() {
270+
if (g_setting.osd.embedded_mode == EMBEDDED_4x3)
271+
lv_obj_set_pos(analog_rssi_bar, g_setting.osd.element[OSD_GOGGLE_ANT0].position.mode_4_3.x, g_setting.osd.element[OSD_GOGGLE_ANT0].position.mode_4_3.y + 14);
272+
else
273+
lv_obj_set_pos(analog_rssi_bar, g_setting.osd.element[OSD_GOGGLE_ANT0].position.mode_16_9.x, g_setting.osd.element[OSD_GOGGLE_ANT0].position.mode_16_9.y + 14);
274+
}
275+
273276
void osd_analog_rssi_create() {
274277

275278
pthread_mutex_lock(&lvgl_mutex);
@@ -293,13 +296,6 @@ void osd_analog_rssi_create() {
293296
pthread_mutex_unlock(&lvgl_mutex);
294297
}
295298

296-
void osd_analog_rssi_update_location() {
297-
if (g_setting.osd.embedded_mode == EMBEDDED_4x3)
298-
lv_obj_set_pos(analog_rssi_bar, g_setting.osd.element[OSD_GOGGLE_ANT0].position.mode_4_3.x, g_setting.osd.element[OSD_GOGGLE_ANT0].position.mode_4_3.y + 14);
299-
else
300-
lv_obj_set_pos(analog_rssi_bar, g_setting.osd.element[OSD_GOGGLE_ANT0].position.mode_16_9.x, g_setting.osd.element[OSD_GOGGLE_ANT0].position.mode_16_9.y + 14);
301-
}
302-
303299
void osd_analog_rssi_show(bool bShow) {
304300
char buf[128];
305301
// static uint8_t cnt = 0;
@@ -330,7 +326,6 @@ void osd_analog_rssi_show(bool bShow) {
330326
// }
331327
lv_bar_set_value(analog_rssi_bar, rssi_volt_mv, LV_ANIM_OFF);
332328
}
333-
#endif
334329

335330
///////////////////////////////////:////////////////////////////////////////////
336331
// OSD channel
@@ -666,7 +661,12 @@ void osd_hdzero_update(void) {
666661

667662
bool source_is_hdzero = (g_source_info.source == SOURCE_HDZERO);
668663
bool source_is_analog = (g_source_info.source == SOURCE_AV_MODULE);
669-
bool showRXOSD = g_setting.osd.is_visible && source_is_hdzero;
664+
bool showRXOSD = false;
665+
666+
if ((TARGET_GOGGLE == getTargetType() && source_is_hdzero) ||
667+
(TARGET_BOXPRO == getTargetType() && (source_is_hdzero || source_is_analog))) {
668+
showRXOSD = g_setting.osd.is_visible;
669+
}
670670

671671
osd_rec_show(g_setting.osd.is_visible);
672672
osd_llock_show(g_setting.osd.is_visible);
@@ -702,9 +702,9 @@ void osd_hdzero_update(void) {
702702
osd_channel_show(showRXOSD);
703703
osd_vlq_show(showRXOSD && source_is_hdzero);
704704

705-
#if HDZBOXPRO
706-
osd_analog_rssi_show(showRXOSD && source_is_analog);
707-
#endif
705+
if (TARGET_BOXPRO == getTargetType()) {
706+
osd_analog_rssi_show(showRXOSD && source_is_analog);
707+
}
708708

709709
if (gif_cnt % 10 == 0) { // delay needed to allow gif to flash
710710
osd_resource_path(buf, "%s", is_fhd, lowBattery_gif);
@@ -863,9 +863,9 @@ void osd_update_element_positions() {
863863
osd_object_set_pos(is_fhd, g_osd_hdzero.ant2[is_fhd], &g_setting.osd.element[OSD_GOGGLE_ANT2].position);
864864
osd_object_set_pos(is_fhd, g_osd_hdzero.ant3[is_fhd], &g_setting.osd.element[OSD_GOGGLE_ANT3].position);
865865

866-
#if HDZBOXPRO
867-
osd_analog_rssi_update_location();
868-
#endif
866+
if (TARGET_BOXPRO == getTargetType()) {
867+
osd_analog_rssi_update_location();
868+
}
869869

870870
if (g_setting.storage.selftest) {
871871
osd_object_set_pos(is_fhd, g_osd_hdzero.osd_tempe[is_fhd][0], &g_setting.osd.element[OSD_GOGGLE_TEMP_TOP].position);
@@ -892,11 +892,9 @@ static void fc_osd_init(uint8_t fhd, uint16_t OFFSET_X, uint16_t OFFSET_Y) {
892892
}
893893
}
894894

895-
#if HDZBOXPRO
896-
if (!fhd) {
895+
if (TARGET_BOXPRO == getTargetType() && !fhd) {
897896
osd_analog_rssi_create();
898897
}
899-
#endif
900898
}
901899

902900
static void create_osd_scr(void) {

src/core/osd.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ void load_fc_osd_font(uint8_t);
101101
void *thread_osd(void *ptr);
102102
void osd_resource_path(char *buf, const char *fmt, osd_resource_t osd_resource_type, ...);
103103
void osd_toggle();
104-
105-
#if HDZBOXPRO
106104
void osd_analog_rssi_update_location();
107-
#endif
108105

109106
#ifdef __cplusplus
110107
}

src/core/self_test.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ void self_test() {
9191
i = Get_HAN_status() & 1;
9292
LOGI("%sHAN Status. ", msg[i]);
9393

94-
#if HDZBOXPRO
95-
// 9. DDR calib_done
96-
i = I2C_Read(ADDR_FPGA, 0x1B);
97-
LOGI("%sDDR calib_done = %d ", msg[i == 1], i);
98-
#endif
94+
if (TARGET_BOXPRO == getTargetType()) {
95+
// 9. DDR calib_done
96+
i = I2C_Read(ADDR_FPGA, 0x1B);
97+
LOGI("%sDDR calib_done = %d ", msg[i == 1], i);
98+
}
9999

100100
LOGI("==== Log ======================\n");
101101
}

src/core/settings.c

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <log/log.h>
88
#include <minIni.h>
99

10+
#include "../conf/targets.h"
11+
1012
#include "core/self_test.h"
1113
#include "lang/language.h"
1214
#include "ui/page_common.h"
@@ -492,29 +494,29 @@ void settings_load(void) {
492494
g_setting.storage.logging = log_file_open(APP_LOG_FILE);
493495
}
494496

495-
#if HDZBOXPRO
496-
char buf[64];
497-
char value_str[2] = {0};
498-
fs_printf("/sys/class/gpio/export", "%d", GPIO_IS_PRO);
499-
sprintf(buf, "/sys/class/gpio/gpio%d/direction", GPIO_IS_PRO);
500-
fs_printf(buf, "in");
501-
usleep(1000 * 100);
502-
sprintf(buf, "/sys/class/gpio/gpio%d/value", GPIO_IS_PRO);
503-
FILE *fp = fopen(buf, "r");
504-
if (!fp) {
505-
return;
506-
}
507-
if (fgets(value_str, sizeof(value_str), fp) == NULL) {
508-
LOGE("Failed to read GPIO_IS_PRO");
497+
if (TARGET_BOXPRO == getTargetType()) {
498+
char buf[64];
499+
char value_str[2] = {0};
500+
fs_printf("/sys/class/gpio/export", "%d", GPIO_IS_PRO);
501+
sprintf(buf, "/sys/class/gpio/gpio%d/direction", GPIO_IS_PRO);
502+
fs_printf(buf, "in");
503+
usleep(1000 * 100);
504+
sprintf(buf, "/sys/class/gpio/gpio%d/value", GPIO_IS_PRO);
505+
FILE *fp = fopen(buf, "r");
506+
if (!fp) {
507+
return;
508+
}
509+
if (fgets(value_str, sizeof(value_str), fp) == NULL) {
510+
LOGE("Failed to read GPIO_IS_PRO");
511+
fclose(fp);
512+
return;
513+
}
509514
fclose(fp);
510-
return;
511-
}
512-
fclose(fp);
513-
if (atoi(value_str)) {
514-
LOGI("IS NOT PRO");
515-
g_setting.has_all_features = false;
516-
} else {
517-
LOGI("IS PRO");
515+
if (atoi(value_str)) {
516+
LOGI("IS NOT PRO");
517+
g_setting.has_all_features = false;
518+
} else {
519+
LOGI("IS PRO");
520+
}
518521
}
519-
#endif
520522
}

0 commit comments

Comments
 (0)