Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #56 on: August 29, 2011, 01:41:50 am » |
Hey, working with your code and am slightly confused as how you got this to work without a function really being created as to how this works or i simply can not find it...
// The macro below uses 3 instructions per pin to generate the byte to transfer with SPI // Retreive duty cycle setting from memory (ldd, 2 clockcycles) // Compare with the counter (cp, 1 clockcycle) --> result is stored in carry // Use the rotate over carry right to shift the compare result into the byte. (1 clockcycle). #define add_one_pin_to_byte(sendbyte, counter, ledPtr) .
which is than used in the intterupt routine by : add_one_pin_to_byte(sendbyte, counter, --ledPtr);
i understand that if ledPtr >= counter, sendbyte(actually bit) = 1 else sendbyte(actually bit) = 0 but i don't see how its actually done.
The reason why i am asking is because i want to add this look-up table for gamma correction to create a more realistic appearance of how the lights should look and possibly create more performance.
Gamma array size: 64 Total PWM steps: 255 Gamma correction: .74
static int Gamma_Cor[64] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 13, 14, 16, 17, 18, 20, 22, 23, 25, 27, 30, 32, 34, 37, 40, 43, 46, 50, 54, 58, 62, 66, 71, 76, 82, 88, 94,101,108,116,124,132,141, 151,162,173,184,197, 210,224,239,255 };
using look-up table during interrupt would yield: add_one_pin_to_byte(sendbyte, Gamma_Cor[counter], --ledPtr); if i am not mistaken.
If the counter has to only go through 64 steps instead of 255 to complete a full pwm cycle, would that not cut down the need of the interrupt to send bytes out by 75% or so lessening the load of the program?
|