Beispiel #1
0
        /// <summary>
        /// Wrapper for the native <see cref="GpioSerialReadUnmanaged"/>.
        /// </summary>
        /// <param name="userGpio">The user gpio.</param>
        /// <param name="readLength">Length of the read.</param>
        /// <returns>The array containing the bytes that were read.</returns>
        public static byte[] GpioSerialRead(UserGpio userGpio, int readLength)
        {
            var buffer = new byte[readLength];
            var result = BoardException.ValidateResult(GpioSerialReadUnmanaged(userGpio, buffer, (uint)readLength));

            if (result == buffer.Length)
            {
                return(buffer);
            }

            var outputBuffer = new byte[result];

            Buffer.BlockCopy(buffer, 0, outputBuffer, 0, result);
            return(outputBuffer);
        }
Beispiel #2
0
 static void Change(UserGpio pin, LevelChange change, uint time)
 {
     if (change == LevelChange.LowToHigh)
     {
         lastHigh = time;
     }
     else if (change == LevelChange.HighToLow)
     {
         uint diff = time - lastHigh;
         if (diff >= TICKS_MIN_DCC_ONE && diff <= TICKS_MAX_DCC_ONE)
         {
             AddDidget(true);
         }
         else if (diff >= TICKS_MIN_DCC_ZERO && diff <= TICKS_MAX_DCC_ZERO)
         {
             AddDidget(false);
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// This function configures the level logic for bit bang serial reads.
 ///
 /// Use PI_BB_SER_INVERT to invert the serial logic and PI_BB_SER_NORMAL for
 /// normal logic.  Default is PI_BB_SER_NORMAL.
 ///
 /// The GPIO must be opened for bit bang reading of serial data using
 /// <see cref="GpioSerialReadOpen"/> prior to calling this function.
 /// </summary>
 /// <param name="userGpio">0-31.</param>
 /// <param name="invert">0-1.</param>
 /// <returns>Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_GPIO_IN_USE, PI_NOT_SERIAL_GPIO, or PI_BAD_SER_INVERT.</returns>
 public static ResultCode GpioSerialReadInvert(UserGpio userGpio, bool invert)
 {
     return(GpioSerialReadInvertUnmanaged(userGpio, invert ? DigitalValue.True : DigitalValue.False));
 }
Beispiel #4
0
 public static extern ResultCode GpioNoiseFilter(UserGpio userGpio, uint steadyMicroseconds, uint activeMicroseconds);
Beispiel #5
0
 public static extern ResultCode GpioSetWatchdog(UserGpio userGpio, uint timeoutMilliseconds);
Beispiel #6
0
 public static extern ResultCode GpioSetAlertFunc(UserGpio userGpio, [In, MarshalAs(UnmanagedType.FunctionPtr)] PiGpioAlertDelegate callback);
Beispiel #7
0
 public static extern int BbSPIXfer(UserGpio csPin, [In, MarshalAs(UnmanagedType.LPArray)] byte[] inputBuffer, [In, MarshalAs(UnmanagedType.LPArray)] byte[] outputBuffer, uint count);
Beispiel #8
0
 public static extern ResultCode BbSPIOpen(UserGpio csPin, UserGpio misoPin, UserGpio mosiPin, UserGpio clockPin, uint baudRate, SoftSpiFlags spiFlags);
Beispiel #9
0
 /// <summary>
 /// Gets the PWM duty cycle.
 /// </summary>
 /// <param name="userGpio">The user gpio.</param>
 /// <returns>The PWM duty cycle</returns>
 public static int GpioGetPwmDutyCycle(UserGpio userGpio)
 {
     return(BoardException.ValidateResult(GpioGetPwmDutyCycleUnmanaged(userGpio)));
 }
Beispiel #10
0
 public static extern int BbI2CZip(UserGpio sdaPin, [In, MarshalAs(UnmanagedType.LPArray)] byte[] inputBuffer, uint inputLength, [In, MarshalAs(UnmanagedType.LPArray)] byte[] outputBuffer, uint outputLength);
Beispiel #11
0
 public static extern ResultCode BbI2CClose(UserGpio sdaPin);
Beispiel #12
0
 public static extern ResultCode BbI2COpen(UserGpio sdaPin, UserGpio sclPin, uint baudRate);
Beispiel #13
0
 public static extern int GpioWaveAddSerial(UserGpio userGpio, uint baudRate, uint dataBits, uint stopBits, uint offset, uint numBytes, [In, MarshalAs(UnmanagedType.LPArray)] byte[] str);
Beispiel #14
0
 public static extern ResultCode GpioSerialReadClose(UserGpio userGpio);
Beispiel #15
0
        /// <summary>
        /// Wrapper for the native <see cref="GpioSerialReadUnmanaged"/>.
        /// </summary>
        /// <param name="userGpio">The user gpio.</param>
        /// <param name="buffer">The buffer.</param>
        /// <param name="readLength">Length of the read.</param>
        /// <returns>The amount of bytes read.</returns>
        public static int GpioSerialRead(UserGpio userGpio, byte[] buffer, int readLength)
        {
            var result = BoardException.ValidateResult(GpioSerialReadUnmanaged(userGpio, buffer, (uint)readLength));

            return(result);
        }
Beispiel #16
0
 public static extern ResultCode GpioPwm(UserGpio userGpio, uint dutyCycle);
Beispiel #17
0
 private static extern int GpioGetPwmRealRangeUnmanaged(UserGpio userGpio);
Beispiel #18
0
 /// <summary>
 /// Returns 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise)
 /// </summary>
 /// <param name="userGpio">The user gpio.</param>
 /// <returns>The Servo pulse width</returns>
 public static int GpioGetServoPulseWidth(UserGpio userGpio)
 {
     return(BoardException.ValidateResult(GpioGetServoPulseWidthUnmanaged(userGpio)));
 }
Beispiel #19
0
 public static extern ResultCode GpioServo(UserGpio userGpio, uint pulseWidth);
Beispiel #20
0
 public static extern ResultCode GpioSetPwmRange(UserGpio userGpio, uint range);
Beispiel #21
0
 public static extern ResultCode BbSPIClose(UserGpio csPin);
Beispiel #22
0
 public static extern int GpioGetPwmRange(UserGpio userGpio);
Beispiel #23
0
 /// <summary>
 /// This function sends a trigger pulse to a GPIO.  The GPIO is set to
 /// level for pulseLen microseconds and then reset to not level.
 ///
 /// or PI_BAD_PULSELEN.
 /// </summary>
 /// <param name="userGpio">0-31.</param>
 /// <param name="pulseLength">1-100.</param>
 /// <param name="value">0,1.</param>
 /// <returns>Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_LEVEL, or PI_BAD_PULSELEN.</returns>
 public static ResultCode GpioTrigger(UserGpio userGpio, uint pulseLength, bool value)
 {
     return(GpioTriggerUnmanaged(userGpio, pulseLength, value ? DigitalValue.True : DigitalValue.False));
 }
Beispiel #24
0
 public static extern ResultCode GpioSetPwmFrequency(UserGpio userGpio, uint frequency);
Beispiel #25
0
 public static extern ResultCode GpioSetAlertFuncEx(UserGpio userGpio, [In, MarshalAs(UnmanagedType.FunctionPtr)] PiGpioAlertExDelegate callback, UIntPtr userData);
Beispiel #26
0
 public static extern int GpioGetPwmFrequency(UserGpio userGpio);
Beispiel #27
0
 public static extern ResultCode GpioGlitchFilter(UserGpio userGpio, uint steadyMicroseconds);
Beispiel #28
0
 private static extern int GpioGetServoPulseWidthUnmanaged(UserGpio userGpio);
Beispiel #29
0
 private static extern ResultCode GpioTriggerUnmanaged(UserGpio userGpio, uint pulseLength, DigitalValue value);
Beispiel #30
0
 private static extern int GpioGetPwmDutyCycleUnmanaged(UserGpio userGpio);