yes... ok...
hope to hear from u again soon!
thanks a lot!!!
yes... ok...
hope to hear from u again soon!
thanks a lot!!!
OK, this is the C program, but now we need to see about using it's guts, with your display.
Run this on your pc, and see if it does what you want, first.
Code:#include <stdio.h> int main() { unsigned char digit, snum[4]; int i, n, j; int num[] = {3,14,159,26,53,155,218,91,79,66}; snum[3] = '\0'; //this must stay, and never change value for(i = 0; i < sizeof(num)/sizeof(int); ++i) { //for each number for(j = 0; j < 3; j++) //reset the string array snum[j] = 32; //fill 3 elements with blank spaces n = num[i]; j = 2; while(n) { //strip off each digit from n digit = n % 10; n /= 10; snum[j] = digit + '0'; //assign digit's string value to snum --j; } printf("Original Number: %d String Digits: %s\n", num[i], snum); getchar(); } printf("\n\n\t\t\t press enter when ready"); i = getchar(); return 0; }
thanks for the reply..
but my display will not be able do printf... it print value only by ascii value.
Currently what im able to do to the display is to:
1.) display 1 character. the ADC value in ascii format.. e.g. when i adjust the adc value to 114, the display shows 1 character 'r'(but what i want is to show 3 character '1''1''4', which is '49''49''52' in ascii).
2.) display 3 character.. but is hard coded.Code:op=ADC0H; void OLED_String(char cmd, char col, char row, char font, char color5, char color6, char op, char ter); OLED_String(0x73,col,row,font,color5,color6,op,ter);
so now i need to find out how do i change the ADC value from integer to string to ascii?Code:void OLED_String(char cmd, char col, char row, char font, char color5, char color6, char char1, char char2, char char3, char ter); char1 = 49; char2 = 49; char3 = 52; OLED_String(0x73,col,row,font,color5,color6,char1,char2,char3,ter);
e.g.when ADC value ='114' how do i change to '1''1''4' then to '49''49''52'
so i can put them into char1,char2,char3.
sry if i cant explain well.
pls help~~..
Thank you......
The problem is solved, it just has to be integrated into your program, my good Dr. Watson.
Some experimentation will be necessary, since I don't have your setup to work with.
Something like this, for the device:
Code:void OLED_String(char cmd, char col, char row, char font, char color5, char color6, char char1, char char2, char char3, char ter); char1 = 49; char2 = 49; char3 = 52; OLED_String(0x73,col,row,font,color5,color6,char1,char2,char3,ter); Now we change that to: void OLED_String(char cmd, char col, char row, char font, char color5, char color6, char char1, char char2, char char3, char ter); char1 = snum[0]; char2 = snum[1]; char3 = snum[2]; char4 = '\0'; OLED_String(0x73,col,row,font,color5,color6,char1,char2,char3,char4,ter);My program does that, by adding '0' to the number - ascii 48.(but what i want is to show 3 character '1''1''4', which is '49''49''52' in ascii).
1+48 = 49, 4+48= 52.
Sweet, yes?
ok... i'll try it out thee few days...
but there's a line i dun quite understand..
can u explain to me this line??Code:int num[] = {3,14,159,26,53,155,218,91,79,66};
thx alot....
thank you so much for all ur reply...
ok.. i'll be back in bout 2 days. thank you!!
Those were just testing numbers. Your program won't need them, at all.
oic..... thank you so much........... enjoy ur weekends!! =)
see ya again!
You too.
hi...
i've tried the code.. but its not working right..
currently my ADC value (op) work fine.. it changes as i adjust the signal.
but my char1, char2, char3 all equal to 32 ('blank')..
The following are part of my code.
Code:unsigned char digit, snum[4]; int j, k, l; int num[] = {3,14,159,26,53,155,218,91,79,66}; void main() { Init_Device(); TI=0; RI=0; x=1; //qqq=0; //aaa=0; SendChar(GSGC_AUTOBAUD); Receive(); SendChar(GSGC_CLS); Receive(); convert_all(); DisplayAD(); DisplayLine(); rectangle(); delay(3); DisplayCircle(); ADBUSY = 1;//start a conversion while(1) { if (ADBUSY == 0)//wait until conversion is complete { op=ADC0H; for(j = 0; j < sizeof(num)/sizeof(int); ++j) { //for each number for(l = 0; l < 3; l++) //reset the string array snum[l] = 32; //fill 3 elements with blank spaces k = num[j]; l = 2; while(k) { //strip off each digit from n digit = k % 10; k /= 10; snum[j] = digit + '0'; //assign digit's string value to snum --l; } } char1 = snum[0]; char2 = snum[1]; char3 = snum[2]; ADBUSY = 1;//start another conversion } } }
Never mind.. i got it using another simple method.. thanks for ur help!!! =)
Code:void hundred() /*convert 1st value Axx*/ { opvalue_h = opvalue_h/100; t = opvalue_h+48; } void ten() /*convert 2nd value xAx*/ { opvalue_t = opvalue_t/10; opvalue_t = opvalue_t%10; u = opvalue_t+48; } void one() /*convert 3rd value xxA.*/ { opvalue_o = opvalue_o%10; v = opvalue_o+48; } void OLED_StringTop(char cmd, char col, char row, char font, char color5, char color6, char t, char u, char v, char ter)
It is better to use '0' than 48 since it is more readable (and more portable, though that is not really a concern, I suppose).
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Yes.. agreed.. changed.. Thanks!!
Now i have need another help again..
I need to display the same ADC dec value in Hex.. using ascii...
e.g. dec value = '123' i need to display '7''B'. so i need to store a value '55' to r and '66' to s
Code:void OLED_StringBottom(char cmd, char col2, char row2, char font2, char color7, char color8, char r, char s, char ter);
ok.. im done with the hex...
now i need to convert the ADC dec value back to analog value.
eg.. if i input 3v>> ADC value = 255, analog value = 3.0
if i input 1.5v>> ADC value = ~127, analog value = 1.5
(currenly im already able to get the ADC value)
now i need help getting the analog value to be display....
pls help me with the code..
THANKS!!!
Tell me if this is correct:
If that's correct, then we can adapt that logic, into something that will run on your monitor.Code:/* for Vailant's heart monitor */ #include <stdio.h> int main() { int adc, n; float analog; printf("\n\nEnter an ADC value:" ); scanf("%d", &adc); n = (adc % 50); adc += (50 - n); analog = 1.0 * adc; analog = adc/100.0; printf("\n ADC value is: %.1f", analog); while((n = getchar()) != '\n'); n = getchar(); return 0; }
Last edited by Adak; 01-20-2010 at 08:12 AM.
Hi Adak.
my display wont be able to do the printf function...
so i need to print a character by a character.
e.g. (3.0>>> '3' & '.' & '0')
im able to get the dot('.') now by printing dec (46).... and when i input a 3v singnal im already able to get the value 255...
so now what i need is to get two integer
e.g. '3' & '0' when i input a 255,
'1' & '5' when i input a 127 or 128. ect...