Skip to content

Commit

Permalink
Released v0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Srg213 committed Oct 25, 2022
1 parent aa99761 commit ce9f1ac
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 113 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "ft6x06"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["Shantanu Gaikwad"]
authors = ["Shantanu Gaikwad", "Ken Sedgwick"]
categories = ["embedded", "no-std", "hardware-support"]
description = "A platform agnostic driver for the FT6x06 type touch panel controller used on STM32F4 series board."
license = "MIT OR Apache-2.0"
Expand All @@ -16,7 +16,7 @@ keywords = [
readme = "README.md"

[dependencies]
embedded-hal = "0.2.7"
embedded-hal = { version = "0.2.7", features = ["unproven"] }
cortex-m = "0.7"
heapless = {version = "0.7", optional =true}
panic-probe = { version = "0.2", features = ["print-rtt"] }
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,20 @@ To run an example,
- haves some Rust tools installed and switch to nightly channel,
- run the command: `cargo run --features stm32f413,fsmc_lcd --example interface`


### Version 0.1.1
Issue- Sometimes, STM32F413 would not respond while initializing I2C bus.
Perform a long hard reset, the FT66206 needs at least 5mS ...

- On the STM32F413 the touchscreen shares the reset GPIO pin w/ the LCD.
- The ST7789 driver uses a fast (10uS) reset.
- The touchscreen controller needs 5mS.

### Version 0.1.2
Issue- The touchscreen hangs after waiting for longer than 30 second for user input. The touchscreen controller was going to sleep after 30 seconds.
A solid fix appears to be to poll the touchscreen interrupt output to the stm32 and only attempt to read the registers when the touchscreen controller indicates there are touches waiting.

The ft6x06 indicates when touches are ready by manipulating an interrupt line.
By wait-polling this interrupt before reading the touch status registers we avoid spurious errors when the touchscreen controller becomes dormant (after not being touched for a while).

- Added function to Wait for the touchscreen interrupt to indicate touches
12 changes: 8 additions & 4 deletions examples/display_touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ fn main() -> ! {
)
};

//ft6x06 driver
#[cfg(feature = "stm32f412")]
let ts_int = gpiog.pg5.into_pull_down_input();

#[cfg(feature = "stm32f413")]
let ts_int = gpioc.pc1.into_pull_down_input();

let mut touch = ft6x06::Ft6X06::new(&i2c, 0x38).unwrap();
let mut touch = ft6x06::Ft6X06::new(&i2c, 0x38, ts_int).unwrap();

