libClearCore/src/DigitalInAnalogIn.cpp
void DigitalInAnalogIn::Refresh() {
    switch (m_mode) {
        case INPUT_ANALOG:
            // If the ShiftRegister was not set up for the analog input
            // when this ADC reading was captured then it is not valid
            if (!(AdcMgr.ShiftRegSnapshot() & m_modeControlBitMask)) {
                // If this is the first valid reading, reset the IIR filter
                if (!m_analogValid) {
                    AdcMgr.FilterReset(m_adcChannel, *m_adcResultConvertedPtr);
                    m_analogValid = true;
                }

                // Set the LED PWM representation of this connector's value
                uint8_t value = (*m_adcResultConvertedPtr) >> 7;
                // Set a lower threshold of when to show any duty on the LED
                if (value < 0x03) {
                    value = 0;
                }
                ShiftReg.LedPwmValue(m_clearCorePin, value);
            }
            break;
        case INPUT_DIGITAL:
            DigitalIn::Refresh();
            break;
        default:
            break;
    }
}
/**
    In digital mode, read the input.
    In analog mode, read the raw value and update the filtered value.
**/
In digital mode, read the input.
In analog mode, read the raw value and update the filtered value.
In digital mode read the input . In analog mode read the raw value and update the filtered value .
void DigitalInAnalogIn::Refresh() {
    switch (m_mode) {
        case INPUT_ANALOG:
            if (!(AdcMgr.ShiftRegSnapshot() & m_modeControlBitMask)) {
                if (!m_analogValid) {
                    AdcMgr.FilterReset(m_adcChannel, *m_adcResultConvertedPtr);
                    m_analogValid = true;
                }
                uint8_t value = (*m_adcResultConvertedPtr) >> 7;
                if (value < 0x03) {
                    value = 0;
                }
                ShiftReg.LedPwmValue(m_clearCorePin, value);
            }
            break;
        case INPUT_DIGITAL:
            DigitalIn::Refresh();
            break;
        default:
            break;
    }
}
void DigitalInAnalogIn :: Refresh ( ) { switch ( m_mode ) { case INPUT_ANALOG : if ( ! ( AdcMgr . ShiftRegSnapshot ( ) & m_modeControlBitMask ) ) { if ( ! m_analogValid ) { AdcMgr . FilterReset ( m_adcChannel , * m_adcResultConvertedPtr ) ; m_analogValid = true ; } uint8_t value = ( * m_adcResultConvertedPtr ) >> 7 ; if ( value < 0x03 ) { value = 0 ; } ShiftReg . LedPwmValue ( m_clearCorePin , value ) ; } break ; case INPUT_DIGITAL : DigitalIn :: Refresh ( ) ; break ; default : break ; } }
In digital mode, read the input.
In digital mode read the input .
// If the ShiftRegister was not set up for the analog input // when this ADC reading was captured then it is not valid // If this is the first valid reading, reset the IIR filter // Set the LED PWM representation of this connector's value // Set a lower threshold of when to show any duty on the LED