Closed MarkEMarkEMark closed 12 years ago
Mark, great work! The bug in the first block is that you're setting the index variable past the range of the programs. You want to set index to count - 1, not count. The programs are numbered starting with zero, so if there are 10 they're really 0 through 9.
Also, for clarity you might want to separate the index updating from the range checking. E.g. if up then ++ else --; and after that, if index >= count then index %= count (I am pretty sure index is unsigned so that single range check works for both ends of the range).
On the second question, fillsequence has nothing to do with this. You want to change Do to do just one slice of work and then return whatever value you're using for wait. Basically instead of running through your whole for loop each time Do gets called, do just one iteration of that loop. You will have to change your myColor and i index variables into member variables so that their values are preserved across successive Do calls. I'd also advise getting rid of wait_ and just keeping the return bulbframe.
Oops, looks like GitHub read the underscores as Markdown. Hope you can figure it out.
Hi sowbug - as usual, the answer came to me not long after posting (this always happens!). Anyway - you are right about the -1, but the main problem was with having stock and plus programs. It works if I just stick to one of these. I don't mind, as I'll recreate all my programs in a single new one. I'll post my other program, when I've converted it from the LEDstrip version that I wrote - it's like a random strobe like you can see on the Eiffel Tower at night. I'll try your suggestion for my the rainbow program. Thanks for your help!
PS - the Adafruit LEDStrip code has some great examples using alpha channels in that the programs can fade smoothly into each other! It wouldn't be as smooth with the fewer colors of the G35, but I intend to give it a go anyway...
Hi Sowbug,
I'm glad to see that you are still working on this with the Hallowe'en additions recently.
I've been putting a lot of work into ammending your code for my needs, and new programs.
I've added in code that allows the polling of 9 buttons (using adafruits interupt version in blog: http://www.adafruit.com/blog/2009/10/20/example-code-for-multi-button-checker-with-debouncing/), and it works a treat.
I'm using the first button to step up the programs (with a very long 86400 timeout value, i.e. 24 hours) However, when I try to step down the values with another button, it works down to program zero, but then resets the Arduino when tries to go backwards. I've tried everything I can think of to wrap around, but to no avail.
I'm going to use the other buttons to change colours and speed. I'm pretty excited to be able to do this in time for Xmas like a 42 year old kid!!
Also, I've adapted a nice rainbow function (with a lot of effort) from a different LED strip from Adafruit (thouroughly recommended - I've 10m of these - 320 lights! I got cheap from China). It works brilliantly, but the program has to finish before it will switch programs. I can't get my head around your 'fill_sequence' function which allow you to switch programs immediately. If you any ideas on how to convert this to your way, it'd be really great. (It's a really nice program that cycles through the color wheel)
Thanks, and sorry to ask questions in the issues - but I couldn't see any other way of asking you questions.