inline void nextStep() { advanceNextStep(); m_runtime.prevAnim = m_runtime.currAnim; m_runtime.currAnim = currentStep()->info.animation; m_runtime.duration = currentStep()->duration; }
virtual void process() { switch (m_runtime.currAnim) { case LedAnimation_On: if (m_runtime.prevAnim != LedAnimation_On) { m_runtime.pwm = m_runtime.pwm == 0 ? 255 : m_runtime.pwm; analogWrite(m_pin, m_runtime.pwm); m_runtime.prevAnim = LedAnimation_On; } break; case LedAnimation_Off: if (m_runtime.prevAnim != LedAnimation_Off) { analogWrite(m_pin, 0); m_runtime.prevAnim = LedAnimation_Off; } break; case LedAnimation_FadeIn: if (m_runtime.prevAnim != LedAnimation_FadeIn) { m_runtime.prevAnim = LedAnimation_FadeIn; } switch (currentStep()->info.factor) { case LedAnimationFactor_Quarter: m_runtime.pwm += 0.25; break; case LedAnimationFactor_Half: m_runtime.pwm += 0.5; break; case LedAnimationFactor_Once: m_runtime.pwm += 1.0; break; case LedAnimationFactor_Twice: m_runtime.pwm += 2.0; break; } analogWrite(m_pin, (int)m_runtime.pwm); break; case LedAnimation_FadeOut: if (m_runtime.prevAnim != LedAnimation_FadeOut) { m_runtime.prevAnim = LedAnimation_FadeOut; } switch (currentStep()->info.factor) { case LedAnimationFactor_Quarter: m_runtime.pwm -= 0.25; break; case LedAnimationFactor_Half: m_runtime.pwm -= 0.5; break; case LedAnimationFactor_Once: m_runtime.pwm -= 1.0; break; case LedAnimationFactor_Twice: m_runtime.pwm -= 2.0; break; } analogWrite(m_pin, (int)m_runtime.pwm); break; } if (isNextStep()) { nextStep(); #ifdef _LED_PROCESSOR_DEBUG if (m_runtime.prevAnim != m_runtime.currAnim) { debug(); } #endif } }
virtual void apply(const LedAnimationStep* steps, const byte stepsCount) { m_steps = steps; m_stepsCount = stepsCount; m_runtime.step = 0; m_runtime.pwm = .0; m_runtime.currAnim = currentStep()->info.animation; m_runtime.duration = currentStep()->duration; #ifdef _LED_PROCESSOR_DEBUG debug(); #endif }
bool WorkflowJSON_Impl::incrementStep() { unsigned index = currentStepIndex(); m_value["current_step"] = index + 1; onUpdate(); return currentStep(); }
void ItemAnimation::setTransform(const QTransform &m) { mItem->setTransform(m); switch (mFade) { case FadeOut: mItem->setOpacity(qMax<qreal>(1.0 - currentStep(), 0)); break; case FadeIn: mItem->setVisible(true); mItem->setOpacity(currentStep()); break; case None: mItem->setOpacity(1.0); break; default: break; } }
void advanceNextStep() { const byte initialStepIndex = m_runtime.step; const LedAnimationStep * step = NULL; do { m_runtime.step = (m_runtime.step + 1) % getStepsCount(); step = currentStep(); } while ((!thisLedStep(step) || onceStep(step)) && m_runtime.step != initialStepIndex); }
void debug() const { // [step_idx:led_name] prev to curr: pwm Serial.print(F("[")); Serial.print(m_runtime.step); Serial.print(F(",")); Serial.print(LedNameToString(currentStep()->info.name)); Serial.print(F("]: transit from '")); Serial.print(LedAnimationToString(m_runtime.prevAnim)); Serial.print(F("' to '")); Serial.print(LedAnimationToString(m_runtime.currAnim)); Serial.print(F("': duration=")); Serial.print(m_runtime.duration); Serial.print(F(", pwm=")); Serial.println(m_runtime.pwm); }
void EthereumMiner::setCurrentStep(Step step) { _currentStep = step; emit currentStep(_currentStep); }