deniah
Member level 4
- Joined
- Nov 28, 2005
- Messages
- 74
- Helped
- 6
- Reputation
- 12
- Reaction score
- 5
- Trophy points
- 1,288
- Location
- Montenegro
- Activity points
- 1,777
I'm doing some experiments with 40x7 led matrix display and I'm trying to built effect where dots are switch on randomly to form letters.
Say, first column has to be 0b11111110.
First pass column looks like 0b00000000
Second pass 0b00001010
Third pass 0b10001110
forth pass 0b10111110
fifth pass 0b11111110
Every column must have own random pattern.
i've been struggling with this few days with no success.
Here is my code for static massage:
Fonts definitions are in one dimmension array:
Can you give me idea how to solve this?
Regards
Refik Zaimovic
Say, first column has to be 0b11111110.
First pass column looks like 0b00000000
Second pass 0b00001010
Third pass 0b10001110
forth pass 0b10111110
fifth pass 0b11111110
Every column must have own random pattern.
i've been struggling with this few days with no success.
Here is my code for static massage:
Code:
#define SHIFT_DATA PORTB.F2 // 74HC595 Data
#define SHIFT_LATCH PORTB.F0 // 74HC595 Latch
#define SHIFT_CLOCK PORTB.F1 // 74HC595 Clock
#include "fnt.h"
char x,row,j,pos,i;
char buffer[40];
char msg[] = "Demotxt";
void main() {
init();
row = 0x01;
j=0;
pos=0;
while (1){
for (i=0; i<=39; ++i) {
buffer[i] = font6x7[((msg[pos]-32)*6)+j];
if (++j == 0x06) {
j=0;
pos++;
}
}
for (i=0; i<=200; ++i) {
for (x=0; x<=39; ++x) {
SHIFT_DATA = 1;
if (buffer[x] & row) SHIFT_DATA = 0;
SHIFT_CLOCK = 1;
SHIFT_CLOCK = 0;
}
SHIFT_LATCH = 1;
SHIFT_LATCH = 0;
portc = ~row;
row <<= 1;
if (row == 0x80) row = 0x01;
delay_us(1100);
portc = 0xff;
}
pos=0;
j=0;
}
}
Fonts definitions are in one dimmension array:
Code:
const unsigned short font6x7[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code for char
0x00, 0x00, 0x7D, 0x00, 0x00, 0x00, // Code for char !
0x00, 0x60, 0x00, 0x60, 0x00, 0x00, // Code for char "
....
Can you give me idea how to solve this?
Regards
Refik Zaimovic