Skip to content

Commit 3757aef

Browse files
author
Žiga Miklošič
committed
Merge branch 'develop'
2 parents 0dd7c18 + e9f9876 commit 3757aef

7 files changed

Lines changed: 216 additions & 190 deletions

File tree

CHANGE_LOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Changelog
2+
All notable changes to this project/module will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project/module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
---
8+
## V1.1.0 - 04.11.2022
9+
10+
### Changed
11+
- Removed Filter dependecy and making configurable
12+
- Removed float32_t dependecy
13+
- Replace version notes with changelog
14+
15+
16+
---
17+
## V1.0.0 - 30.09.2021
18+
19+
### Added
20+
- Configuration via single table
21+
- Debounce filtering
22+
- Event callbacks on pressed and released event
23+
- Active & idle timings measurement
24+
---

README.md

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,33 @@
1-
# **Button library**
2-
General C library for button action handling. Library is simple to use as it is configurable by single table. It also features debouncing filtering.
3-
1+
# **Button**
2+
Button library takes care of button handling and debouncing if configured to do so. Library is fully configured via configuration table.
43

54
## **Dependencies**
65

76
### **1. GPIO module**
8-
---
97
Button library is dependend from low level GPIO module thus following function prototypes must be provided:
10-
- gpio_status_t gpio_is_init(bool * const p_is_init)
11-
- void gpio_set(const gpio_pins_t pin, const gpio_state_t state)
8+
- *gpio_status_t gpio_is_init(bool * const p_is_init)*
9+
- *void gpio_get(const gpio_pins_t pin)*
1210

1311
GPIO translation unit must be under following project path:
14-
```C
15-
#include "drivers/peripheral/gpio/gpio.h"
12+
```
13+
"root/drivers/peripheral/gpio/gpio.h"
1614
```
1715

1816
### **2. Filter module**
19-
---
20-
Button library is also dependent from filter module. Filter module sources can be found under this [link](https://github.com/GeneralEmbeddedCLibraries/filter). Filter module must take following path:
17+
[Filter module](https://github.com/GeneralEmbeddedCLibraries/filter) is not mandatory to be used as it can be disabled via *BUTTON_CFG_FILTER_EN* inside ***button_cfg.h*** file.
2118

22-
```C
23-
#include "middleware/filter/src/filter.h"
19+
If Filter module is used, it must take following path:
20+
```
21+
"root/middleware/filter/src/filter.h"
2422
```
2523

26-
### **3. float32_t definition**
27-
Definition of float32_t must be provided by user. In current implementation it is defined in "project_config.h". Just add following statement to your code where it suits the best.
28-
29-
```C
30-
// Define float
31-
typedef float float32_t;
24+
## **General Embedded C Libraries Ecosystem**
25+
In order to be part of *General Embedded C Libraries Ecosystem* this module must be placed in following path:
26+
```
27+
root/drivers/hmi/button/button/"module_space"
3228
```
33-
### **4. Static assert**
34-
Additionaly module uses "static_assert()" function defined in <assert.h>. It is being used for cross-module compatibility.
3529

3630
## **API**
37-
---
3831
| API Functions | Description | Prototype |
3932
| --- | ----------- | ----- |
4033
| **button_init** | Initialization of button module | button_status_t button_init(void) |****
@@ -47,12 +40,13 @@ Additionaly module uses "static_assert()" function defined in <assert.h>. It is
4740
| **button_unregister_callback** | Un-register button callback | button_status_t button_unregister_callback (const button_num_t num) |
4841

4942

43+
## **How to use**
5044

45+
**GENERAL NOTICE: Put all user code between sections: USER CODE BEGIN & USER CODE END!**
5146

52-
## **How to use**
53-
---
47+
1. Copy template files to root directory of module.
5448

55-
1. List all buttons inside **button_cfg.h** file:
49+
2. List all buttons inside **button_cfg.h** file:
5650
```C
5751
/**
5852
* List of Buttons
@@ -79,16 +73,19 @@ typedef enum
7973
} button_num_t;
8074
```
8175

82-
2. Set up main handler period inside **button_cfg.h** file:
83-
```C
84-
/**
85-
* Main button handler period
86-
* Unit: sec
87-
*/
88-
#define BUTTON_CFG_HNDL_PERIOD_S ( 0.01f )
89-
```
76+
3. Configure Button module inside **button_cfg.h** file:
9077

91-
3. Set up configuration table inside **button_cfg.c** file:
78+
| Configuration | Description |
79+
| --- | --- |
80+
| **BUTTON_CFG_HNDL_PERIOD_S** | Main button handler period in seconds. |
81+
| **BUTTON_CFG_FILTER_EN** | Enable/Disable usage of Filter module. It is being used for debouncing. |
82+
| **BUTTON_CFG_DEBUG_EN** | Enable/Disable debug mode. |
83+
| **BUTTON_CFG_ASSERT_EN** | Enable/Disable assertions. |
84+
| **BUTTON_PRINT** | Definition of debug printing. |
85+
| **BUTTON_ASSERT** | Definition of assert. |
86+
87+
88+
4. Set up configuration table inside **button_cfg.c** file:
9289
```C
9390
/**
9491
* Button configuration table
@@ -125,10 +122,12 @@ static const button_cfg_t g_button_cfg[ eBUTTON_NUM_OF ] =
125122
};
126123
```
127124

128-
4. Include, initialize & handle:
125+
5. Include, initialize & handle:
129126

130127
Main button handler **button_hndl()** must be called with a fixed period of **BUTTON_CFG_HNDL_PERIOD_S** (defined inside button_cfg.h).
131128

129+
**NOTICE: Before using Button module GPIO shall be initialized!**
130+
132131
```C
133132
// Include single file to your application!
134133
#include "button.h"
@@ -168,7 +167,7 @@ if ( eBUTTON_OK != button_init())
168167
}
169168
```
170169

171-
5. Register and use callback functions
170+
6. Register and use callback functions
172171
```C
173172
// Declare callback functions
174173
static void my_button_pressed(void);
@@ -180,7 +179,7 @@ button_register_callback( eBUTTON_USER, &my_button_pressed, &my_button_released
180179
// Define callback functions
181180
static void my_button_pressed(void)
182181
{
183-
// Put actions on button release event here...
182+
// Put actions on button pressed event here...
184183
}
185184

186185
static void my_button_released(void)

0 commit comments

Comments
 (0)