public MainPage() { this.InitializeComponent(); _servoDriver = new ServoDriver(18, new ServoPulseModel { ForwardPulseWidth = 2, BackwardPulseWidth = 1, PulseFrequency = 20 }); _ledDriver = new LedDriver(4); _connection = new HubConnection("http://ipwebapp.azurewebsites.net/"); _hubProxy = _connection.CreateHubProxy("bandHub"); _hubProxy.On <string>("sendData", x => { if (x == "left") { _servoDriver.Clockwise(); } else if (x == "right") { _servoDriver.CounterClockwise(); } }); _connection.Start().Wait(); }
public void StartupEnablesOutput() { mock.Setup(g => g.Write(driverSettings.EnablePin, PinValue.Low)).Verifiable(); using (var driver = new LedDriver(mock.Object, driverSettings)) { mock.Verify(); } }
private async Task <int> Run(Options options) { try { using (var ledDriver = LedDriver.Create()) { var displayDriver = new DisplayDriver(ledDriver); Task task; if (options.StringValue != null) { if (options.ForceScroll || DisplayFrame.GetDisplayedStringLength(options.StringValue) > 3) { task = displayDriver.ScrollString(options.StringValue, options.Duration); } else { displayDriver.WriteString(options.StringValue); task = Task.Delay(options.Duration); } } else if (options.DecimalValue != null) { displayDriver.WriteFrame(DisplayFrame.FromDecimal(options.DecimalValue.Value, StatusLed.Blue)); task = Task.Delay(options.Duration); } else if (options.BusyDelay != null) { task = displayDriver.BusyLoop(options.BusyDelay.Value, options.Duration); } else if (options.RawValue != null) { for (int i = 0; i < 32; i++) { bool bit = ((options.RawValue.Value << i) & 0x80000000u) != 0u; ledDriver.WriteBit(bit); } ledDriver.Latch(); task = Task.Delay(options.Duration); } else { Console.WriteLine("No option selected."); return(-1); } await task; displayDriver.Clear(); } return(0); } catch (Exception ex) { Console.WriteLine($"Error: {ex}"); return(-1); } }
public void DisposeClosesPins() { mock.Setup(g => g.ClosePin(driverSettings.DataInPin)).Verifiable(); mock.Setup(g => g.ClosePin(driverSettings.ClockPin)).Verifiable(); mock.Setup(g => g.ClosePin(driverSettings.LatchPin)).Verifiable(); mock.Setup(g => g.ClosePin(driverSettings.EnablePin)).Verifiable(); using (var driver = new LedDriver(mock.Object, driverSettings)) { } mock.Verify(); }
public void StartupOpensPinsForOutput() { mock.Setup(g => g.OpenPin(driverSettings.DataInPin, PinMode.Output)).Verifiable(); mock.Setup(g => g.OpenPin(driverSettings.ClockPin, PinMode.Output)).Verifiable(); mock.Setup(g => g.OpenPin(driverSettings.LatchPin, PinMode.Output)).Verifiable(); mock.Setup(g => g.OpenPin(driverSettings.EnablePin, PinMode.Output)).Verifiable(); using (var driver = new LedDriver(mock.Object, driverSettings)) { mock.Verify(); } }
public void DisposeDisablesOutput() { mock.Setup(g => g.Write(driverSettings.EnablePin, PinValue.High)).Verifiable(); using (var driver = new LedDriver(mock.Object, driverSettings)) { } mock.Verify(); }
public void SetFrameState(LedDriver.Display state) { if (state == LedDriver.Display.On) { InitPanel(MODE_POWER_ON); } else { InitPanel(MODE_POWER_OFF); } }
public void SetBlinkRate(LedDriver.BlinkRate blinkrate) { }
public void SetFrameState(LedDriver.Display state) { driver.SetFrameState(state); }
public void SetDriver(LedDriver driver) { this.driver = driver; }
/// <summary> /// 修改LED屏 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { LedDriver.Send(textBox.Text, "COM3"); }