Skip to content

Commit

Permalink
Added further documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nereuxofficial committed Jun 10, 2023
1 parent 7ef36d4 commit fa723d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/hw390.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use hal::gpio::{
Analog, Bank0GpioRegisterAccess, Gpio2Signals, GpioPin, InputOutputAnalogPinType,
SingleCoreInteruptStatusRegisterAccessBank0,
};
/// A struct containing the hardware(via pointers to the right addresses of course) for the hw390 moisture sensor
pub struct Hw390<'a> {
pub adc: ADC<'a, ADC1>,
pub pin: AdcPin<
Expand All @@ -23,6 +24,7 @@ pub struct Hw390<'a> {
}

impl<'a> Hw390<'a> {
/// Read out moisture data from the hw390 sensor and normalise it
pub fn read(&mut self) -> Data {
let readout = hal::prelude::nb::block!(self.adc.read(&mut self.pin)).unwrap();
Data {
Expand Down
3 changes: 2 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ where
}
array
}

/// Convert an array of chars into an array of u8s. Useful for storing the uuid in flash and more
/// efficient than storing the intermediate result in a vector
pub(crate) fn convert_to_u8s<const N: usize>(array: [char; N]) -> [u8; N] {
let mut u8_array = [0; N];
for (i, c) in array.iter().enumerate() {
Expand Down

0 comments on commit fa723d0

Please sign in to comment.