-
Notifications
You must be signed in to change notification settings - Fork 9
humidity #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
humidity #23
Conversation
| /// | ||
| /// This function is used both for synchronous and asynchronous readings | ||
| pub fn humidity_read() -> Result<(), ErrorCode> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| pub fn humidity_read_sync() -> Result<i32, ErrorCode> { | |
| pub fn read_sync() -> Result<i32, ErrorCode> { |
There was a problem hiding this comment.
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.
| 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(); | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a newline.
| // 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. |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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?
added driver for the humidity sensor and tests