Hello everyone, I would like to ask a rather easy question about bitwise in embedded PIC microcontrollers. I have [10][32] LED array. In other words it is an LED TOWER which uses constant current led drivers connected in series (2 ics per layer (4 bytes)). I have a function that uses USART communication and addresses all leds.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void Update_Display(void){
while(!TRMT); // Wait until transmission register is empty
for (int y = 0; y < LAYERS; y++){
for (int x = 0; x < BYTES; x++){
TXREG = LED_Buffer[y][x];
while (!TRMT);
}
}
LE = 1; // Data is loaded to the Output latch
NOP(); NOP();
LE = 0; }
Now, I want to write a function that would shift a diagonal LEDs across and create the continuous animation. I hope you understand my intention..
I am not entirely sure how to do it, since i want to shift through all 4 bytes [32 leds/layer].
If you need me to provide more code let me know, I appreciate your help in advance.
Similar function that I have written is this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void Switch_Col(char c, char state){
int y;
if (state == ON){
for (y = 0; y < LAYERS; y++)
LED_Buffer[y][c/8] |= (1 << c % 8);
}
else{
for (y = 0; y < LAYERS; y++)
LED_Buffer[y][c/8] &= ~(1 << c % 8);
}
Update_Display();
}
which turns on the column according to the function argument provided.
coder777, thanks for replying back. Are you suggesting to use another buffer that i could write the animations to and than copy all of those elements to the one that is used by Update_Display() ?
Well, I write the animation to the LED_Buffer[y][x] and than i use Update_Display() to load the output latch and on LE falling edge the corresponding LEDS are set. However, since I have it a byte array rather than bit, makes it awkward to write to it every time.. I would love to simplify it, but don't really know how to go about it.