Skip to content

Commit

Permalink
firmware: temp sensor fix and south basement workshop config
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Dec 3, 2024
1 parent c15b8c5 commit 3d569ca
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ jobs:
run:
working-directory: ./firmware

strategy:
matrix:
config:
- test.toml
- south-basement-workshop.toml

steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30

- name: Clippy
env:
CONFIG: ./configs/test.toml
CONFIG: "./configs/${{ matrix.config }}"
run: |
eval "$(nix print-dev-env)"
set -x
Expand All @@ -48,13 +54,19 @@ jobs:
run:
working-directory: ./firmware

strategy:
matrix:
config:
- test.toml
- south-basement-workshop.toml

steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30

- name: Build
env:
CONFIG: ./configs/test.toml
CONFIG: "./configs/${{ matrix.config }}"
run: |
eval "$(nix print-dev-env)"
set -x
Expand Down
2 changes: 1 addition & 1 deletion firmware/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() {

#[derive(Deserialize)]
struct Config {
board_temperature_sensor_address: u64,
board_temperature_sensor_address: String,
}

impl Config {
Expand Down
1 change: 1 addition & 0 deletions firmware/configs/south-basement-workshop.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
board_temperature_sensor_address = "11691230640084377896"
2 changes: 1 addition & 1 deletion firmware/configs/test.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
board_temperature_sensor_address = 2473778391013417256
board_temperature_sensor_address = "2473778391013417256"
8 changes: 6 additions & 2 deletions firmware/src/temperature_sensors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use defmt::{info, warn};
use ds18b20::Ds18b20;
use ds18b20::{Ds18b20, Resolution};
use embassy_rp::gpio::{Level, OutputOpenDrain};
use embassy_time::{Delay, Duration, Ticker, Timer};
use one_wire_bus::{Address, OneWire};
Expand All @@ -16,6 +16,10 @@ pub(super) async fn task(r: crate::OnewireResources) {
info!("Found one wire device at address: {}", device_address.0);
}

info!(
"Configured board temperature sensor address: {}",
env!("BOARD_TEMP_SENSOR_ADDRESS")
);
let onboard_temp_sensor =
Ds18b20::new::<()>(Address(env!("BOARD_TEMP_SENSOR_ADDRESS").parse().unwrap())).unwrap();

Expand All @@ -26,7 +30,7 @@ pub(super) async fn task(r: crate::OnewireResources) {

ds18b20::start_simultaneous_temp_measurement(&mut bus, &mut Delay).unwrap();

Timer::after_millis(ds18b20::Resolution::Bits12.max_measurement_time_millis() as u64).await;
Timer::after_millis(Resolution::Bits12.max_measurement_time_millis() as u64).await;

// TODO: do something sensible with the temperature readings
match onboard_temp_sensor.read_data(&mut bus, &mut Delay) {
Expand Down

0 comments on commit 3d569ca

Please sign in to comment.