jandelgado / jled

Non-blocking LED controlling library for Arduino and friends.
MIT License
324 stars 51 forks source link

Question: How to pass to funtion #97

Closed BernhardSchlegel closed 1 year ago

BernhardSchlegel commented 2 years ago

Hey there,

I've created a JLed, I.e. using

auto my_led = JLed(GPIO_LED).LowActive().Off();

How do I pass that to a function

void fooFunction($WHAT_GOES_HERE$ led) { ... }

I've tried jled::JLed::TJLed, jled::JLed, auto ... nothing works. (I.e. resulting into error: use of deleted function 'jled::JLed::JLed()')

Thanks!

jandelgado commented 2 years ago

The type is simply JLed, so you could for example pass a reference with something like (make sure to a recent JLed version):

#include <jled.h>

auto led = JLed(LED_BUILTIN).Blink(1000, 1000).Repeat(5);

void dosomething(JLed& led) {
    led.Stop();
}

void setup() {
}

void loop() {
  led.Update();
  dosomething(led);
}
github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days