hello_world

Example of the component marcel-cd/tinybus v1.0.3
# Nonsense Hello World Logger  

This is a **rather nonsense example** that logs `"Hello World"` to the console.  
Why? Because we can 🚀 —and because it demonstrates the basic usage of TinyBus.  

## Running the Example  

To run this masterpiece on a Linux host, simply use:  

```sh
make linux
```

## Code  

``` c
/*****************************************************************************
 * Tiny Bus Definitions for the main Module
 *****************************************************************************/

// 1. Define the events using in the state table
TB_EVENT_NAME(MAIN, HELLO_WORLD, "HelloWorld");

// 2. Declare the actions using in the state table
static void onHelloWorld(Event *apEvent);

// 3. Glue everything togehter
static const StateTableRow stateTable[] = {{
    .state = TB_STATE_INITIAL, // only process the event, if the current state
                               // match. TB_STATE_INITIAL is the default state.
                               // use TB_STATE_ANY, if this should be ignored
    .event = MAIN_EVENT_HELLO_WORLD, // process if the event matches
    .conditionCheck =
        NULL, // No condition function.  The action is always executed.
    .entryAction = onHelloWorld, // The function to call when the event occurs.
    .nextState = TB_STATE_KEEP,  // Keep the current state after the action.
    .exitAction = NULL,          // No exit function.
    .stop = true // Stop processing after this entry (this is the default case)
}};

/*****************************************************************************/
// Implement the Actions
static void onHelloWorld(Event *apEvent) {
  ESP_LOGI(TAG, "Action onHellowWorld() called from TinyBus");
}
```

To create a project from this example, run:

idf.py create-project-from-example "marcel-cd/tinybus=1.0.3:hello_world"

or download archive (~9.19 KB)