Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
FrameworkController.h File Reference

The FrameworkController class for event-driven control logic in embedded applications. More...

#include "FrameworkTask.h"
#include <unordered_map>
#include <functional>
#include <string>
#include <FreeRTOS.h>
#include <task.h>
#include "events/Event.h"
#include "http/Router.h"
+ Include dependency graph for FrameworkController.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  FrameworkController
 Base class for event-driven control logic in embedded applications. More...
 

Macros

#define STRINGIFY_DETAIL(x)   #x
 Utility macro for periodic polling using a unique ID.
 
#define STRINGIFY(x)   STRINGIFY_DETAIL(x)
 
#define RUN_EVERY(ms, fn)   runEvery(ms, fn, __FUNCTION__ ":" STRINGIFY(__LINE__))
 

Detailed Description

Author
Ian Archbell

Extends FrameworkTask to provide a convenient structure for application logic with periodic polling, event handling, and timed function execution.

Your application will typically implement one or more controllers to manage different aspects of your system. Each controller can handle its own events, perform background tasks, and run periodic functions.

You will typically use the EventManager, which provides pub/sub capabilities to dispatch events to the appropriate controller. The architucture allows for both event handling and polling in the same controller

This class is designed to be flexible and modular, allowing you to create multiple instances for different parts of your application. For example, you might have a SensorController for reading sensor data, a NetworkController for handling communication, and a MainController to coordinate overall application behavior.

Intended to be subclassed. You override onStart(), onEvent(), and poll() to define your application's behavior.

Version
0.1
Date
2025-03-31
License:\n MIT License

Definition in file FrameworkController.h.

Macro Definition Documentation

◆ RUN_EVERY

#define RUN_EVERY (   ms,
  fn 
)    runEvery(ms, fn, __FUNCTION__ ":" STRINGIFY(__LINE__))

Definition at line 201 of file FrameworkController.h.

◆ STRINGIFY

#define STRINGIFY (   x)    STRINGIFY_DETAIL(x)

Definition at line 200 of file FrameworkController.h.

◆ STRINGIFY_DETAIL

#define STRINGIFY_DETAIL (   x)    #x

Expands to runEvery(ms, fn, "function:line") automatically.

Definition at line 199 of file FrameworkController.h.