| 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 | |
|---|
| 13 | typedef struct |
|---|
| 14 | { |
|---|
| 15 | const char* name; |
|---|
| 16 | int min; |
|---|
| 17 | int max; |
|---|
| 18 | int default_value; |
|---|
| 19 | } CONFIG; |
|---|
| 20 | |
|---|
| 21 | static 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 | }; |
|---|
| 36 | // unsigned aspect_4x3o_4x3i:2; // 0~2 |
|---|
| 37 | // unsigned aspect_4x3o_16x9i:2; // 0~2 |
|---|
| 38 | // unsigned aspect_16x9o_4x3i:2; // 0~2 |
|---|
| 39 | // unsigned aspect_16x9o_16x9i:2; // 0~2 |
|---|
| 40 | void DST_EEPROM_SetAspect(bool bSource4x3, int nVal) |
|---|
| 41 | { |
|---|
| 42 | if (bSource4x3) |
|---|
| 43 | { |
|---|
| 44 | DST_EEPROM_SetConfig("aspect_4x3o_4x3i", 1); |
|---|
| 45 | } |
|---|
| 46 | else |
|---|
| 47 | { |
|---|
| 48 | DST_EEPROM_SetConfig("aspect_4x3o_16x9i", nVal); |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | int DST_EEPROM_GetAspect(bool bSource4x3) |
|---|
| 53 | { |
|---|
| 54 | //µðÆúÆ®°ª 4:3À϶§´Â ³ë¸» |
|---|
| 55 | if (bSource4x3) return DST_EEPROM_GetConfig("aspect_4x3o_4x3i"); |
|---|
| 56 | return DST_EEPROM_GetConfig("aspect_4x3o_16x9i"); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | void DST_EEPROM_SetConfig(const char * name, int value) |
|---|
| 60 | { |
|---|
| 61 | int i; |
|---|
| 62 | for (i = 0; i < DB_CONFIG_MAX; i++) // µ¿ÀÏ Á¤º¸ Áö¿ì±â |
|---|
| 63 | { |
|---|
| 64 | if (strcmp(db_config[i].name, name) != 0) continue; |
|---|
| 65 | memset(&db_config[i], 0, sizeof(_DB_CONFIG_)); |
|---|
| 66 | } |
|---|
| 67 | for (i = 0; i < DB_CONFIG_MAX; i++) // µ¥ÀÌÅÍ Ãß°¡ |
|---|
| 68 | { |
|---|
| 69 | if (strlen(db_config[i].name) != 0) continue; |
|---|
| 70 | strcpy(db_config[i].name, name); |
|---|
| 71 | db_config[i].value = value; |
|---|
| 72 | break; |
|---|
| 73 | } |
|---|
| 74 | DST_DB_Sync(); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | int DST_EEPROM_GetConfig(const char *name) |
|---|
| 78 | { |
|---|
| 79 | int i; |
|---|
| 80 | int nCount = sizeof(config)/sizeof(CONFIG); |
|---|
| 81 | int nPos = -1; |
|---|
| 82 | for (i = 0; i < nCount; i++) |
|---|
| 83 | { |
|---|
| 84 | if (strcmp(config[i].name, name) != 0) continue; |
|---|
| 85 | nPos = i; |
|---|
| 86 | break; |
|---|
| 87 | } |
|---|
| 88 | if (nPos < 0) |
|---|
| 89 | { |
|---|
| 90 | DST_Printf("%s|%d|Invalid name %s", __func__, __LINE__, name); |
|---|
| 91 | return 0; |
|---|
| 92 | } |
|---|
| 93 | for (i = 0; i < DB_CONFIG_MAX; i++) |
|---|
| 94 | { |
|---|
| 95 | if (strcmp(db_config[i].name, name) != 0) continue; |
|---|
| 96 | if (db_config[i].value < config[nPos].min) db_config[i].value = config[nPos].default_value; |
|---|
| 97 | if (db_config[i].value > config[nPos].max) db_config[i].value = config[nPos].default_value; |
|---|
| 98 | return db_config[i].value; |
|---|
| 99 | } |
|---|
| 100 | return config[nPos].default_value; |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | void DST_EEPROM_FactoryInit() |
|---|
| 104 | { |
|---|
| 105 | memset(&db_config, 0, sizeof(_DB_CONFIG_) * DB_CONFIG_MAX); |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | void DST_SetSleepTimer(DS_U8 value) |
|---|
| 109 | { |
|---|
| 110 | DST_g_SleepTimer = (value < 5) ? value : 0; |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | DS_U8 DST_GetSleepTimer() |
|---|
| 114 | { |
|---|
| 115 | return (DST_g_SleepTimer < 5) ? DST_g_SleepTimer : 0; |
|---|
| 116 | } |
|---|
| 117 | |
|---|