frog.plugin.spot.onspot
Class AccelManager

java.lang.Object
  extended by frog.plugin.spot.onspot.AccelManager
All Implemented Interfaces:
TimerCounterBits, ISwitchListener, Frog_Spot_Constants, Killable

public class AccelManager
extends Object
implements Frog_Spot_Constants, ISwitchListener, Killable, TimerCounterBits

Listens to Switch1 and samples acceleration data when it is pressed. If the switch is held for longer than about 100ms, it is passed on to the FilterManager.

There is no Thread in AccelManager. Spots create a thread for ISwitchListeners whenever the switch is depressed or released. This class does all the work using that thread.

Author:
Team Better Recognize

Field Summary
static int DEFAULT_SAMPLE_RATE
          Sets the default sample rate by changing what will be put in the timer.
 
Fields inherited from interface frog.plugin.spot.Frog_Spot_Constants
CORRUPT_DATA, END_OF_DATA, INT_CORRUPT_DATA, INT_END_OF_DATA, MSG_ACK, MSG_ADD_FILTER, MSG_ALIVE, MSG_DISCONNECT, MSG_DISCOVER, MSG_END_OF_DATA, MSG_ERROR, MSG_GESTURE, MSG_REMOVE_FILTERS, MSG_RESEND, MSG_SAMPLE_RATE, PORT_BCAST, PORT_MAX, PORT_REPLY, PORT_START, SPOT1, SPOT1_PORT, SPOT2, SPOT2_PORT, SPOT3, SPOT3_PORT, SPOT4, SPOT4_PORT, SPOT5, SPOT5_PORT, SPOT6, SPOT6_PORT, SPOT7, SPOT7_PORT, SPOT8, SPOT8_PORT, SPOTB1, SPOTB1_PORT, SPOTB2, SPOTB2_PORT, SPOTB3, SPOTB3_PORT, SPOTB4, SPOTB4_PORT
 
