Skip to content

Commit

Permalink
Merge pull request #23 from agrif/set-line-offset
Browse files Browse the repository at this point in the history
Set line offset
  • Loading branch information
Finomnis authored May 22, 2024
2 parents cae6a19 + 99c606d commit c4badf7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
23 changes: 23 additions & 0 deletions src/driver/common_functionality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ where
.send_command(Command::StaticIndicatorSet { mode })
}

/// Sets the line offset, effectively scrolling the display through memory.
pub fn set_line_offset(&mut self, offset: u8) -> Result<(), DisplayError> {
self.interface
.send_command(Command::DisplayStartLineSet { address: offset })
}

/// Sets whether the pixels should be inverted.
pub fn set_inverted(&mut self, inverted: bool) -> Result<(), DisplayError> {
self.interface
.send_command(Command::DisplayNormalReverse { reverse: inverted })
}

/// Displays all points of the display
pub fn display_all_points(&mut self, enable: bool) -> Result<(), DisplayError> {
self.interface
.send_command(Command::DisplayAllPoints { on: enable })
}

/// Enable/Disable the display output
pub fn set_display_on(&mut self, on: bool) -> Result<(), DisplayError> {
self.interface.send_command(Command::DisplayOnOff { on })
Expand Down Expand Up @@ -105,6 +123,11 @@ where
})
.map_err(Error::Comm)?;

// some ICs do not reset line offset to 0, so do that here as well
self.interface
.send_command(Command::DisplayStartLineSet { address: 0 })
.map_err(Error::Comm)?;

Ok(())
}
}
18 changes: 0 additions & 18 deletions src/driver/mode_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ where
.send_command(Command::ColumnAddressSet { address })
}

/// Sets the line offset, effectively scrolling the display through memory.
pub fn set_line_offset(&mut self, offset: u8) -> Result<(), DisplayError> {
self.interface
.send_command(Command::DisplayStartLineSet { address: offset })
}

/// Sets whether the pixels should be inverted.
pub fn set_inverted(&mut self, inverted: bool) -> Result<(), DisplayError> {
self.interface
.send_command(Command::DisplayNormalReverse { reverse: inverted })
}

/// Writes raw pixel data.
///
/// For more information how data is processed by the display, read the
Expand All @@ -62,10 +50,4 @@ where
self.interface
.send_command(Command::CommonOutputModeSelect { reverse })
}

/// Displays all points of the display
pub fn display_all_points(&mut self, enable: bool) -> Result<(), DisplayError> {
self.interface
.send_command(Command::DisplayAllPoints { on: enable })
}
}

0 comments on commit c4badf7

Please sign in to comment.