int vmsStartRecord(VmsPlayRecordType *vmsP) { int er; vmsP->playRecordObj = gsm_create(); SetAudioTypeLocal(0,2);//record vmsP->aqRecordPlayPcm = InitAudio(vmsP, CallBackVmsUI, CallBackVmsSoundPCM);//playback if(CreateSoundThread(false,vmsP->aqRecordPlayPcm,false,0)) { DeInitAudio( vmsP->aqRecordPlayPcm,false); vmsP->aqRecordPlayPcm = 0; return 1; } else { er = PlayAudio(vmsP->aqRecordPlayPcm); if(er) { DeInitAudio( vmsP->aqRecordPlayPcm,true); vmsP->aqRecordPlayPcm = 0; } return er; } }
int setHoldInterface(LtpInterfaceType *ltpInterfaceP,int holdB) { int er = 0; if(ltpInterfaceP->ltpObjectP->sipOnB==false) //ltp interface { if(holdB) { //er = pauseAudio(ltpInterfaceP->recordP); er = pauseAudio(ltpInterfaceP->playbackP); if(er==0) { ltpInterfaceP->holdB = true; } } else { ltpInterfaceP->holdB = false; //PlayAudio(ltpInterfaceP->recordP); return PlayAudio(ltpInterfaceP->playbackP); } return 0; } else { setHold(ltpInterfaceP->ltpObjectP,holdB); } return 0; }
void UpdatePause(void) { while(pause) { StartFoxFrame(); AESysFrameStart(); PlayAudio(&BackgroundSnd); if(FoxInput_KeyTriggered(VK_ESCAPE)) { pause = FALSE; } if(GetNextState() == GS_Quit || GetNextState() == GS_Restart) { pause = FALSE; } DrawPause(); EventPause(); FoxInput_Update(); SaveSettings(); SetChannelGroupVolume(EffectType, SFXVolume); SetChannelGroupVolume(MusicType, BGMVolume); UpdateSoundSystem(); AESysFrameEnd(); EndFoxFrame(); } SaveSettings(); FreePause(); }
/*---------------------------------------------------------------------------* * Routine: MainMenu *---------------------------------------------------------------------------* * Description: * Present the main menu *---------------------------------------------------------------------------*/ void MainMenu(void) { T_uezDevice lcd; T_pixelColor *pixels; // Open the LCD and get the pixel buffer if (UEZLCDOpen("LCD", &lcd) == UEZ_ERROR_NONE) { UEZLCDGetFrame(lcd, 0, (void **)&pixels); #if (!FAsT_STARTUP) // Clear the screen TitleScreen(); //while(1); PlayAudio(523, 100); PlayAudio(659, 100); PlayAudio(783, 100); PlayAudio(1046, 100); PlayAudio(783, 100); PlayAudio(659, 100); PlayAudio(523, 100); // Force calibration? Calibrate(CalibrateTestIfTouchscreenHeld()); UEZTaskDelay(1000); #else UEZLCDBacklight(lcd, 255); Calibrate(FALSE); #endif AppMenu(&mainmenu); UEZLCDClose(lcd); } }
int main() { CoInitialize(NULL); LoadAudioFileIntoMemory(); PlayAudio(); CoUninitialize(); return 0; }
int main() { printf("Simple sine wave generator. UP/DOWN arrows to change frequency, ESC to quit\n"); CoInitialize(NULL); PlayAudio(); CoUninitialize(); return 0; }
static void __AudioOutputCallback(GalSS_Environment *env, Gal_ObjectType o_type, Gal_Object elt, void *caller_data) { AudioPkg *p = (AudioPkg *) caller_data; int n_samples = 0; void *data = Gal_Int16Value(elt, &n_samples); printf("[Audio data to user (%d samples)]\n", n_samples); fflush(stdout); PlayAudio(p->device, data, n_samples); Gal_FreeObject(elt); }
int openSoundInterface(void *udata,int isFullDuplex) { LtpInterfaceType *ltpInterfaceP; ltpInterfaceP = (LtpInterfaceType *)udata; if(ltpInterfaceP->ltpObjectP->sipOnB || ltpInterfaceP->playbackP ||ltpInterfaceP->stopAutioQueueImidateB==true) { return 0; } ltpInterfaceP->holdB = false; DeInitAudio( ltpInterfaceP->playbackP,false); DeInitAudio( ltpInterfaceP->recordP,false); ltpInterfaceP->playbackP = 0; ltpInterfaceP->recordP = 0; SetAudioTypeLocal(ltpInterfaceP,0);//record as well as play back ltpInterfaceP->playbackP = InitAudio(ltpInterfaceP, CallBackUI, 0);//playback if(CreateSoundThread(true,ltpInterfaceP->playbackP,false,0)) { DeInitAudio( ltpInterfaceP->playbackP,false); ltpInterfaceP->playbackP = 0; } ltpInterfaceP->recordP = InitAudio(ltpInterfaceP, CallBackUI, CallBackSoundPCM); if(CreateSoundThread(false,ltpInterfaceP->recordP,false,ltpInterfaceP->ltpObjectP->soundBlockSize*2)) { DeInitAudio( ltpInterfaceP->recordP,false); ltpInterfaceP->recordP = 0; } PlayAudio(ltpInterfaceP->recordP); //sleep(10); PlayAudio(ltpInterfaceP->playbackP); //PlayAudio(ltpInterfaceObjectP->recordP); return 0; }
S32 CPlayHelper::_frameFunc(Frame_t* pFram, Void* Param) { while (!IsPlaying()) { //Open后,堵住,点play后开始 Sleep(3); } //暂停和恢复 PauseResume(); //按帧播放PlayFrame(); PlayFrame(); m_nCurFrame = pFram->FrameNo; if(pFram->FrameType == FRAME_I || pFram->FrameType == FRAME_P) { if(IsPlayingVideo()) { DWORD dwStart = GetTickCount(); PlayVideo(pFram->Data, pFram->DataLen); if(!m_isPlayFrame) { SpeedCtrl(pFram->Pts - m_nPts, dwStart); } } m_nPts = pFram->Pts; } else if(pFram->FrameType == FRAME_A) { if(IsPlayingAudio()) { char* audioBuf = NULL; int iAudioLen = 0; audioBuf = FS_GetPCMData(m_hDecoder, (char*)pFram->Data, pFram->DataLen, iAudioLen); PlayAudio(audioBuf, iAudioLen); } } return 0; }
/*---------------------------------------------------------------------------* * Routine: MainMenu *---------------------------------------------------------------------------* * Description: * Present the main menu *---------------------------------------------------------------------------*/ void MainMenu(void) { T_uezDevice lcd; T_pixelColor *pixels; // Open the LCD and get the pixel buffer if (UEZLCDOpen("LCD", &lcd) == UEZ_ERROR_NONE) { UEZLCDGetFrame(lcd, 0, (void **)&pixels); #if (!FAsT_STARTUP) // Clear the screen TitleScreen(); //while(1); PlayAudio(523, 100); PlayAudio(659, 100); PlayAudio(783, 100); PlayAudio(1046, 100); PlayAudio(783, 100); PlayAudio(659, 100); PlayAudio(523, 100); // Force calibration? Calibrate(CalibrateTestIfTouchscreenHeld()); UEZTaskDelay(1000); #else UEZLCDBacklight(lcd, 255); Calibrate(FALSE); #endif // Set the screen saver icon BouncingLogoSS_Setup( (TUInt8 *)G_uEZLogo, UEZ_ICON_WIDTH, UEZ_ICON_HEIGHT, DISPLAY_WIDTH, DISPLAY_HEIGHT); AppMenu(&mainmenu); UEZLCDClose(lcd); } }
// Audio flow control. void PlayAudio() { if (AudioDevice == -1) return; ssize_t WriteResult; WriteResult = write( AudioDevice, AudioBuffer, BufferSize ); if (WriteResult == -1) { switch (errno) { case 0: // No error condition, try again? case EAGAIN: // No room, write again. case EINTR: // Write blocked, try again. PlayAudio(); break; default: // Handle legit error. break; } } }
/*---------------------------------------------------------------------------*/ int MainTask(void) { // Output a start up banner printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // Start up the heart beat of the LED UEZTaskCreate(Heartbeat, "Heart", 64, (void *)0, UEZ_PRIORITY_NORMAL, 0); // Load any non-volatile settings from the data flash. NVSettingsInit(); // Load the settings from non-volatile memory if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) { printf("EEPROM Settings\n"); NVSettingsInit(); NVSettingsSave(); } // Setup the glyph API to the LCD and draw the title screen. GlyphOpen(&G_glyphLCD, 0); IDrawTitle(); // Setup any additional misc. tasks (such as the heartbeat task) SetupTasks(); // Play startup tones PlayAudio(523, 100); PlayAudio(659, 100); PlayAudio(783, 100); PlayAudio(1046, 100); PlayAudio(783, 100); PlayAudio(659, 100); PlayAudio(523, 100); // Wait in an infinite loop. while(1) { UEZTaskDelay(10000); } return 0; }
/*---------------------------------------------------------------------------* * Task: main *---------------------------------------------------------------------------* * Description: * In the uEZ system, main() is a task. Do not exit this task * unless you want to the board to reset. This function should * setup the system and then run the main loop of the program. * Outputs: * int -- Output error code *---------------------------------------------------------------------------*/ int MainTask(void) { printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // clear serial screen and put up banner // Start up the heart beat of the LED UEZTaskCreate(Heartbeat, "Heart", 64, (void *)0, UEZ_PRIORITY_NORMAL, 0); NVSettingsInit(); // Load the settings from non-volatile memory if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) { printf("EEPROM Settings\n"); NVSettingsInit(); NVSettingsSave(); } // Delete old log file UEZFileDelete("0:/ACCELLOG.TXT"); // Setup any additional misc. tasks (such as the heartbeat task) SetupTasks(); GlyphOpen(&G_glyphLCD, 0); IDrawTitle(); // Play tones PlayAudio(523, 100); PlayAudio(659, 100); PlayAudio(783, 100); PlayAudio(1046, 100); PlayAudio(783, 100); PlayAudio(659, 100); PlayAudio(523, 100); while(1) { UEZTaskDelay(500); } return 0; }
int vmsStartPlay(VmsPlayRecordType *vmsP) { vmsP->playRecordObj = gsm_create(); SetAudioTypeLocal(0,1);// play back SetSpeakerOnOrOff(0, 1); vmsP->aqRecordPlayPcm = InitAudio(vmsP, CallBackVmsUI, CallBackVmsSoundPCM);//playback if(CreateSoundThread(true,vmsP->aqRecordPlayPcm,false,0)) { DeInitAudio( vmsP->aqRecordPlayPcm,false); vmsP->aqRecordPlayPcm = 0; return 1; } else { //vmsP->aqRecordPlayPcm->playStartedB = true; PlayBuffStart(vmsP->aqRecordPlayPcm); PlayAudio(vmsP->aqRecordPlayPcm); return 0; } }
void* DoSound(void* Arguments) { // Allocate the mixing buffer. ALock; MixBuffer = appMalloc(BufferSize, TEXT("Mixing Buffer")); AUnlock; INT Task = SOUND_MIXING, i; while (MixingThread.Valid) { switch (Task) { case SOUND_MIXING: ALock; // Empty the mixing buffer. appMemset(MixBuffer, 0, BufferSize); for (i=0; i<AUDIO_TOTALVOICES; i++) { // Get an enabled and active voice. if ((Voices[i].State&VOICE_ENABLED) && (Voices[i].State&VOICE_ACTIVE) && !AudioPaused) { // Mix a buffer's worth of sound. INT Format = Voices[i].pSample->Type & SAMPLE_16BIT ? SAMPLE_16BIT : SAMPLE_8BIT; switch (Format) { case SAMPLE_8BIT: if (AudioFormat & AUDIO_16BIT) MixVoice8to16( i ); break; case SAMPLE_16BIT: if (AudioFormat & AUDIO_16BIT) MixVoice16to16( i ); break; } } } AUnlock; Task = SOUND_PLAYING; break; case SOUND_PLAYING: // Block until the audio device is writable. if (!AudioPaused) { if (AudioWait() == 0) break; } else break; ALock; // Silence the audio buffer. appMemset(AudioBuffer, 0, BufferSize); // Ready the most recently mixed audio. appMemcpy(AudioBuffer, MixBuffer, BufferSize); // Play it. if (!AudioPaused) { PlayAudio(); } AUnlock; Task = SOUND_MIXING; break; } } // Free the mixing buffer. ALock; if (MixBuffer != NULL) appFree(MixBuffer); AUnlock; ExitAudioThread(&MixingThread); }
void UI_Handler() { /* Up button */ if (Button(&GPIO_PORTB_DATA, 0, 1, 0)) oldstate_up = 1; if (oldstate_up && Button(&GPIO_PORTB_DATA, 0, 1, 1)) { // detect logical one to logical zero transition if (cursorPos > 0) { TFT_Set_Pen(MainScreen.Color, 0); TFT_Set_Brush(1, MainScreen.Color, 0, LEFT_TO_RIGHT, CL_WHITE, CL_WHITE); TFT_Rectangle(Image3.Left, Image3.Top, (Image3.Left+Image3.Width), (Image3.Top+Image3.Height)); Image3.Top -= 16; DrawImage(&Image3); cursorPos--; } else if (filesListOffset > 0) { filesListOffset--; UI_UpdateFilesList(); } oldstate_up = 0; } /* Down button */ if (Button(&GPIO_PORTE_DATA, 5, 1, 0)) oldstate_down = 1; if (oldstate_down && Button(&GPIO_PORTE_DATA, 5, 1, 1)) { // detect logical one to logical zero transition if (cursorPos < 11 && cursorPos < (FilesListCount-1)) { TFT_Set_Pen(MainScreen.Color, 0); TFT_Set_Brush(1, MainScreen.Color, 0, LEFT_TO_RIGHT, CL_WHITE, CL_WHITE); TFT_Rectangle(Image3.Left, Image3.Top, (Image3.Left+Image3.Width), (Image3.Top+Image3.Height)); Image3.Top += 16; DrawImage(&Image3); cursorPos++; } else if ((cursorPos+filesListOffset+1) < FilesListCount) { filesListOffset++; UI_UpdateFilesList(); } oldstate_down = 0; } /* Enter button */ if (Button(&GPIO_PORTH_DATA, 2, 1, 0)) oldstate_press = 1; if (oldstate_press && Button(&GPIO_PORTH_DATA, 2, 1, 1)) { // detect logical one to logical zero transition if (CurrentState == IMAGE_DISPLAY) { UI_ShowMainScreen(); UI_UpdateFolderName(); UI_UpdateFilesList(); CurrentState = IDLE; } else if (CurrentState == IDLE) { if (FilesList[cursorPos+filesListOffset]->Type == 'A') { if (DownloadMode == 0) PlayAudio(FilesList[cursorPos+filesListOffset]->ID); else if (DownloadMode == 1 && SDSave_Disabled == 0) SaveAudio(FilesList[cursorPos+filesListOffset]->ID, FilesList[cursorPos+filesListOffset]->Name); } else if (FilesList[cursorPos+filesListOffset]->Type == 'F') { if (CurrentFolderID == 0 || FilesList[cursorPos+filesListOffset]->ID == 0) // Only possible to enter folders if we are in the ROOT folder currently (Only 1-level deep folder tree currently supported!) RequestFolderContent(FilesList[cursorPos+filesListOffset]->ID, FilesList[cursorPos+filesListOffset]->Name, FilesList[cursorPos+filesListOffset]->NameLength); } else if (FilesList[cursorPos+filesListOffset]->Type == 'I') { DisplayImage(FilesList[cursorPos+filesListOffset]->ID); } } else if (CurrentState == FILE_RECEIVE) { // Stop the playback TerminateAudio(); CurrentState = IDLE; } oldstate_press = 0; } /* Right button */ if (Button(&GPIO_PORTE_DATA, 4, 1, 0)) oldstate_right = 1; if (oldstate_right && Button(&GPIO_PORTE_DATA, 4, 1, 1)) { // detect logical one to logical zero transition if (SDSave_Disabled == 0) { // Enabling the SD Saving mode (right click) is only possible if SD card is inserted DownloadMode = ~DownloadMode; GPIO_PORTA_DATA6_bit = DownloadMode; } oldstate_right = 0; } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; // USER START (Optionally insert additional variables) // USER END switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'menu_window' // hItem = pMsg->hWin; // WINDOW_SetBkColor(hItem, 0x00FF3939); // // Initialization of 'Header' // hItem = WM_GetDialogItem(pMsg->hWin, ID_HEADER_0); HEADER_AddItem(hItem, 120, "LEDS CONTROL", 14); // // Initialization of 'Header' // hItem = WM_GetDialogItem(pMsg->hWin, ID_HEADER_1); HEADER_AddItem(hItem, 120, "SENSORS CONTROL", 14); // // Initialization of 'Header' // hItem = WM_GetDialogItem(pMsg->hWin, ID_HEADER_2); HEADER_AddItem(hItem, 120, "MODBUS DEBUG", 14); // USER START (Optionally insert additional code for further widget initialization) hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2); BUTTON_SetText( hItem, ""); BUTTON_SetBkColor (hItem, 0, GUI_RED); BUTTON_SetBkColor (hItem, 1, GUI_YELLOW); BUTTON_SetBitmapEx(hItem, 0, &bmdebug_icon, 5, 5); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetText( hItem, ""); BUTTON_SetBkColor (hItem, 0, GUI_GREEN); BUTTON_SetBkColor (hItem, 1, GUI_YELLOW); BUTTON_SetBitmapEx(hItem, 0, &bmled_icon, 5, 5); hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); BUTTON_SetText( hItem, ""); BUTTON_SetBkColor (hItem, 0, GUI_BLUE); BUTTON_SetBkColor (hItem, 1, GUI_YELLOW); BUTTON_SetBitmapEx(hItem, 0, &bmsensor_icon, 5, 5); hItem = TEXT_CreateEx(0, 40, 640, 30, 0, WM_CF_SHOW, 0, GUI_ID_TEXT0, "House Control with MODBUS"); TEXT_SetFont(hItem, &GUI_Font24B_ASCII); TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); TEXT_SetTextColor(hItem, GUI_BLACK); // USER END break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_BUTTON_0: // Notifications sent by 'led_button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) BS_wrapper(SWITCH_CONTEXT_TO_LEDS_CONTROLLER, INTERNAL, NULL); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_1: // Notifications sent by 'sensor_button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) BS_wrapper(SWITCH_CONTEXT_TO_SENSORS_CONTROLLER, INTERNAL, NULL); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_2: // Notifications sent by 'debug_button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) BS_wrapper(SWITCH_CONTEXT_TO_DEBUG_MODBUS_CONTROLLER, INTERNAL, NULL); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_HEADER_0: // Notifications sent by 'Header' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_HEADER_1: // Notifications sent by 'Header' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_HEADER_2: // Notifications sent by 'Header' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) // USER END default: WM_DefaultProc(pMsg); break; } }
void CGame::Update(int deltaTime) { TutCheckCondition(deltaTime); _Character->_CS=idle; UpdateInput(deltaTime); int btn_id=_UI->IsTouched(); bool btnYES=false; bool btnCancel=false; if(btn_id>=0) { std::cout<<"Touched"<<std::endl; _SE->Play(3); if(btn_id==BTN_PAUSE&&_GS==GS_Playing) _GS=GS_Pause; else if(btn_id==BTN_PAUSE&&_GS==GS_Pause) _GS=GS_Playing; else if(btn_id==BTN_P_RETURN) _GS=GS_Playing; else if(btn_id==BTN_P_RESTART) _GS=GS_Restart; else if(btn_id==BTN_E_RESTART) { _GS=GS_Restart; std::cout<<"E_RS"<<std::endl;} else if(btn_id==BTN_E_RETURN) _GS=GS_Playing; else if(btn_id==BTN_P_MUSIC) _GS=GS_Playing; else if(btn_id==BTN_P_QUIT) _GS=GS_QUIT; else if(btn_id==BTN_V_YES) btnYES=true; else if(btn_id==BTN_V_CANCEL) btnCancel=true; //current_States=S3E_POINTER_STATE_UP; } if(_GS==GS_QUIT)//quit to lobby { _timeLevelCost=0; _GS=GS_QU_VERIF; } if(_GS==GS_Restart)//restart cur level { _timeLevelCost=0; _setEndingText=false; _levelFinish=false; _GS=GS_RS_VERIF; } if(_GS==GS_QU_VERIF) { if(btnYES) { if(_MapLevel.size()>0&&_currentLevel!=0) { delete _MapLevel[_MapLevel.size()-1]; _MapLevel.pop_back(); } _currentLevel=0; currentMap=_MapLevel[_currentLevel]; _Character->Init(currentMap->_StartPos); currentMap->SetCharacterIndex(_Character->m_Position); currentMap->Init(); _GS=GS_Playing; //current_States=S3E_POINTER_STATE_UP; } else if(btnCancel) { _GS=GS_Playing; } } if(_GS==GS_RS_VERIF) { if(btnYES) { _Character->Init(currentMap->_StartPos); currentMap->SetCharacterIndex(_Character->m_Position); currentMap->Init(); _GS=GS_Playing; //current_States=S3E_POINTER_STATE_UP; } else if(btnCancel) { _GS=GS_Playing; } } if(_GS==GS_Playing) { OnPlaying(deltaTime); } _Character->Update(deltaTime); PlayAudio(); // Update Iw Sound Manager IwGetSoundManager()->Update(); }
void MainMenu(void) { T_uezDevice lcd; T_pixelColor *pixels; T_uezQueue queue; // Setup queue to receive touchscreen events if (UEZQueueCreate(1, sizeof(T_uezTSReading), &queue) == UEZ_ERROR_NONE) { // Open the LCD and get the pixel buffer if (UEZLCDOpen("LCD", &lcd) == UEZ_ERROR_NONE) { UEZLCDGetFrame(lcd, 0, (void **)&pixels); UEZLCDOn(lcd); #if (!FAST_STARTUP) // Clear the screen TitleScreen(); PlayAudio(523, 100); PlayAudio(659, 100); PlayAudio(783, 100); PlayAudio(1046, 100); PlayAudio(783, 100); PlayAudio(659, 100); PlayAudio(523, 100); #if DKTS_BUTTON_SLIDE_SHOW_DEMO // show emwin on button 1, auto slideshow on buttons 2-4 #include <uEZButton.h> #include <GUIDEMO.h> T_uezDevice ButtonBank; TUInt32 buttonsActive = 0x0F; // buttons 1-4 TUInt32 ButtonsPressed; T_slideshowDefinition aDef; aDef.iDrive = 1; if (UEZButtonBankOpen("ButtonBank0", &ButtonBank) == UEZ_ERROR_NONE) { // the device opened properly if (UEZButtonBankSetActive(ButtonBank, buttonsActive) == UEZ_ERROR_NONE) { // set active successful } if (UEZButtonBankRead(ButtonBank, &ButtonsPressed) == UEZ_ERROR_NONE) { // got buttons pressed if (ButtonsPressed == 14) { // button 1 pressed const T_choice aChoice = {0}; emWin(&aChoice); } else if (ButtonsPressed == 13) { // button 2 pressed char str1[] = {'F','D','I',' ','O','v','e','r','v','i','e','w','\0'}; memcpy(aDef.iName,str1,strlen(str1)+1); char str2[] = {'F','D','I','\0'}; memcpy(aDef.iDirectory,str2,strlen(str2)+1); SingleSlideshowMode(&aDef); // change to Speedometer Demo here } else if (ButtonsPressed == 11) { // button 3 pressed char str3[] = {'u','E','Z','G','U','I',' ','F','a','m','i','l','y','\0'}; memcpy(aDef.iName,str3,strlen(str3)+1); char str4[] = {'U','E','Z','G','U','I','\0'}; memcpy(aDef.iDirectory,str4,strlen(str4)+1); SingleSlideshowMode(&aDef); } else if (ButtonsPressed == 7) { // button 4 pressed char str5[] = {'D','e','m','o','n','s','t','r','a','t','i', 'o','n',' ','P','i','c','t','u','r','e','s','\0'}; memcpy(aDef.iName,str5,strlen(str5)+1); char str6[] = {'D','E','M','O','P','I','C','S','\0'}; memcpy(aDef.iDirectory,str6,strlen(str6)+1); SingleSlideshowMode(&aDef); } else{ } } if (UEZButtonBankClose(ButtonBank) != UEZ_ERROR_NONE) {// error closing button bank } } else {// an error occurred opening Button Bank } Calibrate(CalibrateTestIfTouchscreenHeld()); // turn touchscreen back on since touchscreen present on KOE #else // Force calibration? Calibrate(CalibrateTestIfTouchscreenHeld()); #endif //UEZTaskDelay(1000); #else UEZLCDBacklight(lcd, 255); #endif UEZTaskDelay(10000); AppMenu(&mainmenu); UEZLCDClose(lcd); } } }
void AchievementPopup::AddMessage( const MessagePopup& msg ) { m_vMessages.push( msg ); PlayAudio(); }
/*---------------------------------------------------------------------------* * Task: main *---------------------------------------------------------------------------* * Description: * In the uEZ system, main() is a task. Do not exit this task * unless you want to the board to reset. This function should * setup the system and then run the main loop of the program. * Outputs: * int -- Output error code *---------------------------------------------------------------------------*/ int MainTask(void) { T_uezDevice adc; T_uezDevice temp; T_uezDevice accel; T_uezError adcDeviceError; T_uezError tempDeviceError; T_uezError accelDeviceError; ADC_RequestSingle adcRequest; TUInt32 adcReading; TUInt8 displayString[100]; TInt32 tempValue; float tempFloatValue; AccelerometerReading accelReading; printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); NVSettingsInit(); // Load the settings from non-volatile memory if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) { printf("EEPROM Settings\n"); NVSettingsInit(); NVSettingsSave(); } SetupTasks(); GlyphOpen(&G_glyphLCD, 0); IDrawTitle(); PlayAudio(523, 100); PlayAudio(659, 100); PlayAudio(783, 100); PlayAudio(1046, 100); PlayAudio(783, 100); PlayAudio(659, 100); PlayAudio(523, 100); adcDeviceError = UEZADCOpen("ADC_S12AD", &adc); if (adcDeviceError == UEZ_ERROR_NONE) { printf("MainTask: ADC Device Open\n"); } else { printf("MainTask: Failed to Open ADC Device\n"); } tempDeviceError = UEZTemperatureOpen("Temp0", &temp); if (tempDeviceError == UEZ_ERROR_NONE) { printf("MainTask: Temperature Device Open\n"); } else { printf("MainTask: Failed to Open Temperature Device\n"); } accelDeviceError = UEZAccelerometerOpen("Accel0", &accel); if (accelDeviceError == UEZ_ERROR_NONE) { printf("MainTask: Accelerometer Device Open\n"); } else { printf("MainTask: Failed to Open Accelerometer Device\n"); } //PORTE.PDR.BIT.B3 = 1; while(1) { if( adcDeviceError == UEZ_ERROR_NONE ) { // the device opened properly adcRequest.iADCChannel = 2; adcRequest.iBitSampleSize = 12; adcRequest.iTrigger = ADC_TRIGGER_NOW; adcRequest.iCapturedData = &adcReading; if (UEZADCRequestSingle(adc,&adcRequest) == UEZ_ERROR_NONE) { printf("MainTask: Potentiometer Reading: %d\n", adcReading); } else { printf("MainTask: Failed to get a Potentiometer Reading\n"); } } if ( tempDeviceError == UEZ_ERROR_NONE ) { if (UEZTemperatureRead(temp, &tempValue) == UEZ_ERROR_NONE) { tempFloatValue = tempValue/65536.0; sprintf((char *)displayString, "Temp: %.2f C", tempFloatValue); GlyphSetXY(G_glyphLCD, 0, 0); GlyphString(G_glyphLCD, displayString, strlen(displayString)); } } if ( accelDeviceError == UEZ_ERROR_NONE ) { if(UEZAccelerometerReadXYZ(accel, &accelReading, 10) == UEZ_ERROR_NONE ) { sprintf((char *)displayString, "ACCEL X: %d", accelReading.iX); GlyphSetXY(G_glyphLCD, 0, 16); GlyphString(G_glyphLCD, displayString, strlen(displayString)); sprintf((char *)displayString, "ACCEL Y: %d", accelReading.iY); GlyphSetXY(G_glyphLCD, 0, 24); GlyphString(G_glyphLCD, displayString, strlen(displayString)); sprintf((char *)displayString, "ACCEL Z: %d", accelReading.iZ); GlyphSetXY(G_glyphLCD, 0, 32); GlyphString(G_glyphLCD, displayString, strlen(displayString)); } } UEZTaskDelay(1000); } return 0; }
void UpdateMainMenu(void) { PlayAudio(&MenuBackSnd); //Handle input and run background animation if (DogScroll->CurrentFrame == 17) { DogScroll->AnimationActive = FALSE; } //If the position is greater than the final position if(DogScrollBottom->Position.y >= -345) { //Blaze the bottom down based on the total distance traveled divided by the number of frames and frames per change DogScrollBottom->Position.y -= (420) / 18 / DogScroll->AnimationSpeed; } if (DogScrollBottom->Position.y < OptionsButton->ButtonSprite->Position.y) { OptionsButton->ButtonSprite->Visible = TRUE; } if (DogScrollBottom->Position.y < QuitGameButton->ButtonSprite->Position.y) { QuitGameButton->ButtonSprite->Visible = TRUE; } if (FoxScroll->CurrentFrame == 17) FoxScroll->AnimationActive = FALSE; if(FoxScrollBottom->Position.y >= -345) { //Blaze the bottom down based on the total distance traveled divided by the number of frames and frames per change FoxScrollBottom->Position.y -= (420) / 18 / FoxScroll->AnimationSpeed; } if (FoxScrollBottom->Position.y < LoadGameButton->ButtonSprite->Position.y) { LoadGameButton->ButtonSprite->Visible = TRUE; } if (FoxScrollBottom->Position.y < CreditsButton->ButtonSprite->Position.y) { CreditsButton->ButtonSprite->Visible = TRUE; } //Menu navigation help if (TimerGoingUp) GettingImpatientTimer += GetDeltaTime(); else GettingImpatientTimer -= GetDeltaTime(); if (GettingImpatientTimer > 0) { ChangeTextAlpha(SillyGooseUseMouse, GettingImpatientTimer); if (GettingImpatientTimer > 1) TimerGoingUp = FALSE; else if (GettingImpatientTimer < 0.4) TimerGoingUp = TRUE; } #if defined _DEBUG // REMOVE FOR RELEASE BUILD if(FoxInput_KeyTriggered(VK_HOME)) { SetNextState(GS_EPMenu); } #endif InputHandling(); BackgroundAnimation(); }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; // USER START (Optionally insert additional variables) int i; int j; int k; int slave_column; char buffer[10]; new_GUI_value.BUTTON_value.send_button= FALSE; // USER END switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'id_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetText(hItem, "slave id:"); // // Initialization of 'function_radio' // hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0); RADIO_SetText(hItem, "read holding registers", 0); RADIO_SetText(hItem, "write single register", 1); RADIO_SetText(hItem, "read single coil", 2); RADIO_SetText(hItem, "write single coil", 3); RADIO_SetText(hItem, "read multiple coils", 4); // // Initialization of 'multiple_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetText(hItem, "MULTIPLE REGISTER REQUEST"); // // Initialization of 'from_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2); TEXT_SetText(hItem, "from:"); // // Initialization of 'to_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetText(hItem, "to:"); // // Initialization of 'single_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4); TEXT_SetText(hItem, "SINGLE REGISTER REQUEST"); // // Initialization of 'number_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5); TEXT_SetText(hItem, "number:"); // // Initialization of 'send_button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetText(hItem, "SEND"); // // Initialization of 'response_view' // hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); LISTVIEW_AddColumn(hItem, 60, "address", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_AddColumn(hItem, 80, "slave 1", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_AddColumn(hItem, 80, "slave 2", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetGridVis(hItem, 1); LISTVIEW_AddColumn(hItem, 30, "Col", GUI_TA_LEFT | GUI_TA_VCENTER); LISTVIEW_SetAutoScrollV(hItem, 1); // // Initialization of 'status_view' // hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1); LISTVIEW_AddColumn(hItem, 129, "status", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_SetGridVis(hItem, 1); LISTVIEW_SetItemText(hItem, 0, 0, "0"); LISTVIEW_SetItemText(hItem, 0, 0, "0"); LISTVIEW_SetRowHeight(hItem, 20); LISTVIEW_SetHeaderHeight(hItem, 20); // // Initialization of 'exit_button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); BUTTON_SetText(hItem, " X"); // // Initialization of 'write_req_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6); TEXT_SetText(hItem, "WRITE REGISTER REQUEST"); // // Initialization of 'value_txt' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7); TEXT_SetText(hItem, "value:"); // USER START (Optionally insert additional code for further widget initialization) //aggiungo casella Status hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, 0, "Ready"); //aggiungo caselle di risposta hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); for (i = 0; i < 60; i++) LISTVIEW_AddRow(hItem, NULL); // USER END break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_RADIO_0: // Notifications sent by 'function_radio' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0); new_GUI_value.RADIO_value.radio_selection = RADIO_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_0: // Notifications sent by 'send_button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(600, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) modbus_task(); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1); if (modbus_rx.error != 0) { GUI_Delay(100); modbus_task(); } hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1); if (modbus_rx.error != 0) { LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_RED); GUI_Delay(100); LISTVIEW_SetItemText(hItem, 0, 0, "No Response"); PlayAudio(50, 60); PlayAudio(0, 20); PlayAudio(50, 100); } else if (modbus_rx.func & 0x80) { LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_YELLOW); GUI_Delay(100); LISTVIEW_SetItemText(hItem, 0, 0, "R: Wrong Message"); PlayAudio(90, 60); PlayAudio(90, 20); PlayAudio(90, 100); } else { //cancello vecchi valori hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); LISTVIEW_DeleteAllRows(hItem); GUI_Delay(100); for (i = 0; i < 60; i++) LISTVIEW_AddRow(hItem, NULL); GUI_Delay(100); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1); LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_GREEN); GUI_Delay(100); LISTVIEW_SetItemText(hItem, 0, 0, "R: Message Accepted"); PlayAudio(600, 20); PlayAudio(600, 20); PlayAudio(200, 20); //se ho fatto una richiesta read if(new_GUI_value.RADIO_value.radio_selection == 0 || new_GUI_value.RADIO_value.radio_selection == 2 || new_GUI_value.RADIO_value.radio_selection == 4) { if(new_GUI_value.SPINBOX_value.slave_id == 1) slave_column = 1; else slave_column = 2; //scrivo sul listview 0 hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); //mi prendo la sezione dati effettivi //ho chiesto gli holding? if(new_GUI_value.RADIO_value.radio_selection == 0){ for(i = 0; i < modbus_rx.len; i++) { //se leggo holdings sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.multiple_register_from + i +2000); LISTVIEW_SetItemText(hItem, 0, i, buffer); sprintf(buffer, "%d", modbus_rx.data_converted[i]); LISTVIEW_SetItemText(hItem, slave_column, i, buffer); } } //ho chiesto i coils? else if(new_GUI_value.RADIO_value.radio_selection == 4 ){ for(i = 0; i < modbus_rx.len; i++) { sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.multiple_register_from + i ); LISTVIEW_SetItemText(hItem, 0, i, buffer); if(modbus_rx.data_converted[i] != 0) sprintf(buffer, "%s", "ON"); else sprintf(buffer, "%s", "OFF"); LISTVIEW_SetItemText(hItem, slave_column, i, buffer); } } //ho chiesto 1 coil? else if(new_GUI_value.RADIO_value.radio_selection == 2){ sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.single_register_number); LISTVIEW_SetItemText(hItem, 0, 0, buffer); if(modbus_rx.data_converted[0] != 0) sprintf(buffer, "%s", "ON"); else sprintf(buffer, "%s", "OFF"); LISTVIEW_SetItemText(hItem, slave_column, 0, buffer); } } } // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_LISTVIEW_0: // Notifications sent by 'response_view' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_SEL_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_LISTVIEW_1: // Notifications sent by 'status_view' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_SEL_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_1: // Notifications sent by 'exit_button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(600, 20); PlayAudio(600, 20); PlayAudio(200, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) new_GUI_value.SPINBOX_value.slave_id = 0; new_GUI_value.SPINBOX_value.multiple_register_from = 0; new_GUI_value.SPINBOX_value.multiple_register_to = 0; new_GUI_value.SPINBOX_value.single_register_number = 0; new_GUI_value.SPINBOX_value.write_value = 0; new_GUI_value.RADIO_value.radio_selection = 0; PlayAudio(900, 20); PlayAudio(1000, 20); PlayAudio(1100, 20); hItem = pMsg->hWin; GUI_EndDialog(hItem, 0); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_0: // Notifications sent by 'slave_id_spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0); new_GUI_value.SPINBOX_value.slave_id = SPINBOX_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_1: // Notifications sent by 'from_spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_1); new_GUI_value.SPINBOX_value.multiple_register_from = SPINBOX_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_2: // Notifications sent by 'to_spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_2); new_GUI_value.SPINBOX_value.multiple_register_to = SPINBOX_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_3: // Notifications sent by 'number_spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_3); new_GUI_value.SPINBOX_value.single_register_number = SPINBOX_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_4: // Notifications sent by 'write_value_spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_4); new_GUI_value.SPINBOX_value.write_value = SPINBOX_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) // USER END default: WM_DefaultProc(pMsg); break; } }
/*---------------------------------------------------------------------------* * Routine: BeepError *---------------------------------------------------------------------------* * Description: * Play a beep for errors. *---------------------------------------------------------------------------*/ void BeepError(void) { PlayAudio(100, 500); }
/*---------------------------------------------------------------------------* * Routine: ButtonClick *---------------------------------------------------------------------------* * Description: * Play a standard button click sound *---------------------------------------------------------------------------*/ void ButtonClick(void) { PlayAudio(250, 20); }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; // USER START (Optionally insert additional variables) int i; // USER END switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'SensorsControl' // hItem = pMsg->hWin; FRAMEWIN_SetText(hItem, "Sensors Control"); // // Initialization of 'exit_button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetText(hItem, " X"); // // Initialization of 'refresh_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetText(hItem, "delay of refresh:"); // // Initialization of 'temperature_edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); EDIT_SetText(hItem, ""); // // Initialization of 'temp_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetText(hItem, "teperature:"); // // Initialization of 'hum_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2); TEXT_SetText(hItem, "humidity:"); // // Initialization of 'humidity_edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1); EDIT_SetText(hItem, ""); // // Initialization of 'sound_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetText(hItem, "sound:"); // // Initialization of 'sound_edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2); EDIT_SetText(hItem, "SILENCE"); // // Initialization of 'distance_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4); TEXT_SetText(hItem, "distance:"); // // Initialization of 'distance_edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_3); EDIT_SetText(hItem, "FAR"); // // Initialization of 'pres_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5); TEXT_SetText(hItem, "presence:"); // // Initialization of 'presence_edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_4); EDIT_SetText(hItem, "NO"); // // Initialization of 'vibro_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6); TEXT_SetText(hItem, "vibration:"); // // Initialization of 'vibration_edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_5); EDIT_SetText(hItem, "NO"); // // Initialization of 'light_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7); TEXT_SetText(hItem, "light:"); // // Initialization of 'light_edit' // hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_6); EDIT_SetText(hItem, "NO"); // // Initialization of 'light_check' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0); CHECKBOX_SetText(hItem, "turn on all leds when there is no light in the area"); // // Initialization of 'alarm_check' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1); CHECKBOX_SetText(hItem, "activate alarm on presence"); // // Initialization of 'temp_check' // hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_2); CHECKBOX_SetText(hItem, "activate alarm on temperature"); // // Initialization of 'max_temp_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8); TEXT_SetText(hItem, "max temperature:"); // USER START (Optionally insert additional code for further widget initialization) actual_hWin = pMsg->hWin; UEZSemaphoreRelease(semaphore_actual_hWin); // USER END break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_BUTTON_0: // Notifications sent by 'exit_button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(600, 20); PlayAudio(600, 20); PlayAudio(200, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(900, 20); PlayAudio(1000, 20); PlayAudio(1100, 20); check_sensors.alarm = 0; check_sensors.light = 0; check_sensors.temperature = 0; BS_wrapper(EXIT_CONTROLLER, INTERNAL, &pMsg); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SLIDER_0: // Notifications sent by 'refresh_slider' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_0 ); delay_from_slider = 10 + (SLIDER_GetValue(hItem) * 2); BS_wrapper(CHANGE_DELAY_QUERY_FROM_WINDOW, EXTERNAL, &delay_from_slider); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_0: // Notifications sent by 'temperature_edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_1: // Notifications sent by 'humidity_edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_2: // Notifications sent by 'sound_edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_3: // Notifications sent by 'distance_edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_4: // Notifications sent by 'presence_edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_5: // Notifications sent by 'vibration_edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_EDIT_6: // Notifications sent by 'light_edit' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_0: // Notifications sent by 'light_check' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(180, 30); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0 ); check_sensors.light = CHECKBOX_GetState(hItem); BS_wrapper(NOTIFY_NO_LIGHT_SENSOR_CHANGED_FROM_WINDOW, EXTERNAL, NULL); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_1: // Notifications sent by 'alarm_check' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(180, 30); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1 ); check_sensors.alarm = CHECKBOX_GetState(hItem); BS_wrapper(NOTIFY_ALARM_PRESENCE_SENSOR_CHANGED_FROM_WINDOW, EXTERNAL, NULL); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_CHECKBOX_2: // Notifications sent by 'temp_check' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(180, 30); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_2 ); check_sensors.temperature = CHECKBOX_GetState(hItem); BS_wrapper(NOTIFY_ALARM_TEMPERATURE_SENSOR_CHANGED_FROM_WINDOW, EXTERNAL, NULL); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_0: // Notifications sent by 'Spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(180, 30); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0 ); temperature_limit = SPINBOX_GetValue(hItem); BS_wrapper(NOTIFY_MAX_TEMPERATURE_THRESHOLD_FROM_WINDOW, EXTERNAL, &temperature_limit); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) case MB_MSG_SENSOR: //GESTISCO L'AGGIORNAMENTO DEI LABEL DEI SENSORI /** i sensori sono stati mappati così: *(usRegHoldingBuf ) = (USHORT *) &sensors.distance1; *(usRegHoldingBuf + 1 ) = (USHORT *) &sensors.distance2; *(usRegHoldingBuf + 2 ) = (USHORT *) &sensors.lumino; *(usRegHoldingBuf + 3 ) = (USHORT *) &sensors.mic; *(usRegHoldingBuf + 4 ) = (USHORT *) &sensors.vibro; *(usRegHoldingBuf + 5 ) = (USHORT *) &actual_DHT11.humidity; *(usRegHoldingBuf + 6 ) = (USHORT *) &actual_DHT11.temperature; "temperature_edit", ID_EDIT_0 "humidity_edit", ID_EDIT_1 "sound_edit", ID_EDIT_2 "distance_edit", ID_EDIT_3 "presence_edit", ID_EDIT_4 "vibration_edit", ID_EDIT_5 "light_edit", ID_EDIT_6 */ //estrazione della temperatura break; // USER END default: WM_DefaultProc(pMsg); break; } }
void UpdateUpgradeScreenObjects(void) { float camX = GetCameraXPosition(); char CharTemp[32]; int worldX, worldY; Vec2 MouseClick; Vec2 NewPosition; FoxInput_GetWorldPosition(&worldX, &worldY); Vec2Set(&MouseClick, (float)worldX, (float)worldY); //Update the particles ParticleSystemUpdate(); //Check if there are upgrades if (!UpgradesToUpgrade) { if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0) UpgradesToUpgrade = TRUE; else if (CurrentPlayer.CurrentPlayerStats.Upgrades < 1) { //No upgrade points, get out UpgradeComplete = TRUE; return; } } //Title if (CurrentPlayer.CurrentPlayerStats.Strength >= UPGRADE_MAX && CurrentPlayer.CurrentPlayerStats.Agility >= UPGRADE_MAX && CurrentPlayer.CurrentPlayerStats.Defense >= UPGRADE_MAX && !allUpgradesFull) { //If no more upgrades remain, let them know allUpgradesFull = TRUE; ChangeTextString(UpgradesName, "All Upgrades Complete!"); ChangeTextZIndex(UpgradesName, 4003); } Vec2Set(&NewPosition, camX, 470); ChangeTextPosition(UpgradesName, NewPosition, Center); //Upgrades remaining if (lastUpgrades != CurrentPlayer.CurrentPlayerStats.Upgrades) { //Do some flavor text warnings for differnt UP amounts if (allUpgradesFull) sprintf(CharTemp, "Good Work! Keep Mashing!"); else if (CurrentPlayer.CurrentPlayerStats.Upgrades == 1) sprintf(CharTemp, "%i Point Remaining!", CurrentPlayer.CurrentPlayerStats.Upgrades); else if (CurrentPlayer.CurrentPlayerStats.Upgrades < 1) sprintf(CharTemp, "No Points! Level Up More!"); else sprintf(CharTemp, "%i Points to Spend!", CurrentPlayer.CurrentPlayerStats.Upgrades); ChangeTextString(UpgradesLeft, CharTemp); ChangeTextZIndex(UpgradesLeft, 4003); TextAllVisible(UpgradesLeft); lastUpgrades = CurrentPlayer.CurrentPlayerStats.Upgrades; } Vec2Set(&NewPosition, camX, 380); ChangeTextPosition(UpgradesLeft, NewPosition, Center); //Upgrade buttons, all 3 UpdateButtonPosition(UpgradeButton1, 545 + camX, 200); UpdateCollisionPosition(&UpgradeButton1->ButtonCollider, &UpgradeButton1->ButtonSprite->Position); UpdateButtonPosition(UpgradeButton2, 545 + camX, 0); UpdateCollisionPosition(&UpgradeButton2->ButtonCollider, &UpgradeButton2->ButtonSprite->Position); UpdateButtonPosition(UpgradeButton3, 545 + camX, -200); UpdateCollisionPosition(&UpgradeButton3->ButtonCollider, &UpgradeButton3->ButtonSprite->Position); //Upgrade bars UpgradeBar1->Position.x = camX; UpgradeBar1->Position.y = 200; UpgradeBar2->Position.x = camX; UpgradeBar2->Position.y = 0; UpgradeBar3->Position.x = camX; UpgradeBar3->Position.y = -200; //Particle / Haze back HazeBackground->Position.x = camX + 480; HazeBackground->Position.y = 0; SystemOne->Position.y = 0; SystemOne->Position.x = camX; SystemOne->amountTotal = -1; if (HazeBackground->Alpha < 1) HazeBackground->Alpha += 2 * GetDeltaTime(); else HazeBackground->Alpha = 1; //Upgrade bar colors //Str -- UpgradeBarColor1->Position.x = camX - 61 - 52.0f * (UPGRADE_MAX - CurrentPlayer.CurrentPlayerStats.Strength); UpgradeBarColor1->Position.y = 200; UpgradeBarColor1->ScaleX = 1.0f * ((float)CurrentPlayer.CurrentPlayerStats.Strength / UPGRADE_MAX); UpgradeBarColor1->ScaleY = 1.1f; //Agi -- UpgradeBarColor2->Position.x = camX - 61 - 52.0f * (UPGRADE_MAX - CurrentPlayer.CurrentPlayerStats.Agility); UpgradeBarColor2->Position.y = 0; UpgradeBarColor2->ScaleX = 1.0f * ((float)CurrentPlayer.CurrentPlayerStats.Agility / UPGRADE_MAX); UpgradeBarColor2->ScaleY = 1.1f; //Def -- UpgradeBarColor3->Position.x = camX - 61 - 52.0f * (UPGRADE_MAX - CurrentPlayer.CurrentPlayerStats.Defense); UpgradeBarColor3->Position.y = -200; UpgradeBarColor3->ScaleX = 1.0f * ((float)CurrentPlayer.CurrentPlayerStats.Defense / UPGRADE_MAX); UpgradeBarColor3->ScaleY = 1.1f; //Upgrades used placement //Str -- sprintf(CharTemp, "%i", CurrentPlayer.CurrentPlayerStats.Strength); ChangeTextString(UpgradeAmount1, CharTemp); ChangeTextZIndex(UpgradeAmount1, 4003); TextAllVisible(UpgradeAmount1); Vec2Set(&NewPosition, camX - 590, 200); ChangeTextPosition(UpgradeAmount1, NewPosition, Center); //Agi -- sprintf(CharTemp, "%i", CurrentPlayer.CurrentPlayerStats.Agility); ChangeTextString(UpgradeAmount2, CharTemp); ChangeTextZIndex(UpgradeAmount2, 4003); TextAllVisible(UpgradeAmount2); Vec2Set(&NewPosition, camX - 590, 0); ChangeTextPosition(UpgradeAmount2, NewPosition, Center); //Def -- sprintf(CharTemp, "%i", CurrentPlayer.CurrentPlayerStats.Defense); ChangeTextString(UpgradeAmount3, CharTemp); ChangeTextZIndex(UpgradeAmount3, 4003); TextAllVisible(UpgradeAmount3); Vec2Set(&NewPosition, camX - 590, -200); ChangeTextPosition(UpgradeAmount3, NewPosition, Center); //Done upgrading button UpdateButtonPosition(MainMapButton, 400 + camX, -400); UpdateCollisionPosition(&MainMapButton->ButtonCollider, &MainMapButton->ButtonSprite->Position); //STRENGTH (No up allowed if maxed) if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0 && PointRectCollision(&UpgradeButton1->ButtonCollider, &MouseClick) && CurrentPlayer.CurrentPlayerStats.Strength < UPGRADE_MAX) { UpgradeButton1->ButtonSprite->ScaleX = 1.12f; UpgradeButton1->ButtonSprite->ScaleY = 1.12f; //Make the button react if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { CurrentPlayer.CurrentPlayerStats.Upgrades--; CurrentPlayer.CurrentPlayerStats.Strength++; UpgradeButton1->ButtonSprite->ScaleX = 1.16f; UpgradeButton1->ButtonSprite->ScaleY = 1.16f; PlayAudio(CurrentPlayer.CurrentPlayerSounds.KeyPickUp); } } else { if (UpgradeButton1->ButtonSprite->ScaleX > 1.0f) { UpgradeButton1->ButtonSprite->ScaleX -= GetDeltaTime() * 2; UpgradeButton1->ButtonSprite->ScaleY -= GetDeltaTime() * 2; } } //AGILITY (No up allowed if maxed) if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0 && PointRectCollision(&UpgradeButton2->ButtonCollider, &MouseClick) && CurrentPlayer.CurrentPlayerStats.Agility < UPGRADE_MAX) { UpgradeButton2->ButtonSprite->ScaleX = 1.12f; UpgradeButton2->ButtonSprite->ScaleY = 1.12f; //Make the button react if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { CurrentPlayer.CurrentPlayerStats.Upgrades--; CurrentPlayer.CurrentPlayerStats.Agility++; UpgradeButton2->ButtonSprite->ScaleX = 1.16f; UpgradeButton2->ButtonSprite->ScaleY = 1.16f; PlayAudio(CurrentPlayer.CurrentPlayerSounds.KeyPickUp); } } else { if (UpgradeButton2->ButtonSprite->ScaleX > 1.0f) { UpgradeButton2->ButtonSprite->ScaleX -= GetDeltaTime() * 2; UpgradeButton2->ButtonSprite->ScaleY -= GetDeltaTime() * 2; } } //DEFENSE (No up allowed if maxed) if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0 && PointRectCollision(&UpgradeButton3->ButtonCollider, &MouseClick) && CurrentPlayer.CurrentPlayerStats.Defense < UPGRADE_MAX) { UpgradeButton3->ButtonSprite->ScaleX = 1.12f; UpgradeButton3->ButtonSprite->ScaleY = 1.12f; //Make the button react if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { CurrentPlayer.CurrentPlayerStats.Upgrades--; CurrentPlayer.CurrentPlayerStats.Defense++; UpgradeButton3->ButtonSprite->ScaleX = 1.16f; UpgradeButton3->ButtonSprite->ScaleY = 1.16f; PlayAudio(CurrentPlayer.CurrentPlayerSounds.KeyPickUp); } } else { if (UpgradeButton3->ButtonSprite->ScaleX > 1.0f) { UpgradeButton3->ButtonSprite->ScaleX -= GetDeltaTime() * 2; UpgradeButton3->ButtonSprite->ScaleY -= GetDeltaTime() * 2; } } //MAIN MENU if(PointRectCollision(&MainMapButton->ButtonCollider, &MouseClick)) { MainMapButton->ButtonSprite->ScaleX = 1.2f; MainMapButton->ButtonSprite->ScaleY = 1.2f; //Make the button react if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT)) { UpgradeComplete = TRUE; } } else { MainMapButton->ButtonSprite->ScaleX = 1.0f; MainMapButton->ButtonSprite->ScaleY = 1.0f; } }
/*---------------------------------------------------------------------------* * Task: main *---------------------------------------------------------------------------* * Description: * In the uEZ system, main() is a task. Do not exit this task * unless you want to the board to reset. This function should * setup the system and then run the main loop of the program. * Outputs: * int -- Output error code *---------------------------------------------------------------------------*/ int MainTask(void) { T_uezDevice temp; T_uezDevice accel; T_uezError tempDeviceError; T_uezError accelDeviceError; TUInt8 displayString[100]; TInt32 tempValue; float tempFloatValue; AccelerometerReading accelReading; printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // clear serial screen and put up banner // Start up the heart beat of the LED UEZTaskCreate(Heartbeat, "Heart", 64, (void *)0, UEZ_PRIORITY_NORMAL, 0); NVSettingsInit(); // Load the settings from non-volatile memory if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) { printf("EEPROM Settings\n"); NVSettingsInit(); NVSettingsSave(); } // Setup any additional misc. tasks (such as the heartbeat task) SetupTasks(); GlyphOpen(&G_glyphLCD, 0); IDrawTitle(); PlayAudio(523, 100); PlayAudio(659, 100); PlayAudio(783, 100); PlayAudio(1046, 100); PlayAudio(783, 100); PlayAudio(659, 100); PlayAudio(523, 100); tempDeviceError = UEZTemperatureOpen("Temp0", &temp); if (tempDeviceError == UEZ_ERROR_NONE) { printf("MainTask: Temperature Device Open\n"); } else { printf("MainTask: Failed to Open Temperature Device\n"); } accelDeviceError = UEZAccelerometerOpen("Accel0", &accel); if (accelDeviceError == UEZ_ERROR_NONE) { printf("MainTask: Accelerometer Device Open\n"); } else { printf("MainTask: Failed to Open Accelerometer Device\n"); } while(1) { if ( tempDeviceError == UEZ_ERROR_NONE ) { if (UEZTemperatureRead(temp, &tempValue) == UEZ_ERROR_NONE) { tempFloatValue = tempValue/65536.0; sprintf((char *)displayString, "Temp: %.2f C", tempFloatValue); GlyphSetXY(G_glyphLCD, 0, 0); GlyphString(G_glyphLCD, displayString, strlen(displayString)); } } if ( accelDeviceError == UEZ_ERROR_NONE ) { if(UEZAccelerometerReadXYZ(accel, &accelReading, 10) == UEZ_ERROR_NONE ) { sprintf((char *)displayString, "ACCEL X: %d", accelReading.iX); GlyphSetXY(G_glyphLCD, 0, 16); GlyphString(G_glyphLCD, displayString, strlen(displayString)); sprintf((char *)displayString, "ACCEL Y: %d", accelReading.iY); GlyphSetXY(G_glyphLCD, 0, 24); GlyphString(G_glyphLCD, displayString, strlen(displayString)); sprintf((char *)displayString, "ACCEL Z: %d", accelReading.iZ); GlyphSetXY(G_glyphLCD, 0, 32); GlyphString(G_glyphLCD, displayString, strlen(displayString)); } } UEZTaskDelay(500); } return 0; }
/*---------------------------------------------------------------------------* * Routine: Beep *---------------------------------------------------------------------------* * Description: * Play a standard beep. *---------------------------------------------------------------------------*/ void Beep(void) { // Beep at 500 Hz for 250 ms PlayAudio(500, 250); }
void DecodedAudioDataSink::AudioLoop() { AssertOnAudioThread(); mAudioLoopScheduled = false; switch (mState) { case AUDIOSINK_STATE_INIT: { SINK_LOG("AudioLoop started"); nsresult rv = InitializeAudioStream(); if (NS_FAILED(rv)) { NS_WARNING("Initializing AudioStream failed."); mEndPromise.Reject(rv, __func__); SetState(AUDIOSINK_STATE_ERROR); break; } SetState(AUDIOSINK_STATE_PLAYING); ConnectListener(); break; } case AUDIOSINK_STATE_PLAYING: { if (WaitingForAudioToPlay()) { // OnAudioQueueEvent() will schedule next loop. break; } if (!IsPlaybackContinuing()) { SetState(AUDIOSINK_STATE_COMPLETE); break; } if (!PlayAudio()) { SetState(AUDIOSINK_STATE_COMPLETE); break; } // Schedule next loop to play next sample. ScheduleNextLoop(); break; } case AUDIOSINK_STATE_COMPLETE: { DisconnectListener(); FinishAudioLoop(); SetState(AUDIOSINK_STATE_SHUTDOWN); break; } case AUDIOSINK_STATE_SHUTDOWN: break; case AUDIOSINK_STATE_ERROR: break; } // end of switch // We want mState to stay stable during AudioLoop to keep things simple. // Therefore, we only do state transition at the end of AudioLoop. if (mPendingState.isSome()) { MOZ_ASSERT(mState != mPendingState.ref()); SINK_LOG("change mState, %d -> %d", mState, mPendingState.ref()); mState = mPendingState.ref(); mPendingState.reset(); // Schedule next loop when state changes. ScheduleNextLoop(); } }