Exemple #1
0
        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);
        }
Exemple #2
0
 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();
 }
Exemple #3
0
        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;
            }
        }
Exemple #4
0
 public void Mixed()
 {
     this.Led0.High();
     this.Led1.High();
     this.State = BiColorLedState.Yellow;
 }
Exemple #5
0
 public void AllOff()
 {
     this.Led0.Low();
     this.Led1.Low();
     this.State = BiColorLedState.Off;
 }