Yeah sorry, I forgot to attach them -.-
~ Tectu
Modifying GADC example board file.
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
Re: Modifying GADC example board file.
Use the value from the ADC conversion, calculate the voltage level out of it and display it. If you want to use it with multiple threads, make sure you use mutexes or semaphores in order to get a correct read out of the values since they are not atomic.
~ Tectu
~ Tectu
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
Re: Modifying GADC example board file.
i have tried getting the voltage to display this way:
float voltage = (adcsample_t) samples2[0];
sprintf(buffer, "voltage: %fV", voltage);
but it reads " voltage:4063.000000V" off a 3v pin.
am i doing it correctly or should i be doing some sort of calculation first?
float voltage = (adcsample_t) samples2[0];
sprintf(buffer, "voltage: %fV", voltage);
but it reads " voltage:4063.000000V" off a 3v pin.
am i doing it correctly or should i be doing some sort of calculation first?
Re: Modifying GADC example board file.
Yes, as I said three times before, you first have to calculate the real voltage level out of the ADC value.
~ Tectu
Code: Select all
V = (Vref * (ADC value / ADC resolution)
~ Tectu
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
Re: Modifying GADC example board file.
sorry about that i did not realize what you meant until you hit me with it
everything is working good now except when i try to use the buffer to give a drawline value eg. 245(i have striped the buffer back to that) it will not work i get the assignment makes pointer from integer without a cast error.
i an use the buffer in drawstring and it works fine is there a way to get it to work the way i want?

everything is working good now except when i try to use the buffer to give a drawline value eg. 245(i have striped the buffer back to that) it will not work i get the assignment makes pointer from integer without a cast error.
i an use the buffer in drawstring and it works fine is there a way to get it to work the way i want?
Re: Modifying GADC example board file.
I'm sorry but I don't exactly understand what you want to do nor the problem you're hitting. Can you please explain what you want to do, what you did and attach the code part including the compiler errors?
~ Tectu
~ Tectu
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
Re: Modifying GADC example board file.
Ok this is what i am doing..
And this is the error
Code: Select all
float voltage = ((adcsample_t) samples2[0]*2.45/4098);
sprintf(buffer, "voltage: %.2fV", voltage);
sprintf(buffer2,"%.2f", voltage);
buffer2[1] = "_"; // this removes the decimal point
gdispDrawString(10, 150, buffer1, font1, White); // This works fine and displays "voltage:2.45V"
gdispDrawString(10, 170, buffer2, font1, White); // This works fine and displays "245"
//Now i draw a line using the buffer2 value
gdispDrawLine(300, 470, 300, buffer2, Red); // this does not work..
And this is the error
Code: Select all
passing argument 4 of 'gdisp_lld_draw_line' makes integer from pointer without a cast [enabled by default] main.c /display1 line 206 C/C++ Problem
Re: Modifying GADC example board file.
Changes highlighted in red.
float voltage = ((adcsample_t) samples2[0]*2.45/4096);
sprintf(buffer, "voltage: %.2fV", voltage);
gdispDrawString(10, 150, buffer1, font1, White); // This works fine and displays "voltage:2.45V"
gdispDrawLine(300, 470, 300, (coord_t)(voltage*100.0), Red);
float voltage = ((adcsample_t) samples2[0]*2.45/4096);
sprintf(buffer, "voltage: %.2fV", voltage);
gdispDrawString(10, 150, buffer1, font1, White); // This works fine and displays "voltage:2.45V"
gdispDrawLine(300, 470, 300, (coord_t)(voltage*100.0), Red);
Return to “LCD Driver and Graphic Framework”
Who is online
Users browsing this forum: No registered users and 2 guests