public void Stop(int channelIndex) { // This assumes that PwmController has ensured that the channel is already open Windows10PwmDriverChannel channel = _channelMap[channelIndex]; channel.Stop(); }
public void ChangeDutyCycle(int channelIndex, double dutyCyclePercentage) { // This assumes that PwmController has ensured that the channel is already open Windows10PwmDriverChannel channel = _channelMap[channelIndex]; channel.ChangeDutyCycle(dutyCyclePercentage); }
public void Start(int channelIndex, double frequencyInHertz, double dutyCyclePercentage) { // This assumes that PwmController has ensured that the channel is already open Windows10PwmDriverChannel channel = _channelMap[channelIndex]; _winController.SetDesiredFrequency(frequencyInHertz); channel.Start(dutyCyclePercentage); }
public void OpenChannel(int channelIndex) { if (!_channelMap.TryGetValue(channelIndex, out Windows10PwmDriverChannel channel)) { channel = new Windows10PwmDriverChannel(_winController, channelIndex); _channelMap.Add(channelIndex, channel); } }
/// <summary> /// Opens a channel in order for it to be ready to use. /// </summary> /// <param name="pwmChannel">The PWM channel.</param> public void OpenChannel(int pwmChannel) { if (!_channelMap.TryGetValue(pwmChannel, out _)) { Windows10PwmDriverChannel channel = new Windows10PwmDriverChannel(_winController, pwmChannel); _channelMap.Add(pwmChannel, channel); } }
/// <summary> /// Closes the channel. /// </summary> /// <param name="channelIndex">The PWM channel to close.</param> /// <returns><see langword="true" /> if the chip has no more open channels open upon exiting; <see langword="false" /> otherwise.</returns> public bool CloseChannel(int channelIndex) { // This assumes that PwmController has ensured that the channel is already open Windows10PwmDriverChannel channel = _channelMap[channelIndex]; channel.Dispose(); _channelMap.Remove(channelIndex); return(_channelMap.Count == 0); }