The main task routinely checks this variable then pauses until the same sensor is pressed again. It then resets the variable and carries on.
The problem is that I want to add another sensor (the shutter button on the same remote). This might not be pressed, but if it is, it will be very soon after the first button.
I am using 'wait' commands to avoid reading the same sensor twice.
The problem is that the second sensor might be missed because the main thread is in a wait state.
Is what I am trying to do possible, or do I have to think again?
Code: Select all
task pause_1 () // Check for touch sensor in port 1 & set touch_1 variable
{
touch_1 = false ; // Make sure value initialised
while (1 == 1) // Endless loop
{
until (SENSOR_1 == 1); // Wait until touch sensor in Port 1 activated
touch_1 = true ; // Record sensor activated
PlayTone (1000,1000); // Audible confirmation
Wait (1000) ;
ClearSensor(IN_1); // reset sensor
until (touch_1 == false) ; // Check to see if reset by task main
} // End of While loop
} // task pause_1 ended =========================================================
Code: Select all
task main ()
{
SetSensorTouch(S1); // Initialise touch sensor to be used in Pause_1 task
..............
..............
StartTask (pause_1) ; // Start checking touch sensor in port 1
..............
..............
while (shot_count < n_rows) // Loop for all shots in column
{
if (touch_1 == true ) // Check to see if should pause
{
ClearScreen ();
TextOut (1,LCD_LINE1,"PAUSED");
TextOut (3,LCD_LINE1,"PAUSED");
TextOut (5,LCD_LINE1,"PAUSED");
Wait (1000);
until (SENSOR_1 == 1); // Wait until touch sensor in Port 1 re-activated
PlayTone (3000,1000); // Audible confirmation
Wait (1000);
ClearScreen ();
touch_1 = false; // Reset 'sensor activated' variable
ClearSensor(IN_1); // Reset touch sensor
}
..............
..............