Closed sonyhome closed 8 years ago
Ah - right - forgot that those values are constants -- if you're lucky gcc is already generating only 2 instructions for the mask thing:
sbrc x, 2
ori bitmask, 0x04
(avr has sbrc/sbrs - skip if bit in register clear/set - it's also nice because it's constant - 2 cycles if skipping , 1 if not (and then the ori is 1 cycle).
Ah cool. So we're in agreement :)
What you say makes sense: I got worried that sending white pixels (0xFF) on all ports at the same time would impact the timing but I tested that and it doesn't flinch. The contra also tells the same story: if I send mostly zeros I do not get spare cycles as freebees to drive more ports. Also I tried to move the compare and the bitmask ori, and timings fail. It should not if it was 3 ops {cmp,bz, ori}. FYI I was trying to use some cycles when port sends HIGH for a one, after we send zero bits back to LOW. Makes sense? :)
Anyways I'm out of ideas on how to improve timings more to squeeze another 2 ports on an Uno :(
BTW, feel free to poach that code for FastLED if you can make use of it.
One reason I made this library is I couldn't wrap my head around your whole code stack, the ecosystem is too big to just jump in :) My projects use AtTiny85 so DRAM footprint is critical. I ran out of space to drive ~200LEDs with Adafruit and FastLED so I wanted to cover the minimalist user space with this library. If you're in California, I'll be at Maker faire and it'd be a pleasure to say hi live :)
Now works for up to 6 ports on Arduino Uno.