DFMiniMp3 icon indicating copy to clipboard operation
DFMiniMp3 copied to clipboard

T_NOTIFICATION_METHOD callback class enhanced to support non-static methods for context.

Open Makuna opened this issue 5 months ago • 1 comments

Users requested that the callback be made on an instance of class so they can provide context.

Notes: See T_SERIAL_METHOD for a way to define and pass an instance. Another option for backward compatibility is to provide a default implementation with static callbacks like today but it manages a singleton object instance that it then calls onto. Provide an empty implementation so that there is no need for the sketch author to even provide one. Update samples to remove it from the simplest.

typedef DfMp3Notify<MyClass> Mp3Notify;
typedef DFMiniMp3<HardwareSerial, Mp3Notify> DfMp3;

...
MyClass myInstance;
Mp3Notify::SetInstances(myInstance);

Makuna avatar Feb 01 '24 23:02 Makuna

See updated examples of three ways the new update can be used. Class instance callbacks, class static callbacks like today, and no callbacks at all.

Makuna avatar Feb 07 '24 18:02 Makuna