-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadcbtnph.h
More file actions
73 lines (65 loc) · 1.93 KB
/
adcbtnph.h
File metadata and controls
73 lines (65 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// adcbtnph Class
//
// 1 ADC pin with 2 Buttons PullUp R 10k, R 1k
//
// used for 4 different events
//
// no button pressed ADC value ~1023
// event1, button 1 short press ADC value 0
// event2, button 2 short press ADC value ~91 1023 * 1k / (10k + 1k)
// event3, button 1 long press ADC value 0
// event4, button 2 long press ADC value ~91 1023 * 1k / (10k + 1k)
//
//
// typedef struct {
// oosmos_sEvent Event;
// unsigned Value;
// } sAdcButtonEvent;
//
// Event SubscriberListNotifyWithArgs event1: Value = 1, event2: Value = 2, event3: Value = 3, event4: Value = 4
//
// VCC
// |
// 10k
// / |
// +-----/ -----+---- ADC pin
// | button1 |
// | 1k
// | / |
// +-----/ -----+
// | button2
// |
// |
// GND
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2 of the License ("GPLv2").
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef adcbtnh_h
#define adcbtnh_h
#include "oosmos.h"
#include "adc.h"
#include <stdint.h>
typedef struct adcbtnphTag adcbtnph;
typedef struct {
oosmos_sEvent Event;
unsigned Value;
} sAdcButtonEvent;
#if defined(ARDUINO)
extern adcbtnph *adcbtnphNew(adc * pADC, uint32_t HoldTimeMS);
extern void adcbtnphSubscribeButtonPress(adcbtnph *pAdcButton, oosmos_sQueue *pQueue, int PressedEventCode, void *pContext);
#else
#error adcbtnph.h: Unsupported platform.
#endif
#endif