Waiting for user input so game logic can continue

Hi all,

I am creating a little battleship game, where at the beginning the player should enter the coordinates of his ships via a display running with LVGL. I am using Arduino as IDE

As each player has lets say 2 ships. So I though I run a for loop to get all the coordinates of the ships. In the loop I am waiting for the user input from the display:


for (int j = 0; j < NUM_SHIPS; ++j) {
Ship& ship = players[1].ships[j]

        while  (startPointX && startPointY == Null){

       // wait for user input
       ship.startX = startPointX
       ship.startY = startPointY


In the event of the text area I am filling the startPointX & startPointY.

But in this way the display does not react, as it is not running in the usual loop() with the lv_task_handler() function.

How can I best wait for a user input in such a case, so that the game logic can continue?

This is how I did it:

while  (startPointX != Null && startPointY != Null){

 ship.startX = startPointX
       ship.startY = startPointY