the lion عضو برونزي
عدد الرسائل : 199 العمر : 33 الاسم : Ahmed Eltabakh العمل/الترفيه : Engineer الكلية : الهندسه الاليكترونيه دعاء : مزاج العضو : نقاط : 223 السٌّمعَة : 5 تاريخ التسجيل : 05/11/2008
| موضوع: رد: التحكم في 640 جهاز باستخدام الكمبيوتر الأربعاء 14 يوليو 2010, 8:50 pm | |
| يارب الخطوه دي تكون بفايده وهرفع الكود كمان للي عايز يشوفه - الكود:
-
#include"E:\ahmedchar.c" #define order porta.f1=0; #define data porta.f1=1; #define reset porta.f0=0; delay_ms(10);porta.f0=1; #define s1 portb.f6 #define s2 portb.f7 #define data1 porta.f6 #define clk porta.f7=0; porta.f7=1; #define show porta.f4=0; porta.f4=1; int x1,bb,y1,sh,mx; char x,y,nx,nn,m1[8],ky; const char m[5]={33,144,32,13,11}; char relay[80],ser[4],i,flag,p1,p2,p3,bold[4]={1,0,0,0},lcd[3]={1,0,0},lop; char flag2;
//############################################## void d2b(char hex) { for(x=0;x<8;x++) { m1[7-x]=hex%2; hex=hex/2; }
} //############################################### //###############################################
//################################################ void write_shift(char num) { d2b(num); for(x=0;x<8;x++) { data1=m1[7-x]; clk }
} //################################################ //################################################ void write_port() { for(ky=0;ky<80;ky++) { write_shift(relay[ky]); } show }
//##################################### void data_fill(char ful) // full all the ram with zeros { data for(sh=0;sh<=504;sh++) { soft_spi_write(ful); } }
void go_address(char yy, char xx) // goto position of y,x { order yy=64+yy; soft_spi_write(yy); xx=128+xx; soft_spi_write(xx);
} void go_x(char xx) { order soft_spi_write(128+xx); } void go_y(char yy) { order soft_spi_write(64+yy); } //##################################### //##################################### void eltabakh_nokia_print(char mm[50],char invert)//print texts { nx=0; while(mm[nx]) { nx++; }
for(y1=0;y1<nx;y1++) { bb=mm[y1]-32; bb=bb*5; data for(x1=bb;x1<bb+5;x1++) { if(invert==1){ soft_spi_write(ahmednum[x1]);} else {soft_spi_write(~ahmednum[x1]);} } if(invert==1){ soft_spi_write(0); } else {soft_spi_write(0xff);}
} } ////////////////////////////////////////////////// ////////////////////////////////////////////////// void eltabakh_nokia_chr(int mmyr,char inv) // print variable numbers {
bb=mmyr+16; bb=bb*5; data for(x1=bb;x1<bb+5;x1++) { if(inv==1){ soft_spi_write(ahmednum[x1]);} else {soft_spi_write(~ahmednum[x1]);} } if(inv==1){ soft_spi_write(0); } else {soft_spi_write(0xff);} } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// void usart_txt(char jj[50]) {nn=0; while(jj[nn]) { nn++; } for(x1=0;x1<nn;x1++) { usart_write(jj[x1]); } } //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// void menu1() { usart_txt("enter port number\r"); go_address(0,2); eltabakh_nokia_print("enter number",0);
} void menu2() { go_address(2,30); eltabakh_nokia_chr(lcd[2],bold[2]); eltabakh_nokia_chr(lcd[1],bold[1]); eltabakh_nokia_chr(lcd[0],bold[0]); go_address(3,0); if(flag2) { eltabakh_nokia_print("ON ",bold[3]); } if(!flag2) {eltabakh_nokia_print("OFF",bold[3]); } } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void cnvrt(int h,char q) {
p1=(h-1)/8; p2=h%8; if(p2==0) { p2=8; } p3=1; for(i=1;i<p2;i++) { p3=p3<<1; } if(q==1) { relay[p1]=p3|relay[p1]; } if(q==0) {
relay[p1]=p3^relay[p1]; } //usart_txt("done"); usart_write('\r'); usart_write('d'); usart_write('o'); usart_write('n'); usart_write('e');
write_port();
} /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void do_serial() { flag=0; for(i=1;i<4;i++) { if(ser[i]>'9') { flag=1; } if(ser[1]>='6'&&ser[2]>'4') { flag=1; } } if(flag==0) { if(ser[0]=='o') { sh=(ser[1]-48)*100; sh=sh+(ser[2]-48)*10; sh=sh+(ser[3]-48); cnvrt(sh,1);
} if(ser[0]=='c') { sh=(ser[1]-48)*100; sh=sh+(ser[2]-48)*10; sh=sh+(ser[3]-48); cnvrt(sh,0); } } }
void update() {mx=lcd[2]*100; mx=mx+(lcd[1]*10); mx=mx+lcd[0]; if(flag2==255) { cnvrt(mx,1); } if(flag2==0){cnvrt(mx,0);} go_address(4,22); eltabakh_nokia_print("done",0); delay_ms(2000); go_address(4,22); eltabakh_nokia_print(" ",0) ; } void main() {cmcon=7; tmr2=0 ; trisa=0; porta=0; soft_spi_config(&porta , 5, 2, 3); usart_init(9600);
reset for(x=0;x<5;x++) { soft_spi_write(m[x]);
} data_fill(0xff); menu1();
for(;;) { if(usart_data_ready()) { ser[i]=usart_read(); i++; if(ser[i-1]=='*'){i=0;} if(i==4){do_serial();} }
if(!s1) { while(!s1); if(tmr2<3) {
lcd[tmr2]++; if(lcd[tmr2]>9){lcd[tmr2]=0;} if(lcd[2]==7){lcd[2]=0;} if(lcd[1]>4&&lcd[2]==6){lcd[2]=0;lcd[1]=0;tmr2--;} } if(tmr2==3){flag2=~flag2;} }
if(!s2) { while(!s2); bold[tmr2]=0;
tmr2++;
if(tmr2==4){ tmr2=0; update(); }
bold[tmr2]=1;
}
menu2();
}
} وده الملف اللي انا مستدعيه جوا البرنامج - الكود:
-
const char ahmednum[455] = { 0x00, 0x00, 0x00, 0x00, 0x00 , // sp 0x00, 0x00, 0x2f, 0x00, 0x00 , // ! 0x00, 0x07, 0x00, 0x07, 0x00 , // " 0x14, 0x7f, 0x14, 0x7f, 0x14 , // # 0x24, 0x2a, 0x7f, 0x2a, 0x12 , // $ 0xc4, 0xc8, 0x10, 0x26, 0x46 , // % 0x36, 0x49, 0x55, 0x22, 0x50 , // & 0x00, 0x05, 0x03, 0x00, 0x00 , // ' 0x00, 0x1c, 0x22, 0x41, 0x00 , // ( 0x00, 0x41, 0x22, 0x1c, 0x00 , // ) 0x14, 0x08, 0x3E, 0x08, 0x14 , // * 0x08, 0x08, 0x3E, 0x08, 0x08 , // + 0x00, 0x00, 0x50, 0x30, 0x00 , // , 0x10, 0x10, 0x10, 0x10, 0x10 , // - 0x00, 0x60, 0x60, 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 , // ; 0x08, 0x14, 0x22, 0x41, 0x00 , // < 0x14, 0x14, 0x14, 0x14, 0x14 , // = 0x00, 0x41, 0x22, 0x14, 0x08 , // > 0x02, 0x01, 0x51, 0x09, 0x06 , // ? 0x32, 0x49, 0x59, 0x51, 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, 0x09, 0x01 , // F 0x3E, 0x41, 0x49, 0x49, 0x7A , // 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, 0x0C, 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 0x3F, 0x40, 0x38, 0x40, 0x3F , // W 0x63, 0x14, 0x08, 0x14, 0x63 , // X 0x07, 0x08, 0x70, 0x08, 0x07 , // Y 0x61, 0x51, 0x49, 0x45, 0x43 , // Z 0x00, 0x7F, 0x41, 0x41, 0x00 , // [ 0x55, 0x2A, 0x55, 0x2A, 0x55 , // 55 0x00, 0x41, 0x41, 0x7F, 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 0x0C, 0x52, 0x52, 0x52, 0x3E , // g 0x7F, 0x08, 0x04, 0x04, 0x78 , // h 0x00, 0x44, 0x7D, 0x40, 0x00 , // i 0x20, 0x40, 0x44, 0x3D, 0x00 , // j 0x7F, 0x10, 0x28, 0x44, 0x00 , // 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 };
والكود ده بناء علي طلب محمد ابو الحديد | |
|