예제 #1
0
        public int AnalogRead(Pins pin)
        {
            Response result = Post(Functions.analogread,
                String.Format(payloadRead, HttpUtility.UrlEncode(AccessToken), HttpUtility.UrlEncode(pin.ToString())));

            return result.ReturnValue;
        }
예제 #2
0
        public bool AnalogWrite(Pins pin, Int16 val)
        {
            if (val > 255)
            {
                val = 255;
            }
            if (val < 0)
            {
                val = 0;
            }

            Response result = Post(Functions.analogwrite,
                                   String.Format(payloadWrite,
                                                 HttpUtility.UrlEncode(AccessToken),
                                                 HttpUtility.UrlEncode(pin.ToString()), HttpUtility.UrlEncode(val.ToString())));

            switch (result.ReturnValue)
            {
            case -1:
                return(false);

            default:
                return(true);
            }
        }
예제 #3
0
        public override string ToString()
        {
            var s = Pins.ToString();

            if (Bonus > 0)
            {
                s += $"(+{Bonus})";
            }
            return(s);
        }
예제 #4
0
        public GetStates DigitalWrite(Pins pin, SetStates state)
        {
            Response result = Post(Functions.digitalwrite,
                                   String.Format(payloadWrite,
                                                 HttpUtility.UrlEncode(AccessToken),
                                                 HttpUtility.UrlEncode(pin.ToString()), HttpUtility.UrlEncode(state.ToString())));

            switch (result.ReturnValue)
            {
            case -1:
                return(GetStates.FAIL);

            default:
                if (state == SetStates.HIGH)
                {
                    return(GetStates.HIGH);
                }
                return(GetStates.LOW);
            }
        }
예제 #5
0
        public int AnalogRead(Pins pin)
        {
            Response result = Post(Functions.analogread,
                                   String.Format(payloadRead, HttpUtility.UrlEncode(AccessToken), HttpUtility.UrlEncode(pin.ToString())));

            return(result.ReturnValue);
        }
예제 #6
0
        public GetStates DigitalRead(Pins pin)
        {
            Response result = Post(Functions.digitalread,
                                   String.Format(payloadRead, HttpUtility.UrlEncode(AccessToken), HttpUtility.UrlEncode(pin.ToString())));

            switch (result.ReturnValue)
            {
            case 0:
                return(GetStates.LOW);

            case 1:
                return(GetStates.HIGH);

            default:
                return(GetStates.FAIL);
            }
        }
예제 #7
0
        public bool AnalogWrite(Pins pin, Int16 val)
        {
            if (val > 255) val = 255;
            if (val < 0) val = 0;

            Response result = Post(Functions.analogwrite,
                String.Format(payloadWrite,
                              HttpUtility.UrlEncode(AccessToken),
                              HttpUtility.UrlEncode(pin.ToString()), HttpUtility.UrlEncode(val.ToString())));

            switch (result.ReturnValue)
            {
                case -1:
                    return false;
                default:
                    return true;
            }
        }
예제 #8
0
        public GetStates DigitalWrite(Pins pin, SetStates state)
        {
            Response result = Post(Functions.digitalwrite,
                String.Format(payloadWrite,
                              HttpUtility.UrlEncode(AccessToken),
                              HttpUtility.UrlEncode(pin.ToString()), HttpUtility.UrlEncode(state.ToString())));

            switch (result.ReturnValue)
            {
                case -1:
                    return GetStates.FAIL;
                default:
                    if (state == SetStates.HIGH) return GetStates.HIGH;
                    return GetStates.LOW;
            }
        }
예제 #9
0
        public GetStates DigitalRead(Pins pin)
        {
            Response result = Post(Functions.digitalread,
                String.Format(payloadRead, HttpUtility.UrlEncode(AccessToken), HttpUtility.UrlEncode(pin.ToString())));

            switch (result.ReturnValue)
            {
                case 0:
                    return GetStates.LOW;
                case 1:
                    return GetStates.HIGH;
                default:
                    return GetStates.FAIL;
            }
        }