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

Touch Panel HIL and ft6x06 driver #1986

Merged
merged 24 commits into from Jul 23, 2020
Merged

Conversation

alexandruradovici
Copy link
Contributor

Pull Request Overview

This pull request adds:

  • a HIL for touch panels with optional multi touch and gestures
  • a driver for the ft6x06 touch panel

Testing Strategy

This pull request was tested using the STM32F412g Discovery Kit.

TODO or Help Wanted

This pull request still needs some feedback.

Even tough the documentation for ft6x06 states that gestures should be recognized, my device does not seem to recognize them. I might be doing something wrong, any ideas would be helpful. The test setup is https://github.com/UPBIoT/tock/tree/touch.

Documentation Updated

  • no updates are required.

Formatting

  • Ran make prepush.

@alexandruradovici alexandruradovici marked this pull request as draft June 28, 2020 16:21
Copy link
Member

@ppannuto ppannuto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some quick initial comments on the HIL

kernel/src/hil/touch.rs Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
boards/components/src/ft6x06.rs Outdated Show resolved Hide resolved
capsules/src/touch.rs Outdated Show resolved Hide resolved
capsules/src/touch.rs Outdated Show resolved Hide resolved
gesture_callback: Option<Callback>,
multi_touch_callback: Option<Callback>,
events_buffer: Option<AppSlice<Shared, u8>>,
ack: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does ack do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This avoids a read write race. Apps will get the scheduled callback, but they might be in the middle of it when the touch screen sends a new set of touches. The data would be overwritten by the capsule right when the app reads it. To avoid this, I will add a command so that apps can ack that they have read the data.

Am I maybe wrong about how callbacks work and the ack is not necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you're right, that is something that has to be considered.

kernel/src/hil/touch.rs Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
/// Returns the number of concurently supported touches
/// This function must be called in the same interrupt
/// as the event, otherwise data might not be available.
fn get_num_touches(&self) -> usize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow this API. Will the number of concurrent touches supported change? What is the event? Doesn't the event report how many touches there were?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each touch screen might support a different number of maximum touches, I expect this function to be constant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessarily a suggestion, but the way we handle something similar to this in the time HIL is by using an associated type to denote the clock frequency. The associated type itself has only a static method (i.e., one that doesn't take a self) and therefore, presumably, is easier for the compiler to resolve statically and inline the constant.

But... I don't know that we ever evaluated that it actually makes a difference, and I don't know if others agree that it's a better interface than just having an instance method in the trait.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your point, but it does add some complexity to the code and seems to make it more difficult to read.

kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
capsules/src/touch.rs Outdated Show resolved Hide resolved
gesture_callback: Option<Callback>,
multi_touch_callback: Option<Callback>,
events_buffer: Option<AppSlice<Shared, u8>>,
ack: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you're right, that is something that has to be considered.

pub id: usize,

/// touch area
pub area: Option<usize>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just define these, since these are features on modern touchscreens.

kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
bradjc
bradjc previously approved these changes Jul 20, 2020
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
kernel/src/hil/touch.rs Outdated Show resolved Hide resolved
alexandruradovici and others added 18 commits July 22, 2020 00:57
Co-authored-by: Brad Campbell <bradjc5@gmail.com>
Co-authored-by: Brad Campbell <bradjc5@gmail.com>
Co-authored-by: Brad Campbell <bradjc5@gmail.com>
Co-authored-by: Brad Campbell <bradjc5@gmail.com>
Co-authored-by: Brad Campbell <bradjc5@gmail.com>
Co-authored-by: Brad Campbell <bradjc5@gmail.com>
Co-authored-by: Brad Campbell <bradjc5@gmail.com>
Co-authored-by: Brad Campbell <bradjc5@gmail.com>
@bradjc
Copy link
Contributor

bradjc commented Jul 23, 2020

bors r+

@bors bors bot merged commit 2ce7b7b into tock:master Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants