LwEVT

group LWEVT

Lightweight event system.

Defines

LWEVT_TYPE_BASIC(name)

Defines basic event type with respective name, only.

Basic events do not have possibility to send data to application

#define LWEVT_TYPE_BASIC(MY_EVENT_NAME)

LWEVT_TYPE_EXT(name, data)

Defines extended event type with possibily to send data.

Data C-type has to be declared for proper use case

#define LWEVT_TYPE_EXT(MY_EVENT_NAME, struct {int par1; int par2;} my_event_name;)

Typedefs

typedef void (*lwevt_fn)(lwevt_t *evt)

Event callback function prototype.

Enums

enum lwevt_type_t

Event type.

Values:

enumerator LWEVT_TYPE_LAST

Last element on the list

Functions

void lwevt_init(void)

Initialize LwEVT module.

uint8_t lwevt_register(lwevt_fn evt_fn)

Register new event listener callback to event manager.

Parameters

evt_fn – Function to add to list of listeners

Returns

1 if added, 0 otherwise

lwevt_t *lwevt_get_handle(void)

Get default handle object for dispatch purpose.

Note

Available only when LWEVT_CFG_ENABLE_DEFAULT_HANDLE is enabled

Returns

Pointer to default event handle

uint8_t lwevt_dispatch(lwevt_type_t type)

Dispatch event to all registered functions.

Note

It uses default event handle as parameter

Note

Available only when LWEVT_CFG_ENABLE_DEFAULT_HANDLE is enabled

Parameters

type[in] Event type to dispatch

Returns

1 if dispatched, 0 otherwise

uint8_t lwevt_dispatch_ex(lwevt_t *e, lwevt_type_t type)

Dispatch event to all registered functions using custom event handle object.

Parameters
  • ehandle – Event handle used as parameter to listeners

  • type – Event type to dispatch

Returns

1 if dispatched, 0 otherwise

struct lwevt_t
#include <lwevt.h>

Main event structure.

Public Members

lwevt_type_t type

Event type

const unsigned int dummy

Dummy element if no others are used by user

union lwevt_t::[anonymous] msg

Message union for extended event types