Emery Premeaux
/
MS4525_pitot_tube
Library and demo program for MS4525DO differential pressure sensor based pitot tube, using I2C interface
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "F303_logger.h" 00003 #include "MS4525DO.h" 00004 00005 Serial terminal(USBTX, USBRX); 00006 I2C i2c(I2CSDA, I2CSCL); 00007 00008 MS4525DO Pitot(i2c); 00009 00010 DigitalOut myled(LED1); 00011 00012 00013 int main() { 00014 terminal.baud(115200); 00015 terminal.printf("MS4525DO library test\n"); 00016 00017 while(1) { 00018 char PitotStatus; // A two bit field indicating the status of the I2C read 00019 PitotStatus = Pitot.measure(); 00020 00021 switch (PitotStatus) 00022 { 00023 case 0: 00024 //Serial.println("Ok "); 00025 terminal.printf("PSI: %f\n", Pitot.getPSI()); 00026 terminal.printf("Temperature: %f\n", Pitot.getTemperature()); 00027 terminal.printf("Airspeed: %f\n", Pitot.getAirSpeed()); 00028 terminal.printf("\n"); 00029 break; 00030 00031 case 1: 00032 terminal.printf("Busy\n"); 00033 break; 00034 00035 case 2: 00036 terminal.printf("Stale\n"); 00037 break; 00038 00039 default: 00040 terminal.printf("Error\n"); 00041 break; 00042 } 00043 myled = !myled; 00044 wait_ms(200); 00045 } 00046 }
Generated on Tue Jul 12 2022 21:49:13 by 1.7.2