当前位置: 首页>>代码示例>>C#>>正文


C# Socket.PwmOutputIndirector方法代码示例

本文整理汇总了C#中Socket.PwmOutputIndirector方法的典型用法代码示例。如果您正苦于以下问题:C# Socket.PwmOutputIndirector方法的具体用法?C# Socket.PwmOutputIndirector怎么用?C# Socket.PwmOutputIndirector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Socket的用法示例。


在下文中一共展示了Socket.PwmOutputIndirector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        /// <summary>
        /// Creates an instance of <see cref="PwmOutput" /> for the given socket and pin number.
        /// </summary>
        /// <remarks>This automatically checks that the socket supports Type P, and reserves the pin.
        /// An exception will be thrown if there is a problem with these checks.</remarks>
        /// <param name="socket">The socket that supports pulse width modulation (PWM) output.</param>
        /// <param name="pin">The pin on the socket that supports PWM.</param>
        /// <param name="invert">Whether to invert the output voltage.</param>
        /// <param name="module">The module using this PWM output interface, which can be null if unspecified.</param>
        /// <returns>An instance of <see cref="PwmOutput" /> for the given socket and pin number.</returns>
        public static PwmOutput Create(Socket socket, Socket.Pin pin, bool invert, Module module)
        {
            socket.EnsureTypeIsSupported('P', module);
            socket.ReservePin(pin, module);

            Cpu.PWMChannel channel = Cpu.PWMChannel.PWM_NONE;
            switch (pin)
            {
                case Socket.Pin.Seven:
                    channel = socket.PWM7;
                    break;

                case Socket.Pin.Eight:
                    channel = socket.PWM8;
                    break;

                case Socket.Pin.Nine:
                    channel = socket.PWM9;
                    break;
            }

            // native implementation is preferred to an indirected one
            if (channel == Cpu.PWMChannel.PWM_NONE && socket.PwmOutputIndirector != null)
                return socket.PwmOutputIndirector(socket, pin, invert, module);

            else
                return new NativePwmOutput(socket, pin, invert, module, channel);
        }
开发者ID:EmiiFont,项目名称:MyShuttle_RC,代码行数:38,代码来源:PwmOutputFactory.cs

示例2: PWMOutput

        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary>
        /// </summary>
        /// <remarks>This automatically checks that the socket supports Type P, and reserves the pin.
        /// An exception will be thrown if there is a problem with these checks.</remarks>
        /// <param name="socket">The socket that supports pulse width modulation (PWM) output.</param>
        /// <param name="pin">The pin on the socket that supports PWM.</param>
        /// <param name="invert">Whether to invert the output voltage.</param>
        /// <param name="module">The module using this PWM output interface, which can be null if unspecified.</param>
        public PWMOutput(Socket socket, Socket.Pin pin, bool invert, Module module)
        {
            socket.EnsureTypeIsSupported('P', module);
            socket.ReservePin(pin, module);

            Cpu.PWMChannel channel = Cpu.PWMChannel.PWM_NONE;
            switch (pin)
            {
                case Socket.Pin.Seven:
                    channel = socket.PWM7;
                    break;

                case Socket.Pin.Eight:
                    channel = socket.PWM8;
                    break;

                case Socket.Pin.Nine:
                    channel = socket.PWM9;
                    break;
            }

            if (channel == Cpu.PWMChannel.PWM_NONE && socket.PwmOutputIndirector != null)
                Interface = socket.PwmOutputIndirector(socket, pin, invert, module);

            else
                Interface = new NativePwmOutput(socket, pin, invert, module, channel);
        }
开发者ID:EmiiFont,项目名称:MyShuttle_RC,代码行数:36,代码来源:PWMOutput.cs


注:本文中的Socket.PwmOutputIndirector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。