protected override void ProcessRecord()
    {
        ArrayList pinList = new ArrayList();

        if ((this.Id == null) || (this.Id.Length <= 0))
        {
            // TODO: this is "gpio readall" functionality
            // do not forget to change Id param to Mandatory = false when this is implemented
        }
        else
        {
            pinList.AddRange(this.Id);
        }

        PinMode mode = PinMode.Input;

        if (this.PullMode.HasValue)
        {
            switch (this.PullMode.Value)
            {
            case global::PullMode.PullDown: mode = PinMode.InputPullDown; break;

            case global::PullMode.PullUp:   mode = PinMode.InputPullUp; break;

            default:                        mode = PinMode.Input; break;
            }
            ;
        }
        ;

        foreach (int pinId in pinList)
        {
            SignalLevel slResult = SignalLevel.Low;

            this.EnsureOpenPin(pinId, mode);

            if (this.GpioController.Read(pinId) == PinValue.High)
            {
                slResult = SignalLevel.High;
            }
            ;

            if (this.Raw)
            {
                WriteObject(slResult);
            }
            else
            {
                GpioPinData pinData = new GpioPinData(pinId, slResult);
                WriteObject(pinData);
            }
        }
    }
Exemple #2
0
 void Start()
 {
     Frame = 0;
     Image = this.GetComponent <Image>();
     if (blvl != null)
     {
         blvl    = blvl.GetComponent <BatteryLevel>();
         objcode = 0;
     }
     else
     {
         slvl    = slvl.GetComponent <SignalLevel>();
         objcode = 1;
     }
 }
 public GpioPinData(int id, SignalLevel value, Unosquare.RaspberryIO.Gpio.GpioPin pinInfo)
 {
     this.Id      = id;
     this.Value   = value;
     this.PinInfo = pinInfo;
 }
Exemple #4
0
 public GpioPinData(int id, SignalLevel value)
 {
     this.Id    = id;
     this.Value = value;
 }