Skip to content

A Rust library for the Raspberry Pi Sense HAT Joystick.

License

Notifications You must be signed in to change notification settings

CubixSystem/sensehat-stick-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A Rust library for the Raspberry Pi Sense HAT Joystick.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%