mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
add ability to flip rendering of sh1107 screen
this allows a device to be flipped upside-down and have the screen track orientation
This commit is contained in:
parent
6b0972a551
commit
1ce29e80fa
4 changed files with 41 additions and 0 deletions
|
|
@ -514,6 +514,22 @@ impl<'a> Oled128x128<'a> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn flip_vertical(&mut self, flip: bool) -> Result<(), xous::Error> {
|
||||||
|
use Command::*;
|
||||||
|
let cmds = if flip {
|
||||||
|
// flipped
|
||||||
|
[SetSegmentReMap(true), SetCOMScanDirection(Direction::Normal)]
|
||||||
|
} else {
|
||||||
|
// normal
|
||||||
|
[SetSegmentReMap(false), SetCOMScanDirection(Direction::Inverted)]
|
||||||
|
};
|
||||||
|
for c in cmds {
|
||||||
|
let bytes = c.encode();
|
||||||
|
self.send_command(bytes)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn powerdown(&mut self) {
|
pub fn powerdown(&mut self) {
|
||||||
self.powerdown = true;
|
self.powerdown = true;
|
||||||
// assert reset
|
// assert reset
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,8 @@ pub enum GfxOpcode {
|
||||||
BaosecBitmap,
|
BaosecBitmap,
|
||||||
#[cfg(feature = "board-baosec")]
|
#[cfg(feature = "board-baosec")]
|
||||||
Brightness,
|
Brightness,
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
|
FlipScreen,
|
||||||
|
|
||||||
/// Gutter for invalid calls
|
/// Gutter for invalid calls
|
||||||
InvalidCall,
|
InvalidCall,
|
||||||
|
|
|
||||||
|
|
@ -801,6 +801,21 @@ impl Gfx {
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
|
pub fn flip_screen(&self, flip: bool) -> Result<(), xous::Error> {
|
||||||
|
send_message(
|
||||||
|
self.conn,
|
||||||
|
Message::new_blocking_scalar(
|
||||||
|
GfxOpcode::FlipScreen.to_usize().unwrap(),
|
||||||
|
if flip { 1 } else { 0 },
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "hosted-baosec")]
|
#[cfg(feature = "hosted-baosec")]
|
||||||
pub fn acquire_qr(&self) -> Result<QrAcquisition, xous::Error> {
|
pub fn acquire_qr(&self) -> Result<QrAcquisition, xous::Error> {
|
||||||
let dummy = "otpauth://totp/ACME%20Co:john.doe@email.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30".to_string();
|
let dummy = "otpauth://totp/ACME%20Co:john.doe@email.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30".to_string();
|
||||||
|
|
|
||||||
|
|
@ -902,6 +902,14 @@ pub fn wrapped_main(main_thread_token: MainThreadToken) -> ! {
|
||||||
.unwrap_or_else(|_| display_timeout_handler(&udma_global, &mut display));
|
.unwrap_or_else(|_| display_timeout_handler(&udma_global, &mut display));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
|
GfxOpcode::FlipScreen => {
|
||||||
|
if let Some(scalar) = msg.body.scalar_message_mut() {
|
||||||
|
display
|
||||||
|
.flip_vertical(scalar.arg1 != 0)
|
||||||
|
.unwrap_or_else(|_| display_timeout_handler(&udma_global, &mut display))
|
||||||
|
}
|
||||||
|
}
|
||||||
GfxOpcode::Quit => break,
|
GfxOpcode::Quit => break,
|
||||||
_ => {
|
_ => {
|
||||||
// This is perfectly normal because not all opcodes are handled by all platforms.
|
// This is perfectly normal because not all opcodes are handled by all platforms.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue