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@0:4b02060af95b, 2019-08-02 (annotated)
- Committer:
- altb2
- Date:
- Fri Aug 02 14:15:07 2019 +0000
- Revision:
- 0:4b02060af95b
- Child:
- 1:562a583eb77c
- Child:
- 2:ee9896ee7a7a
PX4 Test on nuc L432KC (from hurc)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
altb2 | 0:4b02060af95b | 1 | #include "mbed.h" |
altb2 | 0:4b02060af95b | 2 | #include "PX4Flow.h" |
altb2 | 0:4b02060af95b | 3 | |
altb2 | 0:4b02060af95b | 4 | #define INTEGRAL |
altb2 | 0:4b02060af95b | 5 | |
altb2 | 0:4b02060af95b | 6 | DigitalOut myled(LED1); |
altb2 | 0:4b02060af95b | 7 | I2C i2c(PA_10,PA_9); |
altb2 | 0:4b02060af95b | 8 | Serial pc(SERIAL_TX, SERIAL_RX); |
altb2 | 0:4b02060af95b | 9 | PX4Flow PX4(i2c,pc); |
altb2 | 0:4b02060af95b | 10 | |
altb2 | 0:4b02060af95b | 11 | |
altb2 | 0:4b02060af95b | 12 | |
altb2 | 0:4b02060af95b | 13 | int main() |
altb2 | 0:4b02060af95b | 14 | { |
altb2 | 0:4b02060af95b | 15 | i2c.frequency(400000); |
altb2 | 0:4b02060af95b | 16 | pc.baud(2000000); |
altb2 | 0:4b02060af95b | 17 | while(1) { |
altb2 | 0:4b02060af95b | 18 | |
altb2 | 0:4b02060af95b | 19 | #ifndef INTEGRAL |
altb2 | 0:4b02060af95b | 20 | if(PX4.update()) { |
altb2 | 0:4b02060af95b | 21 | pc.printf("Frame Count: %4.0d\t", PX4.frame_count()); |
altb2 | 0:4b02060af95b | 22 | pc.printf("Pixel Flow X Sum: %d\t", PX4.pixel_flow_x_sum()); |
altb2 | 0:4b02060af95b | 23 | pc.printf("Pixel Flow Y Sum: %d\t", PX4.pixel_flow_y_sum()); |
altb2 | 0:4b02060af95b | 24 | pc.printf("Flow Comp. M X.: %4.0d\t", PX4.flow_comp_m_x()); |
altb2 | 0:4b02060af95b | 25 | pc.printf("Flow Comp. M Y.: %4.0d\t", PX4.flow_comp_m_y()); |
altb2 | 0:4b02060af95b | 26 | pc.printf("Quality: %3.1d\t", PX4.qual()); |
altb2 | 0:4b02060af95b | 27 | pc.printf("Gyro X Rate: %4.0d\t", PX4.gyro_x_rate()); |
altb2 | 0:4b02060af95b | 28 | pc.printf("Gyro Y Rate: %4.0d\t", PX4.gyro_y_rate()); |
altb2 | 0:4b02060af95b | 29 | pc.printf("Gyro Z Rate: %4.0d\t", PX4.gyro_z_rate()); |
altb2 | 0:4b02060af95b | 30 | pc.printf("Sonar Timestamp: %3.d\t", PX4.sonar_timestamp()); |
altb2 | 0:4b02060af95b | 31 | pc.printf("Ground Distance: %.3f\t", float(PX4.ground_distance())/1000); |
altb2 | 0:4b02060af95b | 32 | pc.printf("\r\n"); |
altb2 | 0:4b02060af95b | 33 | } else { |
altb2 | 0:4b02060af95b | 34 | pc.printf("TimeOut\r\n"); |
altb2 | 0:4b02060af95b | 35 | } |
altb2 | 0:4b02060af95b | 36 | #else |
altb2 | 0:4b02060af95b | 37 | if(PX4.update_integral()) { |
altb2 | 0:4b02060af95b | 38 | pc.printf("Frame Count: %3.0d\t", PX4.frame_count_since_last_readout()); |
altb2 | 0:4b02060af95b | 39 | pc.printf("Pixel Flow X Integral: %3.0d\t", PX4.pixel_flow_x_integral()); |
altb2 | 0:4b02060af95b | 40 | pc.printf("Pixel Flow Y Integral: %3.0d\t", PX4.pixel_flow_y_integral()); |
altb2 | 0:4b02060af95b | 41 | pc.printf("Gyro X Rate: %3.0d\t", PX4.gyro_x_rate_integral()); |
altb2 | 0:4b02060af95b | 42 | pc.printf("Gyro Y Rate: %3.0d\t", PX4.gyro_y_rate_integral()); |
altb2 | 0:4b02060af95b | 43 | pc.printf("Gyro Z Rate: %3.0d\t", PX4.gyro_z_rate_integral()); |
altb2 | 0:4b02060af95b | 44 | pc.printf("Quality: %3.0d\t", PX4.quality_integral()); |
altb2 | 0:4b02060af95b | 45 | pc.printf("Sonar Timestamp: %10.d\t", PX4.sonar_timestamp_integral()); |
altb2 | 0:4b02060af95b | 46 | pc.printf("Ground Distance: %3.d\t", PX4.ground_distance_integral()); |
altb2 | 0:4b02060af95b | 47 | pc.printf("Gyro Temperature: %3.d\t", PX4.gyro_temperature()); |
altb2 | 0:4b02060af95b | 48 | pc.printf("Integration Timespan: %8.0d\t", PX4.integration_timespan()); |
altb2 | 0:4b02060af95b | 49 | pc.printf("\r\n"); |
altb2 | 0:4b02060af95b | 50 | |
altb2 | 0:4b02060af95b | 51 | } else { |
altb2 | 0:4b02060af95b | 52 | pc.printf("TimeOut\r\n"); |
altb2 | 0:4b02060af95b | 53 | } |
altb2 | 0:4b02060af95b | 54 | #endif |
altb2 | 0:4b02060af95b | 55 | wait(0.1); |
altb2 | 0:4b02060af95b | 56 | } |
altb2 | 0:4b02060af95b | 57 | } |
altb2 | 0:4b02060af95b | 58 |