source: titan/titan/oled.h @ 39538

Last change on this file since 39538 was 39538, checked in by gost, 7 years ago

dm900 OLED... fix color I hope

  • Property svn:executable set to *
File size: 4.7 KB
Line 
1#ifndef OLED_H_
2#define OLED_H_
3
4void write2oled(unsigned char *buf, int xres, int yres)
5{
6        unsigned char* lfb1 = NULL;
7        unsigned char* lfb2 = NULL;
8        unsigned char byte;
9        int i = 0;
10        int bi = 0;
11        int ret = 0;
12       
13        int lcdfd1 = open(getconfig("vfddev", NULL), O_RDWR);
14       
15        if(checkbox("DM900") == 1)
16                lfb1 = malloc(xres * yres * 2);
17        else
18                lfb1 = malloc(xres * yres);
19        if(lfb1 == NULL)
20                return;
21
22        if(checkbox("DM900") != 1)
23        {
24               
25                for(i = 0; i <= xres*yres; i++)
26                {
27                        //             R                           B                          G
28                        lfb1[i] = ((76 * buf[bi+2]) / 255) + ((150 * buf[bi+1]) / 255) + ((28 * buf[bi]) / 255);
29                        bi = bi + 4;
30                }
31       
32               
33                if(checkchipset("BCM7424") == 1)
34                {
35                        ret = write(lcdfd1, lfb1, xres * yres);
36                        if(ret != xres * yres)
37                                err("write to oled - %s - was not ok", getconfig("vfddev", NULL));
38                }
39                //Die Displays der dm7020hd, dm7025+(?), dm7080 und dm8000 haben 128*64*4bpp, DM800se hat 96*64*16bpp (RGB565), dm800 und dm7025(?) haben 132*64*1bpp (ältere ggf. 120*64 oder 128*64)
40                else if(checkbox("DM7020HD") == 1 || checkbox("DM7020HDV2") == 1)
41                {
42                        bi = 0;
43                        lfb2 = malloc(xres * yres / 2);
44                        if(lfb2 == NULL)
45                                return;
46                        for(i = 0; i <= xres*yres; i = i + 2)
47                        {
48                                byte = lfb1[i] * 15 / 255;
49                                lfb2[bi] = (byte << 4) & 0xf0;
50                                byte = lfb1[i+1] * 15 / 255;
51                                lfb2[bi] |= byte & 0x0f;
52                                bi = bi + 1;
53                        }
54                        ret = write(lcdfd1, lfb2, xres * yres / 2);
55                        if(ret != xres * yres / 2)
56                                err("write to oled - %s - was not ok", getconfig("vfddev", NULL));
57                        free(lfb2);
58                }
59        }
60        else
61        {
62                //RGB565
63                for(i = 0; i <= xres*yres*2; i = i + 2)
64                {
65                        #lfb1[i] = buf[bi+2] & 0xF8;
66                        lfb1[i] = buf[bi+1] & 0xF8;
67                        byte = (buf[bi] >> 5) & 0x07;
68                        lfb1[i] = lfb1[i] ^ byte;
69                        lfb1[i+1] = (buf[bi] << 3) & 0xE0;
70                        #byte = (buf[bi+1] >> 3) & 0x1F;
71                        byte = (buf[bi+2] >> 3) & 0x1F;
72                        lfb1[i+1] = lfb1[i+1] ^ byte;
73                        bi = bi + 4;
74                }
75                ret = write(lcdfd1, lfb1, xres * yres * 2);
76                if(ret != xres * yres * 2)
77                        err("write to oled dm900 - %s - was not ok", getconfig("vfddev", NULL));
78                free(lfb2);
79        }
80        close(lcdfd1);
81       
82        free(lfb1);
83        return;
84}
85
86int oledtext(char *value)
87{
88        struct skin* OLED_all = NULL;
89       
90        if(getconfigint("oled_off", NULL) == 1)
91                return 0;
92
93        m_lock(&status.drawingmutex, 0);
94       
95        if(checkchipset("BCM7424") == 1)
96        {
97                if(status.updatevfd == PAUSE)
98                        OLED_all = getscreen("OLED_nemesis_menu");
99                else if(status.standby > 0)
100                        OLED_all = getscreen("OLED_nemesis_standby");
101                else
102                {
103                        if(getskinconfig("OLED_nemesis", NULL) == NULL)
104                                OLED_all = getscreen("OLED_nemesis");
105                        else
106                                OLED_all = getscreen(getskinconfig("OLED_nemesis", NULL));
107                }
108        }
109        else if(checkbox("DM7020HD") == 1 || checkbox("DM7020HDV2") == 1)
110        {
111                if(status.updatevfd == PAUSE)
112                        OLED_all = getscreen("OLED_dream1_menu");
113                else if(status.standby > 0)
114                        OLED_all = getscreen("OLED_dream1_standby");
115                else
116                {
117                        if(getskinconfig("OLED_dream1", NULL) == NULL)
118                                OLED_all = getscreen("OLED_dream1");
119                        else
120                                OLED_all = getscreen(getskinconfig("OLED_dream1", NULL));
121                }
122        }
123        else if(checkbox("DM900") == 1)
124        {
125                if(status.updatevfd == PAUSE)
126                        OLED_all = getscreen("OLED_dream2_menu");
127                else if(status.standby > 0)
128                        OLED_all = getscreen("OLED_dream2_standby");
129                else
130                {
131                        if(getskinconfig("OLED_dream2", NULL) == NULL)
132                                OLED_all = getscreen("OLED_dream2");
133                        else
134                                OLED_all = getscreen(getskinconfig("OLED_dream2", NULL));
135                }
136        }               
137               
138       
139        struct skin* textbox = getscreennode(OLED_all, "textbox");
140       
141        if(status.standby == 2 && status.epgscanlistthread != NULL)
142                changetext(textbox, "EPG-Scan");
143        else
144                changetext(textbox, value);
145
146        drawscreen(OLED_all, 0, 2);
147        m_unlock(&status.drawingmutex, 0);
148       
149        return 0;
150}
151
152struct fb* oledaddfb(int width, int height)
153{
154        struct fb *newnode = NULL;
155        char *name = ostrcat("oledskinfb", NULL, 0, 0);
156        newnode = (struct fb*)malloc(sizeof(struct fb));
157               
158        unsigned char *newskinfb = calloc(1, 4 * width * height);
159        if(newskinfb == NULL)
160                return NULL;
161        memset(newnode, 0, sizeof(struct fb));
162        newnode->name = name;
163        newnode->dev = 999;
164        newnode->width = width;
165        newnode->height = height;
166        newnode->colbytes = 4;
167        newnode->pitch = newnode->width * newnode->colbytes;
168        newnode->fb = newskinfb;
169        newnode->fblong = (unsigned long*)newnode->fb;
170        newnode->fd = -1;
171        newnode->fixfbsize = 4 * width * height;
172        newnode->data_phys = 0;
173       
174        return newnode;
175}
176
177void initOLEDdream1()
178{
179#ifndef LCD_IOCTL_ASC_MODE
180#define LCDSET                  0x1000
181#define LCD_IOCTL_ASC_MODE              (21|LCDSET)
182#define LCD_MODE_ASC                    0
183#define LCD_MODE_BIN                    1
184#endif
185
186return; //wird nicht benötigt
187
188        int i=LCD_MODE_BIN;
189        //int lcdfd = open("/dev/dbox/oled0", O_RDWR);
190        int lcdfd1 = open(getconfig("vfddev", NULL), O_RDWR);
191        if(lcdfd1 > -1)
192        {
193                ioctl(lcdfd1, LCD_IOCTL_ASC_MODE, &i);
194                close(lcdfd1);
195        }
196}       
197
198#endif 
199       
Note: See TracBrowser for help on using the repository browser.