After messing with it for a day, I’m liking it better without memory. It goes directly into a ramp (one could even call it a *ahem* crescendo) from off, and lets me stop it where I want. This also lets me have a bigger ramp or a few blinkies, even on tiny13. And on tiny25, there’s a lot of extra space.
Also, since the random inconsistency was really bugging me, I ran some automated tests(*) on it. It looks like a robot gets more consistent results than when I test it manually… but only when I have it “tap” for 150ms or less. With a 200ms “tap”, the results are inconsistent. So, it looks like those short-presses have to be really short or it’ll sometimes do surprising things. And by surprising, I mean totally random because some SRAM bits decay before others and it can spontaneously jump to any mode or any level when this happens. Maybe I can avoid it by using an even bigger sample to detect long-vs-short presses.
* Just one quick test: click-tap to moon, measure amps, ramp up, measure, ramp down, measure, turbo, measure, exit turbo, measure, off… repeat 50 times and look for any measurements which look out of place.
… time passes …
Okay, there’s now a compile-time option to choose how careful it should be about this. It can use 8 bits, 16 bits, or 32 bits as the sample size… at the cost of 0, 8, or 28 extra bytes of ROM used. Attiny doesn’t really like integers longer than 8 bits.
… more time passes …
The 32-bit sample doesn’t seem to make things more consistent with 200ms taps. I suspect I’m seeing more variation in my test hardware than actual behavior changes in the light itself. It’s all running via shell scripts on a Beaglebone Black with an ACME Power Cape, which means timing isn’t incredibly precise. And each 50-repetition test run takes about 10 minutes. Maybe if I find just the right threshold though, like maybe 175ms, I can measure an actual difference from the larger SRAM sample method.
… more time passes …
Nope. No measurable difference between 8 and 32 bits worth of sample. On both, I get very clean behavior with 166ms taps and very random behavior with 175ms taps. I’ll take out the “XTREME_RANDOM_PREVENTION” code since it doesn’t help. Regardless, it was kind of a fun experiment, even if I didn’t find a way to fix the issues I found. At least it tells me the randomness is due to user inconsistency rather than hardware inconsistency.