Skip to content

Commit 3025083

Browse files
committed
README + 0.1.1
1 parent 4503f7b commit 3025083

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "max-7219-led-matrix-util"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
authors = ["Philipp Schuster <phip1611@gmail.com>"]
55
edition = "2018"
66
exclude = [

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,31 @@ to access GPIO. Should work on other Linux powered devices with GPIO hardware to
1010

1111
Feel free to learn from the code or to contribute!
1212

13-
![demo](demo.gif)
13+
![demo](demo.gif)
14+
15+
## Usage example
16+
```
17+
use max_7219_led_matrix_util::setup::setup;
18+
use max_7219_led_matrix_util::{shop_moving_text_in_loop, prepare_display};
19+
20+
const NUM_DISPLAYS: usize = 4;
21+
22+
fn main() {
23+
// provide three args for the three pins
24+
let args: Vec<String> = std::env::args().collect();
25+
assert_eq!(args.len(), 4, "Provide three args!");
26+
27+
let data_pin = args[1].parse::<u32>().unwrap();
28+
let cs_pin = args[2].parse::<u32>().unwrap();
29+
let clk_pin = args[3].parse::<u32>().unwrap();
30+
31+
println!("data={}, cs={}, clk={}", data_pin, cs_pin, clk_pin);
32+
33+
let mut display = setup("/dev/gpiochip0", NUM_DISPLAYS, data_pin, cs_pin, clk_pin);
34+
prepare_display(&mut display, NUM_DISPLAYS, 0x0F);
35+
shop_moving_text_in_loop(&mut display, "HELLO 01 ABCDEF ", NUM_DISPLAYS, 50);
36+
}
37+
```
38+
39+
`max_7219_led_matrix_util::setup::setup` returns an instance of a struct defined by crate `max7219` (the actual device driver).
40+
Therefore you can work directly on this driver too without the need of the utility functions. Like `display.write_raw()`.

src/bin/demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ fn main() {
2323
println!("data={}, cs={}, clk={}", data_pin, cs_pin, clk_pin);
2424

2525
let mut display = setup("/dev/gpiochip0", NUM_DISPLAYS, data_pin, cs_pin, clk_pin);
26-
prepare_display(&mut display, NUM_DISPLAYS, 0x0F); // already done inside shop_moving_text_in_loop() :)
26+
prepare_display(&mut display, NUM_DISPLAYS, 0x0F);
2727
shop_moving_text_in_loop(&mut display, "HELLO 01 ABCDEF ", NUM_DISPLAYS, 50);
2828
}

0 commit comments

Comments
 (0)