GP2040-CE
GP2040-CE copied to clipboard
[WIP] Event System Implementation
The idea behind this event system is to implement system-wide notices when certain functions occur. This will allow for more reactive features and potentially improve cross-feature communication, while cutting back on or eliminating duplicate functionality.
Examples of usage:
- On WebConfig restart, an event is triggered and the Display feature will change to a "Restarting" screen.
- With rotary encoders, the direction of travel, as well as the encoder ID is sent in an event that could be used for adjusting turbo rate, or switching profiles.
To add events, the following is needed:
- A new event enum value added to
GPEventTypeinproto/enums.proto - An event header in
headers/events - Event handlers can be registered with
EventManager::getInstance().registerEventHandler(GP_EVENT_ID, GPEVENT_CALLBACK(this->handleEvent(event);)); - Events can be fired with
EventManager::getInstance().triggerEvent(new GPEventClass(...props...));