Skip to content

Conversation

@radueduard
Copy link

added driver for the humidity sensor and tests

///
/// This function is used both for synchronous and asynchronous readings
pub fn humidity_read() -> Result<(), ErrorCode> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn humidity_read() -> Result<(), ErrorCode> {
pub fn read() -> Result<(), ErrorCode> {

/// ## Hello
/// Returns Ok(humidity_value) if the operation was successful
/// humidity_value is returned in hundreds of centigrades
pub fn humidity_read_sync() -> Result<i32, ErrorCode> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn humidity_read_sync() -> Result<i32, ErrorCode> {
pub fn read_sync() -> Result<i32, ErrorCode> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any negative values for the humidity? You are using i32.

Comment on lines +26 to +40
loop {
match Humidity::humidity_read_sync() {
Ok(hum_val) => writeln!(
Console::writer(),
"Humidity: {}{}.{}%\n",
if hum_val > 0 { "" } else { "-" },
i32::abs(hum_val) / 100,
i32::abs(hum_val) % 100
)
.unwrap(),
Err(_) => writeln!(Console::writer(), "error while reading humidity",).unwrap(),
}

Alarm::sleep_for(Milliseconds(2000)).unwrap();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this in the Ok branch of the previous match.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this file.

MEMORY {
FLASH (X) : ORIGIN = 0x00040000, LENGTH = 256K
RAM (W) : ORIGIN = 0x20004000, LENGTH = 112K
RAM (W) : ORIGIN = 0x20004800, LENGTH = 112K

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this file

use libtock_humidity as humidity;
pub type Humidity = humidity::Humidity<super::runtime::TockSyscalls>;
pub use humidity::HumidityListener;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a newline.

Comment on lines +11 to +13
// The `upcall_on_command` field is set to Some(value) if an upcall(with value as its argument) should be called when read command is received,
// or None otherwise. It was needed for testing `read_sync` library function which simulates a synchronous temperature read,
// because it was impossible to schedule an upcall during the `synchronous` read in other ways.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this comment next to the field using ///

fn command() {
let hum = Humidity::new();

assert!(hum.command(EXISTS, 1, 2).is_success());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do the two arguments mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants