-
Notifications
You must be signed in to change notification settings - Fork 5
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
Added row mask methods #16
base: master
Are you sure you want to change the base?
Conversation
Changed DisplayDataAddress as clike enum, added methods to DisplayData.
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.
Overall this looks good, thank you! One typo (spelling) in a comment to fix.
I'm still a beginner in Rust, and a previous contributor made changes to ensure this library works with #![no_std]
, will your changes still work with #![no_std]
?
I am positive that these changes are |
/// Represents the desired values of the device, may not match | ||
/// the current values if it has not been written recently. | ||
/// Remember to use `.write_display_buffer()` after changing buffer. | ||
pub buffer: [u8; ROWS_SIZE], |
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.
Rather than using custom a type, a plain byte is more flexible. It would make sense to restrict users from using u8 if there where invalid states a buffer could be in, which there are none.
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.
Also marking buffer as public means that its way more easier for people to get the buffer in the state consumers want.
Any bit state in the buffer is a valid state, so it's no harm in marking buffer as public.
/// # Ok(()) | ||
/// # } | ||
/// ``` | ||
pub fn update_row_mask(&mut self, row: usize, mask: u8) { |
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.
This function was written before the buffer was marked public. Should it be removed? Should the buffer remain private?
for row in self.buffer.iter_mut() { | ||
*row = DisplayData::COMMON_NONE; | ||
} | ||
self.buffer = [0; ROWS_SIZE]; |
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.
Trust the compiler. No need for iteration.
)?; | ||
|
||
Ok(()) | ||
) | ||
} |
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.
Removing the endings of similar functions is just a preference really, but makes no difference.
@@ -27,6 +30,55 @@ bitflags! { | |||
} |
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.
I dont think it's a good idea to have bitflags when each flag marks a single bit AND all bits can be used to make any byte.
I think it's rather pointless, but it could stay for backwards compatibility.
const ROW_14 = 14; | ||
/// Row 15 | ||
const ROW_15 = 15; | ||
use DisplayDataAddress::*; |
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.
Changing from bitflags into enum as it makes more sense. Addresses should not need bitwise operations.
No description provided.