Modifying GADC example board file.

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Modifying GADC example board file.

Postby Tectu » Sun May 05, 2013 4:34 pm

Yeah sorry, I forgot to attach them -.-


~ Tectu
Attachments
stubs.zip
(1002 Bytes) Downloaded 169 times

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Sun May 05, 2013 4:47 pm

disregard my fault..

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Sun May 05, 2013 5:05 pm

ok that works but how do i tie that to samples

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Modifying GADC example board file.

Postby Tectu » Sun May 05, 2013 6:17 pm

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

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Mon May 06, 2013 7:26 am

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?

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Modifying GADC example board file.

Postby Tectu » Mon May 06, 2013 8:26 am

Yes, as I said three times before, you first have to calculate the real voltage level out of the ADC value.

Code: Select all

V = (Vref * (ADC value / ADC resolution)



~ Tectu

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Mon May 06, 2013 6:25 pm

sorry about that i did not realize what you meant until you hit me with it :oops:
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?

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Modifying GADC example board file.

Postby Tectu » Mon May 06, 2013 6:34 pm

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

daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Postby daviddawe1982 » Tue May 07, 2013 5:37 am

Ok this is what i am doing..

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

inmarket
Posts: 89
Joined: Fri Jul 27, 2012 1:37 pm
Location: Brisbane, Australia

Re: Modifying GADC example board file.

Postby inmarket » Tue May 07, 2013 5:47 am

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);


Return to “LCD Driver and Graphic Framework”

Who is online

Users browsing this forum: No registered users and 1 guest