Esempio n. 1
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Converts a GpioID to a numeric string value. Will not accept a gpioID of
        /// Gpio.GPIO_NONE
        /// </summary>
        /// <param name="gpioIDIn">The gpio we open the port on</param>
        /// <returns>>the GPIO as a string</returns>
        /// <history>
        ///    01 Dec 16  Cynic - Originally written
        /// </history>
        public static string GpioIDToString(GpioEnum gpioIDIn)
        {
            if (gpioIDIn == GpioEnum.GPIO_NONE)
            {
                throw new Exception("Invalid Gpio : " + gpioIDIn.ToString());
            }

            // strip out non digits - want to do this fast so no regex
            // or cycling through the string testing every char.
            return(gpioIDIn.ToString().Replace(GPIOENUM_PREFIX, ""));
        }
Esempio n. 2
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Converts a GpioID to an integer value. Will not accept a gpioID of
        /// Gpio.GPIO_NONE or GpioEnum.GPIO_SYSEVENT
        /// </summary>
        /// <param name="gpioIDIn">The gpio we open the port on</param>
        /// <history>
        ///    28 Aug 14  Cynic - Originally written
        /// </history>
        public static int GpioIDToInt(GpioEnum gpioIDIn)
        {
            if (gpioIDIn == GpioEnum.GPIO_NONE)
            {
                throw new Exception("Invalid Gpio : " + gpioIDIn.ToString());
            }

            // return it as an integer
            return(Convert.ToInt32(GpioIDToString(gpioIDIn)));
        }