R/RcppExports.R

Defines functions write_analog write_pwm read_digital write_digital pin_control pin_mode read_poll stop_poll start_poll read_analog init

Documented in init pin_control pin_mode read_analog read_digital read_poll start_poll stop_poll write_analog write_digital write_pwm

# This file was generated by Rcpp::compileAttributes
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Initialize the Raspberry Pi for IO 
#' @param setup_type Which mode wiringPi should be initialized in. Either
#'   \code{wpi}, \code{gpio}, \code{phys}, or \code{sys}. See
#'   \url{http://wiringpi.com/reference/setup/} for definitions of each.
#' @param spi_channel If using an external ADC, which SPI channel is it running
#'   on?
#' @param pin_base The virtual GPIO pin number which we should use for the 
#'   fake pins we'll use for measuring analog values.
init <- function(setup_type = "wpi", spi_channel = 0L, pin_base = 100L) {
    invisible(.Call('RpiR_init', PACKAGE = 'RpiR', setup_type, spi_channel, pin_base))
}

#' Read an analog value fromt the Raspberry Pi
#' @param chan An integer vector of channel(s) for which we should
#'    read the analog value.
#' @return An integer vector describing the current analog value on the 
#'    specified channel(s).
read_analog <- function(chan) {
    .Call('RpiR_read_analog', PACKAGE = 'RpiR', chan)
}

#' Start a Poll
#' 
#' Creates a background C++ thread which will poll the given channel at the
#' specified interval, accumulating the values in a buffer until 
#' \code{\link{read_poll}} is called.
#' @param chan The channel number on which to poll.
#' @param ms The number of millisecons to wait in between each poll.
#' @param buffer_size The size of the buffer into which we should accumulate
#'   values.
start_poll <- function(chan, ms = 1000, buffer_size = 1024L) {
    invisible(.Call('RpiR_start_poll', PACKAGE = 'RpiR', chan, ms, buffer_size))
}

#' Stop a Current Poll
#'
#' Stops any active poll on the specified channel, or does nothing if there
#' was no poll.
stop_poll <- function(chan) {
    invisible(.Call('RpiR_stop_poll', PACKAGE = 'RpiR', chan))
}

#' Reads From a Poll
#'
#' Read any unread values from an active poll. 
#'
#' If more values have accumulated than the buffer had room for, this function
#' will throw a warning and you will receive the most recent data.
#' @param chan The channel for which you want the unread values.
read_poll <- function(chan) {
    .Call('RpiR_read_poll', PACKAGE = 'RpiR', chan)
}

#' Set the mode of a GPIO pin
pin_mode <- function(pin, mode = as.character( c("in", "out", "pwm", "clock"))) {
    invisible(.Call('RpiR_pin_mode', PACKAGE = 'RpiR', pin, mode))
}

#' Pull a Pin Up or Down
pin_control <- function(pin, mode = as.character( c("off", "down", "up"))) {
    invisible(.Call('RpiR_pin_control', PACKAGE = 'RpiR', pin, mode))
}

#' Digital Write to a Pin
write_digital <- function(pin, signal) {
    invisible(.Call('RpiR_write_digital', PACKAGE = 'RpiR', pin, signal))
}

#' Digital Read from a Pin
read_digital <- function(pin) {
    .Call('RpiR_read_digital', PACKAGE = 'RpiR', pin)
}

#' Write PWM to a signal
write_pwm <- function(pin, value) {
    invisible(.Call('RpiR_write_pwm', PACKAGE = 'RpiR', pin, value))
}

#' Write an Analog Signal
write_analog <- function(pin, value) {
    invisible(.Call('RpiR_write_analog', PACKAGE = 'RpiR', pin, value))
}
trestletech/RpiR documentation built on May 27, 2017, 12:48 p.m.