GithubHelp home page GithubHelp logo

nimgpiod's Introduction

nimgpiod

libgpiod wrapper for nim lang

compiler options:
use -d:bulk to include bulk gpio functions
use -d:ctxless to include ctxless gpio functions

tested on Rpi-2
event tests are using bcm2835pii lib for pulling line high -> creating events
libgpiod v1.4 wrapped, tested with v1.2.3 on Rpi2

optional companion-libs for Raspberry B+ 1..3:

  import posix
  echo "uid: ",getuid(), " euid: ", geteuid()

  block test1:
    echo "\n test#1 \n"
    var gpiochip0: ChipPtr
    try:
      gpiochip0 = chipOpen("/dev/gpiochip0")
      if gpiochip0.isNil : quit("gpiochip0 not available, quitting")
    except:
      quit("gpiochip0 not available, quitting")

    echo "gpiod_chip_num_lines(gpiochip0) ", numLines(gpiochip0)
    echo "gpiod_chip_get_line(gpiochip0, 12)"
    var line12 = getLine(gpiochip0, 12)
    if line12.isNil: 
      chipClose(gpiochip0)
      quit("failed to get line #12")

    echo "gpiod_line_is_used(line12) ", isUsed(line12)
    echo "offset", line12.offset
    echo "gpiod_line_request_input ", requestInput(line12, "gpio test")
    echo "gpiod_line_get_value(line12) ", getValue(line12)
    echo "gpiod_line_is_used(line12) ", isUsed(line12)

    release(line12)
    chipClose(gpiochip0)

nimgpiod's People

Contributors

nais314 avatar

Stargazers

Carlo Capocasa avatar Juan Carlos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.