Hello
Is there a how to implement keyfob press & hold for some time to cause an event. Example, user press & hold the left button for 5 sec to do something. I am using the keyfob application demo. I am looking for a practical design or approach. Please avoid philosophical answers that helps no one.
I am aware that I need to start some timer when key pressed and stop timer when key is released, though not sure how to do using with OSAL architecture.
thanks in advance
~LD
The key to doing this will be to set an OSAL event in keyfobapp_HandleKeys using osal_start_timerEx for five seconds in the future after the left button is pressed. If the key is released (which you would also know because keyfobapp_HandleKeys would get called) then you would stop the timer using osal_stop_timerEx. If the OSAL event gets triggered five seconds after it started, that means that the key was never released. You can then trigger the action that you want.
Sorry if this is too much of a "philosophical answer", but unfortunately I don't really have the time to write the code for you, but I believe that all the information needed to implement this can be found in the SW developer's guide.
Maybe someone else who has written something similar can share their code?
Hi,
I do not think people is wishing to share the code when someone is asking for this that rude.
Anyway, it can be done in less than 5 lines of code.
Please click the Verify Answer button on a post if it answers your question! :)
Wills Thanks for your reply. I was not looking for code snippet or freebies. I was merely asking for design (code is an implementation of a design). That said, what you have indicated is good start; though is not good design as if I press and hold the key, then I insert the battery inside the keyfob then release the key; the entire logic will be inverted as these events are not based on input level state (ie iput is High or Low). I did some reverse engineer of Hal code to see if I can get the input state (that caused the event) but was not able to see where/how. This is where I am looking for help but I guess it was not as clear in my original question.
I want to start the timer when on falling edge, and release timer on rising edge <inverse if input is active high> . The way to do this is get the edge of the input state and compare to previous state >>> logic is easy...
PS, I did not intend to offend anyone by my remarks of "philosophical answer". I was looking for practical approach on how to design/function call for what I needed to do. The reason for this remarks was due from previous posts/forums where I was being asked to verify an ans people where replying with academic answers as oppose to how-to.
thanks
Wednesday I have a demo for which I need the CC2540MiniDK. After this, if your issue is not solved we can try to go through this together :)
It is not a difficult thing.
Kazola / Willis
I got it.. I will post the code for others to use once I clean up few things.
thanks~LD
:)
That's nice. You can even add a wiki entry like "first steps" or "first example program" in CC2540, cannot you?
Can you please share the code, it could be very helpful !
-Fred
Fred
Checkout my profile and see files: http://e2e.ti.com/members/1960865/files/default.aspx
did the code worked out for you? Verify if so....