国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

分享一款嵌入式開源按鍵框架代碼工程MultiButton

這篇具有很好參考價值的文章主要介紹了分享一款嵌入式開源按鍵框架代碼工程MultiButton。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

一、工程簡介

  MultiButton 是一個小巧簡單易用的事件驅(qū)動型按鍵驅(qū)動模塊。

  Github地址:https://github.com/0x1abin/MultiButton

  這個項目非常精簡,只有兩個文件:

 ?。?)可無限擴(kuò)展按鍵;

 ?。?)按鍵事件的回調(diào)異步處理方式可以簡化程序結(jié)構(gòu),去除冗余的按鍵處理硬編碼,讓按鍵業(yè)務(wù)邏輯更清晰。

分享一款嵌入式開源按鍵框架代碼工程MultiButton

  通過此工程可以學(xué)習(xí)到以下知識點:

 ?。?)按鍵各種類型事件;

 ?。?)狀態(tài)機(jī)的思想;

 ?。?)單向鏈表語法。

  工程支持如下的按鍵事件:

分享一款嵌入式開源按鍵框架代碼工程MultiButton

?  MultiButton 的按鍵狀態(tài)及軟件流程圖:

分享一款嵌入式開源按鍵框架代碼工程MultiButton

?二、工程代碼分析

  注:在使用源碼工程時稍微修改了兩個點,后續(xù)貼出修改后的完整代碼,有需要查看修改的同學(xué)可以將源碼工程下載后進(jìn)行對比,修改的點如下:

 ?。?)將按鍵時間的相關(guān)參數(shù)通過接口定義進(jìn)行初始化;

  (2)修改按鍵長按期間一直觸發(fā)事件為真正的長按按鍵定時觸發(fā)事件。

  在頭文件multi_button.h中包括:

  (1)定義了按鍵時間相關(guān)參數(shù);

  (2)定義了按鍵的事件類型;

  (3)定義按鍵鏈表結(jié)構(gòu)體,這里使用了位域操作,解決字節(jié)的存儲空間問題。

 1 #ifndef _MULTI_BUTTON_H_
 2 #define _MULTI_BUTTON_H_
 3  
 4 #include <stdint.h>
 5 #include <string.h>
 6  
 7 typedef struct ButtonPara {
 8   uint8_t ticks_interval;
 9   uint8_t debounce_ticks;
10   uint16_t short_ticks;
11   uint16_t long_ticks;
12 }ButtonPara;
13  
14 typedef void (*BtnCallback)(void*);
15  
16 typedef enum {
17   PRESS_DOWN = 0,
18   PRESS_UP,
19   PRESS_REPEAT,
20   SINGLE_CLICK,
21   DOUBLE_CLICK,
22   LONG_PRESS_START,
23   LONG_PRESS_HOLD,
24   number_of_event,
25   NONE_PRESS
26 }PressEvent;
27  
28 typedef struct Button {
29   uint16_t ticks;
30   uint8_t  repeat : 4;
31   uint8_t  event : 4;
32   uint8_t  state : 3;
33   uint8_t  debounce_cnt : 3;
34   uint8_t  active_level : 1;
35   uint8_t  button_level : 1;
36   uint8_t  button_id;
37   uint8_t  (*hal_button_Level)(uint8_t button_id_);
38   BtnCallback  cb[number_of_event];
39   struct Button* next;
40 }Button;
41  
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 void button_para_init(struct ButtonPara para);
46 void button_init(struct Button* handle, uint8_t(*pin_level)(uint8_t), uint8_t active_level, uint8_t button_id);
47 void button_attach(struct Button* handle, PressEvent event, BtnCallback cb);
48 PressEvent get_button_event(struct Button* handle);
49 int  button_start(struct Button* handle);
50 void button_stop(struct Button* handle);
51 void button_ticks(void);
52  
53 #ifdef __cplusplus
54 }
55 #endif
56  
57 #endif

  在源碼文件multi_button.c中包括:

  (1)對按鍵時間參數(shù)進(jìn)行初始化;

 ?。?)對按鍵對象結(jié)構(gòu)體進(jìn)行初始化,初始化成員包括按鍵句柄,綁定GPIO電平讀取函數(shù),設(shè)置有效觸發(fā)電平;

  (3)初始化按鍵完成之后,進(jìn)行按鍵綁定操作,將綁定按鍵結(jié)構(gòu)體成員,按鍵觸發(fā)事件,按鍵回調(diào)函數(shù);

 ?。?)按鍵啟動:也就是將按鍵加入鏈表當(dāng)中,啟動按鍵。這里選擇的插入方式是頭部插入法,在鏈表的頭部插入按鍵節(jié)點,效率高,時間復(fù)雜度為O(1);

 ?。?)按鍵刪除:將按鍵從當(dāng)前鏈表中刪除。使用到了二級指針刪除一個按鍵元素。與鏈表中成員刪除方法相同;

 ?。?)按鍵滴答函數(shù):每間隔Nms觸發(fā)一次按鍵事件,驅(qū)動狀態(tài)機(jī)運(yùn)行;

 ?。?)讀取當(dāng)前引腳的狀態(tài),獲取按鍵當(dāng)前屬于哪種狀態(tài);

 ?。?)按鍵處理核心函數(shù),驅(qū)動狀態(tài)機(jī)。

  1 #include "multi_button.h"
  2  
  3 #define EVENT_CB(ev)   if(handle->cb[ev])handle->cb[ev]((void*)handle)
  4 #define PRESS_REPEAT_MAX_NUM  15 /*!< The maximum value of the repeat counter */
  5  
  6 static struct ButtonPara buttonpara;
  7 //button handle list head.
  8 static struct Button* head_handle = NULL;
  9  
 10 static void button_handler(struct Button* handle);
 11  
 12  
 13 void button_para_init(struct ButtonPara para)
 14 {
 15   buttonpara.ticks_interval = para.ticks_interval;
 16   buttonpara.debounce_ticks = para.debounce_ticks;
 17   buttonpara.short_ticks = para.short_ticks;
 18   buttonpara.long_ticks = para.long_ticks;
 19 }
 20 /**
 21   * @brief  Initializes the button struct handle.
 22   * @param  handle: the button handle struct.
 23   * @param  pin_level: read the HAL GPIO of the connected button level.
 24   * @param  active_level: pressed GPIO level.
 25   * @param  button_id: the button id.
 26   * @retval None
 27   */
 28 void button_init(struct Button* handle, uint8_t(*pin_level)(uint8_t), uint8_t active_level, uint8_t button_id)
 29 {
 30   memset(handle, 0, sizeof(struct Button));
 31   handle->event = (uint8_t)NONE_PRESS;
 32   handle->hal_button_Level = pin_level;
 33   handle->button_level = handle->hal_button_Level(button_id);
 34   handle->active_level = active_level;
 35   handle->button_id = button_id;
 36 }
 37  
 38 /**
 39   * @brief  Attach the button event callback function.
 40   * @param  handle: the button handle struct.
 41   * @param  event: trigger event type.
 42   * @param  cb: callback function.
 43   * @retval None
 44   */
 45 void button_attach(struct Button* handle, PressEvent event, BtnCallback cb)
 46 {
 47   handle->cb[event] = cb;
 48 }
 49  
 50 /**
 51   * @brief  Inquire the button event happen.
 52   * @param  handle: the button handle struct.
 53   * @retval button event.
 54   */
 55 PressEvent get_button_event(struct Button* handle)
 56 {
 57   return (PressEvent)(handle->event);
 58 }
 59  
 60 /**
 61   * @brief  Button driver core function, driver state machine.
 62   * @param  handle: the button handle struct.
 63   * @retval None
 64   */
 65 static void button_handler(struct Button* handle)
 66 {
 67   uint8_t read_gpio_level = handle->hal_button_Level(handle->button_id);
 68  
 69   //ticks counter working..
 70   if((handle->state) > 0) handle->ticks++;
 71  
 72   /*------------button debounce handle---------------*/
 73   if(read_gpio_level != handle->button_level) { //not equal to prev one
 74     //continue read 3 times same new level change
 75     if(++(handle->debounce_cnt) >= buttonpara.debounce_ticks) {
 76       handle->button_level = read_gpio_level;
 77       handle->debounce_cnt = 0;
 78     }
 79   } else { //level not change ,counter reset.
 80     handle->debounce_cnt = 0;
 81   }
 82  
 83   /*-----------------State machine-------------------*/
 84   switch (handle->state) {
 85   case 0:
 86     if(handle->button_level == handle->active_level) {  //start press down
 87       handle->event = (uint8_t)PRESS_DOWN;
 88       EVENT_CB(PRESS_DOWN);
 89       handle->ticks = 0;
 90       handle->repeat = 1;
 91       handle->state = 1;
 92     } else {
 93       handle->event = (uint8_t)NONE_PRESS;
 94     }
 95     break;
 96  
 97   case 1:
 98     if(handle->button_level != handle->active_level) { //released press up
 99       handle->event = (uint8_t)PRESS_UP;
100       EVENT_CB(PRESS_UP);
101       handle->ticks = 0;
102       handle->state = 2;
103     } else if(handle->ticks > buttonpara.long_ticks) {
104       handle->event = (uint8_t)LONG_PRESS_START;
105       EVENT_CB(LONG_PRESS_START);
106       handle->state = 5;
107     }
108     break;
109  
110   case 2:
111     if(handle->button_level == handle->active_level) { //press down again
112       handle->event = (uint8_t)PRESS_DOWN;
113       EVENT_CB(PRESS_DOWN);
114       if(handle->repeat != PRESS_REPEAT_MAX_NUM) {
115         handle->repeat++;
116       }
117       EVENT_CB(PRESS_REPEAT); // repeat hit
118       handle->ticks = 0;
119       handle->state = 3;
120     } else if(handle->ticks > buttonpara.short_ticks) { //released timeout
121       if(handle->repeat == 1) {
122         handle->event = (uint8_t)SINGLE_CLICK;
123         EVENT_CB(SINGLE_CLICK);
124       } else if(handle->repeat == 2) {
125         handle->event = (uint8_t)DOUBLE_CLICK;
126         EVENT_CB(DOUBLE_CLICK); // repeat hit
127       }
128       handle->state = 0;
129     }
130     break;
131  
132   case 3:
133     if(handle->button_level != handle->active_level) { //released press up
134       handle->event = (uint8_t)PRESS_UP;
135       EVENT_CB(PRESS_UP);
136       if(handle->ticks < buttonpara.short_ticks) {
137         handle->ticks = 0;
138         handle->state = 2; //repeat press
139       } else {
140         handle->state = 0;
141       }
142     } else if(handle->ticks > buttonpara.short_ticks) { // SHORT_TICKS < press down hold time < LONG_TICKS
143       handle->state = 1;
144     }
145     break;
146  
147   case 5:
148     if(handle->button_level == handle->active_level) {
149       //continue hold trigger
150       if(handle->ticks > buttonpara.long_ticks) {
151       handle->event = (uint8_t)LONG_PRESS_HOLD;
152       EVENT_CB(LONG_PRESS_HOLD);
153       handle->ticks = 0;
154       }
155     } else { //released
156       handle->event = (uint8_t)PRESS_UP;
157       EVENT_CB(PRESS_UP);
158       handle->state = 0; //reset
159     }
160     break;
161   default:
162     handle->state = 0; //reset
163     break;
164   }
165 }
166  
167 /**
168   * @brief  Start the button work, add the handle into work list.
169   * @param  handle: target handle struct.
170   * @retval 0: succeed. -1: already exist.
171   */
172 int button_start(struct Button* handle)
173 {
174   struct Button* target = head_handle;
175   while(target) {
176     if(target == handle) return -1;  //already exist.
177     target = target->next;
178   }
179   handle->next = head_handle;
180   head_handle = handle;
181   return 0;
182 }
183  
184 /**
185   * @brief  Stop the button work, remove the handle off work list.
186   * @param  handle: target handle struct.
187   * @retval None
188   */
189 void button_stop(struct Button* handle)
190 {
191   struct Button** curr;
192   for(curr = &head_handle; *curr; ) {
193     struct Button* entry = *curr;
194     if(entry == handle) {
195       *curr = entry->next;
196 //      free(entry);
197       return;//glacier add 2021-8-18
198     } else {
199       curr = &entry->next;
200     }
201   }
202 }
203  
204 /**
205   * @brief  background ticks, timer repeat invoking interval 5ms.
206   * @param  None.
207   * @retval None
208   */
209 void button_ticks(void)
210 {
211   struct Button* target;
212   for(target=head_handle; target; target=target->next) {
213     button_handler(target);
214   }
215 }

