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
- Committer:
- tsumagari
- Date:
- 2017-05-05
- Branch:
- Thread-gyogetsuMPU
- Revision:
- 52:a94cbaef3602
- Parent:
- 51:f391d3a02397
File content as of revision 52:a94cbaef3602:
#ifndef FUSOKUKEI_H
#define FUSOKUKEI_H
#include "mbed.h"
#define AIR_K 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*5, 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
//#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 3
//#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(int x){
// air_sum[air_counter % AIR_SUM_NUM] = (float)AIR_K * (float)pow((double)(x/150.0), 1 / AIR_N);
//
// 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;
// if(air_counter % AIR_SUM_NUM == 0){
// air_counter = 0;
// }
// air_counter++;
// }
//};
//#endif
