Flipper Zero Firmware
Loading...
Searching...
No Matches
example_event_loop_multi.c File Reference

Example application that demonstrates multiple primitives used with two FuriEventLoop instances. More...

#include <furi.h>
#include <gui/gui.h>
#include <gui/view_port.h>
#include <furi_hal_random.h>

Data Structures

struct  EventLoopMultiAppWorker
 
struct  EventLoopMultiApp
 

Macros

#define TAG   "ExampleEventLoopMulti"
 
#define COUNTDOWN_START_VALUE   (5UL)
 
#define COUNTDOWN_INTERVAL_MS   (1000UL)
 
#define WORKER_DATA_INTERVAL_MS   (1500UL)
 
#define INPUT_QUEUE_SIZE   (8)
 
#define STREAM_BUFFER_SIZE   (16)
 

Functions

int32_t example_event_loop_multi_app (void *arg)
 

Detailed Description

Example application that demonstrates multiple primitives used with two FuriEventLoop instances.

This application simulates a complex use case of having two concurrent event loops (each one executing in its own thread) using a stream buffer for communication and additional timers and message passing to handle the keypad input. Additionally, it shows how to use thread signals to stop an event loop in another thread. The GUI functionality is there only for the purpose of exclusive access to the input events.

The application's functionality consists of the following:

  • Print keypad key names and types when pressed,
  • If the Back key is long-pressed, a countdown starts upon completion of which the app exits,
  • The countdown can be cancelled by long-pressing the Ok button, it also resets the counter,
  • Blocks of random data are periodically generated in a separate thread,
  • When ready, the main application thread gets notified and prints the data.