Skip to content

Commit 5f65dce

Browse files
authored
Merge pull request #596 from RaceMiata/analog-ghosting
Fix analog ghosting
2 parents d285ddd + 10a7b78 commit 5f65dce

5 files changed

Lines changed: 83 additions & 55 deletions

File tree

src/core/app_state.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ void app_switch_to_menu() {
6363

6464
rtc6715.init(0, 0);
6565
system_script(REC_STOP_LIVE);
66-
67-
#ifdef HDZBOXPRO
68-
// Restore image settings from av module
69-
screen.brightness(g_setting.image.oled);
70-
Set_Contrast(g_setting.image.contrast);
71-
#endif
7266
}
7367

7468
void app_exit_menu() {
@@ -100,11 +94,6 @@ void app_switch_to_analog(bool is_av_in) {
10094
if (is_av_in) {
10195
rtc6715.init(0, 0);
10296
} else {
103-
#if defined HDZBOXPRO
104-
// Solve LCD residual image
105-
screen.brightness(7);
106-
Set_Contrast(14);
107-
#endif
10897
rtc6715.init(1, g_setting.record.audio_source == SETTING_RECORD_AUDIO_SOURCE_AV_IN);
10998
rtc6715.set_ch(g_setting.source.analog_channel - 1);
11099
}
@@ -124,12 +113,6 @@ void app_switch_to_hdmi_in() {
124113
#if defined HDZGOGGLE2
125114
system_exec("aww 0x0300b084 0x0001555");
126115
#endif
127-
128-
#if defined HDZBOXPRO
129-
// Restore image settings from av module
130-
screen.brightness(g_setting.image.oled);
131-
Set_Contrast(g_setting.image.contrast);
132-
#endif
133116
rtc6715.init(0, 0);
134117

135118
Source_HDMI_in();
@@ -170,11 +153,6 @@ void app_switch_to_hdzero(bool is_default) {
170153
system_exec("aww 0x0300b084 0x0001555");
171154
#endif
172155

173-
#if defined HDZBOXPRO
174-
// Restore image settings from av module
175-
screen.brightness(g_setting.image.oled);
176-
Set_Contrast(g_setting.image.contrast);
177-
#endif
178156
rtc6715.init(0, 0);
179157

180158
if (is_default) {
@@ -247,12 +225,6 @@ void app_switch_to_hdzero(bool is_default) {
247225
void hdzero_switch_channel(int channel) {
248226
channel &= 0x7f;
249227

250-
#if defined HDZBOXPRO
251-
// Restore image settings from av module
252-
screen.brightness(g_setting.image.oled);
253-
Set_Contrast(g_setting.image.contrast);
254-
#endif
255-
256228
LOGI("hdzero_switch_channel to bw:%d, band:%d, ch:%d, CAM_MODE=%d 4:3=%d", g_setting.source.hdzero_bw, g_setting.source.hdzero_band, channel, CAM_MODE, cam_4_3);
257229
DM6302_SetChannel(g_setting.source.hdzero_band, channel);
258230
DM5680_clear_vldflg();

src/core/ht.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,7 @@ static void detect_motion(bool is_moving) {
9696
#endif
9797
if (is_moving) {
9898
// we got motion, turn oled back on, start over
99-
#if defined(HDZGOGGLE) || defined(HDZGOGGLE2)
10099
screen.brightness(g_setting.image.oled);
101-
#elif defined(HDZBOXPRO)
102-
if (g_source_info.source == SOURCE_AV_MODULE) {
103-
screen.brightness(7);
104-
} else {
105-
screen.brightness(g_setting.image.oled);
106-
}
107-
#endif
108100
state = OLED_MD_DETECTING;
109101
cnt = 0;
110102
}
@@ -153,11 +145,6 @@ static void detect_motion(bool is_moving) {
153145
LOGI("OLED ON from protection.");
154146

155147
screen.brightness(g_setting.image.oled);
156-
#ifdef HDZBOXPRO
157-
if (g_source_info.source == SOURCE_AV_MODULE) {
158-
screen.brightness(7);
159-
}
160-
#endif
161148

162149
hw_screen_on(1);
163150
state = OLED_MD_DETECTING;

src/driver/hardware-boxpro.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ int AV_in_detect() // return = 1: vtmg to V536 changed
725725
{
726726
static int det_last = -1;
727727
static int det_cnt = 0, det2_cnt = 0;
728+
static int orbit_cnt = 0;
728729
int rdat, det;
729730
int ret = 0;
730731

@@ -823,6 +824,15 @@ int AV_in_detect() // return = 1: vtmg to V536 changed
823824
det2_cnt = 0;
824825
break;
825826
}
827+
828+
if (g_hw_stat.av_valid[g_hw_stat.is_av_in] == 2 && g_setting.osd.orbit > 0) {
829+
if (orbit_cnt >= (180 >> g_setting.osd.orbit)) {
830+
TP2825_orbit(g_setting.osd.orbit);
831+
orbit_cnt = 0;
832+
} else {
833+
orbit_cnt++;
834+
}
835+
}
826836
}
827837
}
828838

src/driver/tp2825-boxpro.c

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,62 @@
1111
#include <stdlib.h>
1212
#include <unistd.h>
1313

14+
uint8_t orbit_x = 0, orbit_y = 0;
15+
uint8_t orbit_move = 0;
16+
17+
void TP2825_orbit(int orbit_setting) {
18+
static int orbit_level = 0;
19+
20+
if (orbit_setting > 0 && orbit_x > 0 && orbit_y > 0) {
21+
22+
if (orbit_level != orbit_setting) {
23+
orbit_level = orbit_setting;
24+
orbit_move = 0;
25+
}
26+
27+
switch (orbit_move) {
28+
case 0:
29+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x);
30+
I2C_Write(ADDR_TP2825, 0x08, orbit_y);
31+
orbit_move = 1;
32+
break;
33+
case 1:
34+
if (orbit_level > 1) {
35+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x + 1);
36+
I2C_Write(ADDR_TP2825, 0x08, orbit_y + 1);
37+
} else {
38+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x);
39+
I2C_Write(ADDR_TP2825, 0x08, orbit_y + 1);
40+
}
41+
orbit_move = 2;
42+
break;
43+
case 2:
44+
if (orbit_level > 1) {
45+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x + 2);
46+
I2C_Write(ADDR_TP2825, 0x08, orbit_y);
47+
} else {
48+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x + 1);
49+
I2C_Write(ADDR_TP2825, 0x08, orbit_y + 1);
50+
}
51+
orbit_move = 3;
52+
break;
53+
case 3:
54+
if (orbit_level > 1) {
55+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x + 1);
56+
I2C_Write(ADDR_TP2825, 0x08, orbit_y - 1);
57+
} else {
58+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x + 1);
59+
I2C_Write(ADDR_TP2825, 0x08, orbit_y);
60+
}
61+
orbit_move = 0;
62+
break;
63+
default:
64+
orbit_move = 0;
65+
break;
66+
}
67+
}
68+
}
69+
1470
void TP2825_close() {
1571
gpio_set(GPIO_TP2825_RSTB, 0);
1672
LOGI("TP2825 close");
@@ -33,24 +89,25 @@ void TP2825_init(bool is_av_in, bool is_pal) {
3389

3490
if (is_pal) {
3591
I2C_Write(ADDR_TP2825, 0x07, 0x12);
36-
I2C_Write(ADDR_TP2825, 0x08, 0x18);
92+
I2C_Write(ADDR_TP2825, 0x08, orbit_y = 0x18);
3793
I2C_Write(ADDR_TP2825, 0x09, 0x20);
38-
I2C_Write(ADDR_TP2825, 0x0A, 0x10);
94+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x = 0x10);
3995
I2C_Write(ADDR_TP2825, 0x0B, 0xD0);
4096
} else {
4197
I2C_Write(ADDR_TP2825, 0x07, 0x02);
42-
I2C_Write(ADDR_TP2825, 0x08, 0x12);
98+
I2C_Write(ADDR_TP2825, 0x08, orbit_y = 0x12);
4399
I2C_Write(ADDR_TP2825, 0x09, 0xF0);
44-
I2C_Write(ADDR_TP2825, 0x0A, 0x10);
100+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x = 0x10);
45101
I2C_Write(ADDR_TP2825, 0x0B, 0xD0);
46102
}
103+
orbit_move = 0;
47104

