source: svn/trunk/zasc/app/DST_UserInterface.cpp @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
File size: 9.7 KB
Line 
1#include "DST_UserInterface.h"
2#include "DST_ChannelTune.h"
3#include "DST_HostInterface.h"
4#include "DST_WinManagerTask.h"
5#include "DST_CommonAPI.h"
6#include "DST_DataStrings.h"
7#include "DST_FontEngine.h"
8#include "DST_WinManager.h"
9#include "DST_DB.h"
10
11void DST_Tune(DS_U8 RF, DS_U16 program_number);
12void DST_Scan(DS_U8 RF);
13void CT_AudioVolume(DS_U8 nVal);
14
15#if 0
16____Channel_UI___()
17#endif
18
19// ¸Þ´ºÀÇ ¸¶Áö¸· ¿ÀÅ佺ĵ ¸ðµå¸¦ ±â¾ïÇÑ´Ù.
20static DS_U8 DST_g_ChannelScanMode = 1; // 0: Update, 1:Re-Scan
21DS_U8 DST_UI_GetAutoSearchMode(void)
22{
23        return (DST_g_ChannelScanMode == 0) ? 0 : 1;
24}
25
26void DST_UI_SetAutoSearchMode(DS_U8 value)
27{
28        DST_g_ChannelScanMode = value;
29}
30
31// ä³Î ¾÷´Ù¿î ÇÔ¼ö
32void DST_UI_ChannelUpDn(bool bUp)
33{
34        DST_DB_ChannelUpDn(bUp);
35}
36
37// ä³Î Æ©´×À» ÇÑ´Ù.
38void DST_UI_ChannelTune(DS_U8 RF, DS_U16 program_number)
39{
40        T();
41        DST_Printf("RF = %d program_number=%d\n", RF, program_number);
42        if(RF != DST_EEPROM_GetRF() || program_number != DST_EEPROM_GetProgramNumber())
43        {
44                DST_g_PrevRF = DST_EEPROM_GetRF();
45                DST_g_PrevProgramNumber = DST_EEPROM_GetProgramNumber();
46        }
47       
48        DST_EEPROM_SetRF(RF);
49        DST_EEPROM_SetProgramNumber(program_number);
50        if (DST_g_LastTuneTryTime > DST_OS_GetTickCount()) DST_g_LastTuneTryTime = DST_OS_GetTickCount();
51        DST_g_SignalState = SM_WAIT_SIGNAL;
52        DST_Tune(RF, program_number);
53        DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL, 3);
54}
55
56// ä³Î Æ©´×À» ÇÑ´Ù.
57void DST_UI_Scan(DS_U8 RF)
58{
59        DST_Scan(RF);
60}
61
62#if 0
63____Settings_UI___()
64#endif
65
66// 0: ÀÚµ¿ 1: Ç®¼¼±×°íÁ¤ 2:¿ø¼¼±× °íÁ¤
67DS_U8 DST_UI_GetTuneMode(void)
68{
69        return DST_EEPROM_GetTuneMode();
70}
71
72// Æ©´× ¸ðµå¸¦ ¼³Á¤ÇÑ´Ù.
73void DST_UI_SetTuneMode(DS_U8 value)
74{
75        if (DST_EEPROM_GetTuneMode() == value) return;
76        DST_EEPROM_SetTuneMode(value);
77        DST_DB_ChannelUpDn(true);
78        DST_DB_ChannelUpDn(false);
79        //DST_UI_ChannelTune(DST_EEPROM_GetRF(), DST_EEPROM_GetProgramNumber(), DST_EEPROM_GetTuneMode());
80}
81
82
83// MTS Setting (0) Çѱ¹¾î (1) ¿Ü±¹¾î
84DS_U8 DST_UI_GetMTS()
85{
86        return DST_EEPROM_GetAudioPref();
87}
88
89void DST_UI_SetMTS( DS_U8 nVal)
90{
91        DST_EEPROM_SetAudioPref(nVal);
92        DST_g_AudioSettingChanged = true;
93}
94
95// VI Setting (0) Off (1) On
96DS_U8 DST_UI_GetVI()
97{
98        return DST_EEPROM_GetVI();
99}
100
101void DST_UI_SetVI( DS_U8 nVal)
102{
103        DST_EEPROM_SetVI(nVal);
104        DST_g_AudioSettingChanged = true;
105}
106
107
108// CC ¼³Á¤
109void DST_UI_SetCloseCaption(DS_U8 value)
110{
111        DST_EEPROM_SetCC(value ? 1 : 0);
112}
113
114
115
116// 0À̸é RF3 1À̸é RF4
117DS_U8 DST_UI_GetCh34(void)
118{
119        return DST_EEPROM_GetPreferredConn();
120}
121
122void DST_UI_SetCh34(DS_U8 nVal)
123{
124        DST_EEPROM_SetPreferredConn(nVal);
125        DHL_SetCh34(nVal);
126}
127
128#if 0
129____Volum_UI___()
130#endif
131
132// º¼·ý ¼³Á¤
133DS_U8 DST_UI_GetVolume(void)
134{
135        return DST_EEPROM_GetVolume();
136}
137// º¼·ý ¼³Á¤
138void DST_UI_SetVolume(DS_U8 value)
139{
140        if (value > 0) DST_UI_SetMute(false);
141        DST_EEPROM_SetVolume(value);
142        CT_AudioVolume(DST_UI_GetMute() ? 0 : DST_UI_GetVolume());
143}
144
145// ¹ÂÆ® ¼³Á¤
146static bool g_Mute = false;
147bool DST_UI_GetMute(void)
148{
149        return g_Mute;
150}
151
152// ¹ÂÆ® ¼³Á¤
153void DST_UI_SetMute(bool bVal)
154{
155        g_Mute = bVal;
156        CT_AudioVolume(g_Mute ? 0 : DST_UI_GetVolume());
157}
158
159
160#if 0
161____Info_Banner_UI___()
162#endif
163
164// ÇöÀç ½Ã°£À» °¡Á®¿Â´Ù.
165bool DST_UI_GetLocalTime(STime_t *time)
166{
167        return DST_GetTime(time);
168}
169
170// ÇöÀç ¹æ¼ÛÁßÀÎ ºñµð¿À°¡ HD ¹æ¼ÛÀΰ¡?
171bool DST_UI_GetHDInfo(void)
172{
173        return DST_GetHDInfo();
174}
175
176// ÇöÀç CC º¸¿©ÁֱⰡ °¡´ÉÇѰ¡?
177bool DST_UI_GetCCInfo(void)
178{
179        return DST_GetCCInfo();
180}
181
182#if 0
183____EPG_UI___()
184#endif
185
186
187// ÇöÀç ä³Î ¹øÈ£¸¦ ¹®ÀÚ¿­·Î °¡Á®¿Â´Ù.
188// ÀÔ·Â ¹è¿­ ±æÀÌ 20ÀÚ
189void DST_UI_GetCurrentChannelNumber(char *chNum)
190{
191        if (chNum == 0) return;
192        int num = 0;
193        bool bFind = DST_DB_GetCurrentChannelInfo(0, 0, &num);
194        if (bFind == true)
195        {
196                sprintf(chNum, "%03d", num); //ä³Î ¹øÈ£
197        }
198        else
199        {
200                sprintf(chNum, "%d", num); // RF ¹øÈ£
201        }
202}
203
204// ÇöÀç ä³Î¹øÈ£¿¡ RF¸¦ ºÙÀÎ °ªÀ» °¡Á®¿Â´Ù.
205// ÀÔ·Â ¹è¿­±æÀÌ 40ÀÚ
206void DST_UI_GetCurrentChannelNumberWithRF(char *chNum)
207{
208        DST_DB_GetCurrentChannelInfo(chNum, 0, 0);
209}
210
211// ä³Î¹øÈ£ ä³ÎÀ̸§
212// ÀÔ·Â ¹è¿­ ±æÀÌ 40ÀÚ
213int DST_UI_GetCurrentChannelInfo(DS_U32 *chInfo)
214{
215        if (chInfo == 0) return 0;
216        chInfo[0] = 0;
217        char chNum[20];
218        DS_U32 chName[21];
219        int num = 0;
220        if (DST_DB_GetCurrentChannelInfo(chNum, chName, &num) == false) sprintf(chNum, "%d ", num); // RF ¹øÈ£
221        str232(chInfo, chNum);
222        strcpy32(&chInfo[strlen32(chInfo)], chName);
223        return strlen32(chInfo);
224}
225
226// ³¯Â¥ ¹®ÀÚ¿­À» ¹ÝȯÇÑ´Ù.
227int DST_UI_GetDateString(int month, int day, int wday, DS_U16* timeInfo)
228{
229        DS_U16 strSpace[2] = {0x20, 0x00};
230        strcpy16(timeInfo, DST_GetDayOfWeakString(wday));
231        strcpy16(&timeInfo[strlen16(timeInfo)], strSpace);
232        char strText[10];
233        sprintf(strText, "%02d/%02d",day,month);
234        str2uni(&timeInfo[strlen16(timeInfo)], strText);
235        return strlen16(timeInfo);
236}
237
238
239
240// ½Ã°£ ¹®ÀÚ¿­À» ¹ÝȯÇÑ´Ù.
241int DST_UI_GetTimeString(int hour, int min, DS_U16* timeInfo)
242{
243        char strText[16];
244        sprintf(strText, "%02dh%02d", hour, min);
245        str2uni(timeInfo, strText); 
246        return strlen16(timeInfo);
247}
248
249// ÀÔ·ÂµÈ ½Ã°£¿¡ ÇØ´çÇÏ´Â ½Ã°£ ¹®ÀÚ¿­À» ¹ÝȯÇÑ´Ù.
250int DST_UI_GetDateTimeString(STime_t st, DS_U16* strDateTime)
251{
252        DS_U16 strDate[32];
253        DS_U16 strTime[32];
254        DS_U16 strSpace[2] = {0x20, 0x00};
255        DST_UI_GetDateString(st.month, st.day, st.wday, strDate);
256        DST_UI_GetTimeString(st.hour, st.min, strTime);
257        strcpy16(strDateTime, strDate);
258        strcpy16(&strDateTime[strlen16(strDateTime)], strSpace);
259        strcpy16(&strDateTime[strlen16(strDateTime)], strTime);
260        return strlen16(strDateTime);
261}
262
263// Á֯ļö Å×ÀÌºí °ü·Ã ÇÔ¼ö
264#if 0
265static DS_U16 FREQ_TABLE[] =
266{
267          2,   57,   3,  63,    4,  69,    5,   79,  6,  85, 
268          7, 177,    8, 183,    9, 189,  10,  195, 11,  201,
269          12, 207, 13, 213,
270         14, 123,  15, 129,  16, 135,   17, 141, 18, 147,
271         19, 153,  20, 159,  21, 165,   22, 171, 23, 219,
272         24, 225,  25, 231,  26, 237,  27, 243, 28, 249,
273         29, 255, 30, 261,  31, 267, 32, 273, 33, 279,
274         34, 285, 35, 291, 36, 297, 37, 303, 38, 309,
275         39, 315, 40, 321, 41, 327, 42,333, 43,339,
276         44, 345, 45, 351, 46,357, 47,363,48,369,
277         49,375, 50, 381, 51, 387, 52, 393, 53,399,
278         54, 405, 55, 411, 56, 417, 57, 423, 58, 429,
279         59, 435, 60, 441, 61, 447, 62, 453, 63, 459,
280         64, 465, 65, 471, 66, 477, 67, 483, 68, 489,
281         69, 495, 70, 501, 71, 507, 72, 513, 73, 519,
282         74, 525, 75,531, 76,537, 77,543, 78,549,
283         79, 555,  80, 561,  81, 567,  82, 573,  83, 579,
284         84, 585,  85, 591,  86, 597,  87, 603,  88, 609,
285         89, 615,  90, 621,  91, 627,  92, 633,  93, 639,
286         94, 645,   95, 93,   96, 99,   97, 105,
287         100, 651, 101, 657, 102, 663, 103, 669,
288        104, 675, 105, 681, 106, 687, 107, 693, 108, 699,
289        109, 705, 110, 711, 111, 717, 112, 723, 113, 729,
290        114, 735, 115, 741, 116, 747, 117, 753, 118, 759,
291        119, 765, 120, 771, 121, 777, 122, 783, 123, 789,
292        124, 795, 125, 801, 126, 807, 127, 813, 128, 819,
293        129, 825, 130, 831, 131, 837, 132, 843, 133, 849,
294        134, 855, 135, 861, 136, 867, 137, 873, 138, 879,
295        139, 885, 140, 891, 141, 897, 142, 903, 143, 909,
296        144, 915, 145, 921, 146, 927, 147, 933, 148, 939,
297        149, 945, 150, 951, 151, 957, 152, 963, 153, 969,
298        154, 975, 155, 981, 156, 987, 157, 993, 158, 999
299};
300#else
301static DS_U16 FREQ_TABLE[] =
302{
303          2,   57,   3,  63,    4,  69,    5,   79,  6,  85, 
304          7, 177,    8, 183,    9, 189,  10,  195, 11,  201,
305          12, 207, 13, 213,
306         14, 123,  15, 129,  16, 135,   17, 141, 18, 147,
307         19, 153,  20, 159,  21, 165,   22, 171, 23, 219,
308         24, 225,  25, 231,  26, 237,  27, 243, 28, 249,
309         29, 255, 30, 261,  31, 267, 32, 273, 33, 279,
310         34, 285, 35, 291, 36, 297, 37, 303, 38, 309,
311         39, 315, 40, 321, 41, 327, 42,333, 43,339,
312         44, 345, 45, 351, 46,357, 47,363,48,369,
313         49,375, 50, 381, 51, 387, 52, 393, 53,399,
314         54, 405, 55, 411, 56, 417, 57, 423, 58, 429,
315         59, 435, 60, 441, 61, 447, 62, 453, 63, 459,
316         64, 465, 65, 471, 66, 477, 67, 483, 68, 489,
317         69, 495, 70, 501, 71, 507, 72, 513, 73, 519,
318         74, 525, 75,531, 76,537, 77,543, 78,549,
319         79, 555,  80, 561,  81, 567,  82, 573,  83, 579,
320         84, 585,  85, 591,  86, 597,  87, 603,  88, 609,
321         89, 615,  90, 621,  91, 627,  92, 633,  93, 639,
322         94, 645,   95, 93,   96, 99,   97, 105,
323         100, 651, 101, 657, 102, 663, 103, 669,
324        104, 675, 105, 681, 106, 687, 107, 693, 108, 699,
325        109, 705, 110, 711, 111, 717, 112, 723, 113, 729,
326        114, 735, 115, 741, 116, 747, 117, 753, 118, 759,
327        119, 765, 120, 771, 121, 777, 122, 783, 123, 789,
328        124, 795, 125, 801, 126, 807, 127, 813, 128, 819,
329        129, 825, 130, 831, 131, 837, 132, 843, 133, 849,
330        134, 855, 135, 861
331};
332#endif
333
334// Aspect Ratio (0) wide (1) normal (2) zoom
335// DS_U8 DST_EEPROM_GetAspect(bool bOutput4x3, bool bSource4x3);
336DS_U8 DST_UI_GetAspect()
337{
338        if (DST_g_LastTuneTime == 0) return ASPECT_RATIO_NORMAL;
339        if (DST_IsVideoPlay() == false) return ASPECT_RATIO_NORMAL;
340        DS_U16 w = 0, h = 0, fps = 0;
341        bool bWide = false, bInterlace = false;
342        DST_GetVideoSize(&w, &h, &fps, &bInterlace, &bWide);
343        if (h == 0) return ASPECT_RATIO_NORMAL;
344        return DST_EEPROM_GetAspect((!bWide));
345}
346
347// void DST_EEPROM_SetAspect(bool bOutput4x3, bool bSource4x3,  DS_U8 nVal);
348void DST_UI_SetAspect(DS_U8 nVal)
349{
350        if (DST_g_LastTuneTime == 0) return;
351        if (DST_IsVideoPlay() == false) return;
352        DS_U16 w = 0, h = 0, fps = 0;
353        bool bWide = false, bInterlace = false;
354        DST_GetVideoSize(&w, &h, &fps, &bInterlace, &bWide);
355        if (h == 0) return;
356        DST_EEPROM_SetAspect((!bWide), nVal);
357}
358
359
360// Á֯ļö Å×ÀÌºí °¹¼ö
361int DST_GetFreqCount()
362{
363        return sizeof(FREQ_TABLE)/4;
364}
365
366// À妽º¸¦ ÀÔ·ÂÇϰí Á֯ļö ¹øÈ£¸¦ ¹Þ´Â´Ù.
367DS_U16 DST_GetFrequencyNumberbyIndex(int index)
368{
369        return FREQ_TABLE[2*index];
370}
371
372// À妽º¸¦ ÀÔ·ÂÇϰí MHz ´ÜÀ§ÀÇ Á֯ļö¸¦ ¹Þ´Â´Ù.
373DS_U16 DST_GetMHzFrequencybyIndex(int index)
374{
375        return FREQ_TABLE[1+2*index];
376}
377
378// Á֯ļö ¹øÈ£¸¦ ÀÔ·ÂÇϰí À妽º °ªÀ» ¹Þ´Â´Ù.
379int DST_GetIndexByRFNumber(int rf_number)
380{
381        for (int i = 0; i < DST_GetFreqCount(); i++)
382        {
383                if (rf_number == DST_GetFrequencyNumberbyIndex(i)) return i;
384        }
385        return 0;
386}
387
388// MHz´ÜÀ§ÀÇ Á֯ļö¸¦ ÀÔ·ÂÇϰí À妽º °ªÀ» ¹Þ´Â´Ù.
389int DST_GetIndexByMHzFrequency(int MHz)
390{
391        for (int i = 0; i < DST_GetFreqCount(); i++)
392        {
393                if (MHz == DST_GetMHzFrequencybyIndex(i)) return i;
394        }
395        return 0;
396}
Note: See TracBrowser for help on using the repository browser.