按钮驱动
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* Author: wuwenfeng
|
||||
*/
|
||||
#include "my_main.h"
|
||||
#include "button.h"
|
||||
|
||||
#define HC595_DCK(x) HAL_GPIO_WritePin(HC595_DCK_GPIO_Port, HC595_DCK_Pin, x);
|
||||
#define HC595_RCK(x) HAL_GPIO_WritePin(HC595_RCK_GPIO_Port, HC595_RCK_Pin, x);
|
||||
@@ -13,6 +14,13 @@
|
||||
#define MOTA(x) HAL_GPIO_WritePin(MOTA_GPIO_Port, MOTA_Pin, x);
|
||||
#define MOTB(x) HAL_GPIO_WritePin(MOTB_GPIO_Port, MOTB_Pin, x);
|
||||
|
||||
#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)
|
||||
#define KEY4 HAL_GPIO_ReadPin(KEY4_GPIO_Port, KEY4_Pin)
|
||||
|
||||
struct button key1,key2,key3,key4;
|
||||
|
||||
const char d_num_data[2][10]=
|
||||
{
|
||||
{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f},
|
||||
@@ -134,6 +142,7 @@ void mymain()
|
||||
HC595_SCK(0);
|
||||
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(HAL_GetTick()>runtime)
|
||||
@@ -154,6 +163,11 @@ void mymain()
|
||||
dis_buff.led_run=rand()%2;
|
||||
}
|
||||
|
||||
GEI_BUTTON_CODE(&key1,KEY1);
|
||||
GEI_BUTTON_CODE(&key2,KEY2);
|
||||
GEI_BUTTON_CODE(&key3,KEY3);
|
||||
GEI_BUTTON_CODE(&key4,KEY4);
|
||||
|
||||
display();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user