You are here

Component creation. Part 1 of ? | Cypress Semiconductor

Component creation. Part 1 of ?

Summary: 17 Replies, Latest post by Bob Marlowe on 14 Mar 2014 01:08 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
user_1377889's picture
User
10573 posts
user_1377889's picture
User
10573 posts

Not much Text in the post above, Forum Software kicked me out, so let me start over.

 

I decided to write my first component. Mostly because Eugene came up with a self-written component which refered to a program I had written before and I was not quite content with his implementation and favoured mine (of course!!!)

 

I would like to make a KeyPad (matrix keyboard) component which (as a component should be) is adaptable to different keypad-sizes and organization. So keypads from 2x2 (4 keys) up to 8x8 (64 keys) should be supported.

 

The keypad is connected directly to the required number of input-pins and with the help of a timer and an interrupt the key-presses are debounced, put into a buffer, repeated for long keypresses and can be retrieved from the buffer by some API-calls.

 

I will get you informed of every step I perform to get this component working and I would be glad about any comments, suggestions or hints from the community.

So, to start with a component, we will have to define at first its capabilities expressed in the parameters the user may change to fit the needs of his usage. To get a look at the way the software is going to work, look here http://www.cypress.com/?app=forum&id=2233&rID=56644

Parameters:

Columns (2..8)

Rows(2..8) The keypad matrix organization

 Scan Rate (5-100ms)

Number of equal key readings before a key is accepted (1..99)

Initial wait before a keys are repeated (250..1000ms)

Repetition wait time (100..1000ms)

Keyboard buffer size (2..20)

 

APIs

KeyPad_Start()

KeyPad_IsKeyReady()

KeyPad_GetKey()

 

I do not know at this state of the design if I should have a hardware-signal for "Key pressed" or "Key Buffer not empty", so I'll suspend that for "changing a component" which will come later.

 

Bob

 

H L
user_460349's picture
User
1362 posts

May I know what is the purpose of the keyboard buffer?

Keyboard buffer size (2..20)

H L
user_460349's picture
User
1362 posts

How about

1. A function to return the current state of de-bounced matrix,  

2. A function "interruptOnKeyPressed(keyNumber)" which generates an  interrupt if a particular key is being pressed.

3. Same as 2 but operate on release of key  "interruptOnKeyRelease(keyNumber)",  not very ofter being used, but is a useful option to have.

user_1377889's picture
User
10573 posts

Fine! You are #1 that jumped in!

Since it is not always the time for main() to check for a key pressed all detected and debounced keys are stored in a small buffer from which they can be read off. Have a look at the Keypad matrix program I will integrate into the component here:

http://www.cypress.com/?app=forum&id=2233&rID=56644 Then you will get a feeling how it is supposed to work.

 

What do you want  "The current of state the matrix" for??? There is no intermediate debounced matrix state.

I write this component to keep the user apart from the "Key down - Key release" mechanism like in windows.

I think of (as I wrote earlier) to supply a "KeyPressed" signal. To connect an isr to it and question for a particular key is easy and should be supplied by the user (as first implementation). And I want to keep it small for the first version.

 

Bob

 

H L
user_460349's picture
User
1362 posts

 Shall download and have a look.

user_1377889's picture
User
10573 posts

Here is the next part of my experiences in creating a component. Since I have a lot of pictures to show and seemingly I may attach only a single file to my post, I decided to create a PDF-document that contains all the text and pictures.

 

Take your time, relax and have a look at. Any comments are welcome.

 

Bob 

Attachments: 
user_1377889's picture
User
10573 posts

Sorry, the link to the videos does not work as expected, you'll have to cut and paste it into your browser's address.

Bob

user_1377889's picture
User
10573 posts

Here I supply a small project that summarizes the above given component-creation.

A configurable matrix-input for a keypad.

 

Bob

user_22393527's picture
User
65 posts

 thanks for the pdf. I must have watched those videos about 10 times by now, but this is a great little distillation.

user_1377889's picture
User
10573 posts

Here we are. I finished the project and the documentation.

I invite everybody to share his comments on my KeyPad component

 

Happy reading

Bob

 

Log in to post new comments.