diff --git a/examples/stm32f469_discovery/game_of_life/main.cpp b/examples/stm32f469_discovery/game_of_life/main.cpp index b7082811bf..136a315e5b 100644 --- a/examples/stm32f469_discovery/game_of_life/main.cpp +++ b/examples/stm32f469_discovery/game_of_life/main.cpp @@ -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; diff --git a/examples/stm32f469_discovery/touchscreen/main.cpp b/examples/stm32f469_discovery/touchscreen/main.cpp index 73db7226bd..d12f8d0d94 100644 --- a/examples/stm32f469_discovery/touchscreen/main.cpp +++ b/examples/stm32f469_discovery/touchscreen/main.cpp @@ -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); diff --git a/src/modm/board/disco_f469ni/board.hpp.in b/src/modm/board/disco_f469ni/board.hpp.in index 785008cd49..dc1591e179 100644 --- a/src/modm/board/disco_f469ni/board.hpp.in +++ b/src/modm/board/disco_f469ni/board.hpp.in @@ -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}}; /// @} } diff --git a/src/modm/board/disco_f469ni/module.lb b/src/modm/board/disco_f469ni/module.lb index 3a54579cd6..a889e62651 100644 --- a/src/modm/board/disco_f469ni/module.lb +++ b/src/modm/board/disco_f469ni/module.lb @@ -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") diff --git a/src/modm/board/disco_f469ni/module.md b/src/modm/board/disco_f469ni/module.md index 3cc6e10fbe..b22dc26b84 100644 --- a/src/modm/board/disco_f469ni/module.md +++ b/src/modm/board/disco_f469ni/module.md @@ -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); +```