Skip to content

Commit

Permalink
[board] Provide both touch sensor addresses for F469-DISCO
Browse files Browse the repository at this point in the history
To detect the touch sensor address at runtime.
  • Loading branch information
salkinium committed Nov 30, 2024
1 parent ac0f537 commit 17e7d24
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions examples/stm32f469_discovery/game_of_life/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void read_touch()
static Touch touchSensor(touchData, TouchAddress);
static bool initialized = false;
if (not initialized) {
if (not touchSensor.ping()) touchSensor.setAddress(TouchAddress2);
// Configure the touchscreen to sample with 60Hz in active and monitor mode.
touchSensor.configure(Touch::InterruptMode::Polling, 60, 60);
initialized = true;
Expand Down
1 change: 1 addition & 0 deletions examples/stm32f469_discovery/touchscreen/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class LineDrawer : public modm::Fiber<>
void
update()
{
if (not touch.ping()) touch.setAddress(TouchAddress2);

// Configure the touchscreen to sample with 60Hz in active and monitor mode.
touch.configure(Touch::InterruptMode::Trigger, 60, 60);
Expand Down
1 change: 1 addition & 0 deletions src/modm/board/disco_f469ni/board.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ using Sda = GpioB9;
using I2cMaster = I2cMaster1;
using Touch = modm::Ft6x06< I2cMaster >;
constexpr uint8_t TouchAddress = {{touch_address}};
constexpr uint8_t TouchAddress2 = {{touch_address2}};
/// @}
}

Expand Down
6 changes: 5 additions & 1 deletion src/modm/board/disco_f469ni/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ def prepare(module, options):

def build(env):
env.outbasepath = "modm/src/modm/board"
a1, a2 = [0x2a, 0x38]
if env[":disco-f469ni"] == "b-03":
a1, a2 = a2, a1
env.substitutions = {
"with_logger": True,
"with_assert": env.has_module(":architecture:assert"),
"touch_address": 0x38 if env[":disco-f469ni"] == "b-03" else 0x2a,
"touch_address": a1,
"touch_address2": a2,
}
env.template("../board.cpp.in", "board.cpp")
env.copy("board_display.cpp")
Expand Down
12 changes: 8 additions & 4 deletions src/modm/board/disco_f469ni/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ Call `Board::initializeTouchscreen()` to setup the peripherals.

## Hardware Revisions

The revision B-03 has a different touch sensor address from B-01 and B-02, which is
provided as `Board::ft6::TouchAddress`:
The revision B-03 has a different touch sensor address from B-01 and B-02.
The correct address for the revision is provided as `Board::ft6::TouchAddress`:

```cpp
Board::ft6::Touch::Data data;
Board::ft6::Touch touchSensor(data, Board::ft6::TouchAddress);
```
If you have an earlier revision, you can extend your configuration from
`modm:disco-f469ni:b-01`.
If you want to provide the same code for both revisions, you can change the
address at runtime if the device does not respond to a ping:
```cpp
if (not touchSensor.ping()) touchSensor.setAddress(Board::ft6::TouchAddress2);
```

0 comments on commit 17e7d24

Please sign in to comment.