Page 3 of 5

Re: Modifying GADC example board file.

Posted: Sun May 05, 2013 4:34 pm
by Tectu
Yeah sorry, I forgot to attach them -.-


~ Tectu

Re: Modifying GADC example board file.

Posted: Sun May 05, 2013 4:47 pm
by daviddawe1982
disregard my fault..

Re: Modifying GADC example board file.

Posted: Sun May 05, 2013 5:05 pm
by daviddawe1982
ok that works but how do i tie that to samples

Re: Modifying GADC example board file.

Posted: Sun May 05, 2013 6:17 pm
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

Re: Modifying GADC example board file.

Posted: Mon May 06, 2013 7:26 am
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?

Re: Modifying GADC example board file.

Posted: Mon May 06, 2013 8:26 am
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

Re: Modifying GADC example board file.

Posted: Mon May 06, 2013 6:25 pm
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?

Re: Modifying GADC example board file.

Posted: Mon May 06, 2013 6:34 pm
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

Re: Modifying GADC example board file.

Posted: Tue May 07, 2013 5:37 am
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

Re: Modifying GADC example board file.

Posted: Tue May 07, 2013 5:47 am
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);