Chameleon-Mini
 All Classes Files Functions Variables Macros Pages
Button.h
1 /* Copyright 2013 Timo Kasper, Simon Küppers, David Oswald ("ORIGINAL
2  * AUTHORS"). All rights reserved.
3  *
4  * DEFINITIONS:
5  *
6  * "WORK": The material covered by this license includes the schematic
7  * diagrams, designs, circuit or circuit board layouts, mechanical
8  * drawings, documentation (in electronic or printed form), source code,
9  * binary software, data files, assembled devices, and any additional
10  * material provided by the ORIGINAL AUTHORS in the ChameleonMini project
11  * (https://github.com/skuep/ChameleonMini).
12  *
13  * LICENSE TERMS:
14  *
15  * Redistributions and use of this WORK, with or without modification, or
16  * of substantial portions of this WORK are permitted provided that the
17  * following conditions are met:
18  *
19  * Redistributions and use of this WORK, with or without modification, or
20  * of substantial portions of this WORK must include the above copyright
21  * notice, this list of conditions, the below disclaimer, and the following
22  * attribution:
23  *
24  * "Based on ChameleonMini an open-source RFID emulator:
25  * https://github.com/skuep/ChameleonMini"
26  *
27  * The attribution must be clearly visible to a user, for example, by being
28  * printed on the circuit board and an enclosure, and by being displayed by
29  * software (both in binary and source code form).
30  *
31  * At any time, the majority of the ORIGINAL AUTHORS may decide to give
32  * written permission to an entity to use or redistribute the WORK (with or
33  * without modification) WITHOUT having to include the above copyright
34  * notice, this list of conditions, the below disclaimer, and the above
35  * attribution.
36  *
37  * DISCLAIMER:
38  *
39  * THIS PRODUCT IS PROVIDED BY THE ORIGINAL AUTHORS "AS IS" AND ANY EXPRESS
40  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
41  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42  * DISCLAIMED. IN NO EVENT SHALL THE ORIGINAL AUTHORS OR CONTRIBUTORS BE
43  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
44  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
45  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
46  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48  * ARISING IN ANY WAY OUT OF THE USE OF THIS PRODUCT, EVEN IF ADVISED OF
49  * THE POSSIBILITY OF SUCH DAMAGE.
50  *
51  * The views and conclusions contained in the hardware, software, and
52  * documentation should not be interpreted as representing official
53  * policies, either expressed or implied, of the ORIGINAL AUTHORS.
54  */
55 
56 #ifndef BUTTON_H_
57 #define BUTTON_H_
58 
59 #include "Common.h"
60 #include <avr/io.h>
61 #include "Application/Application.h"
62 
63 #define BUTTON_PORT PORTA
64 #define BUTTON_MASK PIN6_bm
65 #define BUTTON_PINCTRL PIN6CTRL
66 
67 typedef enum {
68  BUTTON_ACTION_NONE,
69  BUTTON_ACTION_UID_RANDOM,
70  BUTTON_ACTION_UID_LEFT_INCREMENT,
71  BUTTON_ACTION_UID_RIGHT_INCREMENT,
72  BUTTON_ACTION_UID_LEFT_DECREMENT,
73  BUTTON_ACTION_UID_RIGHT_DECREMENT,
74  BUTTON_ACTION_CYCLE_SETTINGS,
75 
76  /* This has to be last element */
77  BUTTON_ACTION_COUNT
78 } ButtonActionEnum;
79 
80 void ButtonInit(void);
81 void ButtonTick(void);
82 
83 void ButtonGetActionList(char* ListOut, uint16_t BufferSize);
84 void ButtonSetActionById(ButtonActionEnum Action);
85 void ButtonGetActionByName(char* ActionOut, uint16_t BufferSize);
86 bool ButtonSetActionByName(const char* Action);
87 
88 #endif /* BUTTON_H_ */