source: titan/plugins/lcdsamsung/lcdsamsung.c @ 20406

Last change on this file since 20406 was 20406, checked in by gost, 11 years ago

[lcdsamsung] extension for analog clock

  • Property svn:executable set to *
File size: 30.6 KB
Line 
1#include "../../titan/struct.h"
2#include "../../titan/debug.h"
3#include "../../titan/header.h"
4
5#include "lcd_weather.h"
6
7char pluginname[] = "LCD Samsung SPF..";
8char plugindesc[] = "Extensions";
9char pluginpic[] = "%pluginpath%/lcdsamsung/lcdsamsung.png";
10
11int pluginaktiv = 0;
12//int pluginversion = PLUGINVERSION;
13int pluginversion = 999999;
14
15struct stimerthread* LCD_Samsung1thread = NULL;
16
17int firststart = 0;
18
19void weather_getline(FILE* fd, char* fileline)
20{
21        fgets(fileline, 256, fd);
22        if(fileline[0] == '#' || fileline[0] == '\n')
23                return;
24        if(fileline[strlen(fileline) - 1] == '\n')
25                fileline[strlen(fileline) - 1] = '\0';
26        if(fileline[strlen(fileline) - 1] == '\r')
27                fileline[strlen(fileline) - 1] = '\0';
28}
29
30void LCD_start_lcd4linux()
31{
32        int count = 0;
33        char* startlcd = NULL;
34       
35        if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf75h") == 0)
36                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 1", 0, 0);
37        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf83h") == 0)
38                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 6", 0, 0);
39        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87hold") == 0)
40                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 3", 0, 0);
41        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87h") == 0)
42                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 2", 0, 0);
43        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf105p") == 0)
44                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 5", 0, 0);
45        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf107h") == 0)
46                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 4", 0, 0);
47        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf72h") == 0)
48                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 7", 0, 0);
49        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85h") == 0)
50                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 8", 0, 0);
51        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85p") == 0)
52                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 9", 0, 0);
53        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "none") == 0)
54                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 99", 0, 0);
55        else
56                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 2", 0, 0);
57       
58       
59        if(LCD_Samsung1thread == NULL)
60                return;
61        while (LCD_Samsung1thread->aktion != STOP && system("ps | grep -v grep | grep fbread") != 0) {
62                system(startlcd);
63                sleep(6);
64                count ++;
65                if(LCD_Samsung1thread == NULL)
66                        break;
67                if(count == 101) {
68                        textbox(_("Message"), _("ERROR cant start LCD driver"), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 5, 0);
69                        LCD_Samsung1thread->aktion = STOP;
70                }
71        }
72        free(startlcd);startlcd=NULL;   
73}
74
75void LCD_Samsung1_thread()
76{
77       
78        struct skin* LCD_Samsung1 = NULL;
79        struct skin* LCD_Standby = NULL;
80        struct skin* LCD_Play = NULL;
81       
82        struct skin* day0_t = NULL;
83        struct skin* day0_i = NULL;
84        struct skin* day0_d = NULL;
85        struct skin* day1_t = NULL;
86        struct skin* day1_i = NULL;
87        struct skin* day1_d = NULL;
88        struct skin* day2_t = NULL;
89        struct skin* day2_i = NULL;
90        struct skin* day2_d = NULL;
91        struct skin* day3_t = NULL;
92        struct skin* day3_i = NULL;
93        struct skin* day3_d = NULL;
94        struct skin* akttime = NULL;
95        struct skin* akttime_Standby = NULL;
96       
97        struct skin* n_stunde = NULL;
98        struct skin* n_minute = NULL;
99       
100        struct skin* sday0_t = NULL;
101        struct skin* sday0_i = NULL;
102        struct skin* sday0_d = NULL;
103        struct skin* sday1_t = NULL;
104        struct skin* sday1_i = NULL;
105        struct skin* sday1_d = NULL;
106        struct skin* sday2_t = NULL;
107        struct skin* sday2_i = NULL;
108        struct skin* sday2_d = NULL;
109        struct skin* sday3_t = NULL;
110        struct skin* sday3_i = NULL;
111        struct skin* sday3_d = NULL;
112       
113       
114        char* tmpstr = NULL, *tmpstr2 = NULL, *tmpstr3 = NULL, *timemerk = NULL, *sendermerk = NULL, *recmerk = NULL;
115        char* pichr = NULL, *picmin = NULL, *pichr_standby = NULL, *picmin_standby = NULL;
116        FILE *fd = NULL;
117        char *fileline = NULL;
118        int weatherwrite = 999;
119        int weatherref = 0;
120        char* startlcd = NULL;
121       
122        if(ostrcmp(getconfig("lcd_samsung_plugin_wetter", NULL), "yes") == 0)
123        {
124                if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf75h") == 0)
125                        LCD_Samsung1 = getscreen("LCD_spf75_Wetter");
126                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87h") == 0)
127                        LCD_Samsung1 = getscreen("LCD_spf87_Wetter");
128                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf83h") == 0)
129                        LCD_Samsung1 = getscreen("LCD_spf83_Wetter");
130                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87hold") == 0)
131                        LCD_Samsung1 = getscreen("LCD_spf87_Wetter");
132                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf105p") == 0)
133                        LCD_Samsung1 = getscreen("LCD_spf105_Wetter");
134                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf107h") == 0)
135                        LCD_Samsung1 = getscreen("LCD_spf107_Wetter");
136                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf72h") == 0)
137                        LCD_Samsung1 = getscreen("LCD_spf72_Wetter");
138                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85h") == 0)
139                        LCD_Samsung1 = getscreen("LCD_spf85_Wetter");
140                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85p") == 0)
141                        LCD_Samsung1 = getscreen("LCD_spf85_Wetter");
142                else
143                        LCD_Samsung1 = getscreen("LCD_spf87_Wetter");
144                day0_t = getscreennode(LCD_Samsung1, "day0_t");
145                day0_i = getscreennode(LCD_Samsung1, "day0_i");
146                day0_d = getscreennode(LCD_Samsung1, "day0_d");
147                day1_t = getscreennode(LCD_Samsung1, "day1_t");
148                day1_i = getscreennode(LCD_Samsung1, "day1_i");
149                day1_d = getscreennode(LCD_Samsung1, "day1_d");
150                day2_t = getscreennode(LCD_Samsung1, "day2_t");
151                day2_i = getscreennode(LCD_Samsung1, "day2_i");
152                day2_d = getscreennode(LCD_Samsung1, "day2_d");
153                day3_t = getscreennode(LCD_Samsung1, "day3_t");
154                day3_i = getscreennode(LCD_Samsung1, "day3_i");
155                day3_d = getscreennode(LCD_Samsung1, "day3_d");
156                akttime = getscreennode(LCD_Samsung1, "akttime");
157                n_stunde =  getscreennode(LCD_Samsung1, "stunde");
158                n_minute =  getscreennode(LCD_Samsung1, "minute");
159                if(file_exist("/tmp/lcdweather"))
160                        system("rm /tmp/lcdweather");
161                weatherwrite = 0;
162        }
163        else {
164                if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf75h") == 0)
165                        LCD_Samsung1 = getscreen("LCD_spf75");
166                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf83h") == 0)
167                        LCD_Samsung1 = getscreen("LCD_spf83");
168                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87h") == 0)
169                        LCD_Samsung1 = getscreen("LCD_spf87");
170                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87hold") == 0)
171                        LCD_Samsung1 = getscreen("LCD_spf87");
172                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf105p") == 0)
173                        LCD_Samsung1 = getscreen("LCD_spf105");
174                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf107h") == 0)
175                        LCD_Samsung1 = getscreen("LCD_spf107");
176                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf72h") == 0)
177                        LCD_Samsung1 = getscreen("LCD_spf72");
178                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85h") == 0)
179                        LCD_Samsung1 = getscreen("LCD_spf85");
180                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85p") == 0)
181                        LCD_Samsung1 = getscreen("LCD_spf85");
182                else
183                        LCD_Samsung1 = getscreen("LCD_spf87"); 
184                akttime = getscreennode(LCD_Samsung1, "akttime");
185                n_stunde =  getscreennode(LCD_Samsung1, "stunde");
186                if(n_stunde != NULL)
187                        pichr = ostrcat(n_stunde->pic, "", 0, 0);
188                n_minute =  getscreennode(LCD_Samsung1, "minute");
189                if(n_minute != NULL)
190                        picmin = ostrcat(n_minute->pic, "", 0, 0);
191        }
192       
193        if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf75h") == 0)
194                LCD_Play = getscreen("LCD_spf75_Play");
195        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf83h") == 0)
196                LCD_Play = getscreen("LCD_spf83_Play");
197        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87h") == 0)
198                LCD_Play = getscreen("LCD_spf87_Play");
199        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87hold") == 0)
200                LCD_Play = getscreen("LCD_spf87_Play");
201        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf105p") == 0)
202                LCD_Play = getscreen("LCD_spf105_Play");
203        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf107h") == 0)
204                LCD_Play = getscreen("LCD_spf107_Play");
205        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf72h") == 0)
206                LCD_Play = getscreen("LCD_spf72_Play");
207        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85h") == 0)
208                LCD_Play = getscreen("LCD_spf85_Play");
209        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85p") == 0)
210                LCD_Play = getscreen("LCD_spf85_Play");
211        else
212                LCD_Play = getscreen("LCD_spf87_Play");
213        struct skin* akttimeplay = getscreennode(LCD_Play, "akttime");
214        struct skin* sprogress = getscreennode(LCD_Play, "progress");
215        struct skin* stitle = getscreennode(LCD_Play, "title1");
216        struct skin* spos = getscreennode(LCD_Play, "pos");
217        struct skin* slen = getscreennode(LCD_Play, "len");
218        struct skin* sreverse = getscreennode(LCD_Play, "reverse");
219               
220        if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf75h") == 0)
221                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 1", 0, 0);
222        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf83h") == 0)
223                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 6", 0, 0);
224        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87hold") == 0)
225                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 3", 0, 0);
226        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87h") == 0)
227                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 2", 0, 0);
228        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf105p") == 0)
229                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 5", 0, 0);
230        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf107h") == 0)
231                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 4", 0, 0);
232        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf72h") == 0)
233                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 7", 0, 0);
234        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85h") == 0)
235                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 8", 0, 0);
236        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85p") == 0)
237                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 9", 0, 0);
238        else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "none") == 0)
239                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 99", 0, 0);
240        else
241                startlcd = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/start.sh 2", 0, 0);
242       
243       
244        if(ostrcmp(getconfig("lcd_samsung_plugin_standby", NULL), "yes") == 0)
245        {
246                if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf75h") == 0)
247                        LCD_Standby = getscreen("LCD_spf75_Standby");
248                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf83h") == 0)
249                        LCD_Standby = getscreen("LCD_spf83_Standby");
250                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87h") == 0)
251                        LCD_Standby = getscreen("LCD_spf87_Standby");
252                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf87hold") == 0)
253                        LCD_Standby = getscreen("LCD_spf87_Standby");
254                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf105p") == 0)
255                        LCD_Standby = getscreen("LCD_spf105_Standby");
256                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf107h") == 0)
257                        LCD_Standby = getscreen("LCD_spf107_Standby");
258                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf72h") == 0)
259                        LCD_Standby = getscreen("LCD_spf72_Standby");
260                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85h") == 0)
261                        LCD_Standby = getscreen("LCD_spf85_Standby");
262                else if(ostrcmp(getconfig("lcd_samsung_plugin_type", NULL), "spf85p") == 0)
263                        LCD_Standby = getscreen("LCD_spf85_Standby");
264                else
265                        LCD_Standby = getscreen("LCD_spf87_Standby");
266                akttime_Standby = getscreennode(LCD_Standby, "akttime");
267                sday0_t = getscreennode(LCD_Standby, "day0_t");
268                sday0_i = getscreennode(LCD_Standby, "day0_i");
269                sday0_d = getscreennode(LCD_Standby, "day0_d");
270                sday1_t = getscreennode(LCD_Standby, "day1_t");
271                sday1_i = getscreennode(LCD_Standby, "day1_i");
272                sday1_d = getscreennode(LCD_Standby, "day1_d");
273                sday2_t = getscreennode(LCD_Standby, "day2_t");
274                sday2_i = getscreennode(LCD_Standby, "day2_i");
275                sday2_d = getscreennode(LCD_Standby, "day2_d");
276                sday3_t = getscreennode(LCD_Standby, "day3_t");
277                sday3_i = getscreennode(LCD_Standby, "day3_i");
278                sday3_d = getscreennode(LCD_Standby, "day3_d");
279               
280                struct skin* n_stunde_standby =  getscreennode(LCD_Standby, "stunde");
281                if(n_stunde_standby != NULL)
282                        pichr_standby = ostrcat(n_stunde_standby->pic, "", 0, 0);
283                struct skin* n_minute_standby =  getscreennode(LCD_Standby, "minute");
284                if(n_minute_standby != NULL)
285                        picmin_standby = ostrcat(n_minute_standby->pic, "", 0, 0);
286
287        }
288       
289       
290        int put = 0, typemerk = 0, type = 0;
291        int standby = 0;
292       
293        unsigned long long int pos = 0, len = 0, reverse = 0;
294        int playertype = 0;
295        int loopcount = 0;
296       
297        int hr = 0, min = 0;
298       
299        if(firststart == 1)
300                sleep(8);
301        firststart = 0;
302        status.write_png = 0;
303        //if(ostrcmp(getconfig("write_fb_to_jpg", NULL), "yes") == 0)
304        //      status.write_png = 1;
305       
306        while (LCD_Samsung1thread->aktion != STOP) {
307
308                tmpstr = gettime(NULL, "%H:%M");
309                hr = atoi(gettime(NULL, "%H"));
310                min = atoi(gettime(NULL, "%M"));
311               
312                // TV Programm läuft
313                if(status.infobaraktiv == 1)
314                {
315                        if(ostrcmp(getconfig("write_fb_to_jpg", NULL), "yes") == 0) {
316                                //status.write_png = 1;
317                                if(type == 999)
318                                        system("killall -3 fbread");
319                        }
320                        tmpstr2 = getaktchannelname(NULL);
321                        tmpstr3 = getrec(NULL, NULL);
322                        type = 1;
323                }
324                // Aufzeichnung wird abgespielt
325                else if(status.playspeed != 0 || status.play != 0 || status.pause != 0)
326                {
327                        if(type == 999)
328                                system("killall -3 fbread");
329                        //status.write_png = 0;
330                        loopcount++ ;
331                        type = 2;
332                }
333                // Sonstige Anzeigen
334                else if(type != 999)
335                {
336                        if(ostrcmp(getconfig("write_fb_to_jpg", NULL), "yes") == 0) {
337                                //status.write_png = 1;
338                                system("killall -1 fbread");
339                        }
340                        type = 999;
341                }
342                else
343                        type = 999;
344               
345                if(typemerk != type)
346                {
347                        put = 1;
348                        typemerk = type;
349                        free(sendermerk);sendermerk=NULL;
350                        free(recmerk);recmerk=NULL;
351                        loopcount = 0;
352                }
353                else
354                        put = 0;
355
356                if(status.security == 1)
357                {
358                        if(status.standby == 1 && standby == 0)
359                        {
360                                if(ostrcmp(getconfig("lcd_samsung_plugin_standby", NULL), "yes") == 0)
361                                        standby = 2;
362                                else
363                                {
364                                        tmpstr = ostrcat("cp ", getconfig("pluginpath", NULL), 0, 0);
365                                        tmpstr = ostrcat(tmpstr, "/lcdsamsung/standby.jpg", 1, 0);
366                                        tmpstr = ostrcat(tmpstr, " /tmp/titanlcd.jpg", 1, 0);
367                                        system(tmpstr);
368                                        free(tmpstr); tmpstr=NULL;
369                                        sleep(3);
370                                        tmpstr = ostrcat("cp ", getconfig("pluginpath", NULL), 0, 0);
371                                        tmpstr = ostrcat(tmpstr, "/lcdsamsung/black.jpg", 1, 0);
372                                        tmpstr = ostrcat(tmpstr, " /tmp/titanlcd.jpg", 1, 0);
373                                        system(tmpstr);
374                                        sleep(2);
375                                        system("killall fbread");
376                                        standby = 1;
377                                }
378                        }
379                        if(status.standby == 0 && standby > 0)
380                        {
381                                if(standby == 1)
382                                        system(startlcd);
383                                standby = 0;
384                                put = 1;
385                        }
386               
387                        if(weatherthread == NULL && weatherwrite == 0)
388                        {
389                                if(file_exist("/tmp/lcdweather"))
390                                        put = 1;
391                        }                       
392                        if(ostrcmp(tmpstr, timemerk) != 0)
393                        {
394                                free(timemerk);timemerk=NULL;
395                                timemerk = ostrcat(tmpstr, "", 0, 0);
396                                put = 1;
397                        }
398
399                        if(standby == 0 || standby == 2 )
400                        {
401                                if(type == 1 && standby == 0)
402                                {
403                                        if(ostrcmp(tmpstr2, sendermerk) != 0)
404                                        {
405                                                free(sendermerk);sendermerk=NULL;
406                                                sendermerk = ostrcat(tmpstr2, "", 0, 0);
407                                                put = 1;
408                                        }
409                                        if(tmpstr3 == NULL && recmerk != NULL)
410                                        {
411                                                put = 1;
412                                                free(recmerk);recmerk=NULL;
413                                        }
414                                        else if(tmpstr3 != NULL && recmerk == NULL)
415                                        {
416                                                free(recmerk);recmerk=NULL;
417                                                recmerk = ostrcat(tmpstr3, "", 0, 0);
418                                                put = 1;
419                                        }
420                                }
421                                else if(type == 2)
422                                {
423                                        if(loopcount >= 15)
424                                        {
425                                                put = 1;
426                                                loopcount = 0;
427                                        }
428                                }       
429                               
430                                if(put == 1)
431                                {
432                                        if(type == 1)
433                                        {
434                                                // Wettervorhersage
435                                                if(ostrcmp(getconfig("lcd_samsung_plugin_wetter", NULL), "yes") == 0)
436                                                {
437                                                        if(weatherwrite == 0)
438                                                        {
439                                                                if(weatherthread == NULL)
440                                                                {
441                                                                        if(!file_exist("/tmp/lcdweather"))
442                                                                                weatherthread = addtimer(&lcd_writeweather, START, 10000, 1, NULL, NULL, NULL);
443                                                                        else
444                                                                        {
445                                                                                fileline = malloc(256);
446                                                                                if(fileline != NULL)
447                                                                                {
448                                                                                        fd = fopen("/tmp/lcdweather", "r");
449                                                                                        if(fd != NULL)
450                                                                                        {
451                                                                                                if(ostrcmp(getconfig("lcd_samsung_plugin_standby", NULL), "yes") == 0)
452                                                                                                {
453                                                                                                        weather_getline(fd, fileline);weather_getline(fd, fileline);
454                                                                                                        changetext(day0_d, fileline);
455                                                                                                        changetext(sday0_d, fileline);
456                                                                                                        weather_getline(fd, fileline);weather_getline(fd, fileline);
457                                                                                                        changetext(day0_t, fileline);
458                                                                                                        changetext(sday0_t, fileline);
459                                                                                                        weather_getline(fd, fileline);
460                                                                                                        weather_getline(fd, fileline);
461                                                                                                        changepic(day0_i, fileline);
462                                                                                                        changepic(sday0_i, fileline);
463                                                                                               
464                                                                                                        weather_getline(fd, fileline);
465                                                                                                        changetext(day1_d, fileline);
466                                                                                                        changetext(sday1_d, fileline);
467                                                                                                        weather_getline(fd, fileline);weather_getline(fd, fileline);
468                                                                                                        changetext(day1_t, fileline);
469                                                                                                        changetext(sday1_t, fileline);
470                                                                                                        weather_getline(fd, fileline);
471                                                                                                        weather_getline(fd, fileline);
472                                                                                                        changepic(day1_i, fileline);
473                                                                                                        changepic(sday1_i, fileline);
474                                                                                               
475                                                                                                        weather_getline(fd, fileline);
476                                                                                                        changetext(day2_d, fileline);
477                                                                                                        changetext(sday2_d, fileline);
478                                                                                                        weather_getline(fd, fileline);weather_getline(fd, fileline);
479                                                                                                        changetext(day2_t, fileline);
480                                                                                                        changetext(sday2_t, fileline);
481                                                                                                        weather_getline(fd, fileline);
482                                                                                                        weather_getline(fd, fileline);
483                                                                                                        changepic(day2_i, fileline);
484                                                                                                        changepic(sday2_i, fileline);
485                                                                                               
486                                                                                                        weather_getline(fd, fileline);
487                                                                                                        changetext(day3_d, fileline);
488                                                                                                        changetext(sday3_d, fileline);
489                                                                                                        weather_getline(fd, fileline);weather_getline(fd, fileline);
490                                                                                                        changetext(day3_t, fileline);
491                                                                                                        changetext(sday3_t, fileline);
492                                                                                                        weather_getline(fd, fileline);
493                                                                                                        weather_getline(fd, fileline);
494                                                                                                        changepic(day3_i, fileline);
495                                                                                                        changepic(sday3_i, fileline);
496                                                                                                }
497                                                                                                else
498                                                                                                {
499                                                                                                        weather_getline(fd, fileline);weather_getline(fd, fileline);
500                                                                                                        changetext(day0_d, fileline);
501                                                                                                        weather_getline(fd, fileline);weather_getline(fd, fileline);
502                                                                                                        changetext(day0_t, fileline);
503                                                                                                        weather_getline(fd, fileline);
504                                                                                                        weather_getline(fd, fileline);
505                                                                                                        changepic(day0_i, fileline);
506                                                                                               
507                                                                                                        weather_getline(fd, fileline);
508                                                                                                        changetext(day1_d, fileline);
509                                                                                                        weather_getline(fd, fileline);weather_getline(fd, fileline);
510                                                                                                        changetext(day1_t, fileline);
511                                                                                                        weather_getline(fd, fileline);
512                                                                                                        weather_getline(fd, fileline);
513                                                                                                        changepic(day1_i, fileline);
514                                                                                               
515                                                                                                        weather_getline(fd, fileline);
516                                                                                                        changetext(day2_d, fileline);
517                                                                                                        weather_getline(fd, fileline);weather_getline(fd, fileline);
518                                                                                                        changetext(day2_t, fileline);
519                                                                                                        weather_getline(fd, fileline);
520                                                                                                        weather_getline(fd, fileline);
521                                                                                                        changepic(day2_i, fileline);
522                                                                                               
523                                                                                                        weather_getline(fd, fileline);
524                                                                                                        changetext(day3_d, fileline);
525                                                                                                        weather_getline(fd, fileline);weather_getline(fd, fileline);
526                                                                                                        changetext(day3_t, fileline);
527                                                                                                        weather_getline(fd, fileline);
528                                                                                                        weather_getline(fd, fileline);
529                                                                                                        changepic(day3_i, fileline);
530                                                                                                }
531                                                                                                fclose(fd);
532                                                                                        }
533                                                                                        free(fileline); fileline=NULL;
534                                                                                }
535                                                                                weatherwrite = 1;
536                                                                        }                                                               
537                                                                }
538                                                        }               
539                                                }
540                                                if(standby == 0)
541                                                {
542                                                        if(akttime != NULL)
543                                                                changetext(akttime, tmpstr);
544                                                        if(n_minute != NULL)
545                                                        {
546                                                                free(tmpstr);tmpstr=NULL;
547                                                                tmpstr = ostrcat("min_",gettime(NULL, "%M"), 0, 0);
548                                                                free(n_minute->pic);
549                                                                n_minute->pic = string_replace("min_mm", tmpstr, picmin, 0);
550                                                                free(tmpstr);tmpstr=NULL;
551                                                        }
552                                                        if(n_stunde != NULL)
553                                                        {
554                                                                free(tmpstr);tmpstr=NULL;
555                                                                if(hr > 12)
556                                                                        hr = hr - 12;
557                                                                if(hr < 10)
558                                                                        tmpstr = ostrcat("hr_0",oitoa(hr), 0, 1);
559                                                                else
560                                                                        tmpstr = ostrcat("hr_",oitoa(hr), 0, 1);
561                                                                if(min < 15)
562                                                                        tmpstr = ostrcat(tmpstr,"00", 0, 0);
563                                                                else if(min < 30)
564                                                                        tmpstr = ostrcat(tmpstr,"15", 0, 0);
565                                                                else if(min < 45)
566                                                                        tmpstr = ostrcat(tmpstr,"30", 0, 0);
567                                                                else if(min < 59)
568                                                                 tmpstr = ostrcat(tmpstr,"45", 0, 0);
569                                                                free(n_stunde->pic);
570                                                                n_stunde->pic = string_replace("hr_hhmm", tmpstr, pichr, 0);
571                                                                free(tmpstr);tmpstr=NULL;
572                                                        }       
573                                                               
574                                                                       
575                                                        if(drawscreen(LCD_Samsung1, 0, 0) == -2)
576                                                                printf("nicht genug Speicher fuer drawscreen\n");
577                                                }
578                                                else if(standby == 2)
579                                                {
580                                                        if(akttime_Standby != NULL)
581                                                                changetext(akttime_Standby, tmpstr);
582                                                        drawscreen(LCD_Standby, 0, 0);
583                                                        put = 0;
584                                                }
585                                        }
586                                        else if(type == 2)
587                                        {
588                                                if(status.mcaktiv == 1)
589                                                        playertype = 0;
590                                                else   
591                                                        playertype = getconfigint("playertype", NULL);
592                       
593                                                if(playertype == 1)
594                                                {
595                                                        unsigned long long int startpos = 0;
596                                                        playergetinfots(&len, &startpos, NULL, &pos, NULL, 0);
597                                                        len = len / 90000;
598                                                        pos = (pos - startpos) / 90000;
599                                                }
600                                                else
601                                                {
602                                                        pos = playergetpts() / 90000;
603                                                        len = playergetlength();
604                                                }
605                                                if(pos < 0) pos = 0;
606                                                reverse = len - pos;
607                                                if(len == 0)
608                                                        sprogress->progresssize = 0;
609                                                else
610                                                        sprogress->progresssize = pos * 100 / len;
611                                               
612                                                tmpstr2 = convert_timesec(pos);
613                                                changetext(spos, tmpstr2);
614                                                free(tmpstr2); tmpstr2 = NULL;
615
616                                                tmpstr2 = convert_timesec(len);
617                                                changetext(slen, tmpstr2);
618                                                free(tmpstr2); tmpstr2 = NULL;
619
620                                                tmpstr2 = convert_timesec(reverse);
621                                                changetext(sreverse, tmpstr2);
622                                                free(tmpstr2); tmpstr2 = NULL;
623                                               
624                                                changetext(akttimeplay, tmpstr);
625                                                changetext(stitle, basename(status.playfile));
626                                                if(drawscreen(LCD_Play, 0, 0) == -2)
627                                                        printf("nicht genug Speicher fuer drawscreen\n");
628                                        }
629                                }
630                        }
631                        else
632                        {
633                                if(standby == 2)
634                                {       
635                                        if(put == 1)
636                                        {       
637                                                changetext(akttime_Standby, tmpstr);
638                                                drawscreen(LCD_Standby, 0, 0);
639                                                put = 0;
640                                        }
641                                }
642                        }
643                }
644                free(tmpstr); tmpstr = NULL;
645                free(tmpstr2); tmpstr2 = NULL;
646                free(tmpstr3); tmpstr3 = NULL;
647                //sleep(1);
648                usleep(500000);
649               
650                if(ostrcmp(getconfig("lcd_samsung_plugin_wetter", NULL), "yes") == 0)
651                {
652                        weatherref = weatherref + 1;
653                        if(weatherref == 7200)
654                        {
655                                weatherwrite = 0;
656                                system("rm /tmp/lcdweather");
657                                weatherref = 0;
658                        }
659                }
660        }
661        free(timemerk);timemerk=NULL;
662        free(sendermerk);sendermerk=NULL;
663        free(recmerk);recmerk=NULL;
664        free(startlcd);startlcd=NULL;
665        free(pichr);pichr=NULL;
666        free(picmin);picmin=NULL;
667        free(pichr_standby);pichr=NULL;
668        free(picmin_standby);picmin=NULL;
669        addconfig("lcd_samsung_plugin_running", "no");
670        LCD_Samsung1thread = NULL;
671        if(drawscreen(LCD_Samsung1, 0, 0) == -2)
672                printf("nicht genug Speicher fuer drawscreen\n");
673        //status.write_png = 0;
674        return;
675}
676
677void LCD_Samsung1_main()
678{
679        if(LCD_Samsung1thread == NULL)
680        {
681                char* tmpstr = NULL;
682                tmpstr = ostrcat("cp ", getconfig("pluginpath", NULL), 0, 0);
683                tmpstr = ostrcat(tmpstr, "/lcdsamsung/start.jpg", 1, 0);
684                tmpstr = ostrcat(tmpstr, " /tmp/titanlcd.jpg", 1, 0);
685                system(tmpstr);
686                free(tmpstr); tmpstr=NULL;
687                addconfig("lcd_samsung_plugin_running", "yes");
688                LCD_Samsung1thread = addtimer(&LCD_Samsung1_thread, START, 10000, 1, NULL, NULL, NULL);
689                addtimer(&LCD_start_lcd4linux, START, 10000, 1, NULL, NULL, NULL);
690                sleep(1);
691        }
692        else
693        {
694                        LCD_Samsung1thread->aktion = STOP;
695                        system("echo ende > /tmp/titanlcd.jpg");
696                        sleep(1);
697                        system("killall fbread");
698        }
699}       
700                       
701//wird beim laden ausgefuehrt
702void init(void)
703{
704        char* tmpstr = NULL;
705        pluginaktiv = 1;
706        firststart = 1;
707       
708        tmpstr = ostrcat(getconfig("pluginpath", NULL), "/lcdsamsung/skin.xml", 0, 0);
709        readscreen(tmpstr, 119, 1);
710        free(tmpstr); tmpstr = NULL;
711        tmpstr = ostrcat("cp ", getconfig("pluginpath", NULL), 0, 0);
712        tmpstr = ostrcat(tmpstr, "/lcdsamsung/black.jpg", 1, 0);
713        tmpstr = ostrcat(tmpstr, " /tmp/fbreadstop.jpg", 1, 0);
714        system(tmpstr);
715        free(tmpstr); tmpstr = NULL;
716        system("killall fbread");
717        debug(10, "LCD Samsung SPF.. loadet !!!");
718        tmpstr = getconfig("lcd_samsung_plugin_running", NULL);
719        if(ostrcmp(tmpstr, "yes") == 0)
720                LCD_Samsung1_main();
721        tmpstr=NULL;
722}
723
724//wird beim entladen ausgefuehrt
725void deinit(void)
726{
727        delmarkedscreen(119);
728        pluginaktiv = 0;
729        system("echo ende > /tmp/titanlcd.png");
730        sleep(1);
731        system("killall fbread");
732        debug(10, "LCD Samsung unloadet !!!");
733}
734
735
736//wird in der Pluginverwaltung bzw Menue ausfeguehrt
737void start(void)
738{
739        struct skin* samsung1_main = getscreen("samsung1_main");
740        struct skin* listbox = getscreennode(samsung1_main, "listbox");
741        struct skin* lcdtype = getscreennode(samsung1_main, "lcdtype");
742        struct skin* allmenu = getscreennode(samsung1_main, "allmenu");
743        struct skin* aktstandby = getscreennode(samsung1_main, "aktstandby");
744        struct skin* wettervor = getscreennode(samsung1_main, "wettervor");
745        struct skin* wettervorort = getscreennode(samsung1_main, "wettervorort");
746        //struct skin* wettervorplz = getscreennode(samsung1_main, "wettervorplz");
747        //struct skin* wettervorland = getscreennode(samsung1_main, "wettervorland");
748        struct skin* b3 = getscreennode(samsung1_main, "b3");
749        struct skin* tmp = NULL;
750       
751        int rcret = 0;
752        int startstop = 0;
753        int restart = 0;
754       
755  if(getconfig("lcd_samsung_plugin_wetter", NULL) == NULL || ostrcmp(getconfig("lcd_samsung_plugin_wetter", NULL), "no")  == 0)
756  {
757        //wettervorplz->hidden = YES;
758        //wettervorland->hidden = YES;
759        wettervorort->hidden = YES;
760  }
761   
762  addchoicebox(lcdtype, "spf72h", _("SPF-72H"));
763  addchoicebox(lcdtype, "spf75h", _("SPF-75H"));
764  addchoicebox(lcdtype, "spf83h", _("SPF-83H"));
765  addchoicebox(lcdtype, "spf85h", _("SPF-85H"));
766  addchoicebox(lcdtype, "spf85p", _("SPF-85P"));
767  addchoicebox(lcdtype, "spf87h", _("SPF-87H"));
768  addchoicebox(lcdtype, "spf87hold", _("SPF-87H-old"));
769  addchoicebox(lcdtype, "spf105p", _("SPF-105P"));
770  addchoicebox(lcdtype, "spf107h", _("SPF-107H"));
771  addchoicebox(lcdtype, "none", _("tiMote"));
772        setchoiceboxselection(lcdtype, getconfig("lcd_samsung_plugin_type", NULL));
773       
774        addchoicebox(allmenu, "no", _("nein"));
775        addchoicebox(allmenu, "yes", _("ja"));
776        setchoiceboxselection(allmenu, getconfig("write_fb_to_jpg", NULL));
777       
778        addchoicebox(aktstandby, "no", _("nein"));
779        addchoicebox(aktstandby, "yes", _("ja"));
780        setchoiceboxselection(aktstandby, getconfig("lcd_samsung_plugin_standby", NULL));
781       
782        addchoicebox(wettervor, "no", _("nein"));
783  addchoicebox(wettervor, "yes", _("ja"));
784        setchoiceboxselection(wettervor, getconfig("lcd_samsung_plugin_wetter", NULL));
785       
786        //changemask(wettervorplz, "0000");
787        //if(getconfig("lcd_samsung_plugin_wetterplz", NULL) == NULL)
788        //      changeinput(wettervorplz, "10407");
789        //else
790        //      changeinput(wettervorplz, getconfig("lcd_samsung_plugin_wetterplz", NULL));
791               
792        //changemask(wettervorland, "abcdefghijklmnopqrstuvwxyz");
793        //if(getconfig("lcd_samsung_plugin_wetterland", NULL) == NULL)
794        //      changeinput(wettervorland, "Germany");
795        //else
796        //      changeinput(wettervorland, getconfig("lcd_samsung_plugin_wetterland", NULL));
797       
798        changemask(wettervorort, "abcdefghijklmnopqrstuvwxyz");
799        if(getconfig("lcd_samsung_plugin_wetterort", NULL) == NULL)
800                changeinput(wettervorort, "Berlin        ");
801        else
802                changeinput(wettervorort, getconfig("lcd_samsung_plugin_wetterort", NULL));     
803       
804        if(LCD_Samsung1thread != NULL)
805                changetext(b3, "STOP");
806        else
807                changetext(b3, "START");
808               
809        drawscreen(samsung1_main, 0, 0);
810        addscreenrc(samsung1_main, listbox);
811        tmp = listbox->select;
812       
813        while(1)
814        {
815                addscreenrc(samsung1_main, tmp);
816                rcret = waitrc(samsung1_main, 0, 0);
817                tmp = listbox->select;
818               
819                if((rcret == getrcconfigint("rcleft", NULL) || rcret == getrcconfigint("rcright", NULL)) && listbox->select != NULL && ostrcmp(listbox->select->name, "wettervor") == 0)
820                {
821                        if(ostrcmp(wettervor->ret, "yes") == 0)
822                        {
823                                //wettervorplz->hidden = NO;
824                        //wettervorland->hidden = NO;
825                        wettervorort->hidden = NO;
826                        } else {
827                                //wettervorplz->hidden = YES;
828                        //wettervorland->hidden = YES;
829                        wettervorort->hidden = YES;
830                }
831                       
832                        drawscreen(samsung1_main, 0, 0);
833                }
834                                       
835                if(rcret == getrcconfigint("rcexit", NULL))
836                        break;
837                if(rcret == getrcconfigint("rcgreen", NULL))
838                {
839                        addconfig("lcd_samsung_plugin_type", lcdtype->ret);
840                        addconfig("write_fb_to_jpg", allmenu->ret);
841                        addconfig("lcd_samsung_plugin_standby", aktstandby->ret);
842                        addconfig("lcd_samsung_plugin_wetter", wettervor->ret);
843                        addconfig("lcd_samsung_plugin_wetterort", wettervorort->ret);
844                        //addconfig("lcd_samsung_plugin_wetterplz", wettervorplz->ret);
845                        //addconfig("lcd_samsung_plugin_wetterland", wettervorland->ret);
846                        restart = 1;
847                        break;
848                }
849                       
850                if(rcret == getrcconfigint("rcblue", NULL))
851                {
852                        addconfig("lcd_samsung_plugin_type", lcdtype->ret);
853                        addconfig("write_fb_to_jpg", allmenu->ret);
854                        addconfig("lcd_samsung_plugin_standby", aktstandby->ret);
855                        addconfig("lcd_samsung_plugin_wetter", wettervor->ret);
856                        addconfig("lcd_samsung_plugin_wetterort", wettervorort->ret);
857                        //addconfig("lcd_samsung_plugin_wetterplz", wettervorplz->ret);
858                        //addconfig("lcd_samsung_plugin_wetterland", wettervorland->ret);
859                        startstop = 1;
860                        break;
861                }
862        }
863        delownerrc(samsung1_main);
864        clearscreen(samsung1_main);
865       
866        if(LCD_Samsung1thread != NULL && restart == 1)
867        {
868                LCD_Samsung1thread->aktion = STOP;
869                system("killall fbread");       
870                sleep(2);
871                addtimer(&LCD_start_lcd4linux, START, 10000, 1, NULL, NULL, NULL);
872                LCD_Samsung1thread = addtimer(&LCD_Samsung1_thread, START, 10000, 1, NULL, NULL, NULL);
873                sleep(1);
874                return;
875        }
876        if(startstop == 1)
877        {
878                if(LCD_Samsung1thread != NULL)
879                {
880                        addconfig("lcd_samsung_plugin_running", "no");
881                        LCD_Samsung1thread->aktion = STOP;
882                        sleep(1);
883                        system("killall fbread");
884                        debug(10, "LCD Samsung unloadet !!!"); 
885                        sleep(1);
886                }
887                else {
888                        addconfig("lcd_samsung_plugin_running", "yes");
889                        firststart = 1;
890                        LCD_Samsung1_main();
891                }
892        }
893}
Note: See TracBrowser for help on using the repository browser.