Hello there,
I need a "stopwatch"-function that takes in a time in microseconds(milliseconds would also be ok) and a Flag as Parameters and sets the Flag true after the input time has passed while the program keeps running.
Is there any library that includes this kind of functionality?
Project Background Information:
I want to read a pressure sensor(BMP180[avg sampling rate 70Hz]) and an orientation sensor (MPU6050[avg sampling rate 500Hz]) via I2C with different sampling rates. To get the measurements from a
sensor I each need to call a startMeasuring() function then wait a certain amount of time and then get the data once it is ready by a readData() function.
Since my application is very time critical(water rocket control) i want to minimize wait time in my program.
Since the pressure sensor has no interrupt pin but needs about 11ms beetween startMeasuring() and readData() my approach would be to call startMeasuring() then activate my "Stopwatch"-function (with the time 11000 and Flag DATA_READY_BMP) and in the meantime let my sensor for orientation execute its startMeasuring() and readData() function.
After it is executed once it checks whether the flag DATA_READY_BMP is true.
If it is true it reads the data from the pressure sensor.
If it is false it starts to gather data from the orientation sensor again till it is true.
After that the loop() function just repeats the whole process.