diff --git a/README.md b/README.md index e8134d1..28cb010 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,17 @@ void loop() { ``` +### Usage with lambdas that capture context + +You **can't pass** a lambda-**with-context** to an argument which expects a **function pointer**. To work that around, +use `paramtererizedCallbackFunction`. We pass the context (so the pointer to the object we want to access) to the library +and it will give it back to the lambda. + +```CPP +okBtn.attachClick([](void *ctx){Serial.println(*(((BtnHandler*)(ctx))) -> state}}), this); +``` + + ## State Events Here's a full list of events handled by this library: @@ -157,4 +168,4 @@ If your buttons aren't acting they way they should, check these items: 1. Check your wiring and pin numbers. 2. Did you call `tick()` on each button instance in your loop? 3. Did you alter your clock timers in any way without adjusting ticks? - \ No newline at end of file +