Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- pmic
- Date:
- 2019-08-21
- Revision:
- 2:ee9896ee7a7a
- Parent:
- 0:4b02060af95b
File content as of revision 2:ee9896ee7a7a:
#include "mbed.h"
#include "PX4Flow.h"
#define INTEGRAL
DigitalOut myled(LED1);
I2C i2c(PA_10,PA_9);
Serial pc(SERIAL_TX, SERIAL_RX);
PX4Flow PX4(i2c,pc);
int main()
{
i2c.frequency(400000);
pc.baud(2000000);
while(1) {
#ifndef INTEGRAL
if(PX4.update()) {
pc.printf("Frame Count: %4.0d\t", PX4.frame_count());
pc.printf("Pixel Flow X Sum: %d\t", PX4.pixel_flow_x_sum());
pc.printf("Pixel Flow Y Sum: %d\t", PX4.pixel_flow_y_sum());
pc.printf("Flow Comp. M X.: %4.0d\t", PX4.flow_comp_m_x());
pc.printf("Flow Comp. M Y.: %4.0d\t", PX4.flow_comp_m_y());
pc.printf("Quality: %3.1d\t", PX4.qual());
pc.printf("Gyro X Rate: %4.0d\t", PX4.gyro_x_rate());
pc.printf("Gyro Y Rate: %4.0d\t", PX4.gyro_y_rate());
pc.printf("Gyro Z Rate: %4.0d\t", PX4.gyro_z_rate());
pc.printf("Sonar Timestamp: %3.d\t", PX4.sonar_timestamp());
pc.printf("Ground Distance: %.3f\t", float(PX4.ground_distance())/1000);
pc.printf("\r\n");
} else {
pc.printf("TimeOut\r\n");
}
#else
if(PX4.update_integral()) {
pc.printf("Frame Count: %3.0d\t", PX4.frame_count_since_last_readout());
pc.printf("Pixel Flow X Integral: %3.0d\t", PX4.pixel_flow_x_integral());
pc.printf("Pixel Flow Y Integral: %3.0d\t", PX4.pixel_flow_y_integral());
pc.printf("Gyro X Rate: %3.0d\t", PX4.gyro_x_rate_integral());
pc.printf("Gyro Y Rate: %3.0d\t", PX4.gyro_y_rate_integral());
pc.printf("Gyro Z Rate: %3.0d\t", PX4.gyro_z_rate_integral());
pc.printf("Quality: %3.0d\t", PX4.quality_integral());
pc.printf("Sonar Timestamp: %10.d\t", PX4.sonar_timestamp_integral());
pc.printf("Ground Distance: %3.d\t", PX4.ground_distance_integral());
pc.printf("Gyro Temperature: %3.d\t", PX4.gyro_temperature());
pc.printf("Integration Timespan: %8.0d\t", PX4.integration_timespan());
pc.printf("\r\n");
} else {
pc.printf("TimeOut\r\n");
}
#endif
wait(0.01);
}
}