大学生
最后登录1970-1-1
在线时间 小时
注册时间2016-11-2
|
- class PulseOximeter
- {
- public:
- PulseOximeter();
- float getTemperature();
- DCRemover irDCRemover;
- DCRemover redDCRemover;
- private:
- FilterBuLp1 lpf;
- }
- float PulseOximeter::getTemperature()
- {
- return temperature;
- }
- class FilterBuLp1
- {
- public:
- FilterBuLp1()
- {
- v[0]=0.0;
- }
- private:
- float v[2];
- public:
- float step(float x) //class II
- {
- v[0] = v[1];
- v[1] = (2.452372752527856026e-1 * x)
- + (0.50952544949442879485 * v[0]);
- return
- (v[0] + v[1]);
- }
- };
- class DCRemover
- {
- public:
- DCRemover() : alpha(0), dcw(0)
- {
- }
- DCRemover(float alpha_) : alpha(alpha_), dcw(0)
- {
- }
- float step(float x)
- {
- float olddcw = dcw;
- dcw = (float)x + alpha * dcw;
- return dcw - olddcw;
- }
- float getDCW()
- {
- return dcw;
- }
- private:
- float alpha;
- float dcw;
- };
- #endif
- float irACValue = irDCRemover.step(hrm.rawIRValue);
- float redACValue = redDCRemover.step(hrm.rawRedValue);
- float filteredPulseValue = lpf.step(-irACValue);
- if (irDCRemover.getDCW() - redDCRemover.getDCW() > 70000 && redLedPower < max30100_LED_CURR_50MA)
- {
- ++redLedPower;
- changed = true;
- }
- else if (redDCRemover.getDCW() - irDCRemover.getDCW() > 70000 && redLedPower > 0)
- {
- --redLedPower;
- }
复制代码 这段代码怎么改成C语言呢?我花了一段时间,改的不对啊。主要就是改成c的结构体后,(用定义的类结构名再定义两个另外的类名, float irACValue = irDCRemover.step(hrm.rawIRValue);
float redACValue = redDCRemover.step(hrm.rawRedValue); 怎么引用它里面成员)这个问题
|
|