rust-embedded / rust-embedded/linux-embedded-hal

Add example?

Open
#24 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
319
Forks
60
Avg merge
12h 31m
Merged PRs (30d)
1

Description

Greetings.
I was kind of having a hard time getting the grasp of trying to use the digital GPIO pin. I worked it out in the end anyway, but I think it would be cool to add basic examples as simple as LED blinking, LED breathing, etc. like this:

extern crate linux_embedded_hal as hal;

use hal::sysfs_gpio::{Pin, Direction};
use std::error::Error;
use std::thread;
use std::time::Duration;

fn main() -> Result<(), Box<dyn Error>> {
    let gpio = Pin::new(198);

    match gpio.export() {
        Ok(()) => println!("Gpio {} exported!", gpio.get_pin()),
        Err(err) => println!("Gpio {} could not be exported: {}", gpio.get_pin(), err)
    }

    gpio.set_direction(Direction::Out)?;
    gpio.set_value(1)?;
    thread::sleep(Duration::from_secs(1));
    gpio.set_value(0)?;

    Ok(())
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the Rust GPIO snippet in this issue and inspect the repository's existing conventions for examples. Add basic digital GPIO examples such as LED blinking and breathing, then confirm that the examples build and are usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
embedded-iot
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.