Recording time length of a touch/light input?

Supporting Java SE version 7 and up
Charliefaber
Fresh meat
Posts: 4
Joined: Mon Mar 31, 2014 11:49 am
Contact:

Recording time length of a touch/light input?

Postby Charliefaber » Mon Mar 31, 2014 11:53 am

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

User avatar
burley
Human-Cyborg Relations
Posts: 441
Joined: Tue Sep 27, 2011 2:37 pm
Location: Calgary
Contact:

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

Postby burley » Tue Apr 01, 2014 7:28 am

You would just have a timer in your program that starts in a touch change event and ends in the next touch change event.
Brian Burley
403-282-7335 ext. 6003
support@phidgets.com

Charliefaber
Fresh meat
Posts: 4
Joined: Mon Mar 31, 2014 11:49 am
Contact:

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

Postby Charliefaber » Tue Apr 01, 2014 7:37 am

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?

frodegill
Phidget Mastermind
Posts: 114
Joined: Thu Mar 04, 2010 2:51 am
Contact:

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

Postby frodegill » Tue Apr 01, 2014 8:42 am

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.

Charliefaber
Fresh meat
Posts: 4
Joined: Mon Mar 31, 2014 11:49 am
Contact:

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

Postby Charliefaber » Tue Apr 01, 2014 2:04 pm

I was provided with 1110 sensors.

User avatar
mparadis
Site Admin
Posts: 644
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

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

Postby mparadis » Tue Apr 01, 2014 2:38 pm

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.

frodegill
Phidget Mastermind
Posts: 114
Joined: Thu Mar 04, 2010 2:51 am
Contact:

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

Postby frodegill » Tue Apr 01, 2014 2:49 pm

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.

Charliefaber
Fresh meat
Posts: 4
Joined: Mon Mar 31, 2014 11:49 am
Contact:

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

Postby Charliefaber » Fri Apr 04, 2014 8:59 am

That's very helpful! Thanks so much! Do you know where I can find the API for the methods/classes you are referring to?

frodegill
Phidget Mastermind
Posts: 114
Joined: Thu Mar 04, 2010 2:51 am
Contact:

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

Postby frodegill » Fri Apr 04, 2014 1:43 pm

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


Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest