source: svn/branches/remocon/zasc/app_c/DST_Main.c @ 67

Last change on this file since 67 was 67, checked in by megakiss, 11 years ago

키패드 기능 연결

전원키 누르고 리모콘 누르면 학습
CH+ 간격 1초 증가 MAX:15
CH- 간격 1초 감소 MIN :1

File size: 5.6 KB
Line 
1#define _MODEL_NAME_ "Newcon3Kr"
2#ifdef _GET_SW_VERSION_
3// 1000ÀÇ ÀÚ¸®´Â ¸ÞÀÌÀú
4//  100ÀÇ ÀÚ¸®´Â ¸¶À̳Ê
5//    10°ú 1ÀÇ ÀÚ¸®´Â ÆÐÄ¡
6// 1.0.0 ÀÇ °æ¿ì 1000
7// 1.1.1 ÀÇ °æ¿ì 1101
8#define _SW_VERSION_ (1000)
9#include <stdio.h>
10int main(int argc, char* argv[])
11{
12        if (argc > 1)
13        {
14                printf("%s\n",  _MODEL_NAME_);
15        }
16        else
17        {
18                printf("%d\n",  _SW_VERSION_);
19        }
20        return 0;
21}
22#else // _GET_SW_VERSION_
23#include "DST_nec_ir_sender.h"
24
25void DST_CCManagerInit(void);
26void DST_LoadFlash(DS_U8 Version);
27//void DST_SimpleTask(void);
28
29// new delete overloading
30//void* operator new (size_t size) { return DST_OS_Malloc(size); }
31//void* operator new[ ] (size_t size) { return DST_OS_Malloc(size); }
32//void operator delete (void* p) { DST_OS_Free(&p); }
33//void operator delete[ ] (void* p) {   DST_OS_Free(&p); }
34
35const char *DST_GetVendorInfo(void)
36{
37        return "DST";
38}
39
40const char *DST_GetModelName(void)
41{
42        return _MODEL_NAME_;
43}
44
45static char strVersionText[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
46char* DST_GetAppShortVersion()
47{
48        if (strlen(strVersionText) == 0)
49        {
50                sprintf(strVersionText, "%d.%d.%d", _SW_VERSION_/1000, (_SW_VERSION_%1000)/100, (_SW_VERSION_%1000)%100);
51        }
52        return strVersionText;
53}
54
55int DST_GetAppShortVersionNumber()
56{
57        return _SW_VERSION_;
58}
59
60static unsigned int g_ir_code = 0;
61static void IRCallback(unsigned int code, unsigned int repeat)
62{
63        int i = 0;
64        unsigned int _code = 0;
65        for (i = 0; i < 32; i++) // ºñÆ® ¹ÝÀü
66        {
67                _code |= ((code >> i) & 0x1) << (31-i);
68        }
69        g_ir_code = _code;
70        unsigned int g_ir_repeat = (repeat == 85) ? 0 : 1;     
71        DST_Printf("g_ir_code = 0x%X\n", g_ir_code);
72}
73
74static void SaveFlash(DS_U8* flash, unsigned int ir_code, unsigned int duration)
75{
76        memset(flash, 0, 16);
77        flash[0] = 0xCA;
78        flash[1] = 0xFE;
79        flash[2] = 0xBA;
80        flash[3] = 0xBE;
81        flash[4] = 0x00;
82        flash[5] = (ir_code >> 24) & 0xFF;
83        flash[6] = (ir_code >> 16) & 0xFF;
84        flash[7] = (ir_code >> 8) & 0xFF;
85        flash[8] = (ir_code >> 0) & 0xFF;
86        flash[9] = duration & 0xFF;
87        DHL_Flash_Write(FLASH_CH_MAP_POS, 16, flash);
88        DST_Printf("SaveFlash ir_code = 0x%X    duration = %d\n", ir_code, duration);
89}
90/*extern "C" */void Print_All_MemUnit(void);
91void CT_ChMapUpdate(void);
92
93/*extern "C" */void ram_start()
94{
95#ifndef DSTAR
96        m_report();
97#endif
98        DHL_SYS_Initialize(); // Flash ¸Þ¸ð¸® Á¢±ÙÀ» À§ÇØ DST_DB_Open ÀÌÀü¿¡ È£ÃâÇØ¾ß ÇÔ
99        DST_Printf("\n");
100        DST_Printf("--------------------------------------------------\n");
101        DST_Printf("           Model : %s\n", DST_GetModelName());
102        DST_Printf("           SW Version : %s \n", DST_GetAppShortVersion());
103        DST_Printf("           Compile Time : %s %s\n", __DATE__, __TIME__);
104        DST_Printf("           Vendor Info: %s \n", DST_GetVendorInfo());
105#if DESIGN_TYPE == 1
106        DST_Printf("           DESIGN_TYPE : BLACK\n");
107#else
108        DST_Printf("           DESIGN_TYPE : BLUE\n");
109#endif
110        DST_Printf("--------------------------------------------------\n");
111        DST_Printf("\n");
112//      DST_DB_Open();
113//      if (DST_EEPROM_GetNeedReset() == 1)
114//      {
115//              DST_Factory_Reset();
116//      }
117//      CT_ChMapUpdate();
118//      DHL_INFO_SetLastPowerState(true);
119//      DST_UI_SetCh34(DST_UI_GetCh34()); // TV/CVBS Ãâ·Â °áÁ¤
120//      DST_WinManagerInit(); // À©µµ¿ì ¸Þ´ÏÀú ÃʱâÈ­
121//      DST_DB_TuneFirstChannel();
122//      DST_SimpleTask();
123//      DST_CCManagerInit();
124//      DST_UI_SetVolume(DST_EEPROM_GetVolume());
125        IR_Open(IRCallback);
126        unsigned int ir_code = 0xFC030820;
127        unsigned int duration = 3;
128       
129        DS_U8* flash = DHL_Flash_Read(FLASH_CH_MAP_POS, 16);
130        if (flash[0] == 0xCA && flash[1] == 0xFE && flash[2] == 0xBA && flash[3] == 0xBE && flash[4] == 0x00)
131        {
132                ir_code = flash[5] * 0x1000000 + flash[6] * 0x10000 + flash[7] * 0x100 + flash[8];
133                duration = flash[9];
134                DST_Printf("FLASH READ ir_code = 0x%X    duration = %d\n", ir_code, duration);
135        }
136        else
137        {
138                DST_Printf("FLASH READ FAIL!! . SAVE DEFAULT VALUE ir_code = 0x%X    duration = %d\n", ir_code, duration);
139                SaveFlash(flash, ir_code, duration);
140        }
141       
142        unsigned int loop_count = 0;
143        while (1)
144        {
145                DST_OS_Delay(10);
146                if (g_ir_code == 0xFF003411) // POWER KEYPAD
147                {
148                        g_ir_code = 0;
149                        int i = 0;
150                        for (i=0; i < 500; i++) // 5ÃÊ µ¿¾È Ű ÇнÀ
151                        {
152                                DST_OS_Delay(10);
153                                if (g_ir_code == 0xFF003411) g_ir_code = 0; // POWER
154                                if (g_ir_code == 0xF7083411) g_ir_code = 0; // CH+
155                                if (g_ir_code == 0xF6093411) g_ir_code = 0; // CH-
156                                if (g_ir_code == 0) continue;
157                                ir_code = g_ir_code;
158                                DST_Printf("ir_code = 0x%X\n", ir_code);
159                                // FLASH ¿¡ ÀúÀå
160                                g_ir_code = 0;
161                                SaveFlash(flash, ir_code, duration);
162                                break;
163                        }
164                        continue;
165                }
166                if (g_ir_code == 0xF7083411) // CH+
167                {
168                        duration++;
169                        if (duration > 15) duration = 15;
170                        DST_Printf("duration = %d\n", duration);
171                        g_ir_code = 0;
172                        SaveFlash(flash, ir_code, duration);
173                }
174                if (g_ir_code == 0xF6093411) // CH-
175                {
176                        duration--;
177                        if (duration < 1) duration = 1;
178                        DST_Printf("duration = %d\n", duration);       
179                        g_ir_code  = 0;
180                        SaveFlash(flash, ir_code, duration);
181                }
182                if (duration > 15) duration = 15;
183                if (duration < 1) duration = 1; 
184                g_ir_code = 0;
185                //DS_U32 hour = 0, min = 0, sec = 0;
186                //DST_OS_GetRunTime(&hour, &min, &sec);
187                //DST_Printf("Current Time = %02d:%02d:%02d\n", (int)hour, (int)min, (int)sec);
188                //              DST_OS_PrintMemUnit();
189                //ir_code = 0xFC030820;
190                if (loop_count == 0) 
191                {
192                        DST_NEC_IR_Send(ir_code & 0xFF, (ir_code >>8) & 0xFF, (ir_code>>16) & 0xFF); // CMB ¸®¸ðÄÜÀÇ Mute Ű
193                       
194                        DS_U32 hour = 0, min = 0, sec = 0;
195                        DST_OS_GetRunTime(&hour, &min, &sec);
196                        DST_Printf("Current Time = %02d:%02d:%02d\n", (int)hour, (int)min, (int)sec);
197                }
198                loop_count++;
199                if (loop_count > duration * 100) loop_count = 0;
200#ifndef DSTAR
201                // m_report();
202#endif
203        }
204}
205
206#ifdef DSTAR
207int main()
208{
209        ram_start();
210        return 0;
211}
212#endif
213
214#endif // _GET_SW_VERSION_
Note: See TracBrowser for help on using the repository browser.