Code Monkey home page Code Monkey logo

sensehat-stick-rs's Introduction

A Rust library for the Raspberry Pi Sense HAT Joystick.

crates.io docs

The joystick integrated on the Raspberry Pi Sense HAT, is well integrated to Linux systems. The Sense HAT hardware provides a driver for evdev, or event device interface in the Linux kernel.

As such, the evdev file-descriptor for the joystick, can be read for events issued by someone pushing the joystick.

This library provides a thread-safe, strong-typed, high-level API for the joystick, treating it as you would any other input device using evdev.

Usage

To use this crate with the default features, add this to your Cargo.toml:

[dependencies]
sensehat-stick = "0.1"

or, to manually specify the features::

[dependencies]
sensehat-stick = { version = "0.1", default-features = false, features = ["poll"] }

Features

default

By default, the linux-evdev, and poll features are included.

linux-evdev

In default. Makes use of the evdev interface.

poll

In default. Provides efficient-polling capabilities by implementing mio::Evented for JoyStick.

Example

//! Prints out the events received from the joystick, in a
//! blocking fashion.
extern crate sensehat_stick;

use sensehat_stick::JoyStick;

fn main() {
    let mut stick = JoyStick::open().unwrap();
    loop {
        // This call will block the current thread until
        // an event is triggered on the joystick.
        for ev in &stick.events().unwrap() {
            println!("{:?}", ev);
        }
    }
}

For more, read the indiviual examples.

sensehat-stick-rs's People

Stargazers

 avatar  avatar

Watchers

 avatar  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.