Crates.io | mlua-periphery |
lib.rs | mlua-periphery |
version | 0.1.9 |
source | src |
created_at | 2023-10-07 12:18:57.253746 |
updated_at | 2024-10-29 13:22:22.582046 |
description | A Rust-native implementation of lua-periphery for mlua. |
homepage | https://on-prem.net |
repository | https://gitlab.com/megalithic-llc/mlua-periphery.git |
max_upload_size | |
id | 996269 |
size | 82,782 |
A Rust-native implementation of lua-periphery for mlua.
From lua-periphery:
lua-periphery is a library for GPIO, LED, PWM, SPI, I2C, MMIO, and Serial peripheral I/O interface access in userspace Linux. It is useful in embedded Linux environments (including Raspberry Pi, BeagleBone, etc. platforms) for interfacing with external peripherals.
Using Python or C? Check out the python-periphery and c-periphery projects.
Add to your Rust project using one of MLua's features: [lua51, lua52, lua53, lua54, luajit, luajit52].
$ cargo add mlua-periphery --features luajit
use mlua::Lua;
let lua = Lua::new();
mlua_periphery::preload(&lua);
let script = r#"
local LED = require('periphery.LED')
local led = LED('led0')
return led:read(), led.brightness, led.max_brightness
"#;
let (value, brightness, max_brightness): (bool, u32, u32) = lua.load(script).eval()?;
An integration_tests.rs
file exists in each submodule and demonstrates:
$ cargo run -v --example i2cdetect --features lua54
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- 1a -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --