Hi,
I’m relatively new to Electric Imp and Squirrel. I’m using IMP001 with an April Rev3 (20121016), in case that’s relevant.
I’m using the Imp to control one RGB LED (WS2801, from Adafruit. datasheet).
Wiring
April is plugged into USB power (and jumper is set accordingly). LED has its own (USB-based) power supply. LED ground is connected to April ground. LED green (SPI clock) is connected to Pin5 LED yellow (SPI MOSI) is connected to Pin7Problem
I'd like to be able to control the LED's pattern with HTTP requests made to the agent. I have a simple program that takes in an array of hex values and cycles the LED from color to color fluidly. The problem is when I send another request to the agent the imp does not get interrupted. I've tried a couple of solutions to this, but the ideal one would be one involving threads or child processes that I could fork and kill as necessary.I’ve tried using global variables as interrupt/ready flags so that a new command coming down from the agent would interrupt the previous command. I’ve also tried imp.sleep(t)
but that didn’t do anything apparent. I’ve also tried storing the LED program with server.save()
but ran into memory/serialization problems.
Can anyone think of a way to interrupt the Imp on the fly, while it’s running code?
My code is on Github, if you want to take a deeper look.
Thanks,
Spencer