source: titan/titan/oled.h @ 39572

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

fix oled code

  • Property svn:executable set to *
File size: 4.6 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                //gggbbbbbrrrrrggg
63                for(i = 0; i < xres*yres*2; i = i + 2)
64                {
65                        lfb1[i] = ((buf[bi+1] << 3) & 0xE0) | ((buf[bi] >> 3) & 0x1F);
66                        lfb1[i+1] = (buf[bi+2] & 0xF8) | ((buf[bi+1] >> 5) & 0x07);
67                        bi = bi + 4;
68                }
69                ret = write(lcdfd1, lfb1, xres * yres * 2);
70                if(ret != xres * yres * 2)
71                        err("write to oled dm900 - %s - was not ok", getconfig("vfddev", NULL));
72                free(lfb2);
73        }
74        }
75        close(lcdfd1);
76       
77        free(lfb1);
78        return;
79}
80
81int oledtext(char *value)
82{
83        struct skin* OLED_all = NULL;
84       
85        if(getconfigint("oled_off", NULL) == 1)
86                return 0;
87
88        m_lock(&status.drawingmutex, 0);
89       
90        if(checkchipset("BCM7424") == 1)
91        {
92                if(status.updatevfd == PAUSE)
93                        OLED_all = getscreen("OLED_nemesis_menu");
94                else if(status.standby > 0)
95                        OLED_all = getscreen("OLED_nemesis_standby");
96                else
97                {
98                        if(getskinconfig("OLED_nemesis", NULL) == NULL)
99                                OLED_all = getscreen("OLED_nemesis");
100                        else
101                                OLED_all = getscreen(getskinconfig("OLED_nemesis", NULL));
102                }
103        }
104        else if(checkbox("DM7020HD") == 1 || checkbox("DM7020HDV2") == 1)
105        {
106                if(status.updatevfd == PAUSE)
107                        OLED_all = getscreen("OLED_dream1_menu");
108                else if(status.standby > 0)
109                        OLED_all = getscreen("OLED_dream1_standby");
110                else
111                {
112                        if(getskinconfig("OLED_dream1", NULL) == NULL)
113                                OLED_all = getscreen("OLED_dream1");
114                        else
115                                OLED_all = getscreen(getskinconfig("OLED_dream1", NULL));
116                }
117        }
118        else if(checkbox("DM900") == 1)
119        {
120                if(status.updatevfd == PAUSE)
121                        OLED_all = getscreen("OLED_dream2_menu");
122                else if(status.standby > 0)
123                        OLED_all = getscreen("OLED_dream2_standby");
124                else
125                {
126                        if(getskinconfig("OLED_dream2", NULL) == NULL)
127                                OLED_all = getscreen("OLED_dream2");
128                        else
129                                OLED_all = getscreen(getskinconfig("OLED_dream2", NULL));
130                }
131        }               
132               
133       
134        struct skin* textbox = getscreennode(OLED_all, "textbox");
135       
136        if(status.standby == 2 && status.epgscanlistthread != NULL)
137                changetext(textbox, "EPG-Scan");
138        else
139                changetext(textbox, value);
140
141        drawscreen(OLED_all, 0, 2);
142        m_unlock(&status.drawingmutex, 0);
143       
144        return 0;
145}
146
147struct fb* oledaddfb(int width, int height)
148{
149        struct fb *newnode = NULL;
150        char *name = ostrcat("oledskinfb", NULL, 0, 0);
151        newnode = (struct fb*)malloc(sizeof(struct fb));
152               
153        unsigned char *newskinfb = calloc(1, 4 * width * height);
154        if(newskinfb == NULL)
155                return NULL;
156        memset(newnode, 0, sizeof(struct fb));
157        newnode->name = name;
158        newnode->dev = 999;
159        newnode->width = width;
160        newnode->height = height;
161        newnode->colbytes = 4;
162        newnode->pitch = newnode->width * newnode->colbytes;
163        newnode->fb = newskinfb;
164        newnode->fblong = (unsigned long*)newnode->fb;
165        newnode->fd = -1;
166        newnode->fixfbsize = 4 * width * height;
167        newnode->data_phys = 0;
168       
169        return newnode;
170}
171
172void initOLEDdream1()
173{
174#ifndef LCD_IOCTL_ASC_MODE
175#define LCDSET                  0x1000
176#define LCD_IOCTL_ASC_MODE              (21|LCDSET)
177#define LCD_MODE_ASC                    0
178#define LCD_MODE_BIN                    1
179#endif
180
181return; //wird nicht benötigt
182
183        int i=LCD_MODE_BIN;
184        //int lcdfd = open("/dev/dbox/oled0", O_RDWR);
185        int lcdfd1 = open(getconfig("vfddev", NULL), O_RDWR);
186        if(lcdfd1 > -1)
187        {
188                ioctl(lcdfd1, LCD_IOCTL_ASC_MODE, &i);
189                close(lcdfd1);
190        }
191}       
192
193#endif 
194       
Note: See TracBrowser for help on using the repository browser.