public ChromeCastClient() { ChromecastSocketService = new ChromecastSocketService(); Channels = new List <IChromecastChannel>(); ConnectionChannel = new ConnectionChannel(this); Channels.Add(ConnectionChannel); HeartbeatChannel = new HeartbeatChannel(this); Channels.Add(HeartbeatChannel); ReceiverChannel = new ReceiverChannel(this); Channels.Add(ReceiverChannel); MediaChannel = new MediaChannel(this); Channels.Add(MediaChannel); }
public void Dispose() { if (!disposedValue) { HeartbeatChannel.Dispose(); ConnectionChannel.Dispose(); MediaChannel.Dispose(); ReceiverChannel.Dispose(); ChromecastSocketService?.Dispose(); } disposedValue = true; }
public HCSR04(int TxPin, int RxPin) { _txChannel = new TransmitterChannel(TxPin); _txPulse = new RmtCommand(10, true, 10, false); _txChannel.AddCommand(_txPulse); _txChannel.AddCommand(new RmtCommand(20, true, 15, false)); _txChannel.ClockDivider = 80; _txChannel.CarrierEnabled = false; _txChannel.IdleLevel = false; // The received echo pulse width represents the distance to obstacle // 150us to 38ms _rxChannel = new ReceiverChannel(RxPin); _rxChannel.ClockDivider = 80; // 1us clock ( 80Mhz / 80 ) = 1Mhz _rxChannel.EnableFilter(true, 100); // filter out 100Us / noise _rxChannel.SetIdleThresold(40000); // 40ms based on 1us clock _rxChannel.ReceiveTimeout = new TimeSpan(0, 0, 0, 0, 60); }
public void Config(int TxPin, int RxPin) { // Set-up TX & RX channels // We need to send a 10us pulse to initiate measurement _txChannel = new TransmitterChannel(TxPin); _txPulse = new RmtCommand(10, true, 10, false); _txChannel.AddCommand(_txPulse); _txChannel.AddCommand(new RmtCommand(20, true, 15, false)); _txChannel.ClockDivider = 80; _txChannel.CarrierEnabled = false; _txChannel.IdleLevel = false; // The received echo pulse width represents the distance to obstacle // 150us to 38ms for HC-SR04 _rxChannel = new ReceiverChannel(RxPin); _rxChannel.ClockDivider = 80; // 1us clock ( 80Mhz / 80 ) = 1Mhz _rxChannel.EnableFilter(true, 100); // filter out 100Us / noise _rxChannel.SetIdleThresold(40000); // 40ms based on 1us clock _rxChannel.ReceiveTimeout = new TimeSpan(0, 0, 0, 0, 60); }