MR16/User/component/keyStatusCheck.c

34 lines
603 B
C

#include "keyStatusCheck.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "bsp/time.h"
/* USER INCLUDE BEGIN */
/* USER INCLUDE END */
/* USER DEFINE BEGIN */
/* USER DEFINE END */
/* USER FUNCTION BEGIN */
bool Key_rise(bool key,bool lastkey) {
return !key && lastkey;
}
bool Key_fall(bool key,bool lastkey) {
return key && !lastkey;
}
bool Key_press(bool key,bool lastkey,float now,float detectTime) {
static float last = 0;
if (key&&lastkey) {
if(now-last>detectTime)return true;
}
last=now;
return false;
}
/* USER FUNCTION END */