Skip to content

Commit

Permalink
First time building on RPi
Browse files Browse the repository at this point in the history
  • Loading branch information
mnr committed Oct 9, 2023
1 parent c71f327 commit 27a3e9c
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 47 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ export(rpi_monitor)
export(rpi_pinToBCM)
export(rpi_pwm)
export(rpi_set)
importFrom(Rcpp,sourceCpp)
useDynLib(rpigpior, .registration = TRUE)
1 change: 0 additions & 1 deletion R/rpi_get.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#' @export
#'
#' @examplesIf is.rpi()
#' 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
rpi_get <- function(pin_number) {
Expand Down
4 changes: 3 additions & 1 deletion R/rpi_monitor.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@
#' }
#' @export
#'
#' @examplesIf is.rpi()
#' @examplesIf FALSE
#'
#' rpi_monitor(21)
#' rpi_monitor(21, numEvents=20)
#'
rpi_monitor <-
function(pin_number,
numEvents = 0,
Expand Down
5 changes: 4 additions & 1 deletion R/rpi_pinToBCM.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
#' @export
#'
#' @examplesIf is.rpi()
#' rpi_pinToBCM(1) # produces error since pin #1 is not data
#'
#' # 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
#'

rpi_pinToBCM <- function(pin_number) {
# check pin number. Are all values valid data lines?
Expand Down
1 change: 1 addition & 0 deletions R/rpi_pwm.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#'
#' rpi_pwm(c(12,33), pwm_period = 50000, pwm_dutycycle = 10000) # provides 20% PWM to pin 12 (PWM0) and pin 33 (PWM1)
#'
#' rpi_pwm(c(12,33), pwm_dutycycle = 0) # turn PWM off
rpi_pwm <- function(pin_number = 12, pwm_period = 50000, pwm_dutycycle = 25000, pwm_debug = FALSE ) {
# check that pin_number == 12, 32, 33, or 35 ---------
if (pwm_debug) {
Expand Down
1 change: 1 addition & 0 deletions R/rpi_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#' rpi_set(toggleThesePins, c(0,1,0)) # turns off pins 19 and 23
#' Sys.sleep(1)
#' rpi_set(toggleThesePins, 0) # turns off all pins
#'
rpi_set <- function(pin_number, onOff) {

bcm_line <- rpigpior::rpi_pinToBCM(pin_number)
Expand Down
10 changes: 10 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,13 @@ rpi_set(toggleThese, 0)

[Related mailing list:
linux-gpio\@vger.kernal.org](https://www.spinics.net/lists/linux-gpio/)

# linux_device_access

C code to access linux devices

Copyright 2020 Leon de Boer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ install the development version of rpigpior from
[GitHub](https://github.com/mnr/rpigpior) with:

``` r
library(remotes)
remotes::install_github("mnr/rpigpior")
library(devtools)
devtools::install_github("mnr/rpigpior")
```

Most documentation will tell you to use devtools, but
`install.packages("devtools")` on a Raspberry Pi is an onerous task.
I highly recommend you use the R install from [r4pi](https://r4pi.org/). They have already set up devtools.

Once you’ve installed, use `library` just like any other R package:

Expand All @@ -48,7 +47,7 @@ library(rpigpior)

## Is this a Raspberry Pi?

It’s helpful to check if your code is running on a Raspberry Pi.
It’s helpful to check if your code is running on a Raspberry Pi. Do this with `is.rpi()`

``` r
if ( is.rpi() ) {
Expand All @@ -72,7 +71,7 @@ rpi_get(c(7,40)) # reads board pins 7 and 40
0 1
```

That assumes the switch to board pin 40 is “pushed” or closed. By the
This assumes the switch to board pin 40 is “pushed” or closed. By the
way, there is a diagram of this located in the *articles* section of the
website (as identified in the package description)

Expand Down
1 change: 0 additions & 1 deletion man/rpi_get.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/rpi_monitor.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/rpi_pinToBCM.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/rpi_pwm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/rpigpior-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions src/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions tests/testthat/test-gpiodetect.R

This file was deleted.

3 changes: 0 additions & 3 deletions tests/testthat/test-gpiofind.R

This file was deleted.

3 changes: 0 additions & 3 deletions tests/testthat/test-gpioget.R

This file was deleted.

3 changes: 0 additions & 3 deletions tests/testthat/test-gpioinfo.R

This file was deleted.

3 changes: 0 additions & 3 deletions tests/testthat/test-gpiomon.R

This file was deleted.

3 changes: 0 additions & 3 deletions tests/testthat/test-gpionotify.R

This file was deleted.

3 changes: 0 additions & 3 deletions tests/testthat/test-gpioset.R

This file was deleted.

0 comments on commit 27a3e9c

Please sign in to comment.