source: titan/plugins/TopfieldVFD/TopfieldVFD.h @ 43372

Last change on this file since 43372 was 9086, checked in by obi, 13 years ago

fix compile warning

File size: 6.3 KB
Line 
1/*
2 * TopfieldVFD.h
3 *
4 *  Created on: Jul 30, 2011
5 *      Author: topfi
6 */
7
8#ifndef TOPFIELDVFD_H_
9#define TOPFIELDVFD_H_
10
11#ifndef dword
12typedef unsigned long   dword;
13#endif
14#ifndef word
15typedef unsigned short  word;
16#endif
17#ifndef byte
18typedef unsigned char   byte;
19#endif
20
21typedef struct
22{
23  word    year;
24  word    month;
25  word    day;
26  word    dow;
27  char    sdow[4];
28  word    hour;
29  word    min;
30  word    sec;
31  dword   now;
32} frontpanel_ioctl_time;
33
34typedef struct
35{
36  byte    bright;
37} frontpanel_ioctl_brightness;
38
39typedef struct
40{
41  byte    reason;
42} frontpanel_ioctl_bootreason;
43
44typedef struct
45{
46  byte    onoff;
47} frontpanel_ioctl_irfilter;
48
49typedef struct
50{
51  dword   Icons1;
52  dword   Icons2;
53  byte    BlinkMode;
54} frontpanel_ioctl_icons;
55
56typedef struct
57{
58  byte    TypematicDelay;
59} frontpanel_ioctl_typematicdelay;
60
61typedef struct
62{
63  byte    TypematicRate;
64} frontpanel_ioctl_typematicrate;
65
66typedef struct
67{
68  byte    KeyEmulation;
69} frontpanel_ioctl_keyemulation;
70
71typedef struct
72{
73  byte    AllCaps;
74} frontpanel_ioctl_allcaps;
75
76typedef struct
77{
78  byte    ScrollMode;
79  byte    ScrollPause;
80  byte    ScrollDelay;
81} frontpanel_ioctl_scrollmode;
82
83#define FRONTPANELGETTIME               0x40003a00 | (sizeof(frontpanel_ioctl_time) << 16)
84#define FRONTPANELSETTIME               0x40003a01
85#define FRONTPANELSYNCSYSTIME           0x40003a02
86#define FRONTPANELCLEARTIMER            0x40003a03
87#define FRONTPANELSETTIMER              0x40003a04
88#define FRONTPANELBRIGHTNESS            0x40003a05 | (sizeof(frontpanel_ioctl_brightness) << 16)
89#define FRONTPANELIRFILTER1             0x40003a06
90#define FRONTPANELIRFILTER2             0x40003a07
91#define FRONTPANELIRFILTER3             0x40003a08
92#define FRONTPANELIRFILTER4             0x40003a09
93#define FRONTPANELPOWEROFF              0x40003a0a
94#define FRONTPANELBOOTREASON            0x40003a0b | (sizeof(frontpanel_ioctl_bootreason) << 16)
95#define FRONTPANELCLEAR                 0x40003a0c
96#define FRONTPANELTYPEMATICDELAY        0x40003a0d | (sizeof(frontpanel_ioctl_typematicdelay) << 16)
97#define FRONTPANELTYPEMATICRATE         0x40003a0e | (sizeof(frontpanel_ioctl_typematicrate) << 16)
98#define FRONTPANELKEYEMULATION          0x40003a0f | (sizeof(frontpanel_ioctl_keyemulation) << 16)
99#define FRONTPANELREBOOT                0x40003a10
100#define FRONTPANELSYNCFPTIME            0x40003a11
101#define FRONTPANELSETGMTOFFSET          0x40003a12
102#define FRONTPANELRESEND                0x40003a13
103#define FRONTPANELALLCAPS               0x40003a14 | (sizeof(frontpanel_ioctl_allcaps) << 16)
104#define FRONTPANELSCROLLMODE            0x40003a15 | (sizeof(frontpanel_ioctl_scrollmode) << 16)
105#define FRONTPANELICON                  0x40003a20 | (sizeof(frontpanel_ioctl_icons) << 16)
106
107frontpanel_ioctl_icons ioOffOn          = {0x00000002,0x00000000,0x0f};
108frontpanel_ioctl_icons ioOffFlush       = {0x00000002,0x00000000,0x06};
109frontpanel_ioctl_icons ioOffOff         = {0x00000002,0x00000000,0x00};
110
111frontpanel_ioctl_icons ioRec1On         = {0x00001000,0x00000000,0x0f};
112frontpanel_ioctl_icons ioRec2On         = {0x00002000,0x00000000,0x0f};
113frontpanel_ioctl_icons ioRecBothOn      = {0x00003000,0x00000000,0x0f};
114frontpanel_ioctl_icons ioRec1Flush      = {0x00001000,0x00000000,0x06};
115frontpanel_ioctl_icons ioRec2Flush      = {0x00002000,0x00000000,0x06};
116frontpanel_ioctl_icons ioRecBothFlush   = {0x00003000,0x00000000,0x06};
117frontpanel_ioctl_icons ioRec1Off        = {0x00001000,0x00000000,0x00};
118frontpanel_ioctl_icons ioRec2Off        = {0x00002000,0x00000000,0x00};
119frontpanel_ioctl_icons ioRecBothOff     = {0x00003000,0x00000000,0x00};
120
121frontpanel_ioctl_icons ioClockFlush     = {0x00000020,0x00000000,0x06};
122frontpanel_ioctl_icons ioClockOff       = {0x00000020,0x00000000,0x00};
123
124frontpanel_ioctl_icons ioHddClear       = {0x00000000,0x00ff8000,0x00};
125
126frontpanel_ioctl_icons ioCDClear        = {0x00000000,0x00001ffe,0x00};
127
128frontpanel_ioctl_icons ioEthOn          = {0x00400000,0x00000000,0x0b};
129frontpanel_ioctl_icons ioEthOff         = {0x00400000,0x00000000,0x00};
130
131frontpanel_ioctl_icons ioUsbOn          = {0x0c000000,0x00000000,0x0f};
132frontpanel_ioctl_icons ioUsbOff         = {0x0c000000,0x00000000,0x00};
133
134frontpanel_ioctl_icons ioTimeshiftOn    = {0x00000080,0x00000000,0x0f};
135frontpanel_ioctl_icons ioTimeshiftOff   = {0x00000080,0x00000000,0x00};
136
137
138void sendIoctl(unsigned long cmd, void* data)
139{
140        char* vfddev = getconfig("vfddev", NULL);
141
142        if(status.updatevfd == STOP) return;
143
144        m_lock(&status.vfdmutex, 3);
145        int fd = open (vfddev, O_WRONLY);
146        ioctl(fd, cmd, data);
147        close (fd);
148        m_unlock(&status.vfdmutex, 3);
149}
150
151void updateRec(int force)
152{
153        static int lastRec = -1;
154        int curRec = status.recording;
155
156        if(force)
157        {
158                lastRec=-1;
159        }
160
161        if(lastRec != curRec)
162        {
163                if(lastRec > curRec)
164                {
165                        sendIoctl(FRONTPANELICON, &ioRecBothOff);
166                }
167
168                if(curRec == 0)
169                {
170                        sendIoctl(FRONTPANELICON, &ioClockOff);
171                }
172                else
173                {
174                        if( getconfigint("blinking_clock_during_recording",pluginname))
175                        {
176                                switch(curRec)
177                                {
178                                        case 1: sendIoctl(FRONTPANELICON, &ioRec1Flush);
179                                                        sendIoctl(FRONTPANELICON, &ioClockFlush);
180                                                        break;
181                                        case 2: sendIoctl(FRONTPANELICON, &ioRec2Flush);
182                                                        sendIoctl(FRONTPANELICON, &ioClockFlush);
183                                                        break;
184                                }
185                        }
186                        else
187                        {
188                                switch(curRec)
189                                {
190                                        case 1: sendIoctl(FRONTPANELICON, &ioRec1On);
191                                                        break;
192                                        case 2: sendIoctl(FRONTPANELICON, &ioRec2On);
193                                                        break;
194                                }
195                        }
196                }
197                lastRec = curRec;
198        }
199}
200
201void updateProgress(int force)
202{
203        static int lastProgress = -1;
204
205        if(force)
206        {
207                lastProgress=-1;
208        }
209
210        if(lastProgress==-1)
211        {
212                // To be done.
213                sendIoctl(FRONTPANELICON, &ioCDClear);
214
215                lastProgress = 0;
216        }
217}
218
219void updateHDD(int force)
220{
221        static int lastHDD = -1;
222
223        if(force)
224        {
225                lastHDD=-1;
226        }
227
228        if(lastHDD==-1)
229        {
230                // To be done.
231                sendIoctl(FRONTPANELICON, &ioHddClear);
232
233                lastHDD = 0;
234        }
235}
236
237void updateUSB(int force)
238{
239        static int lastUSB = -1;
240
241        if(force)
242        {
243                lastUSB=-1;
244        }
245
246        if(lastUSB==-1)
247        {
248                // To be done.
249                sendIoctl(FRONTPANELICON, &ioUsbOff);
250
251                lastUSB = 0;
252        }
253}
254
255void updateEth(int force)
256{
257        static int lastEth = -1;
258
259        if(force)
260        {
261                lastEth=-1;
262        }
263
264        if(lastEth==-1)
265        {
266                // To be done.
267                sendIoctl(FRONTPANELICON, &ioEthOff);
268
269                lastEth = 0;
270        }
271}
272
273void updateTimeshift(int force)
274{
275        static int lastTS = -1;
276
277        if(force)
278        {
279                lastTS=-1;
280        }
281
282        if(lastTS==-1)
283        {
284                // To be done.
285                sendIoctl(FRONTPANELICON, &ioTimeshiftOff);
286
287                lastTS = 0;
288        }
289}
290
291#endif /* TOPFIELDVFD_H_ */
Note: See TracBrowser for help on using the repository browser.