修正port轮询事件

This commit is contained in:
cdy 2017-02-11 16:54:29 +08:00
parent e598963980
commit 9aacf9d6e7
2 changed files with 99 additions and 91 deletions

View File

@ -139,7 +139,8 @@ bool Port_Reserve(Pin pin, bool flag)
Reserved[port] |= bit;
debug_printf("打开 P%c%d", _PIN_NAME(pin));
} else {
}
else {
Reserved[port] &= ~bit;
debug_printf("关闭 P%c%d", _PIN_NAME(pin));
@ -389,10 +390,14 @@ void InputPort::InputTask(void* param)
if (v & Falling) port->Press(*port, false);
}
static void InputNoIRQTask(void* param)
void InputPort::InputNoIRQTask(void* param)
{
auto port = (InputPort*)param;
port->OnPress(port->Read());
auto val = port->Read();
if (val == port->Val) return;
port->Val = val;
port->OnPress(val);
}
void InputPort::OnOpen()

View File

@ -184,16 +184,19 @@ protected:
private:
bool _IRQ = false;
byte _Value = 0; // 当前值
uint _task = 0; // 输入任务
UInt64 _Start = 0; // 开始按下时间
UInt64 _Last = 0; // 最后一次触发时间
static void InputTask(void* param);
static void InputNoIRQTask(void* param);
private:
void OpenPin();
void ClosePin();
bool OnRegister();
byte _Value = 0; // 当前值
bool Val = false;
};
/******************************** AnalogInPort ********************************/