48-
I2C_Write(ADDR_TP2825, 0x10, 0x10);
49-
I2C_Write(ADDR_TP2825, 0x11, 0x48);
50-
// I2C_Write(ADDR_TP2825, 0x12, 0x51);
51-
// I2C_Write(ADDR_TP2825, 0x13, 0x80);
52-
// I2C_Write(ADDR_TP2825, 0x14, 0x80);
53-
// I2C_Write(ADDR_TP2825, 0x15, 0x00);
105+
I2C_Write(ADDR_TP2825, 0x10, 0x10); // brightness
106+
I2C_Write(ADDR_TP2825, 0x11, 0x48); // contrast
107+
I2C_Write(ADDR_TP2825, 0x2C, 0x28); // horizontal sharpness
108+
I2C_Write(ADDR_TP2825, 0x13, 0x80); // hue
109+
I2C_Write(ADDR_TP2825, 0x14, 0x80); // saturation
110+
I2C_Write(ADDR_TP2825, 0x17, 0x31); // vertical sharpness
54111

55112
I2C_Write(ADDR_TP2825, 0x25, 0x28);
56113

@@ -62,19 +119,20 @@ void TP2825_init(bool is_av_in, bool is_pal) {
62119
void TP2825_Switch_Mode(bool is_pal) {
63120
if (is_pal) {
64121
I2C_Write(ADDR_TP2825, 0x07, 0x12);
65-
I2C_Write(ADDR_TP2825, 0x08, 0x18);
122+
I2C_Write(ADDR_TP2825, 0x08, orbit_y = 0x18);
66123
I2C_Write(ADDR_TP2825, 0x09, 0x20);
67-
I2C_Write(ADDR_TP2825, 0x0A, 0x10);
124+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x = 0x10);
68125
I2C_Write(ADDR_TP2825, 0x0B, 0xD0);
69126
} else {
70127
I2C_Write(ADDR_TP2825, 0x07, 0x02);
71-
I2C_Write(ADDR_TP2825, 0x08, 0x12);
128+
I2C_Write(ADDR_TP2825, 0x08, orbit_y = 0x12);
72129
I2C_Write(ADDR_TP2825, 0x09, 0xF0);
73-
I2C_Write(ADDR_TP2825, 0x0A, 0x10);
130+
I2C_Write(ADDR_TP2825, 0x0A, orbit_x = 0x10);
74131
I2C_Write(ADDR_TP2825, 0x0B, 0xD0);
75132
}
76133

77134
I2C_Write(ADDR_TP2825, 0x06, 0x80);
135+
orbit_move = 0;
78136
}
79137

80138
void TP2825_Switch_CH(bool is_av_in) {

src/driver/tp2825.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extern "C" {
88

99
#include "ui/page_common.h"
1010

11+
void TP2825_orbit(int orbit_setting);
1112
void TP2825_close();
1213
void TP2825_open();
1314

0 commit comments

Comments
 (0)