alimohammad_s
25-05-2012, 23:45
اگه اینطوری به کار برده باشید نباید مشکلی باشه.
unsigned char p;
Glcd_Write_Char((p/10)+48, 10, 2, 1);
Glcd_Write_Char((p%10)+48, 12, 2, 1);
اقا درسته error نمیده
چنتا سوال
Glcd_Write_Char((p/10)+48, 10, 2, 1); این دستور مقدار صحیح رو نشون میده؟؟
اگر مقدار صحیح نشون میده اینجا باقیمونده چاپ میشه
بعد اینکه چرا تقسیم به 10 و با48 جمع شده؟؟
یه سوال دیگه
من توی این برنامه زیر میخوام مقدار متغیر cont که از نوع float هست رو چاپ کنم باید چی کار کنم ؟؟
من اومدم مقدار صحیح و اعشاری اونو ریختم تو متغییر sah و ash اوناهم میشه به جای float چاپ کرد
اینم برنامه من
// ------------------------------------------------------
// GLCD Picture name: ali.bmp
// GLCD Model: KS0108 128x64
// ------------------------------------------------------
// ------------------------------------------------------
// GLCD Picture name: dangrhv.bmp
// GLCD Model: KS0108 128x64
// ------------------------------------------------------
const code char dangrhv[1024] = {
255, 255, 255, 255, 255, 255, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 143, 143, 143, 143, 143, 143, 143, 207, 207, 79, 79, 79, 79, 79, 111, 111, 111, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 111, 111, 111, 79, 79, 79, 79, 79, 207, 207, 143, 143, 143, 143, 143, 143, 143, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 0, 128, 192, 96, 48, 48, 24, 8, 12, 12, 4, 4, 230, 226, 226, 227, 225, 97, 97, 225, 225, 225, 224, 192, 0, 0, 0, 0, 0, 128, 224, 224, 96, 224, 224, 224, 192, 0, 0, 0, 0, 0, 224, 224, 224, 224, 224, 192, 0, 0, 0, 224, 224, 224, 224, 0, 0, 0, 0, 0, 192, 224, 224, 96, 96, 32, 32, 96, 96, 96, 96, 192, 0, 0, 0, 0, 0, 224, 224, 224, 224, 96, 96, 96, 96, 96, 96, 32, 0, 0, 224, 224, 224, 225, 225, 97, 97, 97, 97, 227, 226, 226, 198, 4, 4, 12, 12, 8, 16, 48, 48, 224, 192, 128, 0, 0, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 0, 7, 24, 16, 48, 32, 96, 64, 128, 128, 128, 128, 63, 63, 63, 63, 63, 48, 48, 48, 63, 63, 31, 31, 6, 0, 48, 60, 63, 63, 63, 31, 24, 24, 31, 31, 31, 63, 60, 56, 32, 0, 63, 63, 63, 63, 3, 3, 7, 15, 62, 63, 63, 63, 63, 0, 0, 0, 7, 15, 31, 31, 60, 56, 48, 48, 50, 54, 54, 62, 62, 30, 30, 0, 0, 0, 0, 63, 63, 63, 63, 51, 51, 51, 51, 51, 51, 50, 0, 0, 63, 63, 63, 63, 63, 2, 6, 6, 31, 63, 63, 57, 49, 160, 128, 128, 128, 64, 96, 48, 48, 24, 12, 7, 0, 0, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 193, 193, 193, 193, 195, 194, 194, 194, 198, 196, 196, 196, 204, 204, 204, 204, 204, 200, 200, 200, 200, 216, 216, 216, 208, 208, 208, 208, 208, 208, 208, 208, 240, 240, 240, 240, 240, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 240, 240, 240, 240, 208, 208, 208, 208, 208, 208, 208, 208, 216, 216, 216, 216, 200, 200, 200, 200, 204, 204, 204, 204, 196, 196, 196, 196, 198, 194, 194, 194, 193, 193, 193, 193, 193, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 1, 1, 1, 159, 191, 191, 191, 191, 191, 191, 31, 1, 1, 255, 255, 255, 1, 1, 1, 255, 255, 255, 255, 31, 7, 7, 227, 243, 243, 249, 249, 57, 57, 57, 57, 51, 51, 51, 55, 255, 255, 255, 1, 1, 1, 191, 191, 191, 191, 191, 191, 159, 1, 1, 1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 240, 240, 240, 255, 255, 255, 255, 255, 255, 255, 255, 240, 240, 255, 255, 255, 240, 240, 240, 255, 255, 255, 255, 255, 252, 252, 248, 249, 241, 243, 243, 243, 243, 243, 243, 249, 248, 248, 248, 255, 255, 255, 240, 240, 240, 255, 255, 255, 255, 255, 255, 255, 240, 240, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 243, 195, 3, 15, 63, 255, 255, 255, 255, 63, 15, 3, 195, 243, 255, 255, 63, 15, 7, 199, 231, 231, 243, 243, 243, 243, 231, 199, 7, 15, 31, 255, 255, 255, 3, 3, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 243, 243, 243, 243, 227, 3, 3, 227, 243, 243, 243, 243, 255, 255, 127, 31, 7, 131, 227, 227, 135, 31, 127, 255, 255, 255, 255, 255, 255, 63, 15, 15, 199, 231, 231, 247, 243, 243, 243, 231, 231, 199, 207, 207, 255, 255, 255, 3, 3, 3, 115, 115, 115, 115, 115, 115, 115, 115, 243, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 252, 224, 193, 195, 195, 224, 248, 252, 255, 255, 255, 255, 255, 252, 240, 224, 227, 231, 231, 207, 207, 207, 207, 231, 227, 224, 240, 248, 255, 255, 255, 192, 192, 192, 207, 207, 207, 207, 207, 207, 207, 207, 255, 255, 255, 255, 255, 255, 255, 192, 192, 255, 255, 255, 255, 223, 207, 195, 224, 240, 248, 249, 249, 249, 249, 248, 240, 192, 195, 207, 255, 255, 255, 252, 240, 240, 227, 231, 231, 207, 207, 204, 204, 236, 228, 224, 240, 240, 255, 255, 255, 192, 192, 192, 206, 206, 206, 206, 206, 206, 206, 206, 207, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
};
// Glcd module connections
char GLCD_DataPort at PORTD;
sbit GLCD_CS1 at RC0_bit;
sbit GLCD_CS2 at RC1_bit;
sbit GLCD_RS at RC2_bit;
sbit GLCD_RW at RC3_bit;
sbit GLCD_EN at RC4_bit;
sbit GLCD_RST at RC5_bit;
sbit GLCD_CS1_Direction at TRISC0_bit;
sbit GLCD_CS2_Direction at TRISC1_bit;
sbit GLCD_RS_Direction at TRISC2_bit;
sbit GLCD_RW_Direction at TRISC3_bit;
sbit GLCD_EN_Direction at TRISC4_bit;
sbit GLCD_RST_Direction at TRISC5_bit;
void delay2S(){ // 2 seconds delay function
Delay_ms(2000);
}
float cont = 0 ;
unsigned int num,ash,sah;
void main(){
TRISC=0;
TRISB=0;
TRISA=0;
Glcd_Init();
glcd_fill(0b10101010);
delay_ms(1000);
glcd_fill(0);
Glcd_Image(dangrhv);
delay_ms(5000);
glcd_fill(0);
ADCON1=0b10000000;
ADCON0=0b00000101;
Delay_ms(100);
cont=(ADRESH*256);
cont=(cont+ADRESL);
cont=((cont*5)/1023)*1000;
num=cont;
ash=num%1000;
sah=(num-ash)/1000;
Glcd_Rectangle(0, 0, 127, 63, 1);
Glcd_Write_Text("alimohammad shafiee", 2, 1, 1);
Glcd_Write_Text("voltag= ", 2, 3, 1);
while(1);
}
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.