Saif,
Is this your own design?
PCB layout is not so good for understand the circuit, schematic diagram will be much better.
Some advices:
I don't have detail specification of 164 and 7445, 164 have to provide 5~20mA, depends on LED used. 7445 need 5 times the driving current.
Refresh rate should be >40Hz(very flicker) to 70Hz(very stable), that means switching each row in (1/40/7) 3.5ms to (1/70/7) 2ms, setup a timer to involve the scan() function.
A prelimary algorithm for your reference
Assuming Port1 connected to 7445 and port 2 to 164,
4 bytes (25 columns) used for display data for each row.
Code:dispBuffer[row][col/8]; #define Sclock P^0; #define Sdata P^1; void scan(void) { for (row=0; row<7 row++) { P1 = 0x00; // turn off display for (i=0; i<4; i++) // send 4 bytes of display data outOneByte(dispBuffer[row][i]); // send data to 164 P1 = 0x01<<row; // enable one single row } } void outOneByte(dispData) { Sclock = 0; // serial clock low for (i=0; i<8; i++) { //send 8 bits if ((dispData & 0x01)==1) Sdata = 1; else Sdata =0; Sclock =1; dispData >>=1; } }
The above code fragments are by no means accurate, by only give a rough idea, you have to rewrite to fit your situation.
I will search some reference designs for you later.
-1-
... I am folliwng your code
-2-
...but stuck in creating the dispBuffer[][] for all the 32 columns...
dispBuffer[row][col/8];
#define Sclock P^0;
#define Sdata P^1;
void scan(void) {
for (row=0; row<7 row++) {
P1 = 0x00; // turn off display
for (i=0; i<4; i++) // send 4 bytes of display data
outOneByte(dispBuffer[row][i]); // send data to 164
P1 = 0x01<<row; // enable one single row
[COLOR="#FF0000"]Delayms(2); // this is a must if you want to see something :-)[/COLOR]
} }
void outOneByte(dispData) {
Sclock = 0; // serial clock low
for (i=0; i<8; i++) { //send 8 bits
if ((dispData & 0x01)==1) Sdata = 1;
else Sdata =0;
Sclock = 1;
[COLOR="#FF0000"]Sclock = 0; // each bit requires a complete clock pulse !![/COLOR]
dispData >>=1;
} }
Hi;
@1:
The code fragment (written - a long ago- by Epegic) contains two basic errors, so it will not work. Look for my red corrections:
@2:Code:dispBuffer[row][col/8]; #define Sclock P^0; #define Sdata P^1; void scan(void) { for (row=0; row<7 row++) { P1 = 0x00; // turn off display for (i=0; i<4; i++) // send 4 bytes of display data outOneByte(dispBuffer[row][i]); // send data to 164 P1 = 0x01<<row; // enable one single row [COLOR="#FF0000"]Delayms(2); // this is a must if you want to see something :-)[/COLOR] } } void outOneByte(dispData) { Sclock = 0; // serial clock low for (i=0; i<8; i++) { //send 8 bits if ((dispData & 0x01)==1) Sdata = 1; else Sdata =0; Sclock = 1; [COLOR="#FF0000"]Sclock = 0; // each bit requires a complete clock pulse !![/COLOR] dispData >>=1; } }
There are a lot of methods to do this but in any case it depends on what kind of character bitmap table structure you are using. Many examples can be found on the net, but here in the forums too.
Good luck!
zuisti
static const char PROGMEM font5x8[] = {
0x00, 0x00, 0x00, 0x00, 0x00,// (spacja)
0x00, 0x00, 0x5F, 0x00, 0x00,// !
0x00, 0x07, 0x00, 0x07, 0x00,// "
0x14, 0x7F, 0x14, 0x7F, 0x14,// #
0x24, 0x2A, 0x7F, 0x2A, 0x12,// $
0x23, 0x13, 0x08, 0x64, 0x62,// %
0x36, 0x49, 0x55, 0x22, 0x50,// &
0x00, 0x05, 0x03, 0x00, 0x00,// '
0x00, 0x1C, 0x22, 0x41, 0x00,// (
0x00, 0x41, 0x22, 0x1C, 0x00,// )
0x08, 0x2A, 0x1C, 0x2A, 0x08,// *
0x08, 0x08, 0x3E, 0x08, 0x08,// +
0x00, 0x50, 0x30, 0x00, 0x00,// ,
0x08, 0x08, 0x08, 0x08, 0x08,// -
0x00, 0x30, 0x30, 0x00, 0x00,// .
0x20, 0x10, 0x08, 0x04, 0x02,// /
0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
0x00, 0x42, 0x7F, 0x40, 0x00,// 1
0x42, 0x61, 0x51, 0x49, 0x46,// 2
0x21, 0x41, 0x45, 0x4B, 0x31,// 3
0x18, 0x14, 0x12, 0x7F, 0x10,// 4
0x27, 0x45, 0x45, 0x45, 0x39,// 5
0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
0x01, 0x71, 0x09, 0x05, 0x03,// 7
0x36, 0x49, 0x49, 0x49, 0x36,// 8
0x06, 0x49, 0x49, 0x29, 0x1E,// 9
0x00, 0x36, 0x36, 0x00, 0x00,// :
0x00, 0x56, 0x36, 0x00, 0x00,// ;
0x00, 0x08, 0x14, 0x22, 0x41,// <
0x14, 0x14, 0x14, 0x14, 0x14,// =
0x41, 0x22, 0x14, 0x08, 0x00,// >
0x02, 0x01, 0x51, 0x09, 0x06,// ?
0x32, 0x49, 0x79, 0x41, 0x3E,// @
0x7E, 0x11, 0x11, 0x11, 0x7E,// A
0x7F, 0x49, 0x49, 0x49, 0x36,// B
0x3E, 0x41, 0x41, 0x41, 0x22,// C
0x7F, 0x41, 0x41, 0x22, 0x1C,// D
0x7F, 0x49, 0x49, 0x49, 0x41,// E
0x7F, 0x09, 0x09, 0x01, 0x01,// F
0x3E, 0x41, 0x41, 0x51, 0x32,// G
0x7F, 0x08, 0x08, 0x08, 0x7F,// H
0x00, 0x41, 0x7F, 0x41, 0x00,// I
0x20, 0x40, 0x41, 0x3F, 0x01,// J
0x7F, 0x08, 0x14, 0x22, 0x41,// K
0x7F, 0x40, 0x40, 0x40, 0x40,// L
0x7F, 0x02, 0x04, 0x02, 0x7F,// M
0x7F, 0x04, 0x08, 0x10, 0x7F,// N
0x3E, 0x41, 0x41, 0x41, 0x3E,// O
0x7F, 0x09, 0x09, 0x09, 0x06,// P
0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
0x7F, 0x09, 0x19, 0x29, 0x46,// R
0x46, 0x49, 0x49, 0x49, 0x31,// S
0x01, 0x01, 0x7F, 0x01, 0x01,// T
0x3F, 0x40, 0x40, 0x40, 0x3F,// U
0x1F, 0x20, 0x40, 0x20, 0x1F,// V
0x7F, 0x20, 0x18, 0x20, 0x7F,// W
0x63, 0x14, 0x08, 0x14, 0x63,// X
0x03, 0x04, 0x78, 0x04, 0x03,// Y
0x61, 0x51, 0x49, 0x45, 0x43,// Z
0x00, 0x00, 0x7F, 0x41, 0x41,// [
0x02, 0x04, 0x08, 0x10, 0x20,// "\"
0x41, 0x41, 0x7F, 0x00, 0x00,// ]
0x04, 0x02, 0x01, 0x02, 0x04,// ^
0x40, 0x40, 0x40, 0x40, 0x40,// _
0x00, 0x01, 0x02, 0x04, 0x00,// `
0x20, 0x54, 0x54, 0x54, 0x78,// a
0x7F, 0x48, 0x44, 0x44, 0x38,// b
0x38, 0x44, 0x44, 0x44, 0x20,// c
0x38, 0x44, 0x44, 0x48, 0x7F,// d
0x38, 0x54, 0x54, 0x54, 0x18,// e
0x08, 0x7E, 0x09, 0x01, 0x02,// f
0x08, 0x14, 0x54, 0x54, 0x3C,// g
0x7F, 0x08, 0x04, 0x04, 0x78,// h
0x00, 0x44, 0x7D, 0x40, 0x00,// i
0x20, 0x40, 0x44, 0x3D, 0x00,// j
0x00, 0x7F, 0x10, 0x28, 0x44,// k
0x00, 0x41, 0x7F, 0x40, 0x00,// l
0x7C, 0x04, 0x18, 0x04, 0x78,// m
0x7C, 0x08, 0x04, 0x04, 0x78,// n
0x38, 0x44, 0x44, 0x44, 0x38,// o
0x7C, 0x14, 0x14, 0x14, 0x08,// p
0x08, 0x14, 0x14, 0x18, 0x7C,// q
0x7C, 0x08, 0x04, 0x04, 0x08,// r
0x48, 0x54, 0x54, 0x54, 0x20,// s
0x04, 0x3F, 0x44, 0x40, 0x20,// t
0x3C, 0x40, 0x40, 0x20, 0x7C,// u
0x1C, 0x20, 0x40, 0x20, 0x1C,// v
0x3C, 0x40, 0x30, 0x40, 0x3C,// w
0x44, 0x28, 0x10, 0x28, 0x44,// x
0x0C, 0x50, 0x50, 0x50, 0x3C,// y
0x44, 0x64, 0x54, 0x4C, 0x44,// z
0x00, 0x08, 0x36, 0x41, 0x00,// {
0x00, 0x00, 0x7F, 0x00, 0x00,// |
0x00, 0x41, 0x36, 0x08, 0x00,// }
0x08, 0x08, 0x2A, 0x1C, 0x08,// ->
0x08, 0x1C, 0x2A, 0x08, 0x08 // <-
};
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 unsigned char buffer_data[256]; ... ... ... void run_from_right() { unsigned int a; unsigned char d; looping=speed; for (a=0;a<num_char;a++) { xep_add++; d=xread(xep_add); //read external eeprom shift_to_left(); buffer_data[255]=font_7_5[0,d]; display(); //refresh display shift_to_left(); buffer_data[255]=font_7_5[1,d]; display(); shift_to_left(); buffer_data[255]=font_7_5[2,d]; display(); shift_to_left(); buffer_data[255]=font_7_5[3,d]; display(); shift_to_left(); buffer_data[255]=font_7_5[4,d]; display(); shift_to_left(); buffer_data[255]=0; display(); }; looping=delaying; looping*=44; if (looping!=0) { display(); } } void shift_to_left() { unsigned int a; for (a=128;a<255;a++) { buffer_data[a]=buffer_data[a+1]; } }
Hi Zuisti,
Its ok for me if I get the PIC code. I would understand the logic. ...
// defining all of the symbols
#define A {B01110000,B10001000,B10001000,B11111000,B10001000,B10001000}
#define B {B11110000,B10001000,B10001000,B11110000,B10001000,B11111000}
#define C {B11111000,B10000000,B10000000,B10000000,B10000000,B11111000}
#define D {B11110000,B10001000,B10001000,B10001000,B10001000,B11110000}
#define E {B11111000,B10000000,B10000000,B11110000,B10000000,B11111000}
#define F {B11111000,B10000000,B10000000,B11110000,B10000000,B10000000}
#define G {B01110000,B10001000,B10000000,B10011000,B10001000,B01110000}
#define H {B10001000,B10001000,B11111000,B10001000,B10001000,B10001000}
#define I {B11111000,B00100000,B00100000,B00100000,B00100000,B11111000}
#define J {B00111000,B00010000,B00010000,B00010000,B10010000,B01100000}
#define M {B10001000,B11011000,B10101000,B10101000,B10001000,B10001000}
#define N {B10001000,B11001000,B10101000,B10101000,B10011000,B10001000}
#define L {B10000000,B10000000,B10000000,B10000000,B10000000,B11111000}
#define O {B01110000,B10001000,B10001000,B10001000,B10001000,B01110000}
#define P {B11110000,B10001000,B10001000,B11110000,B10000000,B10000000}
#define Q {B01110000,B10001000,B10101000,B10011000,B01111000,B00001000}
#define R {B11110000,B10001000,B10001000,B11110000,B10001000,B10001000}
#define S {B01110000,B10001000,B01100000,B00010000,B10001000,B01110000}
#define K {B10001000,B10010000,B11100000,B11100000,B10010000,B10001000}
#define T {B11111000,B00100000,B00100000,B00100000,B00100000,B00100000}
#define U {B10001000,B10001000,B10001000,B10001000,B10001000,B01110000}
#define V {B10001000,B10001000,B10001000,B10001000,B01010000,B00100000}
#define W {B10001000,B10001000,B10101000,B10101000,B10101000,B01010000}
#define X {B10001000,B01010000,B00100000,B00100000,B01010000,B10001000}
#define Y {B10001000,B01010000,B00100000,B00100000,B00100000,B00100000}
#define Z {B11111000,B00001000,B00110000,B01100000,B10000000,B11111000}
#define LA{B00000000,B01110000,B00001000,B01111000,B10001000,B01111000}
#define LB{B10000000,B10000000,B10110000,B11001000,B10001000,B11110000}
#define LC{B00000000,B01110000,B10000000,B10000000,B10001000,B01110000}
#define LD{B00001000,B00001000,B01111000,B10001000,B10001000,B01111000}
#define LE{B00000000,B01110000,B10001000,B11111000,B10000000,B01110000}
#define LF{B00110000,B01001000,B01000000,B11100000,B01000000,B01000000}
#define LG{B00000000,B01111000,B10001000,B01111000,B00001000,B01110000}
#define LH{B10000000,B10000000,B10110000,B11001000,B10001000,B10001000}
#define LI{B00100000,B00000000,B01100000,B00100000,B00100000,B01111000}
#define LJ{B00010000,B00000000,B00111000,B00010000,B10010000,B01100000}
#define LK{B10000000,B10010000,B10100000,B11000000,B10100000,B10010000}
#define LL{B01100000,B00100000,B00100000,B00100000,B00100000,B01111000}
#define LM{B00000000,B00000000,B11010000,B10101000,B10101000,B10001000}
#define LN{B00000000,B00000000,B10110000,B11001000,B10001000,B10001000}
#define LO{B00000000,B01110000,B10001000,B10001000,B10001000,B01110000}
#define LP{B00000000,B11110000,B10001000,B11110000,B10000000,B10000000}
#define LQ{B00000000,B01101000,B10011000,B01111000,B00001000,B00001000}
#define LR{B00000000,B00000000,B10110000,B11001000,B10000000,B10000000}
#define LS{B00000000,B01110000,B10000000,B01110000,B00001000,B11110000}
#define LT{B01000000,B01000000,B11100000,B01000000,B01001000,B00110000}
#define LU{B00000000,B00000000,B10001000,B10001000,B10011000,B01101000}
#define LV{B00000000,B00000000,B10001000,B10001000,B01010000,B00100000}
#define LW{B00000000,B00000000,B10001000,B10101000,B10101000,B01010000}
#define LX{B00000000,B10001000,B01010000,B00100000,B01010000,B10001000}
#define LY{B00000000,B10001000,B10001000,B01111000,B00001000,B01110000}
#define LZ{B00000000,B11111000,B00010000,B00100000,B01000000,B11111000}
#define SPACE{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000}
#define NUM0{B01110000,B10011000,B10101000,B10101000,B11001000,B01110000}
#define NUM1{B00100000,B01100000,B10100000,B00100000,B00100000,B01110000}
#define NUM2{B01110000,B10001000,B00001000,B01110000,B10000000,B11111000}
#define NUM3{B11110000,B00001000,B00001000,B01111000,B00001000,B11110000}
#define NUM4{B10001000,B10001000,B10001000,B11111000,B00001000,B00001000}
#define NUM5{B11111000,B10000000,B11110000,B00001000,B10001000,B01110000}
#define NUM6{B11111000,B10000000,B11111000,B10001000,B10001000,B11111000}
#define NUM7{B11111000,B00001000,B00001000,B01111000,B00001000,B00001000}
#define NUM8{B11111000,B10001000,B11111000,B10001000,B10001000,B11111000}
#define NUM9{B11111000,B10001000,B11111000,B00001000,B00001000,B11111000}
#define DEVIDE{B00001000,B00010000,B00100000,B00100000,B01000000,B10000000}
#define TWODOTS{B01100000,B01100000,B00000000,B00000000,B01100000,B01100000}
#define DOT{B00000000,B00000000,B00000000,B00000000,B01100000,B01100000}
#define COMA{B00000000,B00000000,B00000000,B00110000,B00110000,B01100000}
#define LINE{B00000000,B00000000,B11111000,B11111000,B00000000,B00000000}
#define QUASTION{B01110000,B10001000,B00010000,B00100000,B00000000,B00100000}
#define MARK{B00100000,B01110000,B01110000,B00100000,B00000000,B00100000}
int latchPin = 10; //latch pin of the shift register
int clockPin = 13; //clock pin of the shift register
int dataPin = 11; //data pin of the shift register
int clock = 9; //clock pin of the 4017 counter
int Reset = 8; //reset pin of the 4017 counter
// setting the pins for easy operation with PORTB
int latchPinPORTB = latchPin - 8;
int clockPinPORTB = clockPin - 8;
int dataPinPORTB = dataPin - 8;
int i = 0;
int incomingByte[44];// the incoming words go here
byte scrolling_word[6][3];// this is for the scrolling text
int array_turn=0;
byte patterns[100][6];
byte dummy_array[70][6] ={A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,SPACE,NUM0,NUM1,NUM2,NUM3,NUM4,NUM5,NUM6,NUM7,NUM8,NUM9,DEVIDE,TWODOTS,DOT,COMA,LINE,QUASTION,MARK,LA,LB,LC,LD,LE,LF,LG,LH,LI,LJ,LK,LL,LM,LN,LO,LP,LQ,LR,LS,LT,LU,LV,LW,LX,LY,LZ};
void setup(){
Serial.begin(9600);//starting communicatino with the PC at 9600 boud
// config for all the pins
pinMode(dataPin,OUTPUT);
pinMode(clockPin,OUTPUT);
pinMode(latchPin,OUTPUT);
pinMode(clock,OUTPUT);
pinMode(Reset,OUTPUT);
//reseting the 4017 counter
digitalWrite(Reset,HIGH);
digitalWrite(Reset,LOW);
setupSPI();//starting SPI communication
}
void display_word(int loops,byte word_print[][6],int num_patterns,int delay_langth){ // the main funcion for displaying and scrolling the word
i = 0;
for(int first=0;first<6;first++){ // reseting the scrolling_word array
for(int second=0;second<5;second++)
scrolling_word[first][second] = 0x00;
}
for(int x=0;x<num_patterns;x++){//main loop that goes over all of the symbols
for(int scroll=0;scroll<6;scroll++){// loop for scrolling, each symbols scrolls for 6 columns
for(int r=0;r<6;r++){//going over all of the rows
// this is the scrolling function it's like making a 3 byte word to scroll al once.
scrolling_word[r][2] = (scrolling_word[r][2] << 1)+((scrolling_word[r][1] & 0x80) >> 7);
scrolling_word[r][1] = (scrolling_word[r][1] << 1)+((scrolling_word[r][0] & 0x80) >> 7);
scrolling_word[r][0] = (scrolling_word[r][0] << 1)+(((word_print[x][r]<<scroll)&0x80)>>7);
}
for(int t=0;t<delay_langth;t++){// a delay loop that just shows the same frame over and over to create a delay
for(int y=0;y<6;y++){// the scaning loop that goes over all 6 rows
if(i == 6){//if the 4017 counter counts up to 6 reset it
digitalWrite(Reset,HIGH);
digitalWrite(Reset,LOW);
i = 0;// resetinf the counter
}
latchOff();// starint the communication with the shift registers
spi_transfer(scrolling_word[y][2]);// sending info
spi_transfer(scrolling_word[y][1]);
spi_transfer(scrolling_word[y][0]);
latchOn();
delayMicroseconds(800);//a small delay for each row
latchOff();// clearing the shift registers to make sure we will not get a ghosting effect
spi_transfer(0);
spi_transfer(0);
spi_transfer(0);
latchOn();
// advensing the 4017 counter by one( we just send a positive pulse)
digitalWrite(clock,HIGH);
digitalWrite(clock,LOW);
i++;
}
}
}
}
finish_scroll(delay_langth);// calling for a function to finish scrolling the last 4 symbols
}
void finish_scroll(int delay_scroll){// this function finishs the scrolling and it's very similar to the display_word function
for (int n=0;n<26;n++){
for(int h=0;h<6;h++){
scrolling_word[h][2] = (scrolling_word[h][2] << 1) | ((scrolling_word[h][1] & 0x80) >> 7);
scrolling_word[h][1] = (scrolling_word[h][1] << 1) | ((scrolling_word[h][0] & 0x80) >> 7);
scrolling_word[h][0] = (scrolling_word[h][0] << 1) | 0 ;
}
for(int t=0;t<delay_scroll;t++){
for(int y=0;y<6;y++){
if(i == 6){
digitalWrite(Reset,HIGH);
digitalWrite(Reset,LOW);
i = 0;
}
latchOff();
spi_transfer(scrolling_word[y][2]);
spi_transfer(scrolling_word[y][1]);
spi_transfer(scrolling_word[y][0]);
latchOn();
delayMicroseconds(800);
latchOff();
spi_transfer(0);
spi_transfer(0);
spi_transfer(0);
latchOn();
digitalWrite(clock,HIGH);
digitalWrite(clock,LOW);
i++;
}
}
}
}
void loop() {
// send data only when you receive data:
if(Serial.available() > 0){
delay(100);
incomingByte[array_turn] = Serial.read();// putting the symbol in the array
array_turn++;//counting the number of incomming symbols
}
else{
//this part is for getting the info we got and putting it in a form we could work with
if(array_turn != 0){
for(int az=0;az<array_turn;az++){//for latters
if((incomingByte[az] > 64 && incomingByte[az] < 91) || (incomingByte[az] > 96 && incomingByte[az] < 123)){
if(incomingByte[az] > 64 && incomingByte[az] < 91){
for(int lal=0;lal<6;lal++)
patterns[az][lal] = dummy_array[incomingByte[az] - 65][lal];
}
else{//for numbers
for(int lal=0;lal<6;lal++)
patterns[az][lal] = dummy_array[incomingByte[az] - 53][lal];
}}
else{// for odd symbols
switch(incomingByte[az]){
case 32://space
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[26][lol];
break;
case 33://mark
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[43][lol];
break;
case 45://line
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[41][lol];
break;
case 44://coma
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[40][lol];
break;
case 46://dot
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[39][lol];
break;
case 47://dvide
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[37][lol];
break;
case 48://0
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[27][lol];
break;
case 49://1
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[28][lol];
break;
case 50://2
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[29][lol];
break;
case 51://3
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[30][lol];
break;
case 52://4
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[31][lol];
break;
case 53://5
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[32][lol];
break;
case 54://6
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[33][lol];
break;
case 55://7
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[34][lol];
break;
case 56://8
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[35][lol];
break;
case 57://9
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[36][lol];
break;
case 58://tow dots
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[38][lol];
break;
case 63://quastion
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[42][lol];
break;
default:
for(int lol=0;lol<6;lol++)
patterns[az][lol] = dummy_array[26][lol];
break;
}
}
}
}
display_word(1,patterns,array_turn,15);
array_turn =0;
}
}
//display_word(1,patterns,43,15);// calls for the display_pattern function and says that int loop = 15(if you do more loop the pattern whould scrrol slower).
void latchOn(){
bitSet(PORTB,latchPinPORTB);
}
void latchOff(){
bitClear(PORTB,latchPinPORTB);
}
void setupSPI(){// setting all the registers for SPI cummunication
byte clr;
SPCR |= ( (1<<SPE) | (1<<MSTR) ); // enable SPI as master
//SPCR |= ( (1<<SPR1) | (1<<SPR0) ); // set prescaler bits
SPCR &= ~( (1<<SPR1) | (1<<SPR0) ); // clear prescaler bits
clr=SPSR; // clear SPI status reg
clr=SPDR; // clear SPI data reg
SPSR |= (1<<SPI2X); // set prescaler bits
//SPSR &= ~(1<<SPI2X); // clear prescaler bits
delay(10);
}
byte spi_transfer(byte data)
{
SPDR = data; // Start the transmission
while (!(SPSR & (1<<SPIF))) // Wait the end of the transmission
{
};
return SPDR; // return the received byte, we don't need that
}
I never use the SPI in the running text programming because i think that will be useless.
For example, to display 8x16, then I put in 16 memory locations. Each column occupies one memory location.
because each output of HC595 represents one column, then need to send the data for row 1 of column 16, row 1 of column 15 and beyond.
When using spi, the spi's advantage would be futile because it still requires the arrangement of the bits before it is sent. Fill data with bit 16 - bit 8 and then send SPI Data.
Even be faster when using regular bit-bang method.
The next question, why should arrange display memory in the order as above? It is the consideration of the ease in making the next animation. For example, to shift the display to the left, just transfer buffer number 2 to the buffer number 1, the buffer number 3 to number 2 and so on. Except if we use 16 or 32-bits microcontroller, so it only need single word to handle one row when we make bit manipulation to animate the display.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?