Tessel Matrix Keypad
This library will allow your Tessel to read any matrix type keypad.
About Matrix Keyboards
A really good write up on how key matrices work
The arduino matrix keypad how-to provides inspiration for this library.
npm install tessel-matrix-keypad --save
var tessel =Keypad = ;gpio = tesselport'GPIO'pin //shortcut for referencing Tessel pinsmodD = tesselport'D'pin;var keypad =keys:'1' '2' '3' 'A''4' '5' '6' 'B''7' '8' '9' 'C''*' '0' '#' 'D'rows: gpioG1 gpioG2 gpioG3 gpioG4cols: gpioG5 gpioG6 modDG1 modDG2scan: 'row' // 'col' or 'both'poll: false // number sets for auto polling (integer);keypad;keypad;keypad;
Create keypad instance
var Keypad = ;var keypad = options;
keys: array of keys by row ex: [[1,2,3],[4,5,6],[7,8,9]] required
rows: array of digital pins on tessel associated with rows required
cols: array of digital pins on tessel associated with cols required
scan: direction to scan the keys default:
row: row pins are pulled high to correspond with columns.
col: column pins are pulled high to correspond with row pins.
both: both rows and column are scanned. This helps to solve for ghosting with multiple keys. It is also slower.
poll: how often to poll for key updates in ms. Relative to last poll. __default:
isPressed(key), isPressed(row, col)
Checks to see if key(s) are pressed. Valid argument is a string separated by spaces.
Returns a boolean.
In the example above the key
A must be pressed to be true.
Check to see if the key at row 0, col 0 is pressed.
returns an array of keys that are currently pressed.
Stops polling the keypad for events.
Starts polling the keypad.
Index the keys. Allows for reassignment of the keys on a keypad instance. This will reset all key states to false.
Reset the all key states to false. Uses the existing key layout.
Allows changing the polling of the keyboard.
Changes how the matrix is scanned. See options for valid arguments (
Emitted when a key is pressed and was previously not pressed. The key value is passed to the listener.
Emitted when a key that was pressed in a prior polling is no longer pressed. The key value is passed to the listener.
Anytime a key state changes
change is emitted with two arguments.
key: the key that has changed state.
type: a boolean indicating the new state.
When polling is stopped this is emitted.
The MIT License (MIT)
Copyright (c) 2014 Nathan White
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.