From b4ba83a9995068758a796ae6e0cddfd35539456d Mon Sep 17 00:00:00 2001 From: Mark Niemann-Ross Date: Wed, 15 May 2024 13:07:20 -0700 Subject: [PATCH] documentation update --- man/is.rpi.Rd | 28 +++++++--------------------- man/rpi_get.Rd | 4 +++- man/rpi_i2c_get.Rd | 2 +- man/rpi_monitor.Rd | 16 ++++++++-------- man/rpi_pinToBCM.Rd | 11 +++++------ man/rpi_pin_desc.Rd | 14 ++++++++------ man/rpi_pwm.Rd | 21 +++++++++++---------- man/rpi_set.Rd | 6 +++--- 8 files changed, 46 insertions(+), 56 deletions(-) diff --git a/man/is.rpi.Rd b/man/is.rpi.Rd index f2af85a..1ad0d84 100644 --- a/man/is.rpi.Rd +++ b/man/is.rpi.Rd @@ -2,37 +2,23 @@ % Please edit documentation in R/is_rpi.R \name{is.rpi} \alias{is.rpi} -\title{Provide information about the Operating System} +\title{Confirm this code is running on a Raspberry Pi} \usage{ -is.rpi(onlyThis = "IsThisRPI") +is.rpi(tellme = FALSE) } \arguments{ -\item{onlyThis}{If no value is passed to onlyThis, is.rpi() will return a logical - -If 'onlyThis' is specified, 'is.rpi()' will return the value for that field in /etc/os-release. Here are some typical values found in os-release - -\itemize{ - \item PRETTY_NAME is a concatenation of NAME, VERSION_ID, VERSION - \item NAME is the name of the OS, typically "Raspbian GNU/LINUX" - \item VERSION_ID is the version. Currently = 11 - \item VERSION is a concatenation of VERSION_ID and (VERSION_CODENAME) - \item VERSION_CODENAME is the OS Name. Currently = "bullseye" - \item ID is the OS. Currently = "raspbian" - \item ID_LIKE is the OS base. Currently = "debian" - \item HOME_URL Currently = "http://www.raspbian.org" - \item SUPPORT_URL Currently = "http://www.raspbian.org/RaspbianForums" - \item BUG_REPORT Currently = "http://www.raspbian.org/RaspbianBugs" -}} +\item{tellme}{if TRUE the is.rpi will return the device-tree/model. +This typically looks like "Raspberry Pi 5 Model B Rev 1.0"} } \value{ -If `onlyThis` is specified, returns that value. Otherwise returns TRUE if running Raspbian +TRUE if running on a Raspberry Pi. +if tellme = TRUE, return the model string } \description{ -Returns TRUE if this code is running under Raspbian or return information about the operating system. +Returns TRUE if this code is running on a Raspberry Pi } \examples{ \dontshow{if (is.rpi()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} is.rpi() -is.rpi("NAME") \dontshow{\}) # examplesIf} } diff --git a/man/rpi_get.Rd b/man/rpi_get.Rd index 254d272..0ccb1f8 100644 --- a/man/rpi_get.Rd +++ b/man/rpi_get.Rd @@ -17,7 +17,9 @@ Returns the value of one or more specified board-level pin number (0-40). Stops } \examples{ \dontshow{if (is.rpi()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -\dontrun{ rpi_get(1) # produces error since pin #1 is not data } +\dontrun{ +rpi_get(1) # produces error since pin #1 is not data +} rpi_get(40) # returns a named vector of the state of GPIO21. i.e. return["GPIO21"] = 1 rpi_get(c(7, 40)) # returns a named vector of values from pins 7 and 40 \dontshow{\}) # examplesIf} diff --git a/man/rpi_i2c_get.Rd b/man/rpi_i2c_get.Rd index d916b03..bfa840e 100644 --- a/man/rpi_i2c_get.Rd +++ b/man/rpi_i2c_get.Rd @@ -22,6 +22,6 @@ Return a byte from an i2c device \examples{ \dontshow{if (is.rpi()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} #' # get a byte from an i2c device located at 0x77 -rpi_i2c_get(chip_address = 0x77, data_address = 0xfa, data_size = 'b') +rpi_i2c_get(chip_address = 0x77, data_address = 0xfa, data_size = "b") \dontshow{\}) # examplesIf} } diff --git a/man/rpi_monitor.Rd b/man/rpi_monitor.Rd index d4cd26b..e1a2e22 100644 --- a/man/rpi_monitor.Rd +++ b/man/rpi_monitor.Rd @@ -15,13 +15,13 @@ rpi_monitor(pin_number, numEvents = 0, edge = "both") } \value{ a list of events - \itemize{ - \item raw text of each event - \item event: RISING EDGE|FALLING EDGE - \item line: the bcm line (not board pin) exhibiting change - \item timestamp: seconds component - \item timestamp: nanoseconds component - } +\itemize{ +\item raw text of each event +\item event: RISING EDGE|FALLING EDGE +\item line: the bcm line (not board pin) exhibiting change +\item timestamp: seconds component +\item timestamp: nanoseconds component +} } \description{ Watch a Raspberry pi GPIO pin (or pins) for changes. @@ -30,7 +30,7 @@ Watch a Raspberry pi GPIO pin (or pins) for changes. \dontshow{if (is.rpi()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \donttest{ rpi_monitor(21) -rpi_monitor(21, numEvents=20) +rpi_monitor(21, numEvents = 20) } \dontshow{\}) # examplesIf} } diff --git a/man/rpi_pinToBCM.Rd b/man/rpi_pinToBCM.Rd index 1e7e6b2..576b965 100644 --- a/man/rpi_pinToBCM.Rd +++ b/man/rpi_pinToBCM.Rd @@ -11,19 +11,18 @@ rpi_pinToBCM(pin_number) } \value{ a named vector. - bcm_line = broadcom line connected to this pin - pin_name = broadcom name such as RXD1 or GPIO21 +bcm_line = broadcom line connected to this pin +pin_name = broadcom name such as RXD1 or GPIO21 } \description{ Look up a board pin number and return BCM_line and line_name - Pin number is the physical board of the Raspberry pi. +Pin number is the physical board of the Raspberry pi. } \details{ -This checks for a valid range of pins (1:40) and for valid input/output lines. This prevents trying to read a 3.3v or ground line. +\if{html}{\out{
}}\preformatted{This checks for a valid range of pins (1:40) and for valid input/output lines. This prevents trying to read a 3.3v or ground line. +}\if{html}{\out{
}} } \examples{ \dontshow{if (is.rpi()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -rpi_pinToBCM(1) # produces error since pin #1 is not data -rpi_pinToBCM(40) # returns a named vector where bcm_line = 21 and pin_name = GPIO21 \dontshow{\}) # examplesIf} } diff --git a/man/rpi_pin_desc.Rd b/man/rpi_pin_desc.Rd index e24f68b..6b6737e 100644 --- a/man/rpi_pin_desc.Rd +++ b/man/rpi_pin_desc.Rd @@ -5,13 +5,15 @@ \alias{rpi_pin_desc} \title{Raspberry Pi Pins} \format{ -## `rpi_pin_desc` +\subsection{\code{rpi_pin_desc}}{ + A data frame with 40 rows and two columns: \itemize{ - \item description. Primary function of the pin - \item secondary. Secondary function of the pin - \item valid_PWM_pair_1, valid_PWM_pair_2. Used by rpi_pwm() to determine valid PWM pins and channel combinations. - \item PWM_channel. Unambiguously relates the PWM channel to each board pin +\item description. Primary function of the pin +\item secondary. Secondary function of the pin +\item valid_PWM_pair_1, valid_PWM_pair_2. Used by rpi_pwm() to determine valid PWM pins and channel combinations. +\item PWM_channel. Unambiguously relates the PWM channel to each board pin +} } } \source{ @@ -22,6 +24,6 @@ rpi_pin_desc } \description{ A board-level description of the 40 GPIO pins found on a Raspberry Pi. - This is different than wiring pi or BCM numbering schemes. Instead, this reflects the function of pins by their physical location on the board. +This is different than wiring pi or BCM numbering schemes. Instead, this reflects the function of pins by their physical location on the board. } \keyword{datasets} diff --git a/man/rpi_pwm.Rd b/man/rpi_pwm.Rd index 6a08110..0692c3d 100644 --- a/man/rpi_pwm.Rd +++ b/man/rpi_pwm.Rd @@ -23,26 +23,27 @@ If two pins are selected, they must be one of these combinations: (12,33), (32,3 } \value{ void - `rpi_pwm()` provides extensive error checking. Possible errors include: - \itemize{ - \item Invalid PWM pin: Hardware PWM is only supplied to pins 12, 32, 33, or 35. - \item Invalid PWM pin combination: The combination of pins both select PWM0 or PWM1 - \item PWM not enabled: This PWM channel is not enabled - \item (see https://mnr.github.io/rpigpior/articles/rpi_pwm.html for fixing errors) - } +\code{rpi_pwm()} provides extensive error checking. Possible errors include: +\itemize{ +\item Invalid PWM pin: Hardware PWM is only supplied to pins 12, 32, 33, or 35. +\item Invalid PWM pin combination: The combination of pins both select PWM0 or PWM1 +\item PWM not enabled: This PWM channel is not enabled +\item (see https://mnr.github.io/rpigpior/articles/rpi_pwm.html for fixing errors) +} } \description{ Provides the R programming language with access to Raspberry Pi hardware Pulse Width Modulation (PWM) } \details{ -Only two PWM lines are available on the Raspberry Pi - pwm0 and pwm1. Although it is possible to create software PWM, this isn't advised due to latency of linux and R. - It might be helpful to read the article on `rpi_pwm()` located at the [rpigpior website](https://mnr.github.io/rpigpior/articles/rpi_pwm.html). +\if{html}{\out{
}}\preformatted{Only two PWM lines are available on the Raspberry Pi - pwm0 and pwm1. Although it is possible to create software PWM, this isn't advised due to latency of linux and R. +It might be helpful to read the article on `rpi_pwm()` located at the [rpigpior website](https://mnr.github.io/rpigpior/articles/rpi_pwm.html). +}\if{html}{\out{
}} } \examples{ \dontshow{if (is.rpi()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} rpi_pwm(12) # provides 50\% PWM to pin 12 (PWM0) #' # provides 20\% PWM to pin 12 (PWM0) and pin 33 (PWM1) -rpi_pwm(c(12,33), pwm_period = 50000, pwm_dutycycle = 10000) +rpi_pwm(c(12, 33), pwm_period = 50000, pwm_dutycycle = 10000) \dontshow{\}) # examplesIf} } diff --git a/man/rpi_set.Rd b/man/rpi_set.Rd index 9cae554..380d87e 100644 --- a/man/rpi_set.Rd +++ b/man/rpi_set.Rd @@ -21,12 +21,12 @@ Turn lines on or off \dontshow{if (is.rpi()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # turns pin 19 on, 21 off, and 23 on. # This corresponds to gpio09, gpio10, and gpio11 -rpi_set(pin_number = c(19, 21, 23), onOff = c(1,0,1)) +rpi_set(pin_number = c(19, 21, 23), onOff = c(1, 0, 1)) -toggleThesePins <- c(19,21,23) +toggleThesePins <- c(19, 21, 23) rpi_set(toggleThesePins, 1) # turns all three pins on. onOff is recycled Sys.sleep(1) -rpi_set(toggleThesePins, c(0,1,0)) # turns off pins 19 and 23 +rpi_set(toggleThesePins, c(0, 1, 0)) # turns off pins 19 and 23 Sys.sleep(1) rpi_set(toggleThesePins, 0) # turns off all pins \dontshow{\}) # examplesIf}