Page 1 of 1

Recording time length of a touch/light input?

Posted: Mon Mar 31, 2014 11:53 am
by Charliefaber
Good afternoon!
I'm doing a project for school and am attempting to make a morse code translator. I want it to accept both touch inputs and light inputs to translate into text on the screen. If the touch sensor is touched for less than a second, the program would record a dot, and for more than a second, a dash.
Is there a way to record the time length of inputs like this with a phidget?
Any help is appreciated!
Thanks
-Charlie

Re: Recording time length of a touch/light input?

Posted: Tue Apr 01, 2014 7:28 am
by burley
You would just have a timer in your program that starts in a touch change event and ends in the next touch change event.

Re: Recording time length of a touch/light input?

Posted: Tue Apr 01, 2014 7:37 am
by Charliefaber
The thing is, it wouldn't really be a different tap, it would just be a continuous hold. If it's a tap, then it registers a dot, if it's held, it registers a dash. Is it possible to even differentiate taps and holds with a touch sensor phidget?

Re: Recording time length of a touch/light input?

Posted: Tue Apr 01, 2014 8:42 am
by frodegill
Charliefaber wrote:Is it possible to even differentiate taps and holds with a touch sensor phidget?

What sensor are you using? It it's the 1129, it is basically just an analog sensor and you will handle everything yourself in the OnSensorChange handler.

Re: Recording time length of a touch/light input?

Posted: Tue Apr 01, 2014 2:04 pm
by Charliefaber
I was provided with 1110 sensors.

Re: Recording time length of a touch/light input?

Posted: Tue Apr 01, 2014 2:38 pm
by mparadis
Charliefaber wrote:The thing is, it wouldn't really be a different tap, it would just be a continuous hold. If it's a tap, then it registers a dot, if it's held, it registers a dash. Is it possible to even differentiate taps and holds with a touch sensor phidget?


The touch change event will trigger whenever the capacitance changes, so you'll get separate events triggering both when the touch begins and when it ends. If you set a timer, then you can easily determine the length of the touch. You'll also want to change the SensorChangeTrigger to a higher value so that you only get an event when there is a large change.

Re: Recording time length of a touch/light input?

Posted: Tue Apr 01, 2014 2:49 pm
by frodegill
Charliefaber wrote:I was provided with 1110 sensors.

1110 was replaced by 1129, but even though it has some weaker specs it will be perfect for your project.

You will have to rely on OnSensorChange. Record the timestamp and state (touched or not touched) and calculate the tap or hold from this info.

Note that you might get change events if you hold for 10+ seconds, but at that rate the typer should probably do something else than sending morse code.

Re: Recording time length of a touch/light input?

Posted: Fri Apr 04, 2014 8:59 am
by Charliefaber
That's very helpful! Thanks so much! Do you know where I can find the API for the methods/classes you are referring to?

Re: Recording time length of a touch/light input?

Posted: Fri Apr 04, 2014 1:43 pm
by frodegill
Charliefaber wrote:Do you know where I can find the API for the methods/classes you are referring to?

I'm used to C/C++, but you probably want http://www.phidgets.com/docs/Language_-_Java#Documentation. The 1110 connects to an InterfaceKit, and you defintly want to have a look at its addSensorChangeListener