Skip to content

humidity#23

Open
radueduard wants to merge 1 commit into
UPB-CS-OpenSourceUpstream:masterfrom
radueduard:master
Open

humidity#23
radueduard wants to merge 1 commit into
UPB-CS-OpenSourceUpstream:masterfrom
radueduard:master

Conversation

@radueduard
Copy link
Copy Markdown

added driver for the humidity sensor and tests

Comment thread apis/humidity/src/lib.rs
///
/// This function is used both for synchronous and asynchronous readings

pub fn humidity_read() -> Result<(), ErrorCode> {
Copy link
Copy Markdown

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> {

Comment thread apis/humidity/src/lib.rs
/// ## 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> {
Copy link
Copy Markdown

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> {

Copy link
Copy Markdown

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 thread examples/humidity.rs
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();
}
Copy link
Copy Markdown

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.

Comment thread runner/src/tockloader.rs
Copy link
Copy Markdown

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Revert this file

Comment thread src/lib.rs
use libtock_humidity as humidity;
pub type Humidity = humidity::Humidity<super::runtime::TockSyscalls>;
pub use humidity::HumidityListener;
} No newline at end of file
Copy link
Copy Markdown

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.
Copy link
Copy Markdown

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());
Copy link
Copy Markdown

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