source: titan/titan/oled.h @ 34127

Last change on this file since 34127 was 34127, checked in by gost, 9 years ago

[titan] fix unexpected reboot... I hope

  • Property svn:executable set to *
File size: 2.1 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        int i = 0;
8        int bi = 0;
9       
10        lfb1 = malloc(xres * yres);
11        if(lfb1 == NULL)
12                return;
13               
14        for(i = 0; i <= xres*yres; i++)
15        {
16                //             R                           B                          G
17                lfb1[i] = ((76 * buf[bi+2]) / 255) + ((150 * buf[bi+1]) / 255) + ((28 * buf[bi]) / 255);
18                bi = bi + 4;
19        }
20       
21        int lcdfd1 = open("/dev/dbox/oled0", O_RDWR);
22        write(lcdfd1, lfb1, xres * yres);
23        close(lcdfd1);
24       
25        free(lfb1);
26        return;
27}
28
29int oledtext(char *value)
30{
31        struct skin* OLED_nemesis = NULL;
32       
33        if(getconfigint("oled_off", NULL) == 1)
34                return 0;
35       
36        //if(getconfigint("oled_mutex", NULL) == 1)
37        //{
38        m_lock(&status.drawingmutex, 0);
39        //}
40       
41        if(status.updatevfd == PAUSE)
42                OLED_nemesis = getscreen("OLED_nemesis_menu");
43        else if(status.standby > 0)
44                OLED_nemesis = getscreen("OLED_nemesis_standby");
45        else
46        {
47                if(getskinconfig("OLED_nemesis", NULL) == NULL)
48                        OLED_nemesis = getscreen("OLED_nemesis");
49                else
50                        OLED_nemesis = getscreen(getskinconfig("OLED_nemesis", NULL));
51        }
52       
53        struct skin* textbox = getscreennode(OLED_nemesis, "textbox");
54       
55        if(status.standby == 2 && status.epgscanlistthread != NULL)
56                changetext(textbox, "EPG-Scan");
57        else
58                changetext(textbox, value);
59        //if(getconfigint("oled_mutex", NULL) == 1)
60        //{
61        drawscreen(OLED_nemesis, 0, 2);
62        m_unlock(&status.drawingmutex, 0);
63        //}
64        //else
65        //      drawscreen(OLED_nemesis, 0, 0);
66       
67       
68       
69        return 0;
70}
71
72struct fb* oledaddfb(int width, int height)
73{
74        struct fb *newnode = NULL;
75        char *name = ostrcat("oledskinfb", NULL, 0, 0);
76        newnode = (struct fb*)malloc(sizeof(struct fb));
77               
78        unsigned char *newskinfb = calloc(1, 4 * width * height);
79        if(newskinfb == NULL)
80                return NULL;
81        memset(newnode, 0, sizeof(struct fb));
82        newnode->name = name;
83        newnode->dev = 999;
84        newnode->width = width;
85        newnode->height = height;
86        newnode->colbytes = 4;
87        newnode->pitch = newnode->width * newnode->colbytes;
88        newnode->fb = newskinfb;
89        newnode->fblong = (unsigned long*)newnode->fb;
90        newnode->fd = -1;
91        newnode->fixfbsize = 4 * width * height;
92       
93        return newnode;
94}       
95
96#endif 
97       
Note: See TracBrowser for help on using the repository browser.