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: SDFileSystem mbed
Fork of keiki2016ver3 by
Fusokukei.h
00001 #ifndef FUSOKUKEI_H 00002 #define FUSOKUKEI_H 00003 00004 #include "mbed.h" 00005 00006 #define AIR_K 0.14737 00007 #define AIR_N 1.19 00008 #define AIR_A 1.4314 00009 #define AIR_B 0.209 00010 #define AIR_SUM_NUM 20 00011 #define AIR_BUFFER 30 00012 00013 float airSpeed = 0.0; 00014 float airSpeed_ave = 0.0; 00015 float airSpeed_max = 0.0; 00016 int air_counter = 0; 00017 float air_sum[AIR_SUM_NUM] = {0.0}; 00018 00019 class Fusokukei{ 00020 protected: 00021 00022 public: 00023 float make_ave(float s[], int n){ 00024 float p = 0; 00025 int i; 00026 for(i = 0; i < n; i++){ 00027 p += s[i]; 00028 } 00029 if(n != 0) 00030 return p / n; 00031 else 00032 return 0; 00033 } 00034 00035 void calcAirSpeed(float x){ 00036 air_sum[air_counter % AIR_SUM_NUM] = (float)AIR_K * (float)pow((double)x, 1 / AIR_N); 00037 if(air_counter % AIR_SUM_NUM == 0) 00038 air_counter = 0; 00039 airSpeed_ave = make_ave(air_sum, AIR_SUM_NUM); 00040 airSpeed = airSpeed_ave*AIR_A+AIR_B; 00041 if(airSpeed > airSpeed_max) 00042 airSpeed_max = airSpeed; 00043 air_counter++; 00044 } 00045 }; 00046 #endif
Generated on Tue Jul 26 2022 22:30:12 by
1.7.2
