embedded system library for e-puck  1.0.1
A redesigned API library for the e-puck robot platform
 All Data Structures Files Functions Variables Enumerations Enumerator Modules Pages
Typedefs | Enumerations | Functions
el_trigger.h File Reference
#include "el_common.h"
#include "el_process.h"

Go to the source code of this file.

Typedefs

typedef bool(* el_condition )(void *)
 

Enumerations

enum  el_trigger_event_type {
  EL_EVENT_NONE = 0, EL_EVENT_INTERNAL_A = 1, EL_EVENT_INTERNAL_B = 2, EL_EVENT_INTERNAL_C = 3,
  EL_EVENT_INTERNAL_D = 4, EL_EVENT_INTERNAL_E = 5, EL_EVENT_INTERNAL_F = 6, EL_EVENT_IR_RECEIVER_INCOME = 10,
  EL_EVENT_UART1_RECEIVED = 11, EL_EVENT_UART2_RECEIVED = 12, EL_EVENT_ACCELEROMETER_UPDATE = 20, EL_EVENT_IR_PROXIMITY_UPDATE = 21,
  EL_EVENT_CAMERA_FRAME_UPDATE = 22
}
 

Functions

el_handle el_create_trigger ()
 create a trigger in the system More...
 
void el_delete_trigger (el_handle trigger)
 delete the trigger More...
 
void el_trigger_enable (el_handle h)
 enable a trigger More...
 
void el_trigger_disable (el_handle h)
 disable a trigger More...
 
el_bool el_trigger_is_enabled (el_handle h)
 check whether a trigger More...
 
void el_trigger_set_event (el_handle h, el_trigger_event_type e)
 set the event of the trigger More...
 
void el_trigger_set_condition (el_handle h, el_condition f)
 set the condition callback function of the trigger More...
 
void el_trigger_set_process (el_handle h, el_process func)
 set the process entry function of the trigger More...
 
el_uint32 el_trigger_get_counter (el_handle h)
 get the number of times the trigger passed its condition More...
 
void el_trigger_issue_internal_event (el_enum e)
 issue an internal event More...
 

Detailed Description

Author
Jianing Chen

Enumeration Type Documentation

This enum is used in el_trigger_set_event to specify the event of a trigger. Internal events are manually triggered using el_trigger_issue_internal_event.

Enumerator
EL_EVENT_NONE 

no event

EL_EVENT_INTERNAL_A 

internal event A

EL_EVENT_INTERNAL_B 

internal event B

EL_EVENT_INTERNAL_C 

internal event C

EL_EVENT_INTERNAL_D 

internal event D

EL_EVENT_INTERNAL_E 

internal event E

EL_EVENT_INTERNAL_F 

internal event F

EL_EVENT_IR_RECEIVER_INCOME 

when the ir receiver receives data

EL_EVENT_UART1_RECEIVED 

when UART1 receives data

EL_EVENT_UART2_RECEIVED 

when UART2 receives data (not implemented yet)

EL_EVENT_ACCELEROMETER_UPDATE 

when the accelerometer output is updated (120 Hz)

EL_EVENT_IR_PROXIMITY_UPDATE 

when the ir proximity sensor outputs are updated (30 Hz)

EL_EVENT_CAMERA_FRAME_UPDATE 

when a new image frame from the camera is ready (9~18 fps)

Function Documentation

el_handle el_create_trigger ( )

create a trigger in the system

Returns
handle of the trigger

This function create a trigger in the system. It returns a handle to the trigger created. This handle is used to refer the trigger in the related functions.

void el_delete_trigger ( el_handle  trigger)

delete the trigger

Parameters
handleof the trigger
void el_trigger_enable ( el_handle  h)

enable a trigger

Parameters
hhandle of the trigger

Only when a trigger is enabled, its event will be effective. A trigger is enabled by default after its creation.

void el_trigger_disable ( el_handle  h)

disable a trigger

Parameters
hhandle of the trigger

When a trigger is disabled, its event will be ignored. A trigger is automatically disabled when its process is launched.

el_bool el_trigger_is_enabled ( el_handle  h)

check whether a trigger

Parameters
hhandle of the trigger
Returns
the enabling status
void el_trigger_set_event ( el_handle  h,
el_trigger_event_type  e 
)

set the event of the trigger

Parameters
hhandle of the trigger
etype of the event within the category

This function defines the event of the trigger.

void el_trigger_set_condition ( el_handle  h,
el_condition  f 
)

set the condition callback function of the trigger

Parameters
hhandle of the trigger
fpointer to the callback function

When the event of the trigger occurs, the trigger's condition callback will be called. If this callback function returns true, the trigger passes the condition. Otherwise, the trigger does not pass the condition.

If a trigger does not have a condition callback (by default), the trigger will automatically pass it's condition.

void el_trigger_set_process ( el_handle  h,
el_process  func 
)

set the process entry function of the trigger

Parameters
hhandle of the trigger
funcpointer to the process function

When the trigger passes its condition and it has a registered process, the process will be launched while the trigger will be disabled automatically.

The parameter of the process function of a trigger will be assigned with the handle of the trigger. The following code can be used to make the handle more explicit:

1 void TriggerA_Process(void*arg){
2  el_handle this_trigger = arg;
3 
4  // the program to be executed
5  ...
6 
7  // re-enable the trigger if the trigger is supposed to be periodic.
8  el_trigger_enable(this_trigger);
9 
10 }

To learn more about the usage of a process, see Process.

el_uint32 el_trigger_get_counter ( el_handle  h)

get the number of times the trigger passed its condition

Parameters
hhandle of the trigger
Returns
counter of the trigger

For each time the trigger passes its condition, its counter will +1.

void el_trigger_issue_internal_event ( el_enum  e)

issue an internal event

Parameters
eevent type (must be internal events)

This will affect those triggers using "EL_EVENT_INTERNAL_<*>" as their events.