A rust program that polls a GPIO button for button press. Once the button is pressed it will output text and execute a local program of your choice. This program is preconfigured to execute the pushtotext rust program that sends a text message.
- Install rust using the steps for your operating system here: https://www.rust-lang.org/tools/install
- Test your install by running;
rustc --version
- Create a new folder for your awesome rust projects;
mkdir projects
- Change directory to your projects folder;
cd projects
- (optional) make sure you are in the right folder;
pwd
- Create a new rust application by running;
cargo new APPLICATION_NAME
- Change directory to your new project;
cd APPLICATION_NAME
- Replace the main.rs and toml file dependencies with the ones in this repository.
- From terminal run the following command with pin being the pin number your want to poll;
cargo run *pin*
You should see the program start and print aline saying the button is set to "High". When you press the button the terminal will print a line saying "Low" which indicates the button was pressed. If you have placed the pre-compiled pushtotext code into the same folder then it will run the command to start that program as well.
Big thanks to the Rust-Embedded team https://github.com/rust-embedded Also big thanks to the rust-sysfs-gpio team https://github.com/rust-embedded/rust-sysfs-gpio