CChannelHandlerVRC7::CChannelHandlerVRC7(SoundGen *gen) : CChannelHandler(gen), m_iCommand(0), m_iTriggeredNote(0) { m_iVolume = MAX_VOL; SetMaxPeriod(2047); }
/** * Common initialization code for Encoders. * This code allocates resources for Encoders and is common to all constructors. * * The counter will start counting immediately. * * @param reverseDirection If true, counts down instead of up (this is all relative) * @param encodingType either k1X, k2X, or k4X to indicate 1X, 2X or 4X decoding. If 4X is * selected, then an encoder FPGA object is used and the returned counts will be 4x the encoder * spec'd value since all rising and falling edges are counted. If 1X or 2X are selected then * a counter object will be used and the returned value will either exactly match the spec'd count * or be double (2x) the spec'd count. */ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) { m_table = NULL; m_encodingType = encodingType; m_index = 0; switch (encodingType) { case k4X: { m_encodingScale = 4; if (m_aSource->StatusIsFatal()) { CloneError(m_aSource); return; } if (m_bSource->StatusIsFatal()) { CloneError(m_bSource); return; } int32_t status = 0; m_encoder = initializeEncoder(m_aSource->GetModuleForRouting(), m_aSource->GetChannelForRouting(), m_aSource->GetAnalogTriggerForRouting(), m_bSource->GetModuleForRouting(), m_bSource->GetChannelForRouting(), m_bSource->GetAnalogTriggerForRouting(), reverseDirection, &m_index, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); m_counter = NULL; SetMaxPeriod(.5); break; } case k1X: case k2X: { m_encodingScale = encodingType == k1X ? 1 : 2; m_counter = new Counter(m_encodingType, m_aSource, m_bSource, reverseDirection); m_index = m_counter->GetFPGAIndex(); break; } default: wpi_setErrorWithContext(-1, "Invalid encodingType argument"); break; } m_distancePerPulse = 1.0; m_pidSource = kDistance; HALReport(HALUsageReporting::kResourceType_Encoder, m_index, encodingType); LiveWindow::GetInstance()->AddSensor("Encoder", m_aSource->GetChannelForRouting(), this); }
/** * Set the minimum rate of the device before the hardware reports it stopped. * * @param minRate The minimum rate. The units are in distance per second as * scaled by the value from SetDistancePerPulse(). */ void Encoder::SetMinRate(double minRate) { if (StatusIsFatal()) return; SetMaxPeriod(m_distancePerPulse / minRate); }
/** * Set the minimum rate of the device before the hardware reports it stopped. * * @param minRate The minimum rate. The units are in distance per second as scaled by the value from SetDistancePerPulse(). */ void Encoder::SetMinRate(double minRate) { SetMaxPeriod(m_distancePerPulse / minRate); }
CChannelHandlerVRC6::CChannelHandlerVRC6(SoundGen *gen) : CChannelHandler(gen) { SetMaxPeriod(0xFFF); }
CChannelHandlerMMC5::CChannelHandlerMMC5() : CChannelHandler() { SetMaxPeriod(0x7FF); // same as 2A03 }