添加莫尔斯译码器

Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
2022-03-06 13:20:10 +08:00
parent 3d017dd9fe
commit 88344b12bd
28 changed files with 12883 additions and 14189 deletions
+62
View File
@@ -0,0 +1,62 @@
/*
* key.c
*
* Created on: 2022Äê3ÔÂ5ÈÕ
* Author: wuwen
*/
#include "key.h"
struct button k1,k2,k3;
void GEI_BUTTON_CODE(struct button *bt,uint8_t in)
{
#define t 250
bt->code=0;
if(in==0)
{
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==1)
{
if(bt->lock==1)
{
if(bt->code==-1)
{
}else
{
bt->code=bt->times;
}
bt->lock=0;
}
}
}
+30
View File
@@ -0,0 +1,30 @@
/*
* key.h
*
* Created on: 2022Äê3ÔÂ5ÈÕ
* Author: wuwen
*/
#ifndef KEY_H_
#define KEY_H_
#include "main.h"
#define KEY0 HAL_GPIO_ReadPin(KEY0_GPIO_Port, KEY0_Pin)
#define KEY1 HAL_GPIO_ReadPin(KEY1_GPIO_Port, KEY1_Pin)
#define KEY2 HAL_GPIO_ReadPin(KEY2_GPIO_Port, KEY2_Pin)
#define KEY3 HAL_GPIO_ReadPin(KEY3_GPIO_Port, KEY3_Pin)
extern struct button k1,k2,k3;
struct button
{
int code;
uint8_t lock;
uint32_t time;
int times;
};
void GEI_BUTTON_CODE(struct button *bt,uint8_t in);
#endif /* KEY_H_ */