From 11bde918b8dd4475acd1ae5fa2375df83566dc52 Mon Sep 17 00:00:00 2001 From: Barrett Date: Wed, 12 Mar 2025 16:34:46 -0500 Subject: [PATCH 1/4] chore(.gitignore): add `.DS_Store` --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 972b0c4..4349fd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ **/target **/Cargo.lock + +# macos :p +**/.DS_Store From d39ec767f7e859f9007e2073c601ef4b8280d66e Mon Sep 17 00:00:00 2001 From: Barrett Date: Wed, 12 Mar 2025 16:35:07 -0500 Subject: [PATCH 2/4] docs(README): use `cargo-rdme` for sync w/ docs.rs --- README.md | 40 ++++++++++++++++++++++++++-------------- src/lib.rs | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ad1208e..e70d5ed 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,26 @@ + + # max6675-hal +An embedded-hal driver for the MAX6675 digital thermocouple converter. + [license badge](https://github.com/onkoe/max6675-hal) [docs.rs badge](https://docs.rs/max6675-hal) [crates.io badge](https://crates.io/crates/max6675-hal) [GitHub badge](https://github.com/onkoe/max6675-hal) [GitHub Actions badge](https://github.com/onkoe/max6675-hal/actions) -An `embedded-hal` driver for the MAX6675 digital thermocouple converter. - ## Usage -This example code will change depending on which HAL device driver you're using. An `arduino-hal` project's SPI isn't like that of an `esp32-hal` project. - -However, you only have to focus on two parts: +This example code will change depending on which HAL device driver you're +using. An `arduino-hal` project's SPI isn't like that of an `esp32-hal` +project. -1. A CS (chip select) pin as an `OutputPin` -2. Some SPI representation that doesn't exclusively own the CS pin (I'm looking at you, `linux-embedded-hal`!) +However, you only need to focus on your device's SPI implementation! +(thanks, `embedded-hal` 1.0 ☺️) -Your SPI settings should use MSB (most significant bit) first, target a clock speed of at least 4mhz, and utilize SPI Mode 1. - -After both are good, pass them into the `Max6675::new(spi, chip_select)` constructor. Ta-da! Your MAX6675 gets put to good use. +Your SPI settings should use MSB (most significant bit) first, target a clock speed of +at least 4mhz, and utilize SPI Mode 1. ```rust // first, define what pins you're connecting to @@ -31,7 +32,7 @@ let sck_pin = pins.("your sck/clock pin").into_output(); // if so, just pick some pin that you're not using ☺️ let dummy_mosi = pins.("some pin you're not using").into_output(); -let (spi, cs) = device-hal::spi::Spi::new( +let (spi, _) = device-hal::spi::Spi::new( sck_pin, dummy_mosi, so_pin, cs_pin, device-hal::spi::Settings { // pick some settings that roughly align like so: @@ -40,17 +41,28 @@ let (spi, cs) = device-hal::spi::Spi::new( mode: embedded_hal::spi::MODE_1, } ); -let mut max = Max6675::new(spi, cs)?; // your spi and chip select here +let mut max = Max6675::new(spi)?; // your spi and chip select here let temp = max.read_celsius()? // ayo! we got the temperature ``` +## Note + +This crate re-exports a Temperature type from another crate, `simmer`. +You can change and play with the temperatures in various ways, so feel free +to [check out its docs](https://docs.rs/crate/simmer/latest) for more info. + ## Contributions -Contributions are welcome to this project! Since it's pretty small, feel free to submit a PR whenever. You can also make an issue - I'll likely get to it soon! +Contributions are welcome to this project! Since it's pretty small, feel +free to submit a PR whenever. You can also make an issue - I'll likely get +to it soon! ## Help Please don't hesitate to make an issue if you experience any problems! -If you can, please submit a [`hw-probe` report](https://linux-hardware.org/?view=howto) alongside any error messages or useful logs you have! +If you can, please submit a [`hw-probe` report](https://linux-hardware.org/?view=howto) +alongside any error messages or useful logs you have! + + diff --git a/src/lib.rs b/src/lib.rs index 73b9fe6..c226b4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,12 @@ //! //! An embedded-hal driver for the MAX6675 digital thermocouple converter. //! +//! [license badge](https://github.com/onkoe/max6675-hal) +//! [docs.rs badge](https://docs.rs/max6675-hal) +//! [crates.io badge](https://crates.io/crates/max6675-hal) +//! [GitHub badge](https://github.com/onkoe/max6675-hal) +//! [GitHub Actions badge](https://github.com/onkoe/max6675-hal/actions) +//! //! ## Usage //! //! This example code will change depending on which HAL device driver you're @@ -44,6 +50,19 @@ //! This crate re-exports a Temperature type from another crate, `simmer`. //! You can change and play with the temperatures in various ways, so feel free //! to [check out its docs](https://docs.rs/crate/simmer/latest) for more info. +//! +//! ## Contributions +//! +//! Contributions are welcome to this project! Since it's pretty small, feel +//! free to submit a PR whenever. You can also make an issue - I'll likely get +//! to it soon! +//! +//! ## Help +//! +//! Please don't hesitate to make an issue if you experience any problems! +//! +//! If you can, please submit a [`hw-probe` report](https://linux-hardware.org/?view=howto) +//! alongside any error messages or useful logs you have! use core::marker::PhantomData; use embedded_hal::spi::SpiDevice; From 212c5209ed408b546c4e862f5bb7abd077f1312a Mon Sep 17 00:00:00 2001 From: Barrett Date: Wed, 12 Mar 2025 16:35:19 -0500 Subject: [PATCH 3/4] ci: check `cargo-rdme` in github actions --- .github/workflows/ci.yml | 47 +++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d687352..f940454 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,9 +8,44 @@ env: CARGO_TERM_COLOR: always jobs: + # Ensures the README is up-to-date with that of docs.rs. + check_rdme: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + + - name: Install `cargo-rdme` + uses: taiki-e/install-action@v2 + with: + tool: cargo-rdme + + - name: Use `cargo-rdme` to see if README matches `lib.rs` + run: cargo rdme --check + + # Checks for missed Clippy lints. + clippy: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + toolchain: stable + + - name: Check for missed Clippy lints + run: RUSTFLAGS="-Dwarnings" cargo clippy + + # Build the project and runs the test suite. build_and_test: name: Rust project - latest - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: toolchain: @@ -21,10 +56,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Rust toolchain - uses: dtolnay/rust-toolchain@stable + - name: Install Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: ${{ matrix.toolchain }} + toolchain: ${{ matrix.toolchain }} - name: Cache cargo registry uses: actions/cache@v3 @@ -68,7 +103,7 @@ jobs: run: rustc main.rs --verbose --forbid warnings test_semver: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 @@ -76,7 +111,7 @@ jobs: uses: obi1kenobi/cargo-semver-checks-action@v2 build_examples: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 From b84456d0246f3ad06235ecb310c42a1d8d34826a Mon Sep 17 00:00:00 2001 From: Barrett Date: Wed, 12 Mar 2025 16:43:30 -0500 Subject: [PATCH 4/4] ci: just use `cargo-deny` cmd over action the action seems to cache the rust version, which caused a failure in the ci --- .github/workflows/ci.yml | 4 ++-- deny.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f940454..58e9174 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,7 +87,7 @@ jobs: - uses: taiki-e/install-action@v2 with: - tool: cargo-all-features + tool: cargo-all-features,cargo-deny - name: Build run: cargo build-all-features --verbose @@ -96,7 +96,7 @@ jobs: run: cargo test-all-features - name: Run `cargo-deny` - uses: EmbarkStudios/cargo-deny-action@v1 + run: cargo deny check - name: Check feature gate working-directory: ./.github/workflows/ci diff --git a/deny.toml b/deny.toml index 031cd9f..9c9ea37 100644 --- a/deny.toml +++ b/deny.toml @@ -1,5 +1,5 @@ [licenses] -allow = ["MIT", "Apache-2.0", "Unicode-DFS-2016"] +allow = ["MIT", "Apache-2.0", "Unicode-3.0"] [bans] # disable duplicate crates