Fields inherited from interface com.sun.spot.peripheral.TimerCounterBits
TC_ABETRG, TC_ABETRG_TIOA, TC_ABETRG_TIOB, TC_ACPA, TC_ACPA_CLEAR_OUTPUT, TC_ACPA_OUTPUT_NONE, TC_ACPA_SET_OUTPUT, TC_ACPA_TOGGLE_OUTPUT, TC_ACPC, TC_ACPC_CLEAR_OUTPUT, TC_ACPC_OUTPUT_NONE, TC_ACPC_SET_OUTPUT, TC_ACPC_TOGGLE_OUTPUT, TC_AEEVT, TC_AEEVT_CLEAR_OUTPUT, TC_AEEVT_OUTPUT_NONE, TC_AEEVT_SET_OUTPUT, TC_AEEVT_TOGGLE_OUTPUT, TC_ASWTRG, TC_ASWTRG_CLEAR_OUTPUT, TC_ASWTRG_OUTPUT_NONE, TC_ASWTRG_SET_OUTPUT, TC_ASWTRG_TOGGLE_OUTPUT, TC_BCPB, TC_BCPB_CLEAR_OUTPUT, TC_BCPB_OUTPUT_NONE, TC_BCPB_SET_OUTPUT, TC_BCPB_TOGGLE_OUTPUT, TC_BCPC, TC_BCPC_CLEAR_OUTPUT, TC_BCPC_OUTPUT_NONE, TC_BCPC_SET_OUTPUT, TC_BCPC_TOGGLE_OUTPUT, TC_BEEVT, TC_BEEVT_CLEAR_OUTPUT, TC_BEEVT_OUTPUT_NONE, TC_BEEVT_SET_OUTPUT, TC_BEEVT_TOGGLE_OUTPUT, TC_BSWTRG, TC_BSWTRG_CLEAR_OUTPUT, TC_BSWTRG_OUTPUT_NONE, TC_BSWTRG_SET_OUTPUT, TC_BSWTRG_TOGGLE_OUTPUT, TC_BURST, TC_BURST_NONE, TC_BURST_XC1, TC_BURST_XC2, TC_BUSRT_XC0, TC_CAPT, TC_CLKDIS, TC_CLKEN, TC_CLKI, TC_CLKS, TC_CLKS_MCK128, TC_CLKS_MCK2, TC_CLKS_MCK32, TC_CLKS_MCK8, TC_CLKS_SLCK, TC_CLKS_XC0, TC_CLKS_XC1, TC_CLKS_XC2, TC_CLKSTA, TC_COVFS, TC_CPAS, TC_CPBS, TC_CPCDIS, TC_CPCS, TC_CPCSTOP, TC_CPCTRG, TC_EEVT, TC_EEVT_TIOB, TC_EEVT_XC0, TC_EEVT_XC1, TC_EEVT_XC2, TC_EEVTEDG, TC_EEVTEDG_BOTH_EDGE, TC_EEVTEDG_EDGE_NONE, TC_EEVTEDG_FALLING_EDGE, TC_EEVTEDG_RISING_EDGE, TC_ENETRG, TC_ETRGEDG, TC_ETRGEDG_BOTH_EDGE, TC_ETRGEDG_EDGE_NONE, TC_ETRGEDG_FALLING_EDGE, TC_ETRGEDG_RISING_EDGE, TC_ETRGS, TC_LDBDIS, TC_LDBSTOP, TC_LDRA, TC_LDRA_BOTH_EDGE, TC_LDRA_EDGE_NONE, TC_LDRA_FALLING_EDGE, TC_LDRA_RISING_EDGE, TC_LDRAS, TC_LDRB, TC_LDRB_BOTH_EDGE, TC_LDRB_EDGE_NONE, TC_LDRB_FALLING_EDGE, TC_LDRB_RISING_EDGE, TC_LDRBS, TC_LOVRS, TC_MTIOA, TC_MTIOB, TC_NONEXC0, TC_NONEXC1, TC_NONEXC2, TC_SWTRG, TC_SYNC, TC_TC0XC0S, TC_TC1XC1S, TC_TC2XC2S, TC_TCLK0XC0, TC_TCLK1XC1, TC_TCLK2XC2, TC_TIOA0XC1, TC_TIOA0XC2, TC_TIOA1XC0, TC_TIOA1XC2, TC_TIOA2XC0, TC_TIOA2XC1, TC_WAVE, TC_WAVSEL_UP_AUTO_TRG_CP, TC_WAVSEL_UPDOWN_AUTO_TRG_CP, TC_WAVSEL_UPDOWN_NO_TRG_CP
 
Constructor Summary
AccelManager(FrogSpot frog)
          Creates the AccelManager with a permanent reference back to the FrogSpot for quick access to its facilities.
 
Method Summary
 void kill()
          Attempt to unconditionally stop all threads and release all resources.
 void setSampleRate(int hertz)
           
 void switchPressed(ISwitch sw1)
          Samples acceleration data whenever the switch is pressed.
 void switchReleased(ISwitch sw1)
          Deprecated. unused
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SAMPLE_RATE

public static final int DEFAULT_SAMPLE_RATE
Sets the default sample rate by changing what will be put in the timer. This value gets set in FrogSpot.startApp().

The default is 100Hz. 10000 microseconds is the time between ticks if you want something to occur 100 times a second. 30.5176 is the time per tick using the TC_CLKS_SLCK (slow) clock.

See Also:
Constant Field Values
Constructor Detail

AccelManager

public AccelManager(FrogSpot frog)
Creates the AccelManager with a permanent reference back to the FrogSpot for quick access to its facilities.

Parameters:
frog - reference to the FrogSpot object
Method Detail

kill

public void kill()
Description copied from interface: Killable
Attempt to unconditionally stop all threads and release all resources.

Specified by:
kill in interface Killable

setSampleRate

public void setSampleRate(int hertz)

switchPressed

public void switchPressed(ISwitch sw1)
Samples acceleration data whenever the switch is pressed.

Specified by:
switchPressed in interface ISwitchListener
Parameters:
sw1 - switch1 on the SPOT

switchReleased

public void switchReleased(ISwitch sw1)
Deprecated. unused

Specified by:
switchReleased in interface ISwitchListener