3PicoLCOutput::PicoLCOutput() :
4 _outputMode(OutputMode::HighSide),
5 _patternMode(PatternMode::Steady),
9 _blinkTarget(UINT16_MAX),
10 _blinkOnTime(UINT16_MAX),
16uint8_t PicoLCOutput::update(uint32_t currentMillis) {
19 if( _patternMode == PatternMode::Pulse ) {
21 _pulseStart = currentMillis;
24 if( _pulseStart > 0 && currentMillis < _pulseStart + _pulseLength ) {
31 if( _patternMode == PatternMode::Blink ) {
32 if( _blinkStart == 0 ) {
33 _blinkStart = currentMillis;
35 _blinkStart += ((currentMillis - _blinkStart) / _blinkPeriod) * _blinkPeriod;
36 if( currentMillis - _blinkStart < _blinkOnTime ) {
43 switch( _outputMode ) {
44 case OutputMode::HighSide:
47 case OutputMode::LowSide:
49 case OutputMode::PushPull:
50 value = (value << 1) | 1;
52 case OutputMode::Paired:
61 if( _patternMode == PatternMode::Pulse ) {
62 return _pulseStart > 0;
68 if( _patternMode == PatternMode::Pulse && _pulseLength > 0 && !state ) {
85 if( ms > 0 ) _blinkStart = millis();
uint32_t frequency() const
Returns the configured PWM frequency.
uint32_t pulseLength() const
Returns the configured Pulse-mode duration.
bool read() const
Returns the current logical output state.
uint16_t duty(uint16_t duty)
Sets the linear PWM duty.
uint16_t duty() const
Returns the configured linear PWM duty.
uint32_t blinkPeriod() const
Returns the complete Blink-mode cycle period.
uint32_t blinkOnTime() const
Returns the active time within each Blink-mode cycle.
static constexpr uint16_t DUTY_MAX
Maximum user-facing PWM duty value.
bool write(bool state)
Applies a logical command to the output.
PatternMode patternMode() const
Returns the configured timed output behavior.
OutputMode outputMode() const
Returns the configured electrical drive mode.