Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 43 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -52,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
Expand All @@ -61,22 +96,22 @@ 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
run: rustc main.rs --verbose --forbid warnings

test_semver:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2

build_examples:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
**/target
**/Cargo.lock

# macos :p
**/.DS_Store
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<!-- cargo-rdme start -->

# max6675-hal

An embedded-hal driver for the MAX6675 digital thermocouple converter.

[<img alt="license badge" src="https://img.shields.io/github/license/onkoe/max6675-hal">](https://github.com/onkoe/max6675-hal)
[<img alt="docs.rs badge" src="https://img.shields.io/docsrs/max6675-hal">](https://docs.rs/max6675-hal)
[<img alt="crates.io badge" src="https://img.shields.io/crates/dv/max6675-hal?label=crates.io">](https://crates.io/crates/max6675-hal)
[<img alt="GitHub badge" src="https://img.shields.io/badge/github-onkoe/max6675--hal-6e5494">](https://github.com/onkoe/max6675-hal)
[<img alt="GitHub Actions badge" src="https://img.shields.io/github/actions/workflow/status/onkoe/max6675-hal/ci.yml?branch=main">](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
Expand All @@ -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:
Expand All @@ -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!

<!-- cargo-rdme end -->
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
//!
//! An embedded-hal driver for the MAX6675 digital thermocouple converter.
//!
//! [<img alt="license badge" src="https://img.shields.io/github/license/onkoe/max6675-hal">](https://github.com/onkoe/max6675-hal)
//! [<img alt="docs.rs badge" src="https://img.shields.io/docsrs/max6675-hal">](https://docs.rs/max6675-hal)
//! [<img alt="crates.io badge" src="https://img.shields.io/crates/dv/max6675-hal?label=crates.io">](https://crates.io/crates/max6675-hal)
//! [<img alt="GitHub badge" src="https://img.shields.io/badge/github-onkoe/max6675--hal-6e5494">](https://github.com/onkoe/max6675-hal)
//! [<img alt="GitHub Actions badge" src="https://img.shields.io/github/actions/workflow/status/onkoe/max6675-hal/ci.yml?branch=main">](https://github.com/onkoe/max6675-hal/actions)
//!
//! ## Usage
//!
//! This example code will change depending on which HAL device driver you're
Expand Down Expand Up @@ -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;
Expand Down
Loading