let tsc = touch.ts_calibration(&mut i2c, &mut delay);
match tsc {
Expand All @@ -158,7 +162,7 @@ fn main() -> ! {
let t = touch.detect_touch(&mut i2c);
let mut num: u8 = 0;
match t {
Err(e) => rprintln!("Error {} from fetching number of touches", e),
Err(_e) => rprintln!("Error from fetching number of touches"),
Ok(n) => {
num = n;
if num != 0 {
Expand All @@ -183,7 +187,7 @@ fn main() -> ! {
// Circle with 1 pixel wide white stroke with top-left point at (10, 20) with a diameter of 3
Circle::new(
Point::new(
// The coordinates are flipped.
// The coordinates are flipped.
<u16 as Into<i32>>::into(n.y),
240 - <u16 as Into<i32>>::into(n.x),
),
Expand Down
10 changes: 8 additions & 2 deletions examples/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ fn main() -> ! {
)
};

let mut touch = ft6x06::Ft6X06::new(&i2c, 0x38).unwrap();
#[cfg(feature = "stm32f412")]
let ts_int = gpiog.pg5.into_pull_down_input();

#[cfg(feature = "stm32f413")]
let ts_int = gpioc.pc1.into_pull_down_input();

let mut touch = ft6x06::Ft6X06::new(&i2c, 0x38, ts_int).unwrap();

let tsc = touch.ts_calibration(&mut i2c, &mut delay);
match tsc {
Expand All @@ -185,7 +191,7 @@ fn main() -> ! {
let t = touch.detect_touch(&mut i2c);
let mut num: u8 = 0;
match t {
Err(e) => rprintln!("Error {} from fetching number of touches", e),
Err(_e) => rprintln!("Error from fetching number of touches"),
Ok(n) => {
num = n;
if num != 0 {
Expand Down
19 changes: 14 additions & 5 deletions examples/multi_touch.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

#![no_main]
#![no_std]
#![allow(unused_variables)]

/// An example to use access Ft6x06 driver and get coordinates for
/// multiple touch points.
use cortex_m;
use cortex_m_rt::entry;
use rtt_target::{rprintln, rtt_init_print};
Expand All @@ -19,6 +18,7 @@ use panic_semihosting;

extern crate ft6x06;

#[entry]
fn main() -> ! {
rtt_init_print!();
rprintln!("Started");
Expand Down Expand Up @@ -47,9 +47,9 @@ fn main() -> ! {
)
};

let gpioc = perif.GPIOC.split();
#[cfg(feature = "stm32f413")]
let mut i2c = {
let gpioc = perif.GPIOC.split();
FMPI2c::new(
perif.FMPI2C1,
(
Expand All @@ -60,7 +60,16 @@ fn main() -> ! {
)
};

let mut touch = ft6x06::Ft6X06::new(&i2c, 0x38).unwrap();
#[cfg(feature = "stm32f412")]
let ts_int = {
let gpiog = perif.GPIOG.split();
gpiog.pg5.into_pull_down_input()
};

#[cfg(feature = "stm32f413")]
let ts_int = { gpioc.pc1.into_pull_down_input() };

let mut touch = ft6x06::Ft6X06::new(&i2c, 0x38, ts_int).unwrap();

let tsc = touch.ts_calibration(&mut i2c, &mut delay);
match tsc {
Expand All @@ -73,7 +82,7 @@ fn main() -> ! {
let t = touch.detect_touch(&mut i2c);
let mut num: u8 = 0;
match t {
Err(e) => rprintln!("Error {} from fetching number of touches", e),
Err(_e) => rprintln!("Error from fetching number of touches"),
Ok(n) => {
num = n;
if num != 0 {
Expand Down
18 changes: 14 additions & 4 deletions examples/touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ fn main() -> ! {

rprintln!("Connecting to I2c");

#[cfg(feature = "stm32f413")]
let gpioc = perif.GPIOC.split();

// STM32F412 touchscreen controller uses I2C1 module from embedded-hal.
#[cfg(feature = "stm32f412")]
let mut i2c = {
Expand All @@ -50,7 +53,6 @@ fn main() -> ! {
// STM32F413 shares the same I2C bus for both audio driver and touchscreen controller. FMPI2C module from embedded-hal is used.
#[cfg(feature = "stm32f413")]
let mut i2c = {
let gpioc = perif.GPIOC.split();
FMPI2c::new(
perif.FMPI2C1,
(
Expand All @@ -61,7 +63,16 @@ fn main() -> ! {
)
};

let mut touch = ft6x06::Ft6X06::new(&i2c, 0x38).unwrap();
#[cfg(feature = "stm32f412")]
let ts_int = {
let gpiog = perif.GPIOG.split();
gpiog.pg5.into_pull_down_input()
};

#[cfg(feature = "stm32f413")]
let ts_int = { gpioc.pc1.into_pull_down_input() };

let mut touch = ft6x06::Ft6X06::new(&i2c, 0x38, ts_int).unwrap();

let tsc = touch.ts_calibration(&mut i2c, &mut delay);
match tsc {
Expand All @@ -74,7 +85,7 @@ fn main() -> ! {
let t = touch.detect_touch(&mut i2c);
let mut num: u8 = 0;
match t {
Err(e) => rprintln!("Error {} from fetching number of touches", e),
Err(_e) => rprintln!("Error from fetching number of touches"),
Ok(n) => {
num = n;
if num != 0 {
Expand All @@ -98,4 +109,3 @@ fn main() -> ! {
}
}
}

Loading

0 comments on commit ce9f1ac

Please sign in to comment.