int main(void) { // Initialise the clock to have a /1 prescaler and use the external crystal clock source for accuracy. CLK_DeInit(); CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1); CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSE, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE); // Reset ("de-initialise") GPIO port D. GPIO_DeInit(GPIOD); // Initialise pin 0 of port D by setting it as: // - an output pin, // - using a push-pull driver, // - at a low logic level (0V), and // - 10MHz. GPIO_Init(GPIOD, GPIO_PIN_0, GPIO_MODE_OUT_PP_LOW_FAST); LCDInit(); // Init the LCD DecodeInit(); // Init the GPS decoding DrawScreen(); // Setup Screen and Buffer // Infinite loop. for(;;) { // Blink Debug LED GPIO_WriteReverse(GPIOD, GPIO_PIN_0); DrawDemo(); } }
void SongListFile(const wchar_t* filename) { PLAYERINFO* playerinfo = new PLAYERINFO(); ZeroMemory(playerinfo, sizeof(PLAYERINFO)); playerinfo->cd = FALSE; playerinfo->filename = WideCharToChar(filename, wcslen(filename)); InitializeCriticalSection(&playerinfo->lock_lyric); InitializeCriticalSection(&playerinfo->lock_lyricinfo); if (DecodeInit(playerinfo->filename, &playerinfo->decode)) { PWAVEFORMATEXTENSIBLE waveformatEx = &playerinfo->dx.waveformatEx; PLAYERDECODE* decode = &playerinfo->decode; WaveFormatInit(waveformatEx, decode); DecodeTag(playerinfo); PlayInfoRelease(playerinfo, FALSE); } else { PlayInfoRelease(playerinfo, TRUE); return; } if (first == NULL) { playerinfo->n = 0; first = playerinfo; last = playerinfo; } else { playerinfo->n = last->n + 1; last->next = playerinfo; last = playerinfo; } PLAYERTAG* tag = &playerinfo->tag; LVITEM lv = {0}; lv.mask = LVIF_TEXT | LVIF_COLUMNS; lv.pszText = L""; lv.iItem = ListView_GetItemCount(songlist.hWnd); int p = ListView_InsertItem(songlist.hWnd, &lv); if (tag->title != NULL) { ListView_SetItemText(songlist.hWnd, p, 1, tag->title); } else { ListView_SetItemText(songlist.hWnd, p, 1, L""); } if (tag->artist != NULL) { ListView_SetItemText(songlist.hWnd, p, 2, tag->artist); } else { ListView_SetItemText(songlist.hWnd, p, 2, L""); } ListView_SetItemText(songlist.hWnd, p, 3, tag->timer); }
DWORD WINAPI MainThread(LPVOID param) { while (TRUE) { DWORD ret = WaitForSingleObject(main_wnd.handle, INFINITE); if (ret == WAIT_OBJECT_0) { if (playerstatus == ID_STATUS_STOP) { ResetEvent(main_wnd.handle); continue; } if (playerstatus == ID_STATUS_START) { ResetEvent(main_wnd.handle); PLAYERINFO* playerinfo = player.current; BOOL success = FALSE; if (playerinfo->cd) success = DecodeCDInit(playerinfo); else success = DecodeInit(playerinfo->filename, &playerinfo->decode); if (success) { PWAVEFORMATEXTENSIBLE waveformatEx = &playerinfo->dx.waveformatEx; PLAYERDECODE* decode = &playerinfo->decode; WaveFormatInit(waveformatEx, decode); if (playerinfo->cd) DecodeCDTag(playerinfo); else DecodeTag(playerinfo); PWAVEFORMATEX waveformat = &waveformatEx->Format; DspSet(waveformat->nSamplesPerSec, waveformat->nChannels, waveformat->nBlockAlign); if (DxBufferInit(playerinfo)) { SetWindowText(playerinfo); if (!playerinfo->cd) { LyricStart(); LyricSearchArtistTile(playerinfo); } TrackEnable(TRUE); DxPlay(playerinfo, &playerstatus); } } if (playerstatus == ID_STATUS_START || playerstatus == ID_STATUS_PAUSE) playerstatus = ID_STATUS_STOP; TrackEnable(FALSE); LyricStop(); LyricSearchClear(); SpectrumStop(); ClockInfoStop(); playerinfo->playing = FALSE; playerinfo->pause = FALSE; SetWindowText(playerinfo); RefreshItem(playerinfo->n); PLAYERINFO* next = playerinfo->next; if (player.stop) player.current = NULL; else { if (player.entry) { playerstatus = ID_STATUS_START; player.current = player.next; player.next = NULL; player.entry = FALSE; if (player.current->n == -1 && playerinfo->n != -1) player.current->next = playerinfo; SetEvent(main_wnd.handle); } else { if (next != NULL) { playerstatus = ID_STATUS_START; player.current = next; player.next = NULL; player.entry = FALSE; SetEvent(main_wnd.handle); } else player.current = NULL; } } PlayInfoRelease(playerinfo, FALSE); } if (playerstatus == ID_STATUS_EXIT) { if (player.next != NULL) PlayInfoRelease(player.next, FALSE); CDROMRelease(); break; } } } SpectrumExit(); ClockInfoExit(); SongListExit(); LyricSearchExit(); LyricExit(); Gdiplus::GdiplusShutdown(main_wnd.gdiToken); PostMessage(main_wnd.hWnd, WM_QUIT, 0, 0); return 1; }