libwebsockets
Lightweight C library for HTML5 websockets
lws-button.h
Go to the documentation of this file.
1
/*
2
* Generic button ops
3
*
4
* Copyright (C) 2019 - 2020 Andy Green <andy@warmcat.com>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
* IN THE SOFTWARE.
23
*
24
* Leverages the lws generic gpio pieces to bind gpio buttons to smd events
25
*/
26
27
#if !defined(__LWS_BUTTON_H__)
28
#define __LWS_BUTTON_H__
29
30
typedef
uint16_t
lws_button_idx_t
;
31
32
/* actual minimum may be 1 x RTOS tick depending on platform */
33
#define LWS_BUTTON_MON_TIMER_MS 5
34
35
typedef
void (*
lws_button_cb_t
)(
void
*opaque,
lws_button_idx_t
idx,
int
state);
36
37
/* These are specified in ms but the granularity is LWS_BUTTON_MON_TIMER_MS,
38
* which may have been rounded up to an RTOS tick depending on platform */
39
40
enum
{
41
LWSBTNRGMFLAG_CLASSIFY_DOUBLECLICK
= (1 << 0)
42
};
43
44
typedef
struct
lws_button_regime
{
45
uint16_t
ms_min_down
;
46
uint16_t
ms_min_down_longpress
;
47
uint16_t
ms_up_settle
;
48
uint16_t
ms_doubleclick_grace
;
49
uint16_t
ms_repeat_down
;
50
uint8_t
flags
;
57
}
lws_button_regime_t
;
58
59
/*
60
* This is the const part of the button controller, describing the static
61
* bindings to gpio, and lws_smd event name information
62
*/
63
64
typedef
struct
lws_button_map
{
65
_lws_plat_gpio_t
gpio
;
66
const
char
*
smd_interaction_name
;
67
const
lws_button_regime_t
*
regime
;
69
}
lws_button_map_t
;
70
71
typedef
struct
lws_button_controller
{
72
const
char
*
smd_bc_name
;
73
const
lws_gpio_ops_t
*
gpio_ops
;
74
const
lws_button_map_t
*
button_map
;
75
lws_button_idx_t
active_state_bitmap
;
76
uint8_t
count_buttons
;
77
}
lws_button_controller_t
;
78
79
struct
lws_button_state;
/* opaque */
80
91
LWS_VISIBLE
LWS_EXTERN
struct
lws_button_state *
92
lws_button_controller_create
(
struct
lws_context *ctx,
93
const
lws_button_controller_t
*controller);
94
104
LWS_VISIBLE
LWS_EXTERN
void
105
lws_button_controller_destroy
(
struct
lws_button_state *bcs);
106
107
108
LWS_VISIBLE
LWS_EXTERN
lws_button_idx_t
109
lws_button_get_bit
(
struct
lws_button_state *bcs,
const
char
*name);
110
111
/*
112
* lws_button_enable() - enable and disable buttons
113
*/
114
115
LWS_VISIBLE
LWS_EXTERN
void
116
lws_button_enable
(
struct
lws_button_state *bcs,
117
lws_button_idx_t
_reset,
lws_button_idx_t
_set);
118
119
#endif
120
uint16_t
unsigned short uint16_t
Definition:
libwebsockets.h:571
LWS_EXTERN
#define LWS_EXTERN
Definition:
libwebsockets.h:225
uint8_t
unsigned char uint8_t
Definition:
libwebsockets.h:572
LWS_VISIBLE
#define LWS_VISIBLE
Definition:
libwebsockets.h:220
LWSBTNRGMFLAG_CLASSIFY_DOUBLECLICK
@ LWSBTNRGMFLAG_CLASSIFY_DOUBLECLICK
Definition:
lws-button.h:41
lws_button_idx_t
uint16_t lws_button_idx_t
Definition:
lws-button.h:30
lws_button_controller::button_map
const lws_button_map_t * button_map
Definition:
lws-button.h:74
lws_button_get_bit
LWS_VISIBLE LWS_EXTERN lws_button_idx_t lws_button_get_bit(struct lws_button_state *bcs, const char *name)
lws_button_map::gpio
_lws_plat_gpio_t gpio
Definition:
lws-button.h:65
lws_button_regime::flags
uint8_t flags
Definition:
lws-button.h:50
lws_button_regime::ms_min_down_longpress
uint16_t ms_min_down_longpress
Definition:
lws-button.h:46
lws_button_regime::ms_min_down
uint16_t ms_min_down
Definition:
lws-button.h:45
lws_button_map::smd_interaction_name
const char * smd_interaction_name
Definition:
lws-button.h:66
lws_button_controller_create
LWS_VISIBLE LWS_EXTERN struct lws_button_state * lws_button_controller_create(struct lws_context *ctx, const lws_button_controller_t *controller)
lws_button_controller::gpio_ops
const lws_gpio_ops_t * gpio_ops
Definition:
lws-button.h:73
lws_button_regime::ms_doubleclick_grace
uint16_t ms_doubleclick_grace
Definition:
lws-button.h:48
lws_button_controller_t
struct lws_button_controller lws_button_controller_t
lws_button_controller::count_buttons
uint8_t count_buttons
Definition:
lws-button.h:76
lws_button_map::regime
const lws_button_regime_t * regime
Definition:
lws-button.h:67
lws_button_cb_t
void(* lws_button_cb_t)(void *opaque, lws_button_idx_t idx, int state)
Definition:
lws-button.h:35
lws_button_regime::ms_repeat_down
uint16_t ms_repeat_down
Definition:
lws-button.h:49
lws_button_controller::active_state_bitmap
lws_button_idx_t active_state_bitmap
Definition:
lws-button.h:75
lws_button_regime_t
struct lws_button_regime lws_button_regime_t
lws_button_controller_destroy
LWS_VISIBLE LWS_EXTERN void lws_button_controller_destroy(struct lws_button_state *bcs)
lws_button_map_t
struct lws_button_map lws_button_map_t
lws_button_controller::smd_bc_name
const char * smd_bc_name
Definition:
lws-button.h:72
lws_button_enable
LWS_VISIBLE LWS_EXTERN void lws_button_enable(struct lws_button_state *bcs, lws_button_idx_t _reset, lws_button_idx_t _set)
lws_button_regime::ms_up_settle
uint16_t ms_up_settle
Definition:
lws-button.h:47
lws_button_controller
Definition:
lws-button.h:71
lws_button_map
Definition:
lws-button.h:64
lws_button_regime
Definition:
lws-button.h:44
_lws_plat_gpio_t
int _lws_plat_gpio_t
Definition:
lws-gpio.h:31
lws_gpio_ops
Definition:
lws-gpio.h:52
include
libwebsockets
lws-button.h
Generated on Wed Dec 18 2024 07:29:37 for libwebsockets by
1.9.1