public static void callback(Limbus.AudioStream audio_stream) { unsafe { short* buffer = (short*)audio_stream.Buffer; uint buffer_size = audio_stream.BufferSize; for (uint i = 0; i < buffer_size * 2; i += 2) { double sample = System.Math.Sin(t / System.Math.PI / 2) * 0.25; buffer[i] = (short)(((sample + 1) / 2) * ushort.MaxValue + short.MinValue); buffer[i + 1] = buffer[i]; t += 1; } } }
private void Apply(Limbus.Arduino.Settings settings, Limbus.Arduino.Driver arduino) { AddPinPair(settings.AnalogIn0, settings.AnalogOut9, arduino); AddPinPair(settings.AnalogIn1, settings.AnalogOut10, arduino); AddPinPair(settings.AnalogIn2, settings.AnalogOut11, arduino); arduino.Connect(settings.SerialPort, settings.BaudRate); var arduinoSettings = settings.ToJson() .Replace(",", ",\n").Replace("{", "{\n").Replace("}","\n}"); txtArduinoSettings.Buffer.Text = arduinoSettings; }
private void Apply(Limbus.Lab.Settings settings) { this.lblPoti1.Text = settings.Poti1; this.lblPoti2.Text = settings.Poti2; this.lblPoti3.Text = settings.Poti3; this.lblPoti4.Text = settings.Poti4; this.lblPoti5.Text = settings.Poti5; this.vscalePoti1.Adjustment.Upper = settings.PotiMax; this.vscalePoti1.Adjustment.Lower = settings.PotiMin; this.vscalePoti2.Adjustment.Upper = settings.PotiMax; this.vscalePoti2.Adjustment.Lower = settings.PotiMin; this.vscalePoti3.Adjustment.Upper = settings.PotiMax; this.vscalePoti3.Adjustment.Lower = settings.PotiMin; this.vscalePoti4.Adjustment.Upper = settings.PotiMax; this.vscalePoti4.Adjustment.Lower = settings.PotiMin; this.vscalePoti5.Adjustment.Upper = settings.PotiMax; this.vscalePoti5.Adjustment.Lower = settings.PotiMin; vbxPlot.Remove(timePlotView); timePlot = new TimePlot("Oscilloscope", settings.PlotWidth, settings.PlotHeight, DateTimeOffset.UtcNow); timePlotView = new OxyPlot.GtkSharp.PlotView { Model = timePlot }; timePlotView.SetSizeRequest(1000, 200); timePlotView.Visible = true; this.SetSizeRequest(1000, 600); vbxPlot.Add(timePlotView); var labSettingsText = settings.ToJson() .Replace(",", ",\n").Replace("{", "{\n").Replace("}","\n}"); txtLabSettings.Buffer.Text = labSettingsText; }
private void AddPinPair(string inPin, string outPin, Limbus.Arduino.Driver arduino) { var name = inPin + outPin; var pinPair = arduino.AddPinPair(inPin, outPin); pinPair.Receive += (ts) => { this.timePlot.AddActual(inPin, ts); this.timePlot.InvalidatePlot(true); }; pinPairs.Add(name, pinPair); timePlot.AddActualLine(inPin); timePlot.AddSetpointLine(outPin); }