| 1 | #include "DST_Window.h" |
|---|
| 2 | #include "DST_WinManager.h" |
|---|
| 3 | #include "DST_DataStrings.h" |
|---|
| 4 | #include "DST_CommonAPI.h" |
|---|
| 5 | #include "DST_EEPROM.h" |
|---|
| 6 | #include "DST_ChannelTune.h" |
|---|
| 7 | #include "DST_UserInterface.h" |
|---|
| 8 | #include "DST_Updates.h" |
|---|
| 9 | #include "DST_OSDImage.h" |
|---|
| 10 | |
|---|
| 11 | #if 0 |
|---|
| 12 | ____CMessageWin___() |
|---|
| 13 | #endif |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | //class CUpdateWin : public CWindow |
|---|
| 17 | //{ |
|---|
| 18 | //private: |
|---|
| 19 | static bool CUpdateWin_bDone; |
|---|
| 20 | static bool CUpdateWin_bNeedLine; |
|---|
| 21 | static int CUpdateWin_progress; |
|---|
| 22 | static int CUpdateWin_center_pos; |
|---|
| 23 | static int CUpdateWin_line_spacing; |
|---|
| 24 | |
|---|
| 25 | // static int CUpdateWin_nBlock; |
|---|
| 26 | static int CUpdateWin_nErr; |
|---|
| 27 | static int CUpdateWin_ErrCategory; |
|---|
| 28 | static int CUpdateWin_category; |
|---|
| 29 | |
|---|
| 30 | //public: |
|---|
| 31 | // CUpdateWin(SWinEventMsg event):CWindow(event) |
|---|
| 32 | void CUpdateWin_Constructor(CWindow *this, SWinEventMsg event) |
|---|
| 33 | { |
|---|
| 34 | this->SetWinName(this, "Update"); |
|---|
| 35 | DST_g_RFUpdateState = 0; |
|---|
| 36 | this->rect.w = 382; |
|---|
| 37 | this->rect.h = 241; |
|---|
| 38 | this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2; |
|---|
| 39 | this->rect.y = (DST_GetScreenHeight()- this->rect.h) / 2; |
|---|
| 40 | |
|---|
| 41 | DST_Printf("\n\n--------------------------WIN_UPDATE----------------------------------\n\n"); |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | CUpdateWin_center_pos = this->rect.h / 2; |
|---|
| 45 | CUpdateWin_line_spacing = DST_GetFontHeight(fontItemSize) * 150 / 100; |
|---|
| 46 | |
|---|
| 47 | CUpdateWin_nErr = 0; |
|---|
| 48 | CUpdateWin_ErrCategory = 0; |
|---|
| 49 | CUpdateWin_category = 0; |
|---|
| 50 | CUpdateWin_bNeedLine = false; |
|---|
| 51 | // RegisterAllKey(); |
|---|
| 52 | this->SetTimeOut(this, 0); |
|---|
| 53 | CUpdateWin_bDone = false; |
|---|
| 54 | CUpdateWin_progress = 0; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | void CUpdateWin_Destructor(CWindow *this) |
|---|
| 58 | { |
|---|
| 59 | |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | void CUpdateWin_DrawProgressBar(CWindow *this, DS_U32 nPos, DS_U32 nTotal, int x, int y, DS_U32 width) |
|---|
| 63 | { |
|---|
| 64 | this->DrawBox32(this, x, y, width, 10, CONV32_16(0xffe5e5ff)); |
|---|
| 65 | if(nPos == nTotal) |
|---|
| 66 | this->DrawBox32(this, x, y, width, 10, CONV32_16(0xff65a5cc)); |
|---|
| 67 | else |
|---|
| 68 | this->DrawBox32(this, x, y, (nPos*width)/nTotal, 10, CONV32_16(0xff65a5cc)); |
|---|
| 69 | this->UpdateScreen(this); |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | void CUpdateWin_Draw(CWindow *this, DS_U16 * category) |
|---|
| 73 | { |
|---|
| 74 | this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e)); |
|---|
| 75 | |
|---|
| 76 | this->setFontStyle(this, fontItemSize,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER); |
|---|
| 77 | |
|---|
| 78 | this->DrawTextUni(this, 0, CUpdateWin_center_pos-2*CUpdateWin_line_spacing-10, this->rect.w, CUpdateWin_line_spacing, category, &(this->font)); |
|---|
| 79 | this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing-10, this->rect.w, CUpdateWin_line_spacing, pz_Updating_1[OSD_Lang], &(this->font)); |
|---|
| 80 | this->DrawTextUni(this, 0, CUpdateWin_center_pos-10, this->rect.w, CUpdateWin_line_spacing, pz_Updating_2[OSD_Lang], &(this->font)); |
|---|
| 81 | this->DrawTextUni(this, 0, CUpdateWin_center_pos+CUpdateWin_line_spacing-10, this->rect.w, CUpdateWin_line_spacing, pz_Updating_3[OSD_Lang], &(this->font)); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | // virtual void OnTimer(char nID) |
|---|
| 85 | void CUpdateWin_OnTimer(CWindow *this, char nID) |
|---|
| 86 | { |
|---|
| 87 | switch(nID) |
|---|
| 88 | { |
|---|
| 89 | case 1: |
|---|
| 90 | DST_Printf("CUpdateWin_nErr : %d \n",CUpdateWin_nErr); |
|---|
| 91 | this->KillTimer(this, 1); |
|---|
| 92 | this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e)); |
|---|
| 93 | switch(CUpdateWin_ErrCategory) |
|---|
| 94 | { |
|---|
| 95 | case UPDATE_BOOTLOADER: |
|---|
| 96 | this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_Cat_1[OSD_Lang], &(this->font)); |
|---|
| 97 | break; |
|---|
| 98 | case UPDATE_APPLICATION: |
|---|
| 99 | this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_Cat_4[OSD_Lang], &(this->font)); |
|---|
| 100 | break; |
|---|
| 101 | case UPDATE_APPLICATION0: |
|---|
| 102 | this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_Cat_4_1[OSD_Lang], &(this->font)); |
|---|
| 103 | break; |
|---|
| 104 | case UPDATE_APPLICATION1: |
|---|
| 105 | this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_Cat_4_2[OSD_Lang], &(this->font)); |
|---|
| 106 | break; |
|---|
| 107 | case UPDATE_VERSION_READ: |
|---|
| 108 | this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_Cat_5[OSD_Lang], &(this->font)); |
|---|
| 109 | break; |
|---|
| 110 | default: |
|---|
| 111 | break; |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | switch(CUpdateWin_nErr) |
|---|
| 115 | { |
|---|
| 116 | case WRITE_FLASH_FAIL: |
|---|
| 117 | this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_301[OSD_Lang], &(this->font)); |
|---|
| 118 | break; |
|---|
| 119 | case CRC_FLASH_BOOTLOADER_FAIL: |
|---|
| 120 | this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_401[OSD_Lang], &(this->font)); |
|---|
| 121 | break; |
|---|
| 122 | case CRC_FLASH_APPLICATION_FAIL: |
|---|
| 123 | this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_402[OSD_Lang], &(this->font)); |
|---|
| 124 | break; |
|---|
| 125 | case CRC_READ_BOOTLOADER_FAIL: |
|---|
| 126 | this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_403[OSD_Lang], &(this->font)); |
|---|
| 127 | break; |
|---|
| 128 | case CRC_READ_APPLICATION_FAIL: |
|---|
| 129 | this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_404[OSD_Lang], &(this->font)); |
|---|
| 130 | break; |
|---|
| 131 | case CRC_READ_TOTAL_FAIL: |
|---|
| 132 | this->DrawTextUni(this, 0, (CUpdateWin_bNeedLine?CUpdateWin_center_pos:0), this->rect.w, (CUpdateWin_bNeedLine?CUpdateWin_line_spacing:this->rect.h), pz_Update_Err_405[OSD_Lang], &(this->font)); |
|---|
| 133 | break; |
|---|
| 134 | case UPDATE_CHECKING_CRC: |
|---|
| 135 | this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_4[OSD_Lang], &(this->font)); |
|---|
| 136 | this->DrawTextUni(this, 0, CUpdateWin_center_pos, this->rect.w, CUpdateWin_line_spacing, pz_Updating_5[OSD_Lang], &(this->font)); |
|---|
| 137 | break; |
|---|
| 138 | case UPDATE_FINISHED: |
|---|
| 139 | this->DrawTextUni(this, 0, CUpdateWin_center_pos-CUpdateWin_line_spacing, this->rect.w, CUpdateWin_line_spacing, pz_Updating_6[OSD_Lang], &(this->font)); |
|---|
| 140 | this->DrawTextUni(this, 0, CUpdateWin_center_pos, this->rect.w, CUpdateWin_line_spacing, pz_sysreset[OSD_Lang], &(this->font)); |
|---|
| 141 | |
|---|
| 142 | break; |
|---|
| 143 | default: |
|---|
| 144 | break; |
|---|
| 145 | } |
|---|
| 146 | if(CUpdateWin_nErr == UPDATE_FINISHED || CUpdateWin_nErr == UPDATE_CHECKING_CRC) |
|---|
| 147 | { |
|---|
| 148 | DST_g_LED_PowerState = 2; |
|---|
| 149 | |
|---|
| 150 | this->SetTimer(this, 2,5000); |
|---|
| 151 | } |
|---|
| 152 | else |
|---|
| 153 | { |
|---|
| 154 | DST_g_LED_PowerState = 1; |
|---|
| 155 | } |
|---|
| 156 | this->UpdateScreen(this); |
|---|
| 157 | break; |
|---|
| 158 | case 2: |
|---|
| 159 | this->Close(this); |
|---|
| 160 | DST_CreateWin(WIN_UPDATE_RESET, 0, 0, 0, 0, 0); |
|---|
| 161 | break; |
|---|
| 162 | default: |
|---|
| 163 | break; |
|---|
| 164 | } |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | // virtual void OnMessage(SWinEventMsg event) |
|---|
| 168 | void CUpdateWin_OnMessage(CWindow *this, SWinEventMsg event) |
|---|
| 169 | { |
|---|
| 170 | switch (event.cmd) |
|---|
| 171 | { |
|---|
| 172 | case WM_RF_UPDATE: |
|---|
| 173 | switch(event.data32[0]) |
|---|
| 174 | { |
|---|
| 175 | case FLASH_WRITING: // FLASH WRITING |
|---|
| 176 | if(CUpdateWin_category != (int)event.data32[2]) |
|---|
| 177 | { |
|---|
| 178 | CUpdateWin_category = event.data32[2]; |
|---|
| 179 | switch(CUpdateWin_category) |
|---|
| 180 | { |
|---|
| 181 | case UPDATE_BOOTLOADER: CUpdateWin_Draw(this, pz_Updating_Cat_str_1[OSD_Lang]); break; |
|---|
| 182 | case UPDATE_APPLICATION0: CUpdateWin_Draw(this, pz_Updating_Cat_str_4_1[OSD_Lang]); break; |
|---|
| 183 | case UPDATE_APPLICATION1: CUpdateWin_Draw(this, pz_Updating_Cat_str_4_2[OSD_Lang]); break; |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | CUpdateWin_DrawProgressBar(this, event.data32[1], 100,this->rect.w/10,CUpdateWin_center_pos+2*CUpdateWin_line_spacing-10,this->rect.w*8/10); |
|---|
| 189 | |
|---|
| 190 | DST_g_RFUpdateState = 1; |
|---|
| 191 | break; |
|---|
| 192 | case FLASH_WRITING_COMPLETE: // FLASH WRITING COMPLETE |
|---|
| 193 | case FLASH_WRITING_FAIL: |
|---|
| 194 | CUpdateWin_nErr = event.data32[1]; |
|---|
| 195 | CUpdateWin_ErrCategory = event.data32[2]; |
|---|
| 196 | if(CUpdateWin_ErrCategory != UPDATE_OK) CUpdateWin_bNeedLine = true; |
|---|
| 197 | else CUpdateWin_bNeedLine = false; |
|---|
| 198 | if (CUpdateWin_nErr != 0) this->SetTimer(this, 1, 500); |
|---|
| 199 | break; |
|---|
| 200 | default: break; |
|---|
| 201 | |
|---|
| 202 | } |
|---|
| 203 | break; |
|---|
| 204 | default: break; |
|---|
| 205 | |
|---|
| 206 | } |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | // virtual void Show(void) |
|---|
| 211 | void CUpdateWin_Show(CWindow *this) |
|---|
| 212 | { |
|---|
| 213 | |
|---|
| 214 | CUpdateWin_Draw(this, pz_Updating_Cat_str_system[OSD_Lang]); |
|---|
| 215 | this->RegisterAllKey(this); |
|---|
| 216 | } |
|---|
| 217 | |
|---|
| 218 | // virtual void KeyInput(DS_U8 key, bool /*bRepeat*/) |
|---|
| 219 | void CUpdateWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat) |
|---|
| 220 | { |
|---|
| 221 | switch (key) |
|---|
| 222 | { |
|---|
| 223 | case VK_KEY_PWR: |
|---|
| 224 | case VK_PWR: |
|---|
| 225 | if (DST_g_PowerOn) // ÄÑÁø»óÅÂ |
|---|
| 226 | { |
|---|
| 227 | DST_g_PowerOn = false;// ȸéÀ» ²ö´Ù. |
|---|
| 228 | } |
|---|
| 229 | else // ²¨Áø»óÅ |
|---|
| 230 | { |
|---|
| 231 | DST_g_PowerOn = true;// ȸéÀ» ÄÒ´Ù |
|---|
| 232 | } |
|---|
| 233 | JST_POWER_Display(DST_g_PowerOn); |
|---|
| 234 | break; |
|---|
| 235 | default: break; |
|---|
| 236 | } |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | //}; |
|---|
| 240 | |
|---|
| 241 | void DST_CreateUpdateWin(SWinEventMsg event) |
|---|
| 242 | { |
|---|
| 243 | if (DST_GetWin(WIN_UPDATE)) return; |
|---|
| 244 | DST_RemoveAllWindowExceptBasicWin(); |
|---|
| 245 | CWindow*pWin = NewCWindow(event); |
|---|
| 246 | pWin->Destructor = CUpdateWin_Destructor; |
|---|
| 247 | pWin->KeyInput = CUpdateWin_KeyInput; |
|---|
| 248 | pWin->OnMessage = CUpdateWin_OnMessage; |
|---|
| 249 | pWin->OnTimer = CUpdateWin_OnTimer; |
|---|
| 250 | pWin->Show = CUpdateWin_Show; |
|---|
| 251 | // »ý¼ºÀÚ È£Ãâ |
|---|
| 252 | CUpdateWin_Constructor(pWin, event); |
|---|
| 253 | // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï |
|---|
| 254 | DST_AddWin((WinID)(event.data[0]), pWin); |
|---|
| 255 | |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | //class CUpdateResetWin : public CWindow |
|---|
| 260 | //{ |
|---|
| 261 | //private: |
|---|
| 262 | // static DS_U8 winParentID; |
|---|
| 263 | // static DS_U8 msg; |
|---|
| 264 | |
|---|
| 265 | //public: |
|---|
| 266 | // CUpdateResetWin(SWinEventMsg event):CWindow(event) |
|---|
| 267 | void CUpdateResetWin_Constructor(CWindow *this, SWinEventMsg event) |
|---|
| 268 | { |
|---|
| 269 | this->SetWinName(this, "UpdateReset"); |
|---|
| 270 | this->rect.w = 382; |
|---|
| 271 | this->rect.h = 241; |
|---|
| 272 | |
|---|
| 273 | this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2; |
|---|
| 274 | this->rect.y = (DST_GetScreenHeight()- this->rect.h) / 2; |
|---|
| 275 | this->SetTimeOut(this, 0); |
|---|
| 276 | |
|---|
| 277 | |
|---|
| 278 | } |
|---|
| 279 | void CUpdateResetWin_Destructor(CWindow *this) |
|---|
| 280 | { |
|---|
| 281 | DST_g_bUpdateCompleted = true; |
|---|
| 282 | if (DST_g_PowerOn) |
|---|
| 283 | { |
|---|
| 284 | DST_Reset(__func__); // âÀÌ ´ÝÈ÷¸é¼ ÀçºÎÆÃ |
|---|
| 285 | } |
|---|
| 286 | else |
|---|
| 287 | { |
|---|
| 288 | DST_PowerDown(); |
|---|
| 289 | } |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | // virtual void OnTimer(char nID) |
|---|
| 293 | void CUpdateResetWin_OnTimer(CWindow *this, char nID) |
|---|
| 294 | { |
|---|
| 295 | switch(nID) |
|---|
| 296 | { |
|---|
| 297 | case 1: |
|---|
| 298 | this->KillTimer(this, 1); |
|---|
| 299 | this->Close(this); |
|---|
| 300 | break; |
|---|
| 301 | default: |
|---|
| 302 | break; |
|---|
| 303 | } |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | // virtual void Show(void) |
|---|
| 307 | void CUpdateResetWin_Show(CWindow *this) |
|---|
| 308 | { |
|---|
| 309 | this->RegisterAllKey(this); |
|---|
| 310 | this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0xff24435e)); |
|---|
| 311 | this->setFontStyle(this, 22,0xFFFFFFFF,ALIGN_MIDDLE,ALIGN_CENTER); |
|---|
| 312 | this->DrawTextUni(this, 0, 0, this->rect.w, this->rect.h, pz_sysreset[OSD_Lang], &(this->font)); |
|---|
| 313 | this->UpdateScreen(this); |
|---|
| 314 | |
|---|
| 315 | this->SetTimer(this, 1, 1000); |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | // virtual void KeyInput(DS_U8 key, bool /*bRepeat*/) |
|---|
| 319 | void CUpdateResetWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat) |
|---|
| 320 | { |
|---|
| 321 | switch (key) |
|---|
| 322 | { |
|---|
| 323 | case VK_KEY_PWR: |
|---|
| 324 | case VK_PWR: |
|---|
| 325 | if (DST_g_PowerOn) // ÄÑÁø»óÅÂ |
|---|
| 326 | { |
|---|
| 327 | DST_g_PowerOn = false; // ȸéÀ» ²ö´Ù. |
|---|
| 328 | } |
|---|
| 329 | else // ²¨Áø»óÅ |
|---|
| 330 | { |
|---|
| 331 | DST_g_PowerOn = true;// ȸéÀ» ÄÒ´Ù |
|---|
| 332 | } |
|---|
| 333 | JST_POWER_Display(DST_g_PowerOn); |
|---|
| 334 | break; |
|---|
| 335 | default: |
|---|
| 336 | break; |
|---|
| 337 | } |
|---|
| 338 | } |
|---|
| 339 | |
|---|
| 340 | //}; |
|---|
| 341 | void DST_CreateUpdateResetWin(SWinEventMsg event) |
|---|
| 342 | { |
|---|
| 343 | DST_RemoveAllWindowExceptBasicWin(); |
|---|
| 344 | CWindow*pWin = NewCWindow(event); |
|---|
| 345 | pWin->Destructor = CUpdateResetWin_Destructor; |
|---|
| 346 | pWin->KeyInput = CUpdateResetWin_KeyInput; |
|---|
| 347 | pWin->OnTimer = CUpdateResetWin_OnTimer; |
|---|
| 348 | pWin->Show = CUpdateResetWin_Show; |
|---|
| 349 | // »ý¼ºÀÚ È£Ãâ |
|---|
| 350 | CUpdateResetWin_Constructor(pWin, event); |
|---|
| 351 | // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï |
|---|
| 352 | DST_AddWin((WinID)(event.data[0]), pWin); |
|---|
| 353 | } |
|---|
| 354 | |
|---|
| 355 | |
|---|