source: titan/titan/oled.h @ 39562

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

fix

  • Property svn:executable set to *
File size: 4.6 KB
RevLine 
[28941]1#ifndef OLED_H_
2#define OLED_H_
3
[28943]4void write2oled(unsigned char *buf, int xres, int yres)
[28941]5{
[29094]6        unsigned char* lfb1 = NULL;
[36636]7        unsigned char* lfb2 = NULL;
[39428]8        unsigned char byte;
[28941]9        int i = 0;
10        int bi = 0;
[36636]11        int ret = 0;
[28941]12       
[39428]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);
[29094]19        if(lfb1 == NULL)
[28941]20                return;
[39428]21
22        if(checkbox("DM900") != 1)
23        {
[28941]24               
[39428]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                }
[28941]31       
[39428]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                }
[36636]59        }
[39428]60        else
[36636]61        {
[39555]62                //gggbbbbbrrrrrggg
63                for(i = 0; i < xres*yres*2; i = i + 2)
[36636]64                {
[39562]65                        lfb2[i] = ((buf[bi+1] << 3) & 0xE0) | ((buf[bi] >> 3) & 0x1F);
66                        lfb2[i+1] = (buf[bi+2] & 0xF8) | ((buf[bi+1] >> 3) & 0x07);
[39561]67                        bi = bi + 4;
[39555]68                       
[36636]69                }
[39561]70                ret = write(lcdfd1, lfb2, xres * yres * 2);
[39428]71                if(ret != xres * yres * 2)
72                        err("write to oled dm900 - %s - was not ok", getconfig("vfddev", NULL));
[36636]73                free(lfb2);
74        }
[29094]75        close(lcdfd1);
[28941]76       
[29094]77        free(lfb1);
[28941]78        return;
79}
80
[29094]81int oledtext(char *value)
82{
[36636]83        struct skin* OLED_all = NULL;
[29107]84       
[34044]85        if(getconfigint("oled_off", NULL) == 1)
[34041]86                return 0;
[36636]87
[34127]88        m_lock(&status.drawingmutex, 0);
[34120]89       
[36636]90        if(checkchipset("BCM7424") == 1)
[29930]91        {
[36636]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");
[30888]96                else
[36636]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                }
[29930]103        }
[36753]104        else if(checkbox("DM7020HD") == 1 || checkbox("DM7020HDV2") == 1)
[36636]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                }
[39428]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        }               
[36636]132               
[29107]133       
[36636]134        struct skin* textbox = getscreennode(OLED_all, "textbox");
[29094]135       
[32031]136        if(status.standby == 2 && status.epgscanlistthread != NULL)
137                changetext(textbox, "EPG-Scan");
138        else
139                changetext(textbox, value);
[36636]140
141        drawscreen(OLED_all, 0, 2);
[34127]142        m_unlock(&status.drawingmutex, 0);
[29094]143       
144        return 0;
145}
146
[29235]147struct fb* oledaddfb(int width, int height)
[29094]148{
149        struct fb *newnode = NULL;
150        char *name = ostrcat("oledskinfb", NULL, 0, 0);
151        newnode = (struct fb*)malloc(sizeof(struct fb));
[29235]152               
[29094]153        unsigned char *newskinfb = calloc(1, 4 * width * height);
[29235]154        if(newskinfb == NULL)
155                return NULL;
[29094]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;
[36636]167        newnode->data_phys = 0;
[29094]168       
169        return newnode;
[36636]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
[36824]181return; //wird nicht benötigt
182
[36636]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        }
[29094]191}       
192
[28941]193#endif 
194       
Note: See TracBrowser for help on using the repository browser.