1#![cfg_attr(not(any(test, feature = "std")), no_std)]
2
3#[macro_use]
4pub(crate) mod fmt;
5
6use thiserror::Error;
7
8device_driver::create_device!(device_name: Ft6336uLowLevel, manifest: "device.yaml");
9pub const FT6336U_I2C_ADDRESS: u8 = 0x38;
10
11#[derive(Debug, Error)]
12#[cfg_attr(feature = "defmt", derive(defmt::Format))]
13pub enum Ft6336uError<I2cErr> {
14 #[error("I2C error")]
15 I2c(I2cErr),
16 #[error("Not supported: {0}")]
17 NotSupported(&'static str),
18}
19
20#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21#[cfg_attr(feature = "defmt", derive(defmt::Format))]
22pub enum TouchStatus {
23 Touch,
24 Stream,
25 Release,
26}
27
28#[derive(Debug, Clone, Copy)]
29#[cfg_attr(feature = "defmt", derive(defmt::Format))]
30pub struct TouchPoint {
31 pub status: TouchStatus,
32 pub x: u16,
33 pub y: u16,
34}
35
36impl Default for TouchPoint {
37 fn default() -> Self {
38 Self {
39 status: TouchStatus::Release,
40 x: 0,
41 y: 0,
42 }
43 }
44}
45
46#[derive(Debug, Clone, Copy, Default)]
47#[cfg_attr(feature = "defmt", derive(defmt::Format))]
48pub struct TouchData {
49 pub touch_count: u8,
50 pub points: [TouchPoint; 2],
51}
52
53pub struct Ft6336uInterface<I2CBus> {
54 i2c_bus: I2CBus,
55}
56
57impl<I2CBus> Ft6336uInterface<I2CBus> {
58 pub fn new(i2c_bus: I2CBus) -> Self {
59 Self { i2c_bus }
60 }
61}
62
63#[path = "."]
64mod asynchronous {
65 use bisync::asynchronous::*;
66 use device_driver::AsyncRegisterInterface as RegisterInterface;
67 use embedded_hal_async::i2c::I2c;
68 mod driver;
69 pub use driver::*;
70}
71pub use asynchronous::Ft6336u as Ft6336uAsync;
72
73#[path = "."]
74mod blocking {
75 use bisync::synchronous::*;
76 use device_driver::RegisterInterface;
77 use embedded_hal::i2c::I2c;
78 #[allow(clippy::duplicate_mod)]
79 mod driver;
80 pub use driver::*;
81}
82pub use blocking::Ft6336u;