it's just a programming task.However I'm still puzzled as to how data from a gyro sensor can detect how much power you are/want to input ??
This paper shows how to calculate speed and distance using gyro data:
https://www.nxp.com/docs/en/application-note/AN3397.pdf
From the speed and gradient (you get it from the same I2C bus), you calculate the required power.