int main(void){ unsigned char CB = 0x00; SystemCoreClockUpdate(); /* Get Core Clock Frequency */ SysTick_Config(SystemCoreClock/1000); /* Generate interrupt each 1 ms */ BUTTON_Config(); LED_Config(); SegLCD_Init(); while(1) { if(Get_Button(SW2)) t/=2; if(Get_Button(SW1)) t*=2; SegLCD_DisplayDecimal(t); Delay(200); } }
void vHeartbeatTask (void * pvParameters){ int Key, Entries, ySize; uint16_t click_cnt=0; int8_t Item_nb; BUTTON_Handle hOK_Button, hTest_Key; LISTBOX_Handle hStationListBox; static enum GuiState eGuiState = SELECT; static const GUI_ConstString StationList[] = {"ZET", "RMFFM", "RMFMAXXX", "SKY.FM", "ESKA ROCK", "TERMINAL", NULL}; vSemaphoreCreateBinary(xButton_pushed_Semaphore); if(xDMAch1_Semaphore != NULL){ xSemaphoreTake(xButton_pushed_Semaphore, 0); }else{ // The semaphore was not created } BUTTON_Config(); //INT0 Button as source of interrupt xSemaphoreTake(xButton_pushed_Semaphore, 0); xListBoxQueue = xQueueCreate(2, sizeof(int8_t)); GUI_Init(); if(0){ _ExecCalibration(); }else{ _DefaultCalibration(); } GUI_SetBkColor(GUI_BLUE); GUI_Clear(); if (xSemaphoreTake(xDhcpCmplSemaphore_1, portMAX_DELAY) == pdTRUE) { /* OK button */ hOK_Button = BUTTON_CreateEx(120, 210, 80, 20, 0, WM_CF_SHOW, 0, 12); GUI_SetFont(&GUI_Font32_ASCII); BUTTON_SetText(hOK_Button, "OK"); /* Cancel button */ hTest_Key = BUTTON_CreateEx(120, 180, 80, 20, 0, WM_CF_SHOW, 0, 13); GUI_SetFont(&GUI_Font16B_ASCII); BUTTON_SetText(hTest_Key, "CLICK"); WM_SetStayOnTop(hTest_Key, 1); /* Station list */ Entries = 6;//countof(StationList) - 1; ySize = GUI_GetYDistOfFont(&GUI_Font16B_ASCII)*Entries; hStationListBox = LISTBOX_CreateEx(100, 10, 120, ySize, 0, WM_CF_SHOW, 0, 5, StationList); SCROLLBAR_CreateAttached(hStationListBox, SCROLLBAR_CF_VERTICAL); } while(1){ Key = GUI_GetKey(); //top = WM_GetStayOnTop(hTest_Key); switch(eGuiState){ case SELECT: switch (Key){ case 12: Item_nb = LISTBOX_GetSel(hStationListBox); if(Item_nb >= 0){ if(xQueueSendToBack(xListBoxQueue, &Item_nb, 50/portTICK_RATE_MS) == pdPASS){ /* OK button delete */ BUTTON_Delete(hOK_Button); GUI_SetBkColor(GUI_BLUE); GUI_ClearRect(120, 210, 200, 230); GUI_ClearKeyBuffer(); /* Listbox delete */ LISTBOX_Delete(hStationListBox); GUI_ClearRect(100, 10, 220, ySize+10); eGuiState = PLAYING; } } vTaskResume(xShoutcastTaskHandle); break; case 13: click_cnt++; GUI_SetFont(&GUI_Font16B_ASCII); Item_nb = LISTBOX_GetSel(hStationListBox); GUI_DispStringAt("CNT = ", 0, 210); GUI_DispDecSpace(Item_nb, 3); break; default: break; } break; case PLAYING: switch (Key){ case 13: click_cnt++; GUI_SetFont(&GUI_Font16B_ASCII); // Item_nb = LISTBOX_GetSel(hStationListBox); GUI_DispStringAt("CNT = ", 0, 210); GUI_DispDecSpace(123, 3); break; default: break; } } vTaskDelay(20/portTICK_RATE_MS); } }