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@1:562a583eb77c, 2019-08-21 (annotated)
- Committer:
- altb2
- Date:
- Wed Aug 21 13:21:41 2019 +0000
- Revision:
- 1:562a583eb77c
- Parent:
- 0:4b02060af95b
- Child:
- 3:e03714326b83
Just log data
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 | 1:562a583eb77c | 4 | #define INTEGRAL false |
altb2 | 0:4b02060af95b | 5 | |
altb2 | 0:4b02060af95b | 6 | DigitalOut myled(LED1); |
altb2 | 1:562a583eb77c | 7 | //I2C i2c(PA_10,PA_9); |
altb2 | 1:562a583eb77c | 8 | I2C i2c(PC_9, PA_8); |
altb2 | 0:4b02060af95b | 9 | Serial pc(SERIAL_TX, SERIAL_RX); |
altb2 | 0:4b02060af95b | 10 | PX4Flow PX4(i2c,pc); |
altb2 | 0:4b02060af95b | 11 | |
altb2 | 0:4b02060af95b | 12 | |
altb2 | 0:4b02060af95b | 13 | |
altb2 | 0:4b02060af95b | 14 | int main() |
altb2 | 0:4b02060af95b | 15 | { |
altb2 | 0:4b02060af95b | 16 | i2c.frequency(400000); |
altb2 | 0:4b02060af95b | 17 | pc.baud(2000000); |
altb2 | 0:4b02060af95b | 18 | while(1) { |
altb2 | 0:4b02060af95b | 19 | |
altb2 | 1:562a583eb77c | 20 | if(1){ |
altb2 | 0:4b02060af95b | 21 | if(PX4.update()) { |
altb2 | 1:562a583eb77c | 22 | //pc.printf("Frame Count: %4.0d\t", PX4.frame_count()); |
altb2 | 1:562a583eb77c | 23 | // pc.printf("Pixel Flow X Sum: %d\t", -PX4.pixel_flow_y_sum()); |
altb2 | 1:562a583eb77c | 24 | // pc.printf("Pixel Flow Y Sum: %d\t", -PX4.pixel_flow_x_sum()); |
altb2 | 1:562a583eb77c | 25 | pc.printf("Flow Comp. M X.: %4d\t", -PX4.flow_comp_m_y()); |
altb2 | 1:562a583eb77c | 26 | pc.printf("Flow Comp. M Y.: %4d\t", -PX4.flow_comp_m_x()); |
altb2 | 1:562a583eb77c | 27 | pc.printf("Quality: %d\t", PX4.qual()); |
altb2 | 1:562a583eb77c | 28 | pc.printf("Gyro X: %d\t", PX4.gyro_x_rate()); |
altb2 | 1:562a583eb77c | 29 | pc.printf("Gyro Y: %d\t", PX4.gyro_y_rate()); |
altb2 | 1:562a583eb77c | 30 | pc.printf("Gyro Z: %d\t", PX4.gyro_z_rate()); |
altb2 | 1:562a583eb77c | 31 | //pc.printf("Sonar Timestamp: %3.d\t", PX4.sonar_timestamp()); |
altb2 | 1:562a583eb77c | 32 | pc.printf("z: %.3f\t", float(PX4.ground_distance())/1000); |
altb2 | 0:4b02060af95b | 33 | pc.printf("\r\n"); |
altb2 | 0:4b02060af95b | 34 | } else { |
altb2 | 0:4b02060af95b | 35 | pc.printf("TimeOut\r\n"); |
altb2 | 0:4b02060af95b | 36 | } |
altb2 | 1:562a583eb77c | 37 | } |
altb2 | 1:562a583eb77c | 38 | else |
altb2 | 1:562a583eb77c | 39 | { |
altb2 | 0:4b02060af95b | 40 | if(PX4.update_integral()) { |
altb2 | 1:562a583eb77c | 41 | // pc.printf("Frame Count: %3.0d\t", PX4.frame_count_since_last_readout()); |
altb2 | 0:4b02060af95b | 42 | pc.printf("Pixel Flow X Integral: %3.0d\t", PX4.pixel_flow_x_integral()); |
altb2 | 0:4b02060af95b | 43 | pc.printf("Pixel Flow Y Integral: %3.0d\t", PX4.pixel_flow_y_integral()); |
altb2 | 0:4b02060af95b | 44 | pc.printf("Gyro X Rate: %3.0d\t", PX4.gyro_x_rate_integral()); |
altb2 | 0:4b02060af95b | 45 | pc.printf("Gyro Y Rate: %3.0d\t", PX4.gyro_y_rate_integral()); |
altb2 | 0:4b02060af95b | 46 | pc.printf("Gyro Z Rate: %3.0d\t", PX4.gyro_z_rate_integral()); |
altb2 | 0:4b02060af95b | 47 | pc.printf("Quality: %3.0d\t", PX4.quality_integral()); |
altb2 | 0:4b02060af95b | 48 | pc.printf("Sonar Timestamp: %10.d\t", PX4.sonar_timestamp_integral()); |
altb2 | 0:4b02060af95b | 49 | pc.printf("Ground Distance: %3.d\t", PX4.ground_distance_integral()); |
altb2 | 0:4b02060af95b | 50 | pc.printf("Gyro Temperature: %3.d\t", PX4.gyro_temperature()); |
altb2 | 0:4b02060af95b | 51 | pc.printf("Integration Timespan: %8.0d\t", PX4.integration_timespan()); |
altb2 | 0:4b02060af95b | 52 | pc.printf("\r\n"); |
altb2 | 0:4b02060af95b | 53 | |
altb2 | 0:4b02060af95b | 54 | } else { |
altb2 | 0:4b02060af95b | 55 | pc.printf("TimeOut\r\n"); |
altb2 | 0:4b02060af95b | 56 | } |
altb2 | 1:562a583eb77c | 57 | } |
altb2 | 1:562a583eb77c | 58 | wait(0.025 ); |
altb2 | 0:4b02060af95b | 59 | } |
altb2 | 0:4b02060af95b | 60 | } |
altb2 | 0:4b02060af95b | 61 |