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: BufferedSoftSerial2 SDFileSystem-RTOS mbed mbed-rtos INA226_ver1
Fork of keiki2016ver5 by
Fusokukei.h
00001 #ifndef FUSOKUKEI_H 00002 #define FUSOKUKEI_H 00003 00004 #include "mbed.h" 00005 00006 00007 #define AIR_K 0.14737 00008 #define AIR_N 1.12 00009 #define AIR_A 1.4314 00010 #define AIR_B 0.209 00011 #define AIR_SUM_NUM 20 00012 #define AIR_BUFFER 30 00013 00014 float airSpeed = 0.0; 00015 float airSpeed_ave = 0.0; 00016 float airSpeed_max = 0.0; 00017 int air_counter = 0; 00018 float air_sum[AIR_SUM_NUM] = {0.0}; 00019 00020 class Fusokukei{ 00021 protected: 00022 00023 public: 00024 float make_ave(float s[], int n){ 00025 float p = 0; 00026 int i; 00027 for(i = 0; i < n; i++){ 00028 p += s[i]; 00029 } 00030 if(n != 0) 00031 return p / n; 00032 else 00033 return 0; 00034 } 00035 00036 void calcAirSpeed(float x){ 00037 air_sum[air_counter % AIR_SUM_NUM] = 0.0529*x;//2017 5/27 校正 00038 /*(float)AIR_K * (float)pow((double)x, 1 / AIR_N);*/ 00039 if(air_counter % AIR_SUM_NUM == 0) 00040 air_counter = 0; 00041 airSpeed_ave = make_ave(air_sum, AIR_SUM_NUM); 00042 //airSpeed = airSpeed_ave*AIR_A+AIR_B; 00043 airSpeed=airSpeed_ave; 00044 if(airSpeed > airSpeed_max) 00045 airSpeed_max = airSpeed; 00046 air_counter++; 00047 } 00048 }; 00049 #endif 00050 //#ifndef FUSOKUKEI_H 00051 //#define FUSOKUKEI_H 00052 // 00053 //#include "mbed.h" 00054 // 00055 // 00056 //#define AIR_K 4.70591884 //0.14737 00057 //#define AIR_N 1.12 00058 //#define AIR_A 1.4314 00059 //#define AIR_B 0.209 00060 //#define AIR_SUM_NUM 3 00061 //#define AIR_BUFFER 30 00062 // 00063 //float airSpeed = 0.0; 00064 //float airSpeed_ave = 0.0; 00065 //float airSpeed_max = 0.0; 00066 //int air_counter = 0; 00067 //float air_sum[AIR_SUM_NUM] = {0.0}; 00068 // 00069 //class Fusokukei{ 00070 // protected: 00071 // 00072 // public: 00073 // float make_ave(float s[], int n){ 00074 // float p = 0; 00075 // int i; 00076 // for(i = 0; i < n; i++){ 00077 // p += s[i]; 00078 // } 00079 // if(n != 0) 00080 // return p / n; 00081 // else 00082 // return 0; 00083 // } 00084 // 00085 // void calcAirSpeed(int x){ 00086 // air_sum[air_counter % AIR_SUM_NUM] = (float)AIR_K * (float)pow((double)(x/150.0), 1 / AIR_N); 00087 // 00088 // airSpeed_ave = make_ave(air_sum, AIR_SUM_NUM); 00089 // 00090 // //airSpeed = airSpeed_ave*AIR_A+AIR_B; 00091 // airSpeed=airSpeed_ave; 00092 // if(airSpeed > airSpeed_max) 00093 // airSpeed_max = airSpeed; 00094 // if(air_counter % AIR_SUM_NUM == 0){ 00095 // air_counter = 0; 00096 // } 00097 // air_counter++; 00098 // } 00099 //}; 00100 //#endif
Generated on Sat Jul 16 2022 23:53:49 by
1.7.2
