Modifying GADC example board file.

User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Modifying GADC example board file.

Post by Tectu »

Yeah sorry, I forgot to attach them -.-


~ Tectu
Attachments
stubs.zip
(1002 Bytes) Downloaded 988 times
daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Post by daviddawe1982 »

disregard my fault..
daviddawe1982
Posts: 94
Joined: Thu Apr 11, 2013 10:35 am

Re: Modifying GADC example board file.

Post by daviddawe1982 »

ok that works but how do i tie that to samples
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Modifying GADC example board file.

Post by Tectu »

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.

Post by daviddawe1982 »

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: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Modifying GADC example board file.

Post by Tectu »

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.

Post by daviddawe1982 »

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: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Modifying GADC example board file.

Post by Tectu »

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.

Post by daviddawe1982 »

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

Re: Modifying GADC example board file.

Post by inmarket »

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