void DualTriggerControlAdjust(void* data) { uint8_t* input = data; SoftTimer2[SC_AutoMenuUpdate].timeCompare = FAST_AUTO_MENU_UPDATE; SoftTimerStart(SoftTimer2[SC_AutoMenuUpdate]); switch( *input ) { case KP_UP: SetTrigger(SelectedChannel, GetTrigger(SelectedChannel)+1); break; case KP_DOWN: SetTrigger(SelectedChannel, GetTrigger(SelectedChannel)-1); break; case KP_BACK: UF_MenuUpOneLevel(ActiveMenu); return; } MenuUpdate(ActiveMenu, RESET_MENU | NO_EXECUTE); UF_MenuSetInput(KP_INVALID); PrintDualTriggerInformation(3); }
/** * Get buttons based on an enumerated type. * * The button type will be looked up in the list of buttons and then read. * * @param button The type of button to read. * @return The state of the button. */ bool Joystick::GetButton(ButtonType button) { switch (button) { case kTriggerButton: return GetTrigger(); case kTopButton: return GetTop(); default: return false; } }
void MIDI_DigitalOutput(void) { uint8_t i; MIDI_MSG_t msg; uint8_t selectedDigitalInput; for( i = ANALOGUE_INPUTS; i < NUMBER_OF_INPUTS; i++) { selectedDigitalInput = i - ANALOGUE_INPUTS; if( GetChannelStatus(i) && (RetriggerPeriod[i].timerEnable == SOFTTIMER_DISABLED)) { /* If the channel selected in a MetroNome one, automatically * trigger a signal. */ if( SignalPeak[i] || (i >= ANALOGUE_INPUTS + DIGITAL_INPUTS)) { /* Send a NOTE ON (default) | Channel */ if( GetDualMode(i) && GetChannelState(GetTrigger(i)) ) { msg.StatusCode = GetClosedChannelCommand(i); msg.Data[0] = GetChannelKeyClosed(i); } else { msg.StatusCode = GetChannelCommand(i); msg.Data[0] = GetChannelKey(i); /* If the channel is a metronome input, do not check * to see if it has an active release */ if((i >= ANALOGUE_INPUTS + DIGITAL_INPUTS) ) { } else { if( GetActiveRelease(selectedDigitalInput) && SignalPeak[i] == INPUT_IS_RELEASED ) { msg.StatusCode = GetClosedChannelCommand(i); msg.Data[0] = GetChannelKeyClosed(i); } } } msg.Data[1] = GetDigitalVelocity(selectedDigitalInput); MIDI_SendMsg(&msg); if( SoftTimer2[SC_DigitalVUUpdate].timerEnable ) { VUValues[selectedDigitalInput] = GetDigitalVelocity(selectedDigitalInput); } SoftTimerStart(RetriggerPeriod[i]); } } } }
void MIDI_OutputAnalogueChannel(uint8_t channel) { MIDI_MSG_t msg; if( GetChannelStatus(channel) && (RetriggerPeriod[channel].timerEnable == SOFTTIMER_DISABLED) && (SignalPeak[channel]) ) { //uint16_t conditionedSignal = (SignalPeak[i] - GetChannelThresh(i)); /* Make the conditioned signal start at the Threshold */ uint16_t conditionedSignal = (SignalPeak[channel]); conditionedSignal = GainFunction(channel, conditionedSignal); if( conditionedSignal ) { /* Make it slightly larger, so we can reach 0x7F */ conditionedSignal++; /* Output the correct Closed or Open Key */ if( GetDualMode(channel) && GetChannelState(GetTrigger(channel)) ) { /* The channel code is appended at the midi_send function */ msg.StatusCode = GetClosedChannelCommand(channel); msg.Data[0] = GetChannelKeyClosed(channel); } else { msg.StatusCode = GetChannelCommand(channel); msg.Data[0] = GetChannelKey(channel); } if( conditionedSignal > MIDI_MAX_DATA ) { conditionedSignal = MIDI_MAX_DATA; } msg.Data[1] = (uint8_t)(conditionedSignal); MIDI_SendMsg(&msg); /* Auxiliary MIDI functions */ MIDI_LastMIDIValue[channel] = conditionedSignal; if( SoftTimer2[SC_VUMeterUpdate].timerEnable ) { if( SignalPeak[channel] > VUValues[channel] ) { VUValues[channel] = SignalPeak[channel]; } } SoftTimerStart(RetriggerPeriod[channel]); } } }
void Game_CommonEvent::Refresh() { if ( (GetTrigger() == Game_Character::TriggerParallelProcess) && ( Game_Switches[GetSwitchId()] ) ) { if (interpreter == NULL) { interpreter = battle ? (Game_Interpreter*) new Game_Interpreter_Battle() : (Game_Interpreter*) new Game_Interpreter_Map(); Update(); } } else { delete interpreter; interpreter = NULL; } }
void OUI_Initialize(){ GUI_SetBkColor(OUI_GRAPH_BACKGROUND); GUI_Clear(); UI_CreateMemoryDevice(&OUI_MemoryDeviceGrid, 40, 15, 270, 180); OUI_Components[0] = GetTime(); OUI_Components[1] = GetChannel1(); OUI_Components[2] = GetChannel2(); OUI_Components[3] = GetTrigger(); OUI_Components[4] = GetMarkers(); for(int i = 0; i < 5; i++){ OUI_Components[i]->DrawLabel(OUI_Components[i], 0, i*42); } }
unsigned long Measurement::GetLengthBeforeTrigger() { FILE_LOG(logDEBUG3) << "Measurement::GetLengthBeforeTrigger"; double x_fraction; if(IsTriggered()) { x_fraction = GetTrigger()->GetXFraction(); if(x_fraction>=0 && x_fraction<=1) { return (unsigned long)round((double)GetLength()*x_fraction); // we didn't allow that when creating new trigger, but we could // the idea is to use a number of samples instead of a fraction } else if(x_fraction>=0 && x_fraction<=GetLength()) { return (unsigned long)round(x_fraction); } else { throw("invalid value of x fraction of a simple trigger.\n"); } } else { return 0UL; } }
void Measurement::RunBlock() { FILE_LOG(logDEBUG3) << "Measurement::RunBlock"; int i; Timing t; uint32_t max_length=0; // we will have to start reading our data from beginning again SetNextIndex(0); // test if channel settings have already been passed to picoscope // and only pass them again if that isn't the case FILE_LOG(logDEBUG4) << "Measurement::RunBlock - we have " << GetNumberOfChannels() << " channels"; for(i=0; i<GetNumberOfChannels(); i++) { FILE_LOG(logDEBUG4) << "Measurement::RunBlock - setting channel " << (char)('A'+i) << " (which holds index " << GetChannel(i)->GetIndex() << ")"; GetChannel(i)->SetChannelInPicoscope(); } // this fixes the timebase if more than a single channel is selected FixTimebase(); // timebase SetTimebaseInPicoscope(); // trigger if(IsTriggered()) { GetTrigger()->SetTriggerInPicoscope(); } // for rapid block mode if(GetNTraces() > 1) { // TODO - check that GetLength()*GetNumberOfEnabledChannels()*GetNTraces() doesn't exceed the limit if(GetSeries() == PICO_4000) { FILE_LOG(logDEBUG2) << "ps4000SetNoOfCaptures(handle=" << GetHandle() << ", nCaptures=" << GetNTraces() << ")"; GetPicoscope()->SetStatus(ps4000SetNoOfCaptures( GetHandle(), // handle GetNTraces())); // nCaptures } else { FILE_LOG(logDEBUG2) << "ps6000SetNoOfCaptures(handle=" << GetHandle() << ", nCaptures=" << GetNTraces() << ")"; GetPicoscope()->SetStatus(ps6000SetNoOfCaptures( GetHandle(), // handle GetNTraces())); // nCaptures } if(GetPicoscope()->GetStatus() != PICO_OK) { std::cerr << "Unable to set number of captures to " << GetNTraces() << std::endl; throw Picoscope::PicoscopeException(GetPicoscope()->GetStatus()); } if(GetSeries() == PICO_4000) { FILE_LOG(logDEBUG2) << "ps4000MemorySegments(handle=" << GetHandle() << ", nSegments=" << GetNTraces() << ", &max_length=" << max_length << ")"; GetPicoscope()->SetStatus(ps4000MemorySegments( GetHandle(), // handle GetNTraces(), // nSegments &max_length)); FILE_LOG(logDEBUG2) << "->ps4000MemorySegments(... max_length=" << max_length << ")"; } else { FILE_LOG(logDEBUG2) << "ps6000MemorySegments(handle=" << GetHandle() << ", nSegments=" << GetNTraces() << ", &max_length=" << max_length << ")"; GetPicoscope()->SetStatus(ps6000MemorySegments( GetHandle(), // handle GetNTraces(), // nSegments &max_length)); FILE_LOG(logDEBUG2) << "->ps6000MemorySegments(... max_length=" << max_length << ")"; } if(GetPicoscope()->GetStatus() != PICO_OK) { std::cerr << "Unable to set number of segments to " << GetNTraces() << std::endl; throw Picoscope::PicoscopeException(GetPicoscope()->GetStatus()); } if(max_length < GetLength()) { // TODO: times number of enabled channels std::cerr << "The maximum length of trace you can get with " << GetNTraces() << " traces is " << max_length << ", but you requested " << GetLength() << "\n"; throw; } if(GetSeries() == PICO_4000) { FILE_LOG(logDEBUG2) << "ps4000SetNoOfCaptures(handle=" << GetHandle() << ", nCaptures=" << GetNTraces() << ")"; GetPicoscope()->SetStatus(ps4000SetNoOfCaptures( GetHandle(), // handle GetNTraces())); // nCaptures } else { FILE_LOG(logDEBUG2) << "ps6000SetNoOfCaptures(handle=" << GetHandle() << ", nCaptures=" << GetNTraces() << ")"; GetPicoscope()->SetStatus(ps6000SetNoOfCaptures( GetHandle(), // handle GetNTraces())); // nCaptures } if(GetPicoscope()->GetStatus() != PICO_OK) { std::cerr << "Unable to set number of captures to " << GetNTraces() << std::endl; throw Picoscope::PicoscopeException(GetPicoscope()->GetStatus()); } } //std::cerr << "\nPress a key to start fetching the data ...\n"; //_getch(); t.Start(); GetPicoscope()->SetReady(false); if(GetSeries() == PICO_4000) { FILE_LOG(logDEBUG2) << "ps4000RunBlock(handle=" << GetHandle() << ", noOfPreTriggerSamples=" << GetLengthBeforeTrigger() << ", noOfPostTriggerSamples=" << GetLengthAfterTrigger() << ", timebase=" << timebase << ", oversample=1, *timeIndisposedMs=NULL, segmentIndex=0, lpReady=CallBackBlock, *pParameter=NULL)"; GetPicoscope()->SetStatus(ps4000RunBlock( GetHandle(), // handle GetLengthBeforeTrigger(), // noOfPreTriggerSamples GetLengthAfterTrigger(), // noOfPostTriggerSamples timebase, // timebase 1, // ovesample NULL, // *timeIndisposedMs 0, // segmentIndex CallBackBlock, // lpReady NULL)); // *pParameter } else { FILE_LOG(logDEBUG2) << "ps6000RunBlock(handle=" << GetHandle() << ", noOfPreTriggerSamples=" << GetLengthBeforeTrigger() << ", noOfPostTriggerSamples=" << GetLengthAfterTrigger() << ", timebase=" << timebase << ", oversample=1, *timeIndisposedMs=NULL, segmentIndex=0, lpReady=CallBackBlock, *pParameter=NULL)"; GetPicoscope()->SetStatus(ps6000RunBlock( GetHandle(), // handle GetLengthBeforeTrigger(), // noOfPreTriggerSamples GetLengthAfterTrigger(), // noOfPostTriggerSamples timebase, // timebase 1, // ovesample NULL, // *timeIndisposedMs 0, // segmentIndex CallBackBlock, // lpReady NULL)); // *pParameter } if(GetPicoscope()->GetStatus() != PICO_OK) { std::cerr << "Unable to start collecting samples" << std::endl; throw Picoscope::PicoscopeException(GetPicoscope()->GetStatus()); } else { std::cerr << "Start collecting samples in " << ((GetNTraces() > 1) ? "rapid " : "") << "block mode ... "; } // TODO: maybe we want it to be asynchronous // TODO: catch the _kbhit event!!! // while (!Picoscope::IsReady() && !_kbhit()) { while (!Picoscope::IsReady()) { Sleep(200); } t.Stop(); std::cerr << "OK (" << t.GetSecondsDouble() << "s)\n"; // sets the index from where we want to start reading data to zero SetNextIndex(0UL); }
void PrintDualTriggerInformation(uint8_t UpDownPosition) { static uint8_t enterCount; enterCount ^= (1); UF_MenuReset(); /* Indicate the channel selected */ UF_MenuPrint_P(PSTR("CH:")); utoa(SelectedChannel + 1, outputString, 10); UF_MenuPrint(outputString); UF_MenuPrint_P(PSTR(" Dual Trig:")); if( UpDownPosition == 0 && enterCount) { UF_MenuPrint_P( PSTR(" ") ); } else { if( GetDualMode(SelectedChannel) == HAS_DUAL_INPUT ) { UF_MenuPrint_P( PSTR("On") ); } else { UF_MenuPrint_P( PSTR("Off") ); } } UF_MenuNewLine(); /* Display the open note */ UF_MenuPrint_P(PSTR("Note:")); if( UpDownPosition == 1 && enterCount) { UF_MenuPrint_P( PSTR(" ") ); } else { PrintNoteFormat(OPEN_KEY); } UF_MenuNewLine(); /* Display the closed note */ UF_MenuPrint_P(PSTR("C.Note:")); if( UpDownPosition == 2 && enterCount) { UF_MenuPrint_P( PSTR(" ") ); } else { PrintNoteFormat(CLOSED_KEY); } UF_MenuNewLine(); UF_MenuPrint_P(PSTR("Activated by:CH")); /* Indicate whether it is an Analogue, Digital or MetroNome trigger */ char channelType; channelType = 'A'; utoa(GetTrigger(SelectedChannel)+1, outputString, 10); if( GetTrigger(SelectedChannel) >= ANALOGUE_INPUTS) { channelType = 'D'; utoa(GetTrigger(SelectedChannel) - ANALOGUE_INPUTS + 1, outputString, 10); } else if( GetTrigger(SelectedChannel) >= (ANALOGUE_INPUTS + DIGITAL_INPUTS)) { channelType = 'M'; utoa(GetTrigger(SelectedChannel) - ANALOGUE_INPUTS + DIGITAL_INPUTS + 1, outputString, 10); } UF_MenuChar(channelType); if( UpDownPosition == 3 && enterCount) { UF_MenuPrint_P( PSTR(" ") ); } else { UF_MenuPrint(outputString); } SoftTimerStart(SoftTimer2[SC_AutoMenuUpdate]); SelectedSubMenu = &dualTrigMenu; }