A SERVICE OF

logo

124
Chapter 11: Sensors
You can, for example, trigger events based on the time of day using
csTime::getTimeOfDay(), which returns the current time of day. Your application can
then determine whether or not that time falls between startTime and stopTime.
The following methods are used to get and set the values of startTime and stopTime:
csTimeSensor::getStartTime();
csTimeSensor::setStartTime();
csTimeSensor::getStopTime();
csTimeSensor::setStopTime();
isActive
A csTimeSensor generates an isActive event when the csTimeSensor is rst activated or
deactivated. A csTimeSensor is activated if:
Time sensors are updated.
The current time is between startTime and stopTime.
A csTimeSensor is deactivated when the current time is past stopTime or when the
argument of loop() is FALSE and the time sensor has completed one cycle.
You can retrieve the current value of isActive by calling:
csTimeSensor::getIsActive();
Setting Cycle Duration
cycleInterval is a oat representing the duration of a single cycle in seconds.
For example, if csTimeSensor is driving an animation, a cycle generally represents the
number of times you want an animation to run. To run an animation once, set
cycleInterval to the length of the animation. To run an animation twice, set cycleInterval to
twice the length of the animation.
The following two methods are used to get and set the value of cycleInterval:
csTimeSensor::getCycleInterval();
csTimeSensor::setCycleInterval();