三、工程代碼應(yīng)用

  以在freertos中應(yīng)用為例,包括:

 ?。?)按鍵對象的定義及時間參數(shù)定義;

 ?。?)按鍵回調(diào)函數(shù)包括讀取按鍵電平函數(shù)和各按鍵事件處理函數(shù)的編寫;

  (3)按鍵初始化操作及啟動按鍵功能;

 ?。?)在while(1)中添加按鍵滴答函數(shù)。

  1 #define TICKS_INTERVAL    5  //按鍵狀態(tài)輪詢周期,單位ms
  2 #define DEBOUNCE_TICKS    3  //MAX 7 (0 ~ 7) 去抖時間次數(shù),此為15ms/TICKS_INTERVAL=3次
  3 #define SHORT_TICKS       (300 /TICKS_INTERVAL) //短按時間次數(shù),300ms/TICKS_INTERVAL 
  4 #define LONG_TICKS        (2000 /TICKS_INTERVAL) //長按時間次數(shù),2000ms/TICKS_INTERVAL
  5          
  6 enum Button_IDs {
  7   btn1_id,
  8   btn2_id,
  9   btn3_id,
 10 };
 11 struct ButtonPara btnpara = {TICKS_INTERVAL, DEBOUNCE_TICKS, SHORT_TICKS, LONG_TICKS};
 12 struct Button btn1;
 13 struct Button btn2;
 14 struct Button btn3;
 15  
 16 //According to your need to modify the constants.
 17  
 18 uint8_t read_button_GPIO(uint8_t button_id)
 19 {
 20   // you can share the GPIO read function with multiple Buttons
 21   switch(button_id)
 22   {
 23     case btn1_id:
 24       return GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_4);
 25     case btn2_id:
 26       return GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_3);
 27     case btn3_id:
 28       return GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2);
 29     default:
 30       return 0;
 31   }
 32 }
 33  
 34 void BTN1_PRESS_DOWN_Handler(void* btn)
 35 {
 36   printf("BTN1_PRESS_DOWN_Handler!\r\n");
 37 }
 38  
 39 void BTN1_PRESS_UP_Handler(void* btn)
 40 {
 41   printf("BTN1_PRESS_UP_Handler!\r\n");
 42 }
 43  
 44 void BTN1_PRESS_REPEAT_Handler(void* btn)
 45 {
 46   printf("BTN1_PRESS_REPEAT_Handler, repeatcount = %d!\r\n",btn1.repeat);
 47 }
 48  
 49 void BTN1_SINGLE_Click_Handler(void* btn)
 50 {
 51   printf("BTN1_SINGLE_Click_Handler!\r\n");
 52 }
 53  
 54 void BTN1_DOUBLE_Click_Handler(void* btn)
 55 {
 56   printf("BTN1_DOUBLE_Click_Handler!\r\n");
 57 }
 58  
 59 void BTN1_LONG_PRESS_START_Handler(void* btn)
 60 {
 61   printf("BTN1_LONG_PRESS_START_Handler!\r\n");
 62 }
 63  
 64 void BTN1_LONG_PRESS_HOLD_Handler(void* btn)
 65 {
 66   printf("BTN1_LONG_PRESS_HOLD_Handler!\r\n");
 67 }
 68  
 69 void BTN2_SINGLE_Click_Handler(void* btn)
 70 {
 71   printf("BTN2_SINGLE_Click_Handler!\r\n");
 72 }
 73  
 74 void BTN2_DOUBLE_Click_Handler(void* btn)
 75 {
 76   printf("BTN2_DOUBLE_Click_Handler!\r\n");
 77 }
 78  
 79 void BTN3_LONG_PRESS_START_Handler(void* btn)
 80 {
 81   printf("BTN3_LONG_PRESS_START_Handler!\r\n");
 82 }
 83  
 84 void BTN3_LONG_PRESS_HOLD_Handler(void* btn)
 85 {
 86   printf("BTN3_LONG_PRESS_HOLD_Handler!\r\n");
 87 }
 88  
 89 int main(void)
 90 { 
 91   button_para_init(btnpara);
 92   button_init(&btn1, read_button_GPIO, 0, btn1_id);
 93   button_init(&btn2, read_button_GPIO, 0, btn2_id);
 94   button_init(&btn3, read_button_GPIO, 0, btn3_id);
 95  
 96   button_attach(&btn1, PRESS_DOWN,       BTN1_PRESS_DOWN_Handler);
 97   button_attach(&btn1, PRESS_UP,         BTN1_PRESS_UP_Handler);
 98   button_attach(&btn1, PRESS_REPEAT,     BTN1_PRESS_REPEAT_Handler);
 99   button_attach(&btn1, SINGLE_CLICK,     BTN1_SINGLE_Click_Handler);
100   button_attach(&btn1, DOUBLE_CLICK,     BTN1_DOUBLE_Click_Handler);
101   button_attach(&btn1, LONG_PRESS_START, BTN1_LONG_PRESS_START_Handler);
102   button_attach(&btn1, LONG_PRESS_HOLD,  BTN1_LONG_PRESS_HOLD_Handler);
103  
104   button_attach(&btn2, PRESS_REPEAT,     BTN2_PRESS_REPEAT_Handler);
105   button_attach(&btn2, SINGLE_CLICK,     BTN2_SINGLE_Click_Handler);
106   button_attach(&btn2, DOUBLE_CLICK,     BTN2_DOUBLE_Click_Handler);
107   
108   button_attach(&btn3, LONG_PRESS_START, BTN3_LONG_PRESS_START_Handler);
109   button_attach(&btn3, LONG_PRESS_HOLD,  BTN3_LONG_PRESS_HOLD_Handler);
110  
111   button_start(&btn1);
112   button_start(&btn2);
113   button_start(&btn3);
114   
115  
116   xTaskCreate((TaskFunction_t )key_task,             
117                 (const char*    )"key_task",           
118                 (uint16_t       )KEY_STK_SIZE,        
119                 (void*          )NULL,                  
120                 (UBaseType_t    )KEY_TASK_PRIO,        
121                 (TaskHandle_t*  )&KeyTask_Handler);              
122     vTaskStartScheduler();          
123 }
124  
125  
126 void key_task(void *pvParameters)
127 {
128   while(1)
129   {
130     button_ticks();
131     vTaskDelay(5);      //5ms周期輪詢
132   }
133 }

