/// <summary> /// Creates an initialized instance. /// </summary> /// <param name="frequency"> /// <see cref="NxpPca9685Device.Frequency"/> for important information. /// Use <see cref="ServoFrequencyDefault"/> to support most analog servos. /// </param> /// <param name="clear">Clears all LED/PWM values.</param> /// <param name="restart"> /// Set true to restart the device which also enables the osciallator. /// When false, you have to call <see cref="NxpPca9685Device.Wake"/> or <see cref="Restart"/> later to enable the oscillator. /// </param> /// <param name="enable"> /// Set true to enable output, or false to continue with further initialization before enabling output. /// When false, you have to set it later before any output can occur. /// Defaults to false to prevent unexpected behaviour from damaging hardware. /// </param> public static NavioLedPwmDevice Initialize(float frequency, bool clear = true, bool restart = true, bool enable = false) { // Create device var device = new NavioLedPwmDevice(); // Disable output device.OutputEnabled = false; // Set frequency device.WriteFrequency(frequency); // Clear LED/PWM values when specified if (clear) { device.Clear(); } // Restart when specified if (restart) { device.Restart(); } // Enable output when specified if (enable) { device.OutputEnabled = true; } // Return initialized device return(device); }
/// <summary> /// Creates an initialized instance. /// </summary> /// <param name="frequency"> /// <see cref="NxpPca9685Device.Frequency"/> for important information. /// Use <see cref="ServoFrequencyDefault"/> to support most analog servos. /// </param> /// <param name="clear">Clears all LED/PWM values.</param> /// <param name="restart"> /// Set true to restart the device which also enables the osciallator. /// When false, you have to call <see cref="NxpPca9685Device.Wake"/> or <see cref="Restart"/> later to enable the oscillator. /// </param> /// <param name="enable"> /// Set true to enable output, or false to continue with further initialization before enabling output. /// When false, you have to set it later before any output can occur. /// Defaults to false to prevent unexpected behaviour from damaging hardware. /// </param> public static NavioLedPwmDevice Initialize(float frequency, bool clear = true, bool restart = true, bool enable = false) { // Create device var device = new NavioLedPwmDevice(); // Disable output device.OutputEnabled = false; // Set frequency device.WriteFrequency(frequency); // Clear LED/PWM values when specified if (clear) device.Clear(); // Restart when specified if (restart) device.Restart(); // Enable output when specified if (enable) device.OutputEnabled = true; // Return initialized device return device; }