source: svn/trunk/zasc/app_c/DST_EEPROM.c @ 32

Last change on this file since 32 was 32, checked in by megakiss, 11 years ago
File size: 3.0 KB
Line 
1#include "DST_Common.h"
2#include "DST_EEPROM.h"
3#include "DST_HostInterface.h"
4#include "DST_GlobalVariables.h"
5#include "DST_CommonAPI.h"
6#include "DST_ChannelTune.h"
7#include "DST_WinManagerTask.h" //ui
8
9#include "DST_DB_Engine.h"
10#include "DST_DB.h"
11#include "DST_MemoryDB.h"
12
13typedef struct 
14{
15        const char* name;
16        int min;
17        int max;
18        int default_value;
19} CONFIG;
20
21static CONFIG config[] =
22{
23        {"NeedReset", 0, 1, 0},
24        {"First", 0, 1, 1},
25        {"TuneMode", 0, 2, 1},
26        {"Volume", 0, 50, 25},
27        {"CC", 0, 1, 0},
28        {"RF", 0, 154, 0}, // RFÀÇ index¸¦ ÀúÀåÇÑ´Ù.
29        {"program_number", 0, 0xFFFF, 0},
30        {"aspect_4x3o_4x3i", 0, 2, 1},
31        {"aspect_4x3o_16x9i", 0, 2, 1},
32        {"AudioPref", 0, 1, 0},
33        {"VI", 0, 1, 0},
34        {"PreferredConn", 0, 1, 0},
35        {"FrequencySetting", 0, 1, 0}, 
36        {"MinRF", 0, RF_COUNT-1, 0}, 
37        {"MaxRF", 0, RF_COUNT-1, 0}
38};
39// unsigned aspect_4x3o_4x3i:2; // 0~2
40// unsigned aspect_4x3o_16x9i:2; // 0~2
41// unsigned aspect_16x9o_4x3i:2; // 0~2
42// unsigned aspect_16x9o_16x9i:2; // 0~2
43void DST_EEPROM_SetAspect(bool bSource4x3,  int nVal) 
44{
45        if (bSource4x3)
46        {
47                DST_EEPROM_SetConfig("aspect_4x3o_4x3i", 1);
48        }       
49        else
50        {
51                DST_EEPROM_SetConfig("aspect_4x3o_16x9i", nVal);
52        }
53}
54
55int DST_EEPROM_GetAspect(bool bSource4x3)
56{
57         //µðÆúÆ®°ª 4:3À϶§´Â ³ë¸»
58        if (bSource4x3) return DST_EEPROM_GetConfig("aspect_4x3o_4x3i");
59        return DST_EEPROM_GetConfig("aspect_4x3o_16x9i");
60}
61
62void DST_EEPROM_SetConfig(const char * name, int value)
63{
64        int i;
65        for (i = 0; i < DB_CONFIG_MAX; i++) // µ¿ÀÏ Á¤º¸ Áö¿ì±â
66        {
67                if (strcmp(db_config[i].name, name) != 0) continue;
68                memset(&db_config[i], 0, sizeof(_DB_CONFIG_));
69        }
70        for (i = 0; i < DB_CONFIG_MAX; i++) // µ¥ÀÌÅÍ Ãß°¡
71        {
72                if (strlen(db_config[i].name) != 0) continue; 
73                strcpy(db_config[i].name, name);
74                db_config[i].value = value;
75                break;
76        }
77        DST_DB_Sync();
78}
79
80int DST_EEPROM_GetConfig(const char *name) 
81{
82        int i;
83        int nCount = sizeof(config)/sizeof(CONFIG);
84        int nPos = -1;
85        for (i = 0; i < nCount; i++)
86        {
87                if (strcmp(config[i].name, name) != 0) continue;
88                nPos = i;
89                break;
90        } 
91        if (nPos < 0)
92        {
93                DST_Printf("%s|%d|Invalid name %s", __func__, __LINE__, name);
94                return 0;
95        }
96        for (i = 0; i < DB_CONFIG_MAX; i++)
97        {
98                if (strcmp(db_config[i].name, name) != 0) continue;
99                if (db_config[i].value < config[nPos].min) db_config[i].value = config[nPos].default_value;
100                if (db_config[i].value > config[nPos].max) db_config[i].value = config[nPos].default_value;
101                return db_config[i].value;
102        } 
103        return  config[nPos].default_value;
104}
105
106void DST_EEPROM_FactoryInit()
107{
108        int FrequncySetting = DST_EEPROM_GetFrequencySetting();
109        int MinRF = DST_EEPROM_GetMinRF(); // ÀÌ °ªÀº »ç¿ëÀÚ °øÀåÃʱâÈ­ÇØµµ Áö¿öÁö¸é ¾È µÈ´Ù.
110        int MaxRF = DST_EEPROM_GetMaxRF(); // ÀÌ °ªÀº »ç¿ëÀÚ °øÀåÃʱâÈ­ÇØµµ Áö¿öÁö¸é ¾È µÈ´Ù.
111        memset(&db_config, 0, sizeof(_DB_CONFIG_) * DB_CONFIG_MAX);
112        DST_EEPROM_SetFrequencySetting(FrequncySetting);
113        DST_EEPROM_SetMinRF(MinRF);
114        DST_EEPROM_SetMaxRF(MaxRF);
115}
116
117void DST_SetSleepTimer(DS_U8 value)
118{
119        DST_g_SleepTimer = (value < 5) ? value : 0;
120}
121
122DS_U8 DST_GetSleepTimer()
123{
124        return (DST_g_SleepTimer < 5) ? DST_g_SleepTimer : 0;
125}
126
Note: See TracBrowser for help on using the repository browser.