DFRobot Gesture Sensor (PAJ7620U2)

Hi guys, I am currently having issues with my programming.

Below are the codes for what I have done so far. The aim of the project is for the sensor to detect a forward motion and it will activate Relay1. It will then wait for a backward motion to deactivate Relay1 and activate Relay2.

The problem currently is that the do-while loop is an infinity loop. It is supposed to exit the loop when it detects the backward motion but it does not.

I am using the current board and sensor:

Board: Arduino Uno
Sensor: DFRobot Gesture Sensor (PAJ7620U2)
Link to the sensor : Gravity: PAJ7620U2 Gesture Sensor Wiki - DFRobot

I hope you guys can help me suggest a way to solve this problem. Thanks.

#include <DFRobot_PAJ7620U2.h>


DFRobot_PAJ7620U2 paj;


// Relays
int Relay1 = 8; // ec2-3nu Relay
int Relay2 = 7; // photoMos relay


void setup()
{
  Serial.begin(115200);
  delay(300);
  Serial.println("Gesture recognition system base on PAJ7620U2");
  while (paj.begin() != 0) {
    Serial.println("initial PAJ7620U2 failure! Please check if all the connections are fine, or if the wire sequence is correct?");
    delay(500);
  }
  Serial.println("PAJ7620U2 init completed, start to test the gesture recognition function");
  paj.setGestureHighRate(true);
  Serial.println("Ready for action");


  //Relay init
  pinMode(Relay1, OUTPUT);
  pinMode(Relay2, OUTPUT);
}


void loop()
{
  DFRobot_PAJ7620U2::eGesture_t gesture = paj.getGesture();
  String description  = paj.gestureDescription(gesture);//Convert gesture number into string description


  //Initial position for relays
  digitalWrite(Relay1, LOW);
  digitalWrite(Relay2, LOW);
  
  //Activate Relay2 for discharging
  digitalWrite(Relay2, HIGH);
  delay(500);
  digitalWrite(Relay2, LOW);


  if (gesture == paj.eGestureForward) {
    do {
      Serial.println("--------------Gesture Recognition System---------------------------");
      Serial.print("gesture code        = "); Serial.println(gesture);
      Serial.print("gesture description  = "); Serial.println(description);
      Serial.println();
      digitalWrite(Relay1, HIGH);
      Serial.println("Waiting for next command");
    } while (gesture != paj.eGestureBackward); // exit when backwards is detected
    digitalWrite(Relay1, LOW);
    delay(500);
    digitalWrite(Relay2, HIGH);
    delay(500);
    digitalWrite(Relay1, LOW);
  }
}

How is paj.eGestureBackward updated while in the loop?

I don't know. What do you suggest?