SmartOS/App/ACZero.h

33 lines
653 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __ACZero_H__
#define __ACZero_H__
#include "Kernel\TTime.h"
#include "Device\Port.h"
// 交流过零检测
class ACZero
{
public:
InputPort Port; // 交流过零检测引脚
int Period; // 周期us
int Width; // 零点信号宽度ms
uint Count; // 累计次数
TimeCost Last; // 上一次零点
ACZero();
~ACZero();
// 设置引脚0下拉1上拉2自动检测
void Set(Pin pin, byte invert = 0);
bool Open();
void Close();
// 等待下一次零点,需要考虑继电器动作延迟
bool Wait(int usDelay = 0) const;
private:
void OnHandler(InputPort& port, bool down);
};
#endif