-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add bambu; Signed-off-by: Jess Frazelle <[email protected]> * updates Signed-off-by: Jess Frazelle <[email protected]> * fixes Signed-off-by: Jess Frazelle <[email protected]> * updates Signed-off-by: Jess Frazelle <[email protected]> --------- Signed-off-by: Jess Frazelle <[email protected]>
- Loading branch information
Showing
5 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
mod control; | ||
mod discover; | ||
mod temperature; | ||
|
||
use std::{net::IpAddr, sync::Arc}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use std::{collections::HashMap, sync::Arc}; | ||
|
||
use anyhow::Result; | ||
|
||
use super::X1Carbon; | ||
use crate::{TemperatureSensor, TemperatureSensorReading, TemperatureSensors as TemperatureSensorsTrait}; | ||
|
||
impl X1Carbon { | ||
/// Return a handle to read the temperature information from the | ||
/// Moonraker printer. | ||
pub fn get_temperature_sensors(&self) -> TemperatureSensors { | ||
TemperatureSensors { | ||
client: self.client.clone(), | ||
} | ||
} | ||
} | ||
|
||
/// Struct to read Temperature values from the 3d printer. | ||
#[derive(Clone)] | ||
pub struct TemperatureSensors { | ||
client: Arc<bambulabs::client::Client>, | ||
} | ||
|
||
impl TemperatureSensorsTrait for TemperatureSensors { | ||
type Error = anyhow::Error; | ||
|
||
async fn sensors(&self) -> Result<HashMap<String, TemperatureSensor>> { | ||
Ok(HashMap::from([ | ||
("extruder".to_owned(), TemperatureSensor::Extruder), | ||
("bed".to_owned(), TemperatureSensor::Bed), | ||
("chamber".to_owned(), TemperatureSensor::Chamber), | ||
])) | ||
} | ||
|
||
async fn poll_sensors(&mut self) -> Result<HashMap<String, TemperatureSensorReading>> { | ||
let Some(status) = self.client.get_status()? else { | ||
return Ok(HashMap::new()); | ||
}; | ||
|
||
let mut sensor_readings = HashMap::from([( | ||
"extruder".to_owned(), | ||
TemperatureSensorReading { | ||
temperature_celsius: status.nozzle_temper.unwrap_or(0.0), | ||
target_temperature_celsius: status.nozzle_target_temper, | ||
}, | ||
)]); | ||
|
||
sensor_readings.insert( | ||
"bed".to_owned(), | ||
TemperatureSensorReading { | ||
temperature_celsius: status.bed_temper.unwrap_or(0.0), | ||
target_temperature_celsius: status.bed_target_temper, | ||
}, | ||
); | ||
|
||
sensor_readings.insert( | ||
"chamber".to_owned(), | ||
TemperatureSensorReading { | ||
temperature_celsius: status.chamber_temper.unwrap_or(0.0), | ||
target_temperature_celsius: None, | ||
}, | ||
); | ||
|
||
Ok(sensor_readings) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters