Skip to content

Commit

Permalink
Update embedded-display-controller to 0.2. Use otm8009a from crates. …
Browse files Browse the repository at this point in the history
…Update DSI examples.
  • Loading branch information
romixlab committed Jan 24, 2024
1 parent 2dfc919 commit cf8701e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 59 deletions.
8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ sdio-host = { version = "0.9", optional = true }
embedded-sdmmc = { version = "0.5", optional = true }
stm32-fmc = { version = "0.3", optional = true }
synopsys-usb-otg = { version = "0.4", features = ["cortex-m"], optional = true }
embedded-display-controller = { version = "^0.1.0", optional = true }
embedded-display-controller = { version = "^0.2.0", optional = true }
log = { version = "0.4.14", optional = true} # see also the dev-dependencies section
fdcan = { version = "0.2", optional = true }
embedded-storage = "0.3"
embedded-dsi = { git = "https://github.com/romixlab/embedded-hal.git", branch = "dsi", optional = true }

[dependencies.smoltcp]
version = "0.10.0"
Expand Down Expand Up @@ -82,9 +81,8 @@ usbd-serial = "0.2.0"
numtoa = "0.2.3"
tinybmp = "0.5"
embedded-graphics = "0.8"
otm8009a = { git = "https://github.com/romixlab/otm8009a.git" }
otm8009a = "0.1"
eg-seven-segment = "0.2.0"
ft6236 = { git = "https://github.com/romixlab/ft6236.git" }

[dev-dependencies.smoltcp]
version = "0.10.0"
Expand All @@ -104,7 +102,7 @@ gpio-h72 = []
gpio-h747 = []
gpio-h7a2 = []

dsi = ["embedded-dsi", "embedded-display-controller"]
dsi = ["embedded-display-controller"]
cm4 = []
cm7 = []
smps = []
Expand Down
16 changes: 1 addition & 15 deletions examples/display-dsi-command-teartest-stm32h747i-disco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ use embedded_display_controller::DisplayConfiguration;
use otm8009a::Otm8009A;
use stm32h7xx_hal::dsi::{
DsiCmdModeTransmissionKind, DsiHost, DsiInterrupts, DsiMode, DsiPhyTimers,
DsiVideoMode, LaneCount,
LaneCount,
};
use ft6236::{FT6236};
use crate::utilities::mpu_config::init_mpu;
use crate::utilities::write::write_to::WriteTo;
use core::fmt::Write;
Expand Down Expand Up @@ -303,14 +302,6 @@ fn main() -> ! {
let mut dsi_refresh_handle = dsi_host.refresh_handle();
info!("Initialised Display...");

let scl = gpiod.pd12.into_alternate_open_drain();
let sda = gpiod.pd13.into_alternate_open_drain();
let i2c4 =
dp.I2C4
.i2c((scl, sda), 100.kHz(), ccdr.peripheral.I2C4, &ccdr.clocks);
let mut touch_ctrl = FT6236::new(i2c4);
// let touch_int = gpiok.pk7

let mut x = 0;
let mut y = 0;
let mut frame = 0;
Expand Down Expand Up @@ -348,11 +339,6 @@ fn main() -> ! {
frame += 1;
colored_label(buf.as_str().unwrap(), 50, 20, Rgb888::RED, draw).unwrap();

if let Ok(Some(pt)) = touch_ctrl.get_point0() {
info!("Touch: {} {}", pt.y, 480 - pt.x);
Circle::new(Point::new(480 - pt.x as i32 - 25, pt.y as i32 - 25), 50).into_styled(style_green).draw(draw).unwrap();
}

display_test(draw).unwrap();
});
disp.swap_layer_wait();
Expand Down
29 changes: 14 additions & 15 deletions examples/display-dsi-video-stm32h747i-disco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ use embedded_display_controller::DisplayController;
use chrono::{NaiveDateTime, NaiveTime};
use embedded_graphics::pixelcolor::Rgb888;
use embedded_graphics::prelude::*;
use embedded_graphics::primitives::{Circle, PrimitiveStyleBuilder};

use embedded_display_controller::DisplayConfiguration;
use otm8009a::Otm8009A;
use stm32h7xx_hal::dsi::{
DsiCmdModeTransmissionKind, DsiHost, DsiInterrupts, DsiMode, DsiPhyTimers,
DsiVideoMode, LaneCount,
};
use ft6236::{FT6236};
use crate::utilities::display_primitives::time_circuit;
use crate::utilities::mpu_config::init_mpu;

