source: titan/titan/oled.h @ 39988

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

fix

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