GP2040-CE icon indicating copy to clipboard operation
GP2040-CE copied to clipboard

[WIP] Event System Implementation

Open mikepparks opened this issue 1 year ago • 0 comments

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 GPEventType in proto/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...));

mikepparks avatar Apr 14 '24 18:04 mikepparks