Trying to run JLED functions within a function

I have a large program with about 30 functions that flash LEDs in various patterns. I would like to fade some of these lights and have a sine-based function that works and does the job. But I discovered the JLED library that will do this and more…if I could get it to do what I want.

JLED has to be “started” within the global scope of the program, before Setup. Here’s a sample of one of the statements: JLed led= JLed(11).Blink(1000,500).Forever();

Within the Loop() function is the led.Update(); statement.

Configured this way, it DOES WORK. (I have to jump to one of my functions to get the I2C port number to turn on the correct segment of my display, but that’s it!).

I want to run this inside one or more of my 30 functions, or even be able to create a function with this in it, like this: (I don’t want to bore you with my 800 line program, so I just snipped this function out).

void Blink()//this function is called from Loop() function.
{CS.portWrite(6, 0xFFFF); //CS is Centipede construct. I write to 7-I2C segments. This is #6
//JLed led= JLed(11).Blink(1000,500).Forever()

}

Note the commented out line where I tried to run it. Nothing happens when I do. It ONLY works if the line is in global program space and I cannot run two of them simultaneously because the compiler responds with a “redefinition” error.

I found some docs on JLED from the developer who showed how to run multiple LEDs simultaneously which is attached. However, once again, it can only be run in global space.

How can I run it within a function of my own design?

multiLEDDemo.h (491 Bytes)

I'm not familiar with the JLED library, but I doubt that you have to "start" it at global scope. What you do need is to have declared JLed instances as global scope so that you are able to call their update() function from inside loop() or anywhere else for that matter.

In other words, try declaring the instances globally like this:JLed led= JLed(11);

Then configure them in sub functions like this: led = led.Blink(1000,500).Forever();