From cf499a0fe5855ea2c63f2abe78f9a45da53586e2 Mon Sep 17 00:00:00 2001 From: Happy <54226355+HappyFacade@users.noreply.github.com> Date: Tue, 7 Apr 2020 09:07:07 -0700 Subject: [PATCH] Add syntax highlighting to readme --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 58b0263..d6045fa 100644 --- a/README.md +++ b/README.md @@ -6,29 +6,29 @@ MultiButton 是一个小巧简单易用的事件驱动型按键驱动模块, ## 使用方法 1.先申请一个按键结构 -``` +```c struct Button button1; ``` 2.初始化按键对象,绑定按键的GPIO电平读取接口**read_button_pin()** ,后一个参数设置有效触发电平 -``` +```c button_init(&button1, read_button_pin, 0); ``` 3.注册按键事件 -``` +```c button_attach(&button1, SINGLE_CLICK, Callback_SINGLE_CLICK_Handler); button_attach(&button1, DOUBLE_CLICK, Callback_DOUBLE_Click_Handler); ... ``` 4.启动按键 -``` +```c button_start(&button1); ``` 5.设置一个5ms间隔的定时器循环调用后台处理函数 -``` +```c while(1) { ... if(timer_ticks == 5) { @@ -43,7 +43,7 @@ while(1) { MultiButton 使用C语言实现,基于面向对象方式设计思路,每个按键对象单独用一份数据结构管理: -``` +```c struct Button { uint16_t ticks; uint8_t repeat: 4; @@ -75,7 +75,7 @@ LONG_PRESS_HOLD | 长按期间一直触发 ## Examples -``` +```c #include "button.h" struct Button btn1;