static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { OSStatus err = eventNotHandledErr; HICommand cmd; BYTE defaultmix[5] = {64, 64, 64, 64, 64}; BYTE b; if (GetEventClass(event)==kEventClassCommand && GetEventKind(event)==kEventCommandProcess ) { GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); switch (cmd.commandID) { case 'vDEF': initMixer(defaultmix); break; case '26io': setjmper(&snd26, (getMenuValue == 1)?0x10:0x00, 0x10); break; case '26in': setjmper(&snd26, getsnd26int(cmd.commandID), 0xc0); break; case '26rm': setjmper(&snd26, getMenuValue, 0x07); break; case '26DF': snd26 = 0xd1; set26s(snd26, '26io', '26in', '26rm'); break; case '86io': setjmper(&snd86, (getMenuValue == 0)?0x01:0x00, 0x01); break; case '86it': setjmper(&snd86, (getControlValue(cmd.commandID, 0))?0x10:0x00, 0x10); break; case '86in': setjmper(&snd86, getsnd86int(), 0x0c); break; case '86id': setjmper(&snd86, (~getMenuValue & 7) << 5, 0xe0); break; case '86rm': setjmper(&snd86, (getControlValue(cmd.commandID, 0))?0x02:0x00, 0x02); break; case '86DF': snd86 = 0x7f; set86s(); break; case 'spio': setjmper(&spb, (getMenuValue == 1)?0x10:0x00, 0x10); break; case 'spin': setjmper(&spb, getsnd26int(cmd.commandID), 0xc0); break; case 'sprm': setjmper(&spb, getMenuValue, 0x07); break; case 'spvl': case 'spvr': b = getspbVRch(); if ((spbvrc ^ b) & 3) { spbvrc = b; } break; case 'spDF': spb = 0xd1; spbvrc = 0; setSPB(); break; case kHICommandOK: changeSoundOpt(); endLoop(soundWin); err=noErr; break; case kHICommandCancel: revertTemporal(); endLoop(soundWin); err=noErr; break; case JOYPAD_UP: case JOYPAD_DOWN: case JOYPAD_LEFT: case JOYPAD_RIGHT: case JOYPAD_ABUTTON: case JOYPAD_BBUTTON: err=setupJoyConfig(cmd.commandID); break; default: break; } } (void)myHandler; (void)userData; return err; }
// does what its name suggests void PortVideoSDL::mainLoop() { unsigned char* cameraReadBuffer = NULL; while(running_) { // do nothing if paused if (pause_){ process_events(); SDL_Delay(50); continue; } long start_time = currentTime(); cameraReadBuffer = ringBuffer->getNextBufferToRead(); // loop until we get access to a frame while (cameraReadBuffer==NULL) { cameraReadBuffer = ringBuffer->getNextBufferToRead(); //if (cameraReadBuffer!=NULL) break; SDL_Delay(1); process_events(); if(!running_) { endLoop(); return; } } long camera_time = currentTime(); //memcpy(sourceBuffer_,cameraReadBuffer,ringBuffer->size()); //ringBuffer->readFinished(); // try again if we can get a more recent frame /*do { memcpy(sourceBuffer_,cameraReadBuffer,ringBuffer->size()); ringBuffer->readFinished(); cameraReadBuffer = ringBuffer->getNextBufferToRead(); } while( cameraReadBuffer != NULL );*/ // do the actual image processing job for (frame = processorList.begin(); frame!=processorList.end(); frame++) (*frame)->process(cameraReadBuffer,destBuffer_,displayImage_); long processing_time = currentTime(); if(camera_ != 0){ // update display switch( displayMode_ ) { case NO_DISPLAY: break; case SOURCE_DISPLAY: { memcpy(sourceBuffer_,cameraReadBuffer,ringBuffer->size()); SDL_BlitSurface(sourceImage_, NULL, window_, NULL); if (help_) drawHelp(); camera_->drawGUI(displayImage_); SDL_BlitSurface(displayImage_, NULL, window_, NULL); SDL_FillRect(displayImage_, NULL, 0 ); SDL_Flip(window_); break; } case DEST_DISPLAY: { SDL_BlitSurface(destImage_, NULL, window_, NULL); if (help_) drawHelp(); camera_->drawGUI(displayImage_); SDL_BlitSurface(displayImage_, NULL, window_, NULL); SDL_FillRect(displayImage_, NULL, 0 ); SDL_Flip(window_); break; } } } #ifndef NDEBUG if (recording_) { if (displayMode_!=SOURCE_DISPLAY) memcpy(sourceBuffer_,cameraReadBuffer,ringBuffer->size()); saveBuffer(sourceBuffer_); } #endif ringBuffer->readFinished(); if (!recording_) frameStatistics(camera_time-start_time,processing_time-camera_time, currentTime()-start_time); process_events(); } endLoop(); }
int main(void) { BOOL_T err = CO_FALSE; /* error flag */ UNSIGNED8 temp = 0; uword time_lo = 0, time_hi = 0; /*--- hardware initialization e.g SIO, Chip-Selects, ...----------*/ iniDevice(); IO_vInit(); USIC0_vInit(); USIC1_vInit(); USIC2_vInit(); #if HW_KPS == 1 USIC3_vInit(); #endif //RTC init DAVE_vUnlockProtecReg(); RTC_vInit(); NOP(); /* one cycle delay */ NOP(); /* one cycle delay */ DAVE_vLockProtecReg(); lNodeId = (~IO_uwReadPort(P2))&0xFF; if (lNodeId > 127) { lNodeId = 127; } temp = (~IO_uwReadPort(P10))&0x0F; switch(temp){ case 0: bitRate = 10; break; case 1: bitRate = 20; break; case 2: bitRate = 50; break; case 3: bitRate = 125; break; case 4: bitRate = 250; break; case 5: bitRate = 500; break; case 0x9: case 0xE: case 0xF: bitRate = 125; if (((~IO_uwReadPort(P2)) & 0xFF) == 0){ lNodeId = 127; } break; default: bitRate = 500; break; } initCan(bitRate); init_Library(); initTimer(); Start_CAN(); ENABLE_CPU_INTERRUPTS(); RTC_vSetTime(0,0); sw_init(); //PRINTF("loop\n"); while (err == CO_FALSE) { FlushMbox(); /* Do the CANopen job */ myRTC_ulGetTime(&time_lo, &time_hi); //odczyt temperatury wewn. status_wewn[2] = ad7814_read(U2C0, SPI_CS3); sw_loop(); //sygnalizacja na diodach if (blink(time_lo, ch1_led_st)) { //St1 IO_vResetPin(IO_P0_0_LED_ST1); } else { IO_vSetPin(IO_P0_0_LED_ST1); } if (blink(time_lo, ch2_led_st)) { //St2 IO_vResetPin(IO_P4_1_LED_ST2); } else { IO_vSetPin(IO_P4_1_LED_ST2); } if (blink(time_lo, ch1_led_err)) { //Err1 IO_vResetPin(IO_P4_2_LED_ERR1); } else { IO_vSetPin(IO_P4_2_LED_ERR1); } if (blink(time_lo, ch2_led_err)) { //Err2 IO_vResetPin(IO_P4_0_LED_ERR2); } else { IO_vSetPin(IO_P4_0_LED_ERR2); } //w funkcji err_code dopisac cykliczna informacje o kilku bledach (numer bledu jako bity w slowie "dev_led_st" a nie wartosc) if (err_code(time_lo, dev_led_st)) { //err code - Yellow diode IO_vResetPin(IO_P2_8_LED_C); } else { IO_vSetPin(IO_P2_8_LED_C); } /* give a chance to finish the loop */ err = endLoop(); } PRINTF("\nSTOP\n"); Stop_CAN(); DISABLE_CPU_INTERRUPTS(); releaseTimer(); ResetIntMask(); deinit_Library(); return 0; }