コード例 #1
0
    protected override void ProcessRecord()
    {
        if (this.Id != null)
        {
            foreach (int pinId in this.Id)
            {
                this.EnsureOpenPin(pinId, PinMode.Output);

                if (this.Value == SignalLevel.Low)
                {
                    this.GpioController.Write(pinId, PinValue.Low);
                }
                else
                {
                    this.GpioController.Write(pinId, PinValue.High);
                }

                if (this.PassThru)
                {
                    GpioPinData pinData = new GpioPinData(pinId, this.Value);
                    WriteObject(pinData);
                }
            }
        }
    }
コード例 #2
0
        /// <summary>
        /// process the response from server and update the properties
        /// </summary>
        protected override bool ProcessResponse(HttpResponse response)
        {
            string json = response.Result;

            // deserialize
            PinData = JsonConvert.DeserializeObject <GpioPinData>(json);
            return(true);
        }
コード例 #3
0
    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);
            }
        }
    }
コード例 #4
0
ファイル: GpioPage.xaml.cs プロジェクト: rphuang/riot
        private void DisplayPinValue(GpioPinData pin)
        {
            Label label = null;

            switch (pin.Pin)
            {
            case 3:
                label = pin3Value;
                break;

            case 5:
                label = pin5Value;
                break;

            case 7:
                label = pin7Value;
                break;

            case 8:
                label = pin8Value;
                break;

            case 10:
                label = pin10Value;
                break;

            case 11:
                label = pin11Value;
                break;

            case 12:
                label = pin12Value;
                break;

            case 13:
                label = pin13Value;
                break;

            case 15:
                label = pin15Value;
                break;

            case 16:
                label = pin16Value;
                break;

            case 18:
                label = pin18Value;
                break;

            case 19:
                label = pin19Value;
                break;

            case 21:
                label = pin21Value;
                break;

            case 22:
                label = pin22Value;
                break;

            case 23:
                label = pin23Value;
                break;

            case 24:
                label = pin24Value;
                break;

            case 26:
                label = pin26Value;
                break;

            case 27:
                label = pin27Value;
                break;

            case 28:
                label = pin28Value;
                break;

            case 29:
                label = pin29Value;
                break;

            case 31:
                label = pin31Value;
                break;

            case 32:
                label = pin32Value;
                break;

            case 33:
                label = pin33Value;
                break;

            case 35:
                label = pin35Value;
                break;

            case 36:
                label = pin36Value;
                break;

            case 37:
                label = pin37Value;
                break;

            case 38:
                label = pin38Value;
                break;

            case 40:
                label = pin40Value;
                break;
            }
            if (label != null)
            {
                label.Text = pin.Value.ToString();
            }
        }
コード例 #5
0
ファイル: GpioPage.xaml.cs プロジェクト: rphuang/riot
        private void DisplayPinMode(GpioPinData pin)
        {
            Label label = null;

            switch (pin.Pin)
            {
            case 3:
                label = pin3Mode;
                break;

            case 5:
                label = pin5Mode;
                break;

            case 7:
                label = pin7Mode;
                break;

            case 8:
                label = pin8Mode;
                break;

            case 10:
                label = pin10Mode;
                break;

            case 11:
                label = pin11Mode;
                break;

            case 12:
                label = pin12Mode;
                break;

            case 13:
                label = pin13Mode;
                break;

            case 15:
                label = pin15Mode;
                break;

            case 16:
                label = pin16Mode;
                break;

            case 18:
                label = pin18Mode;
                break;

            case 19:
                label = pin19Mode;
                break;

            case 21:
                label = pin21Mode;
                break;

            case 22:
                label = pin22Mode;
                break;

            case 23:
                label = pin23Mode;
                break;

            case 24:
                label = pin24Mode;
                break;

            case 26:
                label = pin26Mode;
                break;

            case 27:
                label = pin27Mode;
                break;

            case 28:
                label = pin28Mode;
                break;

            case 29:
                label = pin29Mode;
                break;

            case 31:
                label = pin31Mode;
                break;

            case 32:
                label = pin32Mode;
                break;

            case 33:
                label = pin33Mode;
                break;

            case 35:
                label = pin35Mode;
                break;

            case 36:
                label = pin36Mode;
                break;

            case 37:
                label = pin37Mode;
                break;

            case 38:
                label = pin38Mode;
                break;

            case 40:
                label = pin40Mode;
                break;
            }
            if (label != null)
            {
                string mode = "IN";
                if (pin.Mode == 0)
                {
                    mode = "OUT";
                }
                label.Text = mode;
            }
        }