Skip to content
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

add Display::is_sleeping fixes #77 #78

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mipidsi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- added `GC9A01` model support
- added `Display::wake` method
- added `Display::sleep` method
- added `Display::is_sleeping` method

## [v0.7.1] - 2023-05-24

Expand Down
1 change: 1 addition & 0 deletions mipidsi/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ where
rst,
options: self.options,
madctl,
sleeping: false, // TODO: init should lock state
};

Ok(display)
Expand Down
11 changes: 11 additions & 0 deletions mipidsi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ where
options: ModelOptions,
// Current MADCTL value copy for runtime updates
madctl: dcs::SetAddressMode,
// State monitor for sleeping TODO: refactor to a Model-connected state machine
sleeping: bool,
}

impl<DI, M, RST> Display<DI, M, RST>
Expand Down Expand Up @@ -255,6 +257,13 @@ where
.write_command(dcs::SetTearingEffect(tearing_effect))
}

///
/// Returns `true` if display is currently set to sleep.
///
pub fn is_sleeping<D: DelayUs<u32>>(&self) -> bool {
self.sleeping
}

///
/// Puts the display to sleep, reducing power consumption.
/// Need to call [Self::wake] before issuing other commands
Expand All @@ -263,6 +272,7 @@ where
self.dcs.write_command(dcs::EnterSleepMode)?;
// All supported models requires a 120ms delay before issuing other commands
delay.delay_us(120_000);
self.sleeping = true;
Ok(())
}

Expand All @@ -273,6 +283,7 @@ where
self.dcs.write_command(dcs::ExitSleepMode)?;
// ST7789 and st7735s have the highest minimal delay of 120ms
delay.delay_us(120_000);
self.sleeping = false;
Ok(())
}
}
Loading