cgnuino
Public Member Functions | List of all members
CgnPause Class Reference

Temporally pauses task progression by digital-in pin state. More...

#include <cgnuino.h>

Public Member Functions

 CgnPause (byte, bool=LOW, uint16_t=100)
 Constructor. More...
 
void check ()
 Checks the designated digital-in pin for pausing.
 

Detailed Description

During an experiment, there may be an occasion that you want to temporally stop the progression of the task. Normally, this is not common in human experiments in which the task should keep progressing until a predetermined number of trials are correctly finished. However, especially in animal experiments, you will often need to pause the task during an experiment. For example, you may not want the task to start before you finish booting all the measurement apparatus even if the animal is ready. In another case, you may need to halt the trial progression until you finish dealing with accidental failure of some device.

CgnPause class provides a physical switching mechanism to temporally pause your task. It judges whether to proceed or not based on the high/low state of the designated digital-in pin. The pin is automatically pulled up at the time of construction of CgnPause instance. If the pin is connected to GND, CgnPause class halts the task until the pin becomes unconnected, i.e., re-connected to the internal pull-up. (This relationship can be inverted if you wish to.)

If you want to pause the task at any timing during a trial, put check method on a main code of loop function so that the evaluation of pausing can occur in each loop. However, if the task is suddenly paused within a trial, it is possible that some output pins are stuck at undesired state (e.g., high-locked digital-out pin that keeps driving external device, tone output that keeps beeping during the pause). To prevent this, use check method in a task period dedicated for the pausing evaluation during an inter-trial interval.

Examples:
Pause.ino.

Constructor & Destructor Documentation

CgnPause::CgnPause ( byte  pausePin,
bool  stopWhen = LOW,
uint16_t  pauseMs = 100 
)
Parameters
pausePinPin number of digital input to invoke pausing.
stopWhenPin value when the task should pause.
pauseMsChecking cycle for the task to restart in [ms].

The documentation for this class was generated from the following files: