本文整理汇总了C#中GpioPinValue类的典型用法代码示例。如果您正苦于以下问题:C# GpioPinValue类的具体用法?C# GpioPinValue怎么用?C# GpioPinValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GpioPinValue类属于命名空间,在下文中一共展示了GpioPinValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitGPIO
private void InitGPIO()
{
var gpio = GpioController.GetDefault();
// Show an error if there is no GPIO controller
if (gpio == null)
{
pin = null;
waterPin = null;
GpioStatus.Text = "There is no GPIO controller on this device.";
return;
}
pin = gpio.OpenPin(LED_PIN);
pinValue = GpioPinValue.High;
pin.Write(pinValue);
pin.SetDriveMode(GpioPinDriveMode.Output);
waterPin = gpio.OpenPin(WATER_PIN);
waterPinValue = GpioPinValue.High;
//waterPin.Read(waterPinValue);
waterPin.SetDriveMode(GpioPinDriveMode.Input);
GpioStatus.Text = "GPIO pin initialized correctly.";
}
示例2: PinInterruptValue
/// <summary>
/// Constructor.
/// </summary>
/// <param name="pin">oin the value is for.</param>
/// <param name="interruptOccurred">True when interrupt occurs, false otherwise.</param>
/// <param name="edge">Edge that occurred</param>
/// <param name="currentValue">Current value.</param>
internal PinInterruptValue(int pin, bool interruptOccurred, GpioPinEdge edge, GpioPinValue currentValue)
{
this.Pin = pin;
this.InterruptOccurred = interruptOccurred;
this.Edge = edge;
this.CurrentValue = currentValue;
}
示例3: Write
public void Write(byte[] data)
{
var bits = new GpioPinValue[data.Length * 8];
for (int i = 0; i < data.Length; i++)
{
var datumValues = GetBits(data[i]);
datumValues.CopyTo(bits, i * 8);
}
_csPin.Write(GpioPinValue.Low);
SyncWaitInterval();
foreach(var bit in bits)
{
_mosiPin.Write(bit);
_clkPin.Write(GpioPinValue.High);
SyncWaitInterval();
_clkPin.Write(GpioPinValue.Low);
SyncWaitInterval();
}
_csPin.Write(GpioPinValue.High);
SyncWaitInterval();
}
示例4: SetValue
public void SetValue(GpioPinValue value)
{
if(pin == null)
throw new Exception("GPIO Pin not initalized!");
pin.Write(value);
}
示例5: WriteOutputPinValue
public void WriteOutputPinValue(int pinNumber, GpioPinValue pinValue)
{
foreach (var c in _controls.Where(r => r.PinNumber == pinNumber))
{
c.WriteOutputPinValue(pinValue);
}
}
示例6: TurnLEDsOff
public void TurnLEDsOff()
{
greenPinValue = GpioPinValue.High;
greenPin.Write(greenPinValue);
redPinValue = GpioPinValue.High;
redPin.Write(redPinValue);
}
示例7: InitGPIO
private void InitGPIO()
{
var mygpio = GpioController.GetDefault();
// Show an error if there is no GPIO controller
if (mygpio == null)
{
buttonPin = null;
ledPin = null;
return;
}
ledPin = mygpio.OpenPin(LEDPINNBR);
ledPin.Write(GpioPinValue.Low); //initialize Led to On as wired in active Low config (+3.3-Led-GPIO)
ledPin.SetDriveMode(GpioPinDriveMode.Output);
buttonPin = mygpio.OpenPin(BUTTONPINNBR);
buttonPin.Write(GpioPinValue.High);
buttonPin.SetDriveMode(GpioPinDriveMode.Output);
buttonPinValCurrent = buttonPin.Read();
buttonPin.SetDriveMode(GpioPinDriveMode.Input);
buttonPinValPrior = GpioPinValue.High;
Debug.WriteLine("ButtonPin Value at Init: " + buttonPin.Read() + ", with Pin ID = " + buttonPin.PinNumber);
//buttonPinVal = buttonPin.Read();
// Set a debounce timeout to filter out switch bounce noise from a button press
buttonPin.DebounceTimeout = TimeSpan.FromMilliseconds(20);
// Register for the ValueChanged event so our buttonPin_ValueChanged
// function is called when the button is pressed
buttonPin.ValueChanged += buttonPressAction;
}
示例8: InitGPIO
private void InitGPIO()
{
GpioController gpio = null;
try
{
gpio = GpioController.GetDefault();
}
catch (Exception e)
{
GpioStatus.Text = e.Message;
}
if (gpio == null)
{
_pin = null;
GpioStatus.Text = "There is no GPIO controller on this device.";
return;
}
_pin = gpio.OpenPin(LED_PIN);
_pinValue = GpioPinValue.High;
_pin.Write(_pinValue);
_pin.SetDriveMode(GpioPinDriveMode.Output);
GpioStatus.Text = "GPIO pin intitialized correctly.";
}
示例9: PulseIn
private double PulseIn(GpioPin echoPin, GpioPinValue value)
{
var t = Task.Run(() =>
{
//Recieve pusle
while (this.echoPin.Read() != value)
{
}
timeWatcher.Start();
while (this.echoPin.Read() == value)
{
}
timeWatcher.Stop();
//Calculating distance
double distance = timeWatcher.Elapsed.TotalSeconds * 17000;
return distance;
});
bool didComplete = t.Wait(TimeSpan.FromMilliseconds(100));
if(didComplete)
{
return t.Result;
}
else
{
return 0.0;
}
}
示例10: CheckNum
public int CheckNum()
{
var inputs = new GpioPinValue[4];
inputs[0] = irPins[0].Read();
inputs[1] = irPins[1].Read();
inputs[2] = irPins[2].Read();
inputs[3] = irPins[3].Read();
int returnValue = 0;
if (inputs[0] == GpioPinValue.High)
{
returnValue += 1;
}
if (inputs[1] == GpioPinValue.High)
{
returnValue += 2;
}
if (inputs[2] == GpioPinValue.High)
{
returnValue += 4;
}
if (inputs[3] == GpioPinValue.High)
{
returnValue += 8;
}
return returnValue;
}
示例11: Sleep
public void Sleep()
{
if (pin != null)
{
pinValue = GpioPinValue.High;
pin.Write(pinValue);
}
}
示例12: Reset
public void Reset()
{
if (pin != null)
{
pinValue = GpioPinValue.Low;
pin.Write(pinValue);
}
}
示例13: Led
public Led(GpioPin pin)
{
_pin = pin;
_pin.SetDriveMode(GpioPinDriveMode.Output);
_pinValue = GpioPinValue.Low;
_pin.Write(_pinValue);
}
示例14: AccelStepper
public AccelStepper(GpioPin motorPinEntity, GpioPin directionPinEntity, GpioPinValue clockwiseVal)
{
motorPin = motorPinEntity;
directionPin = directionPinEntity;
clockwiseValue = clockwiseVal;
stopwatch = new Stopwatch();
stopwatch.Start();
}
示例15: SignalOutputPin
public void SignalOutputPin(int pinId, GpioPinValue value)
{
if (_pin == null)
{
_pin = _gpioController.OpenPin(pinId);
_pin.SetDriveMode(GpioPinDriveMode.Output);
}
_pin.Write(value);
}