虽然显示翻车了,其他部分还好,按钮成功调用,电机实现冷启动

This commit is contained in:
2021-10-03 17:34:31 +08:00
parent 340f563d1c
commit 9c79a675f4
12 changed files with 5749 additions and 2762 deletions
+64
View File
@@ -0,0 +1,64 @@
/*
* button.c
*
* Created on: 2021年10月3日
* Author: wuwenfeng
*/
#include "button.h"
void GEI_BUTTON_CODE(struct button *bt,uint8_t in)
{
#define t 250
bt->code=0;
if(in==1)
{
if(bt->lock==0)
{
if(HAL_GetTick()<bt->time+t)
{
bt->times++;
bt->time=HAL_GetTick();
bt->lock=1;
}else
{
bt->times=1;
bt->time=HAL_GetTick();
bt->lock=1;
}
}
if(bt->lock==1)
{
if(HAL_GetTick()>bt->time+t)
{
bt->code=-1;
bt->times=-1;
}
}
}
if(in==0)
{
if(bt->lock==1)
{
if(bt->code==-1)
{
}else
{
bt->code=bt->times;
}
bt->lock=0;
}
}
}