protected virtual int OnExecute(CommandLineApplication app) { using FoundationPlate plate = PiTop4Board.Instance.GetOrCreatePlate <FoundationPlate>(); using Led green = plate.GetOrCreateLed(DigitalPort.D0); using Led yellow = plate.GetOrCreateLed(DigitalPort.D1); using Led red = plate.GetOrCreateLed(DigitalPort.D2); Led[] semaphore = new[] { green, yellow, red }; using Potentiometer potentiometer = plate.GetOrCreatePotentiometer(AnaloguePort.A0); potentiometer.Connect(); int currentPosition = -1; Led current = green; while (true) { // 2.9999 instead of 3 so when the Position is 1 it doesn't return 3 and still returns 2 (red light) int newPosition = (int)(potentiometer.Position * 2.9999); if (newPosition != currentPosition) { current.Off(); current = semaphore[newPosition]; currentPosition = newPosition; current.On(); } Thread.Sleep(100); } return(0); }
public void tearDown() { raspberryPi.reset(); raspberryPi = null; TestGpiooInterface = null; TestLcdDisplay = null; Testpotentiometer = null; Testadconverter = null; }
public override void SetSimulationProp(Circuit sim) { Potentiometer potentiometer = sim.Create <Potentiometer>(); potentiometer.position = _potentiometerEntity.Position; Connectors[0].DllConnector = potentiometer.leadVoltage; Connectors[1].DllConnector = potentiometer.leadIn; Connectors[2].DllConnector = potentiometer.leadOut; }
public static IProducer <double> CreateComponent(this Potentiometer potentiometer, Pipeline pipeline, TimeSpan samplingInterval) { if (potentiometer == null) { throw new ArgumentNullException(nameof(potentiometer)); } if (pipeline == null) { throw new ArgumentNullException(nameof(pipeline)); } return(Generators.Sequence(pipeline, 0.0, _ => potentiometer.Position, samplingInterval)); }
public void setUp() { raspberryPi = RaspberryPi.Instance; testAllComponents = new HWComponent[] { new GPIOinterface(), new LCD(), new Potentiometer(), new Multiplexer(), new ADConverter() }; testPartComponents = new HWComponent[] { new GPIOinterface(), new Multiplexer(), new ADConverter() }; testDuplicateComponents = new HWComponent[] { new GPIOinterface(), new Multiplexer(), new Multiplexer(), new ADConverter() }; TestGpiooInterface = new GPIOinterface(); TestLcdDisplay = new LCD(); Testpotentiometer = new Potentiometer(); Testmultiplexer = new Multiplexer(); Testadconverter = new ADConverter(); }
protected Potentiometer AddPot(string name, Point posn, Size size, string knobImage, double initialRotation, double rotationTravel, double minValue, double maxValue, double initialValue, double stepValue, string interfaceDeviceName, string interfaceElementName, bool fromCenter, ClickType clickType = ClickType.Swipe, bool isContinuous = false) { string componentName = GetComponentName(name); if (fromCenter) { posn = FromCenter(posn, size); } Potentiometer _knob = new Potentiometer { Name = componentName, KnobImage = knobImage, InitialRotation = initialRotation, RotationTravel = rotationTravel, MinValue = minValue, MaxValue = maxValue, InitialValue = initialValue, StepValue = stepValue, Top = posn.Y, Left = posn.X, Width = size.Width, Height = size.Height }; _knob.ClickType = clickType; _knob.IsContinuous = isContinuous; Children.Add(_knob); foreach (IBindingTrigger trigger in _knob.Triggers) { AddTrigger(trigger, componentName); } AddAction(_knob.Actions["set.value"], componentName); AddDefaultOutputBinding( childName: componentName, deviceTriggerName: "value.changed", interfaceActionName: interfaceDeviceName + ".set." + interfaceElementName ); AddDefaultInputBinding( childName: componentName, interfaceTriggerName: interfaceDeviceName + "." + interfaceElementName + ".changed", deviceActionName: "set.value"); return(_knob); }
private void AddPot(string name, Point posn, Size size, string interfaceElementName) { Potentiometer knob = AddPot( name: name, posn: posn, size: size, knobImage: "{AV-8B}/Images/Common Knob.png", initialRotation: 219, rotationTravel: 291, minValue: 0, maxValue: 1, initialValue: 1, stepValue: 0.1, interfaceDeviceName: _interfaceDeviceName, interfaceElementName: interfaceElementName, fromCenter: false ); knob.Name = _side + "_" + name; }
internal static PocketView GetSvg(this Potentiometer potentiometer) { var value = potentiometer.Position.ToString("0.##"); return(g( g[transform: "matrix(0.0834819,0,0,0.0762288,-11.0292,-7.71042)"]( CreatePath("M623.239,203.06C623.239,154.054 586.908,114.267 542.16,114.267L225.172,114.267C180.423,114.267 144.093,154.054 144.093,203.06L144.093,550.209C144.093,599.216 180.423,639.003 225.172,639.003L542.16,639.003C586.908,639.003 623.239,599.216 623.239,550.209L623.239,203.06Z", "fill:white;stroke:black;stroke-width:25.02px;") ), g[@class: "Pot", transform: "matrix(1,0,0,1,-859.031,-188)"]( CreatePath("M871.086,208.585L872.604,204.441C871.982,203.245 871.63,201.886 871.63,200.446C871.63,195.659 875.516,191.773 880.303,191.773C885.089,191.773 888.976,195.659 888.976,200.446C888.976,205.233 885.089,209.119 880.303,209.119C878.424,209.119 876.684,208.52 875.263,207.504L871.086,208.585Z", "fill:rgb(235,235,235);fill-opacity:0;stroke:black;stroke-width:2px;"), g[transform: "matrix(0.743034,-0.597245,0.56137,0.698402,93.8923,710.93)"]( _.rect[x: 971.577, y: 104.115, width: 13.572, height: 3.795, style: "fill:rgb(217,217,217);stroke:black;stroke-width:0.92px;stroke-linecap:square;"]() ) ), g[transform: "matrix(1,0,0,1,-756.199,-120)"]( _.text[x: "768.748px", y: "149.76px", style: TextStyle](value) ), g[transform: "matrix(1,0,0,1,-756.199,-112.282)"]( _.text[x: "768.748px", y: "149.76px", style: TextStyle]("POT") ) )); }
public static void Run(string[] args) { Console.WriteLine("Nusbio initialization"); var serialNumber = Nusbio.Detect(); if (serialNumber == null) // Detect the first Nusbio available { Console.WriteLine("nusbio not detected"); return; } var outPin = 0; var inPin = 1; using (var nusbio = new Nusbio(serialNumber)) // , { var pot = new Potentiometer(nusbio, inPin, outPin, 23, 290, 500); // 50k Pot var ddd = pot.PercentValue; Cls(nusbio); while (nusbio.Loop()) { ConsoleEx.Write(0, 10, string.Format("[{0}] Value:{1,-4}, Percent:{2}% ", DateTime.Now, pot.Value, (int)pot.PercentValue), ConsoleColor.DarkCyan); if (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; if (k == ConsoleKey.Q) { break; } } } } Console.Clear(); }
public void PotentiometerCreate(PotentiometerVM potentiometerVM) { Potentiometer potentiometer = new Potentiometer(); }
public PartialViewResult Potentiometer() { CDTEntities db = new CDTEntities(); Potentiometer potentiometer = new Potentiometer(); return PartialView("_PotentiometerPartial", potentiometer); }
private void Sound_ValueChanged(object sender, Potentiometer.ValueChangedEventArgs e) { Model.Model.GetInstance().GlobalSoundVolume = e.Value; }
private void Metronome_ValueChanged(object sender, Potentiometer.ValueChangedEventArgs e) { Model.Model.GetInstance().Metronome.Speed = e.Value; }
// Start is called before the first frame update void Start() { instance = this; }