Expand Down Expand Up @@ -309,17 +307,18 @@ fn main() -> ! {
//let mut dsi_refresh_handle = dsi_host.refresh_handle();
info!("Initialised Display...");

let scl = gpiod.pd12.into_alternate_open_drain();
let sda = gpiod.pd13.into_alternate_open_drain();
let i2c4 =
dp.I2C4
.i2c((scl, sda), 100.kHz(), ccdr.peripheral.I2C4, &ccdr.clocks);
let mut touch_ctrl = FT6236::new(i2c4);
// Works
// let scl = gpiod.pd12.into_alternate_open_drain();
// let sda = gpiod.pd13.into_alternate_open_drain();
// let i2c4 =
// dp.I2C4
// .i2c((scl, sda), 100.kHz(), ccdr.peripheral.I2C4, &ccdr.clocks);
// let mut touch_ctrl = FT6236::new(i2c4);
// let touch_int = gpiok.pk7

let style_green = PrimitiveStyleBuilder::new()
.fill_color(Rgb888::GREEN)
.build();
// let style_green = PrimitiveStyleBuilder::new()
// .fill_color(Rgb888::GREEN)
// .build();

loop {
// Draw on a double buffered display
Expand All @@ -332,10 +331,10 @@ fn main() -> ! {
time_circuit(now, tc_x, 250, "PRESENT TIME", Rgb888::CSS_LIME_GREEN, Rgb888::new(15, 64, 15), draw).unwrap();
time_circuit(NaiveDateTime::new(NaiveDate::from_ymd_opt(1985, 10, 26).unwrap(), NaiveTime::from_hms_opt(01, 20, 0).unwrap()), tc_x, 400, "LAST TIME DEPARTED", Rgb888::CSS_ORANGE, Rgb888::new(77, 42, 0), draw).unwrap();

if let Ok(Some(pt)) = touch_ctrl.get_point0() {
info!("Touch: {} {}", pt.y, 480 - pt.x);
Circle::new(Point::new(pt.y as i32 - 25, 480 - pt.x as i32 - 25), 50).into_styled(style_green).draw(draw).unwrap();
}
// if let Ok(Some(pt)) = touch_ctrl.get_point0() {
// info!("Touch: {} {}", pt.y, 480 - pt.x);
// Circle::new(Point::new(pt.y as i32 - 25, 480 - pt.x as i32 - 25), 50).into_styled(style_green).draw(draw).unwrap();
// }
});
disp.swap_layer_wait();
}
Expand Down
16 changes: 1 addition & 15 deletions examples/display-dsi-video-teartest-stm32h747i-disco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ use embedded_display_controller::DisplayController;

use embedded_graphics::pixelcolor::Rgb888;
use embedded_graphics::prelude::*;
use embedded_graphics::primitives::{Circle, PrimitiveStyleBuilder, Rectangle};
use embedded_graphics::primitives::{PrimitiveStyleBuilder, Rectangle};

use embedded_display_controller::DisplayConfiguration;
use otm8009a::Otm8009A;
use stm32h7xx_hal::dsi::{
DsiCmdModeTransmissionKind, DsiHost, DsiInterrupts, DsiMode, DsiPhyTimers,
DsiVideoMode, LaneCount,
};
use ft6236::{FT6236};
use crate::utilities::mpu_config::init_mpu;
use crate::utilities::write::write_to::WriteTo;
use core::fmt::Write;
Expand Down Expand Up @@ -304,14 +303,6 @@ fn main() -> ! {
//let mut dsi_refresh_handle = dsi_host.refresh_handle();
info!("Initialised Display...");

let scl = gpiod.pd12.into_alternate_open_drain();
let sda = gpiod.pd13.into_alternate_open_drain();
let i2c4 =
dp.I2C4
.i2c((scl, sda), 100.kHz(), ccdr.peripheral.I2C4, &ccdr.clocks);
let mut touch_ctrl = FT6236::new(i2c4);
// let touch_int = gpiok.pk7

let mut x = 0;
let mut y = 0;
let mut frame = 0;
Expand Down Expand Up @@ -349,11 +340,6 @@ fn main() -> ! {
frame += 1;
colored_label(buf.as_str().unwrap(), 50, 20, Rgb888::RED, draw).unwrap();

if let Ok(Some(pt)) = touch_ctrl.get_point0() {
info!("Touch: {} {}", pt.y, 480 - pt.x);
Circle::new(Point::new(480 - pt.x as i32 - 25, pt.y as i32 - 25), 50).into_styled(style_green).draw(draw).unwrap();
}

display_test(draw).unwrap();
});
disp.swap_layer_wait();
Expand Down
18 changes: 9 additions & 9 deletions src/dsi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
};
use core::cmp::{max, min};
use embedded_display_controller::DisplayConfiguration;
use embedded_dsi::{DsiHostCtrlIo, DsiReadCommand, DsiWriteCommand};
use embedded_display_controller::dsi::{DsiHostCtrlIo, DsiReadCommand, DsiWriteCommand};
#[cfg(feature = "log")]
use log::debug;

Expand Down Expand Up @@ -589,19 +589,19 @@ impl DsiHostCtrlIo for DsiHost {
)?;
match kind {
DsiWriteCommand::DcsShortP0 { .. } => todo!(),
DsiWriteCommand::DcsShortP1 { reg, data } => {
DsiWriteCommand::DcsShortP1 { arg, data } => {
// debug!("{}, short_p1: reg: {reg:02x}, data: {data:02x}", self.write_idx);
// self.write_idx += 1;
self.ghcr_write(data, reg, kind.discriminant());
self.ghcr_write(data, arg, kind.discriminant());
}
DsiWriteCommand::DcsLongWrite { dcs_cmd, buf } => {
self.long_write(dcs_cmd, buf, kind.discriminant())?
DsiWriteCommand::DcsLongWrite { arg, data } => {
self.long_write(arg, data, kind.discriminant())?
}
DsiWriteCommand::GenericShortP0 => todo!(),
DsiWriteCommand::GenericShortP1 => todo!(),
DsiWriteCommand::GenericShortP2 => todo!(),
DsiWriteCommand::GenericLongWrite { cmd, buf } => {
self.long_write(cmd, buf, kind.discriminant())?
DsiWriteCommand::GenericLongWrite { arg, data } => {
self.long_write(arg, data, kind.discriminant())?
}
DsiWriteCommand::SetMaximumReturnPacketSize(len) => {
self.ghcr_write(
Expand Down Expand Up @@ -629,8 +629,8 @@ impl DsiHostCtrlIo for DsiHost {
}

match kind {
DsiReadCommand::DcsShort { dcs_cmd } => {
self.ghcr_write(0, dcs_cmd, kind.discriminant());
DsiReadCommand::DcsShort { arg } => {
self.ghcr_write(0, arg, kind.discriminant());
}
DsiReadCommand::GenericShortP0 => {
self.ghcr_write(0, 0, kind.discriminant());
Expand Down

0 comments on commit cf8701e

Please sign in to comment.