PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Interface
libkeypad
libkeypad.c
1
/*
2
@file libkeypad.c
3
4
@author Andy Lindsay
5
6
@copyright
7
Copyright (C) Parallax, Inc. 2017. All Rights MIT Licensed.
8
9
@brief Project and test harness for the keypad library.
10
*/
11
12
#include "
simpletools.h
"
13
#include "
keypad.h
"
14
15
int
rowPins[4] = {7, 6, 5, 4};
16
int
colPins[4] = {3, 2, 1, 0};
17
18
int
values[16] = { 1, 2, 3,
'A'
,
19
4, 5, 6,
'B'
,
20
7, 8, 9,
'C'
,
21
'*'
, 0,
'#'
,
'D'
};
22
int
main
()
23
{
24
keypad_setup
(4, 4, rowPins, colPins, values);
25
26
while
(1)
27
{
28
int
key =
keypad_read
();
29
if
(key <= 9)
30
print
(
"key = %d\r"
, key);
31
else
32
print
(
"key = %c\r"
, key);
33
while
(key != -1)
34
{
35
key =
keypad_readFrom
(key);
36
if
(key <= 9)
37
print
(
"key = %d\r"
, key);
38
else
39
print
(
"key = %c\r"
, key);
40
}
41
print
(
"\r"
);
42
pause
(2000);
43
}
44
}
45
46
keypad_setup
void keypad_setup(int rowCount, int columnCount, int *rowPinCons, int *columnPinCons, int *buttonValues)
Set up the row and column dimensions, pins, and key values.
Definition:
keypad.c:24
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
keypad_read
int keypad_read(void)
Returns the first key pressed, or -1 if no key is pressed.
Definition:
keypad.c:42
keypad_readFrom
int keypad_readFrom(int button)
If more than one key might be pressed and held at one time, use this keyapd_readFrom function to get ...
Definition:
keypad.c:48
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
keypad.h
Scans matrix keypad and returns a unique value for each key that is pressed. For an example circuit a...
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17