diff options
author | Harald Welte <laforge@gnumonks.org> | 2011-07-04 20:52:54 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2011-07-04 20:52:54 +0200 |
commit | 044ad7c3987460ede48ff27afd6bdb0ca05a0432 (patch) | |
tree | 924818cdb0d39ca08aec540d18da7bd406eaae8c /components/kbmatrix |
import at91lib from at91lib_20100901_softpack_1_9_v_1_0_svn_v1501120100901_softpack_1_9_v_1_0_svn_v15011
it's sad to see that atmel doesn't publish their svn repo or has
a centralized location or even puts proper version/release info
into the library itself
Diffstat (limited to 'components/kbmatrix')
-rw-r--r-- | components/kbmatrix/kbmatrix.c | 304 | ||||
-rw-r--r-- | components/kbmatrix/kbmatrix.h | 106 | ||||
-rw-r--r-- | components/kbmatrix/s7lekkbm/s7lekkbm.c | 119 | ||||
-rw-r--r-- | components/kbmatrix/s7lekkbm/s7lekkbm.h | 113 |
4 files changed, 642 insertions, 0 deletions
diff --git a/components/kbmatrix/kbmatrix.c b/components/kbmatrix/kbmatrix.c new file mode 100644 index 0000000..1f0ad54 --- /dev/null +++ b/components/kbmatrix/kbmatrix.c @@ -0,0 +1,304 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+//-----------------------------------------------------------------------------
+// Headers
+//-----------------------------------------------------------------------------
+
+#include "kbmatrix.h"
+#include <pio/pio_it.h>
+#include <irq/irq.h>
+#include <utility/trace.h>
+#include <utility/assert.h>
+
+#include <string.h>
+
+//-----------------------------------------------------------------------------
+// Local functions
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+/// Initializes a KeyState instance by setting all keys are released.
+/// \param pKeyState Pointer to a KeyState instance to initialize.
+//-----------------------------------------------------------------------------
+static void KEYSTATE_Initialize(KeyState *pKeyState)
+{
+ SANITY_CHECK(pKeyState);
+
+ memset(pKeyState->pState, 0, sizeof(KeyState));
+}
+
+//-----------------------------------------------------------------------------
+/// Sets the status of a key given its index in the key state.
+/// \param pKeyState Pointer to a KeyState instance.
+/// \param key Key index.
+/// \param state New key state.
+//-----------------------------------------------------------------------------
+static void KEYSTATE_SetKeyState(
+ KeyState *pKeyState,
+ unsigned int key,
+ unsigned char state)
+{
+ unsigned int byte = key / 8;
+ unsigned int bit = key % 8;
+
+ SANITY_CHECK(pKeyState);
+ SANITY_CHECK(key < KBMATRIX_MAX_NUMKEYS);
+
+ if (state) {
+
+ pKeyState->pState[byte] |= (1 << bit);
+ }
+ else {
+
+ pKeyState->pState[byte] &= ~(1 << bit);
+ }
+}
+
+//-----------------------------------------------------------------------------
+/// Returns 1 if the given key is currently pressed; otherwise returns 0.
+/// \param pKeyState Pointer to a KeyState instance.
+/// \param key Key index.
+//-----------------------------------------------------------------------------
+static unsigned char KEYSTATE_GetKeyState(KeyState *pKeyState, unsigned int key)
+{
+ unsigned int byte = key / 8;
+ unsigned int bit = key % 8;
+
+ SANITY_CHECK(pKeyState);
+ SANITY_CHECK(key < KBMATRIX_MAX_NUMKEYS);
+
+ return ((pKeyState->pState[byte] >> bit) & 1);
+}
+
+//-----------------------------------------------------------------------------
+/// Performs a AND operation between two KeyState instance, storing the result
+/// in a third instance.
+/// \param pA Pointer to the first state to AND.
+/// \param pB Pointer to the second state to AND.
+/// \param pResult Pointer to the resulting KeyState.
+//-----------------------------------------------------------------------------
+static void KEYSTATE_And(KeyState *pA, KeyState *pB, KeyState *pResult)
+{
+ unsigned int i;
+
+ for (i=0; i < sizeof(KeyState); i++) {
+
+ pResult->pState[i] = pA->pState[i] & pB->pState[i];
+ }
+}
+
+//-----------------------------------------------------------------------------
+/// Performs a OR operation between two KeyState instance, storing the result
+/// in a third instance.
+/// \param pA Pointer to the first state to OR.
+/// \param pB Pointer to the second state to OR.
+/// \param pResult Pointer to the resulting KeyState.
+//-----------------------------------------------------------------------------
+static void KEYSTATE_Or(KeyState *pA, KeyState *pB, KeyState *pResult)
+{
+ unsigned int i;
+
+ for (i=0; i < sizeof(KeyState); i++) {
+
+ pResult->pState[i] = pA->pState[i] | pB->pState[i];
+ }
+}
+
+//-----------------------------------------------------------------------------
+/// Performs a XOR operation between two KeyState instance, storing the result
+/// in a third instance.
+/// \param pA Pointer to the first state to XOR.
+/// \param pB Pointer to the second state to XOR.
+/// \param pResult Pointer to the resulting KeyState.
+//-----------------------------------------------------------------------------
+static void KEYSTATE_Xor(KeyState *pA, KeyState *pB, KeyState *pResult)
+{
+ unsigned int i;
+
+ for (i=0; i < sizeof(KeyState); i++) {
+
+ pResult->pState[i] = pA->pState[i] ^ pB->pState[i];
+ }
+}
+
+//-----------------------------------------------------------------------------
+/// Computes the new debounced key state and trigger key events if necessary.
+/// The debouncing is done both when the key is pressed and when it is released.
+/// Returns 1 if changes have been detected; otherwise returns 0.
+/// \param pKbMatrix Pointer to a KbMatrix instance.
+//-----------------------------------------------------------------------------
+unsigned char Debounce(KbMatrix *pKbMatrix)
+{
+ KeyState pressed;
+ KeyState released;
+ KeyState new;
+ KeyState changed;
+ unsigned int i;
+ unsigned char event = 0;
+
+ SANITY_CHECK(pKbMatrix);
+
+ // Debounce pressed keys
+ memcpy(&pressed, &(pKbMatrix->sampledKeyStates[0]), sizeof(KeyState));
+ for (i=1; i < KBMATRIX_NUM_SAMPLES; i++) {
+
+ KEYSTATE_And(&pressed, &(pKbMatrix->sampledKeyStates[i]), &pressed);
+ }
+
+ // Debounce released keys
+ memcpy(&released, &(pKbMatrix->sampledKeyStates[0]), sizeof(KeyState));
+ for (i=1; i < KBMATRIX_NUM_SAMPLES; i++) {
+
+ KEYSTATE_And(&released, &(pKbMatrix->sampledKeyStates[i]), &released);
+ }
+
+ // Compute new key status
+ KEYSTATE_Or(&(pKbMatrix->currentKeyState), &pressed, &new);
+ KEYSTATE_And(&new, &released, &new);
+
+ // Compare with existing status
+ KEYSTATE_Xor(&new, &(pKbMatrix->currentKeyState), &changed);
+
+ // Process each pending event
+ for (i=0; i < (pKbMatrix->numRows * pKbMatrix->numCols); i++) {
+
+ if (KEYSTATE_GetKeyState(&changed, i)) {
+
+ event = 1;
+
+ // Trigger callback
+ if (pKbMatrix->callback) {
+
+ pKbMatrix->callback(i, KEYSTATE_GetKeyState(&new, i));
+ }
+ }
+ }
+
+ // Save new key state
+ memcpy(&(pKbMatrix->currentKeyState), &new, sizeof(KeyState));
+
+ return event;
+}
+
+//-----------------------------------------------------------------------------
+/// Retrieves a new debounce sample by reading the current state of the
+/// keyboard.
+/// \param pKbMatrix Pointer to a KbMatrix instance.
+//-----------------------------------------------------------------------------
+void Fetch(KbMatrix *pKbMatrix)
+{
+ KeyState *pKeyState = &(pKbMatrix->sampledKeyStates[pKbMatrix->sample]);
+ unsigned int row;
+ unsigned int col;
+ volatile unsigned int i;
+
+ SANITY_CHECK(pKbMatrix);
+
+ // Scan the current keyboard status
+ for (row=0; row < pKbMatrix->numRows; row++) {
+
+ // Enable row
+ PIO_Clear(&(pKbMatrix->pRows[row]));
+
+ // Scan each column
+ for (col=0; col < pKbMatrix->numCols; col++) {
+
+ KEYSTATE_SetKeyState(pKeyState,
+ row * pKbMatrix->numCols + col,
+ !PIO_Get(&(pKbMatrix->pCols[col])));
+ }
+
+ // Disable row (and wait for level to become 1)
+ PIO_Set(&(pKbMatrix->pRows[row]));
+ for (i=0; i < 100; i++); // Dirty but works
+ }
+
+ // Update sample index
+ pKbMatrix->sample = (pKbMatrix->sample + 1) % KBMATRIX_NUM_SAMPLES;
+}
+
+//-----------------------------------------------------------------------------
+// Exported functions
+//-----------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Initializes a keyboard matrix driver instance.
+/// \param pKbMatrix Pointer to a KbMatrix instance.
+/// \param pRows Pointer to the list of row pins.
+/// \param numRows Number of rows in matrix.
+/// \param pCols Pointer to the list of column pins.
+/// \param numCols Number of columns in matrix.
+/// \param callback Optional callback for receiving key events.
+//------------------------------------------------------------------------------
+void KBMATRIX_Initialize(
+ KbMatrix * pKbMatrix,
+ const Pin * pRows,
+ unsigned char numRows,
+ const Pin * pCols,
+ unsigned char numCols,
+ KeyEventCallback callback)
+{
+ unsigned int i;
+
+ ASSERT(numRows * numCols <= KBMATRIX_MAX_NUMKEYS,
+ "KBMATRIX_Initialize: too many keys (change KBMATRIX_MAX_NUMKEYS)\n\r");
+
+ // Initialize structure members
+ pKbMatrix->pRows = pRows;
+ pKbMatrix->numRows = numRows;
+ pKbMatrix->pCols = pCols;
+ pKbMatrix->numCols = numCols;
+ pKbMatrix->callback = callback;
+
+ // Initialize key states
+ KEYSTATE_Initialize(&(pKbMatrix->currentKeyState));
+ for (i=0; i < KBMATRIX_NUM_SAMPLES; i++) {
+
+ KEYSTATE_Initialize(&(pKbMatrix->sampledKeyStates[i]));
+ }
+ pKbMatrix->sample = 0;
+}
+
+//-----------------------------------------------------------------------------
+/// Scans the keyboard matrix for key events (key pressed or released). Takes
+/// care of debouncing.
+/// Returns 1 if changes have been detected on the keyboard; otherwise return
+/// 0.
+/// \param pKbMatrix Pointer to a KbMatrix instance.
+//-----------------------------------------------------------------------------
+unsigned char KBMATRIX_Scan(KbMatrix *pKbMatrix)
+{
+ // Fetch new debounce sample
+ Fetch(pKbMatrix);
+
+ // Compute the new debounced key state, triggering events if necessary
+ return Debounce(pKbMatrix);
+}
+
diff --git a/components/kbmatrix/kbmatrix.h b/components/kbmatrix/kbmatrix.h new file mode 100644 index 0000000..02a19cb --- /dev/null +++ b/components/kbmatrix/kbmatrix.h @@ -0,0 +1,106 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+#ifndef KBMATRIX_H
+#define KBMATRIX_H
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include <pio/pio.h>
+
+//-----------------------------------------------------------------------------
+// Definitions
+//-----------------------------------------------------------------------------
+
+/// Size of circular key buffer.
+#define KBMATRIX_BUFFER_SIZE 10
+
+/// Maximum number of keys that can be handled by the driver.
+#define KBMATRIX_MAX_NUMKEYS 40
+
+/// Number of samples that are necessary to debounce a keypress.
+#define KBMATRIX_NUM_SAMPLES 10
+
+//-----------------------------------------------------------------------------
+// Types
+//-----------------------------------------------------------------------------
+
+/// Key event callback.
+typedef void (*KeyEventCallback)(unsigned int key, unsigned char pressed);
+
+/// Key mapping structure, indicating the state of each key in keyboard matrix.
+typedef struct _KeyState {
+
+ unsigned char pState[KBMATRIX_MAX_NUMKEYS / 8];
+
+} KeyState;
+
+/// Keyboard matrix driver structure. Holds information about the row & column
+/// pins used to create the matrix and stores the internal debouncing status.
+typedef struct _KbMatrix {
+
+ /// List of keyboard matrix row pins.
+ const Pin *pRows;
+ /// Number of rows in matrix.
+ unsigned char numRows;
+ /// List of keyboard matrix column pins.
+ const Pin *pCols;
+ /// Number of columns in matrix.
+ unsigned char numCols;
+
+ /// Current debounced key state mapping.
+ KeyState currentKeyState;
+ /// Debouncing samples.
+ KeyState sampledKeyStates[KBMATRIX_NUM_SAMPLES];
+ /// Current debouncing sample.
+ unsigned char sample;
+
+ /// Key pressed/released callback.
+ KeyEventCallback callback;
+
+} KbMatrix;
+
+//------------------------------------------------------------------------------
+// Global functions
+//------------------------------------------------------------------------------
+
+extern void KBMATRIX_Initialize(
+ KbMatrix * pKbMatrix,
+ const Pin * pRows,
+ unsigned char numRows,
+ const Pin * pCols,
+ unsigned char numCols,
+ KeyEventCallback callback);
+
+extern unsigned char KBMATRIX_Scan(KbMatrix *pKbMatrix);
+
+#endif //#ifndef KBMATRIX_H
+
diff --git a/components/kbmatrix/s7lekkbm/s7lekkbm.c b/components/kbmatrix/s7lekkbm/s7lekkbm.c new file mode 100644 index 0000000..c9c5373 --- /dev/null +++ b/components/kbmatrix/s7lekkbm/s7lekkbm.c @@ -0,0 +1,119 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include "s7lekkbm.h"
+
+//------------------------------------------------------------------------------
+// Global variables
+//------------------------------------------------------------------------------
+
+/// Keyboard matrix natural key mapping.
+const unsigned char gpKeyboardMatrix[S7LEKKBM_NUMKEYS] = {
+
+ S7LEKKBM_SQUAREROOT,
+ S7LEKKBM_PERCENTAGE,
+ S7LEKKBM_SIGN,
+ S7LEKKBM_INVERSE,
+ S7LEKKBM_X_POWER_Y,
+ S7LEKKBM_MODE,
+ S7LEKKBM_2NDF,
+ '7',
+ '8',
+ '9',
+ S7LEKKBM_DIVIDE,
+ S7LEKKBM_EXP,
+ S7LEKKBM_HEXDECBIN,
+ S7LEKKBM_2NDF_LOCK,
+ '4',
+ '5',
+ '6',
+ S7LEKKBM_MULTIPLY,
+ S7LEKKBM_LOG,
+ S7LEKKBM_UPARROW,
+ S7LEKKBM_ESCAPE,
+ '1',
+ '2',
+ '3',
+ S7LEKKBM_MINUS,
+ S7LEKKBM_LEFTARROW,
+ S7LEKKBM_OK,
+ S7LEKKBM_RIGHTARROW,
+ '0',
+ S7LEKKBM_DOT,
+ S7LEKKBM_EQUAL,
+ S7LEKKBM_PLUS,
+ S7LEKKBM_LN,
+ S7LEKKBM_DOWNARROW,
+ S7LEKKBM_DELETE
+};
+
+/// Keyboard matrix alternative key mapping (2ndF key pressed).
+const unsigned char gpKeyboardMatrixAlt[S7LEKKBM_NUMKEYS] = {
+
+ 'A',
+ 'B',
+ 'C',
+ 'D',
+ 'E',
+ 'F',
+ S7LEKKBM_2NDF,
+ 'G',
+ 'H',
+ 'I',
+ 'J',
+ 'K',
+ 'L',
+ S7LEKKBM_2NDF_LOCK,
+ 'M',
+ 'N',
+ 'O',
+ 'P',
+ 'Q',
+ S7LEKKBM_PAUSE,
+ S7LEKKBM_ESCAPE,
+ 'R',
+ 'S',
+ 'T',
+ 'U',
+ S7LEKKBM_LEFTARROW,
+ S7LEKKBM_PLAY,
+ S7LEKKBM_RIGHTARROW,
+ 'V',
+ 'W',
+ 'X',
+ 'Y',
+ 'Z',
+ S7LEKKBM_STOP,
+ S7LEKKBM_DELETE
+};
+
diff --git a/components/kbmatrix/s7lekkbm/s7lekkbm.h b/components/kbmatrix/s7lekkbm/s7lekkbm.h new file mode 100644 index 0000000..d3bd131 --- /dev/null +++ b/components/kbmatrix/s7lekkbm/s7lekkbm.h @@ -0,0 +1,113 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+#ifndef S7LEKKBM_H
+#define S7LEKKBM_H
+
+//------------------------------------------------------------------------------
+// Global definitions
+//------------------------------------------------------------------------------
+
+/// Number of keys in keyboard matrix.
+#define S7LEKKBM_NUMKEYS 35
+
+/// Square root key.
+#define S7LEKKBM_SQUAREROOT 128
+/// Percentage key.
+#define S7LEKKBM_PERCENTAGE 129
+/// Plus/minus sign key.
+#define S7LEKKBM_SIGN 130
+/// Inverse (1/x) key.
+#define S7LEKKBM_INVERSE 131
+/// Power key (x^y).
+#define S7LEKKBM_X_POWER_Y 132
+/// Mode key.
+#define S7LEKKBM_MODE 133
+/// 2nd function key.
+#define S7LEKKBM_2NDF 134
+/// Divide key.
+#define S7LEKKBM_DIVIDE 135
+/// Exponential key.
+#define S7LEKKBM_EXP 136
+/// Hex/dec/bin key.
+#define S7LEKKBM_HEXDECBIN 137
+/// 2nd function lock key.
+#define S7LEKKBM_2NDF_LOCK 138
+/// Multiply key.
+#define S7LEKKBM_MULTIPLY 139
+/// Logarithm key.
+#define S7LEKKBM_LOG 140
+/// Up arrow key.
+#define S7LEKKBM_UPARROW 141
+/// Pause key.
+#define S7LEKKBM_PAUSE 142
+/// Escape key.
+#define S7LEKKBM_ESCAPE 143
+/// Minus key.
+#define S7LEKKBM_MINUS 144
+/// Left arrow key.
+#define S7LEKKBM_LEFTARROW 145
+/// Ok key.
+#define S7LEKKBM_OK 146
+/// Play key.
+#define S7LEKKBM_PLAY 147
+/// Right arrow key.
+#define S7LEKKBM_RIGHTARROW 148
+/// Dot key.
+#define S7LEKKBM_DOT 149
+/// Equal key.
+#define S7LEKKBM_EQUAL 150
+/// Plus key.
+#define S7LEKKBM_PLUS 151
+/// Natural logarithm key.
+#define S7LEKKBM_LN 152
+/// Down arrow key.
+#define S7LEKKBM_DOWNARROW 153
+/// Stop key.
+#define S7LEKKBM_STOP 154
+/// Delete key.
+#define S7LEKKBM_DELETE 155
+
+//------------------------------------------------------------------------------
+// Global macros
+//------------------------------------------------------------------------------
+
+/// Returns 1 if the key is a special key; otherwise returns 0.
+#define S7LEKKBM_SPECIALKEY(key) ((key >= 128) ? 1 : 0)
+
+//------------------------------------------------------------------------------
+// Global variables
+//------------------------------------------------------------------------------
+
+extern const unsigned char gpKeyboardMatrix[S7LEKKBM_NUMKEYS];
+
+extern const unsigned char gpKeyboardMatrixAlt[S7LEKKBM_NUMKEYS];
+
+#endif //#ifndef S7LEKKBM_H
+
|