I am having issues with running multiple imp.wakeup calls within the same program.
The objective of my code is to use the imp to check the time and then oscillate a LED at different frequencies based on what time it is. By oscillate, I mean vary the intensity 0-100% at different frequencies using the PWM function of the IMP.
My LED oscillation function looks like this:
`function ledslow()
{
if(dc >= 1)
{
inc = 0;
}
if(dc <= 0.05)
{
inc = 1;
}
dc = inc ? dc + 0.01 : dc - 0.01;
hardware.pin9.write(dc);
imp.wakeup(0.04, ledslow);
}`
where imp.wakeup(0.04, ledslow) oscillates the LED at a slow speed. I have a similar function, ledfast(), with imp.wakeup(0.01, ledfast), to oscillate the LED at a faster speed. Both of these functions have been tested and work perfectly fine on their own.
I then have a main function, main(), that uses date() to check the hour of day, and based on that, determine which LED oscillation function to call. main() uses imp.wakeup(1, main) to check the time every second.
When I run the entire program, the LED does indeed oscillate, but at an ever increasing speed until it reaches a maximum frequency. I am not sure what the terminology is, but I believe the imp.wakeup calls are compounding each other.
Am I doing something wrong? Is there a better way to accomplish this goal? I have read on the forums that the imp should be able to handle multiple imp.wakeup calls.
I am very new to squirrel so would appreciate any help I can get. Thanks.