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+
1470void 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) {
62119void 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
80138void TP2825_Switch_CH (bool is_av_in ) {
0 commit comments