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 INA226_ver1 mbed-rtos mbed SDFileSystem-RTOS
Fork of keiki2017 by
Fusokukei.h
- Committer:
- tsumagari
- Date:
- 2017-01-28
- Branch:
- noThread2017ver.
- Revision:
- 27:d2955f29a3aa
- Parent:
- 15:6966299bea4c
- Child:
- 51:f391d3a02397
File content as of revision 27:d2955f29a3aa:
#ifndef FUSOKUKEI_H #define FUSOKUKEI_H #include "mbed.h" #define AIR_K 4.70591884 //0.14737 #define AIR_N 1.12 #define AIR_A 1.4314 #define AIR_B 0.209 #define AIR_SUM_NUM 20 #define AIR_BUFFER 30 float airSpeed = 0.0; float airSpeed_ave = 0.0; float airSpeed_max = 0.0; int air_counter = 0; float air_sum[AIR_SUM_NUM] = {0.0}; class Fusokukei{ protected: public: float make_ave(float s[], int n){ float p = 0; int i; for(i = 0; i < n; i++){ p += s[i]; } if(n != 0) return p / n; else return 0; } void calcAirSpeed(float x){ air_sum[air_counter % AIR_SUM_NUM] = (float)AIR_K * (float)pow((double)(x/150.0), 1 / AIR_N); if(air_counter % AIR_SUM_NUM == 0) air_counter = 0; airSpeed_ave = make_ave(air_sum, AIR_SUM_NUM); //airSpeed = airSpeed_ave*AIR_A+AIR_B; airSpeed=airSpeed_ave; if(airSpeed > airSpeed_max) airSpeed_max = airSpeed; air_counter++; } }; #endif