public BiColorLedState Set(BiColorLedState state, bool incState = false, int firstStateIndex = 0) { if (incState) { var ix = this.StateIndex + 1; if (ix > MAX_STATE) { ix = firstStateIndex; } this.StateIndex = ix; state = this.State; } switch (state) { case BiColorLedState.Off: this.Set(false, false); break; case BiColorLedState.Red: this.Set(true, false); break; case BiColorLedState.Green: this.Set(false, true); break; case BiColorLedState.Yellow: this.Set(true, true); break; default: this.Set(false, false); break; } return(state); }
public BiColorLed(Nusbio nusbio, NusbioGpio led0GpioPin, NusbioGpio led1GpioPin) { this.Led0 = new Led(nusbio, led0GpioPin); this.Led1 = new Led(nusbio, led1GpioPin); this.State = BiColorLedState.Off; this.AllOff(); }
public void Set(bool led0State, bool led1State) { Led0.DigitalWrite(led0State); Led1.DigitalWrite(led1State); if (led0State && led1State) { this.State = BiColorLedState.Yellow; } else if (!led0State && !led1State) { this.State = BiColorLedState.Off; } else if (led0State && !led1State) { this.State = BiColorLedState.Red; } else if (!led0State && led1State) { this.State = BiColorLedState.Green; } }
public void Mixed() { this.Led0.High(); this.Led1.High(); this.State = BiColorLedState.Yellow; }
public void AllOff() { this.Led0.Low(); this.Led1.Low(); this.State = BiColorLedState.Off; }