四、思考

  使用中有如下問題值得思考:

 ?。?)組合鍵和矩陣按鍵如何實現(xiàn)?

  在函數(shù)uint8_t read_button_GPIO(uint8_t button_id)中進(jìn)行組合鍵和矩陣按鍵返回值的自定義。

 ?。?)多個按鍵時,按鍵參數(shù)進(jìn)行區(qū)分?

  去抖時間,短按時間,長按時間可以放在一個數(shù)組中區(qū)分,各個按鍵定義各自的參數(shù)。

 ?。?)現(xiàn)在按鍵事件較多的情況時,需要多個綁定的事件函數(shù)?

  可以將按鍵事件函數(shù)統(tǒng)一放在一個數(shù)組中進(jìn)行初始化注冊。


↓↓↓更多技術(shù)內(nèi)容和書籍資料獲取,入群技術(shù)交流敬請關(guān)注“明解嵌入式”↓↓↓?

分享一款嵌入式開源按鍵框架代碼工程MultiButton文章來源地址http://www.zghlxwxcb.cn/news/detail-852653.html

?

到了這里,關(guān)于分享一款嵌入式開源按鍵框架代碼工程MultiButton的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 嵌入式畢設(shè)分享 stm32的人體健康狀態(tài)檢測系統(tǒng)(項目開源)

    嵌入式畢設(shè)分享 stm32的人體健康狀態(tài)檢測系統(tǒng)(項目開源)

    ?? 這兩年開始畢業(yè)設(shè)計和畢業(yè)答辯的要求和難度不斷提升,傳統(tǒng)的畢設(shè)題目缺少創(chuàng)新和亮點,往往達(dá)不到畢業(yè)答辯的要求,這兩年不斷有學(xué)弟學(xué)妹告訴學(xué)長自己做的項目系統(tǒng)達(dá)不到老師的要求。 為了大家能夠順利以及最少的精力通過畢設(shè),學(xué)長分享優(yōu)質(zhì)畢業(yè)設(shè)計項目,今天

    2024年03月22日
    瀏覽(93)
  • 嵌入式畢設(shè)分享 stm32與GSM的遠(yuǎn)程無線智能報警系統(tǒng)(項目開源)

    嵌入式畢設(shè)分享 stm32與GSM的遠(yuǎn)程無線智能報警系統(tǒng)(項目開源)

    ?? 這兩年開始畢業(yè)設(shè)計和畢業(yè)答辯的要求和難度不斷提升,傳統(tǒng)的畢設(shè)題目缺少創(chuàng)新和亮點,往往達(dá)不到畢業(yè)答辯的要求,這兩年不斷有學(xué)弟學(xué)妹告訴學(xué)長自己做的項目系統(tǒng)達(dá)不到老師的要求。 為了大家能夠順利以及最少的精力通過畢設(shè),學(xué)長分享優(yōu)質(zhì)畢業(yè)設(shè)計項目,今天

    2024年02月20日
    瀏覽(88)
  • 【C C++開源庫】適合單片機(jī) 嵌入式的C語言單元測試庫_單片機(jī) 單元測試框架

    【C C++開源庫】適合單片機(jī) 嵌入式的C語言單元測試庫_單片機(jī) 單元測試框架

    #define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((thres

    2024年04月25日
    瀏覽(30)
  • 【速成】藍(lán)橋杯嵌入式省一教程:(五)用按鍵和屏幕實現(xiàn)嵌入式交互系統(tǒng)

    【速成】藍(lán)橋杯嵌入式省一教程:(五)用按鍵和屏幕實現(xiàn)嵌入式交互系統(tǒng)

    一個完整的嵌入式系統(tǒng),包括任務(wù)執(zhí)行部分和人機(jī)交互部分。在前四節(jié)中,我們已經(jīng)講解了LED、LCD和按鍵,用這三者就能夠?qū)崿F(xiàn)一個人機(jī)交互系統(tǒng),也即搭建整個嵌入式系統(tǒng)的框架。在后續(xù),只要將各個功能加入到這個交互系統(tǒng)中,即可完成整個嵌入式系統(tǒng)的設(shè)計。因此,盡

    2024年02月09日
    瀏覽(40)
  • 速通藍(lán)橋杯嵌入式省一教程:(五)用按鍵和屏幕實現(xiàn)嵌入式交互系統(tǒng)

    速通藍(lán)橋杯嵌入式省一教程:(五)用按鍵和屏幕實現(xiàn)嵌入式交互系統(tǒng)

    一個完整的嵌入式系統(tǒng),包括任務(wù)執(zhí)行部分和人機(jī)交互部分。在前四節(jié)中,我們已經(jīng)講解了LED、LCD和按鍵,用這三者就能夠?qū)崿F(xiàn)一個人機(jī)交互系統(tǒng),也即搭建整個嵌入式系統(tǒng)的框架。在后續(xù),只要將各個功能加入到這個交互系統(tǒng)中,即可完成整個嵌入式系統(tǒng)的設(shè)計。因此,盡

    2024年02月12日
    瀏覽(18)
  • 嵌入式51單片機(jī)04-矩陣按鍵系列

    嵌入式51單片機(jī)04-矩陣按鍵系列

    一、矩陣按鍵基礎(chǔ)知識 矩陣按鍵工作原理 : 逐行掃描 :通過高四位輪流輸出低電平來對矩陣鍵盤進(jìn)行掃描,當(dāng)?shù)退奈唤邮盏降臄?shù)據(jù)不全為1的時候,說明有按鍵按下,然后通過判斷低四位數(shù)據(jù)中哪一位為零來判斷哪一個按鍵被按下。 逐列掃描 :通過低四位輪流輸出低電平來

    2024年02月07日
    瀏覽(49)
  • 【嵌入式系統(tǒng)課設(shè)】單個按鍵控制LED燈

    【嵌入式系統(tǒng)課設(shè)】單個按鍵控制LED燈

    合工大嵌入式系統(tǒng)課程設(shè)計 設(shè)計要求: 根據(jù)單個按鍵輸入情況控制LED燈的不同顯示效果。K1連續(xù)按下偶數(shù)次時,四個LED燈(LED1~LED4)按1秒(定時器中斷實現(xiàn))的間隔同時閃爍對應(yīng)的次數(shù),然后保持LED1和LED2常亮,LED3和LED4熄滅;K1連續(xù)按下奇數(shù)次時,四個燈按0.5秒(定時器中斷實

    2024年02月12日
    瀏覽(19)
  • 全志V3S嵌入式驅(qū)動開發(fā)(多按鍵輸入驅(qū)動)

    全志V3S嵌入式驅(qū)動開發(fā)(多按鍵輸入驅(qū)動)

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 前面我們說過,荔枝派的開發(fā)板上面,有4個按鍵本身不是通過gpio連接到soc上面的。它是通過ad的方法,連接到主芯片的。這個時候,不同的按鍵被按下的時候,就會生成不同的電壓或

    2024年02月07日
    瀏覽(28)
  • 【嵌入式系統(tǒng)與入門】Day02 Arduino 按鍵、蜂鳴器與濕溫度傳感器

    【嵌入式系統(tǒng)與入門】Day02 Arduino 按鍵、蜂鳴器與濕溫度傳感器

    目的:控制電動機(jī)或其他電氣設(shè)備運(yùn)行,常用來 連通或斷開 ,控制電路 原理:K1、K2、K3、K4【開關(guān)量】與數(shù)字引腳相連,通過對按鍵操作,展現(xiàn)為電平的高低 不按的情況,K1連接R1,與VCC相連,表現(xiàn)為高電平 按下鍵時,K1直接與GND相連,表現(xiàn)為低電平 k1被按下時,看窗口監(jiān)視

    2023年04月22日
    瀏覽(36)
  • 嵌入式項目分享 stm32智能運(yùn)動計步系統(tǒng) - 物聯(lián)網(wǎng) 嵌入式 單片機(jī)

    嵌入式項目分享 stm32智能運(yùn)動計步系統(tǒng) - 物聯(lián)網(wǎng) 嵌入式 單片機(jī)

    ?? 這兩年開始畢業(yè)設(shè)計和畢業(yè)答辯的要求和難度不斷提升,傳統(tǒng)的畢設(shè)題目缺少創(chuàng)新和亮點,往往達(dá)不到畢業(yè)答辯的要求,這兩年不斷有學(xué)弟學(xué)妹告訴學(xué)長自己做的項目系統(tǒng)達(dá)不到老師的要求。 為了大家能夠順利以及最少的精力通過畢設(shè),學(xué)長分享優(yōu)質(zhì)畢業(yè)設(shè)計項目,今天

    2024年02月20日
    瀏覽(108)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包