Modifying GADC example board file.
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
Re: Modifying GADC example board file.
was just trying to start by using the testhal adc example to read a voltage (3.3v) and display it on my lcd and then take it from there..
Re: Modifying GADC example board file.
How do you want to display it? You can use the ChibiOS/RT HAL to get the conversation value, calculate it into your voltage and then use something like sprintf() to convert it to a string and display it using the ChibiOS/GFX high level routines.
The goal of GADC is to provide a uniform ADC abstraction because the interface provideded by ChibiOS/RT is very platform dependend and we cannot create generic applications which run on all the platforms with that.
~ Tectu
The goal of GADC is to provide a uniform ADC abstraction because the interface provideded by ChibiOS/RT is very platform dependend and we cannot create generic applications which run on all the platforms with that.
~ Tectu
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
Re: Modifying GADC example board file.
well yes thats exactly what i want to do just having a hard time figuring out how i get the conversion value.
Re: Modifying GADC example board file.
There are plenty of examples available showing how to use the ADC driver of the ChibiOS/RT HAL. I recommend you taking a look at the ./testhal example.
~ Tectu
~ Tectu
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
Re: Modifying GADC example board file.
yes that is the example i am using but where do i get the result from i cannot see where the result is in the example?
Re: Modifying GADC example board file.
The results are in the sample1 and sample2 buffers. They are of the type adcsample_t.
~ Tectu
~ Tectu
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
Re: Modifying GADC example board file.
i know i probably sound stupid but how do i convert the buffers into strings i have tried and all i get is random characters on lcd
Re: Modifying GADC example board file.
The value in the adcsample_t buffers contain the converted ADC value. You first have to calculate the real voltage from it. This will be a float value. You can now use something like sprintf() to convert it to a string:
Please note that sprintf() is a very memory intensive call. Make sure your stack size is big enough. You will also need to include the syscalls in your makefile. Furthermore, you need to include the stubs I attached into your project.
I hope that helps a bit.
~ Tectu
Code: Select all
#include <string.h> // here we can find the prototype of sprintf()
float voltage = 2.42f; // lets asume our measured voltage level is 2.42V.
char buffer[20]; // this will be our output string. Make sure it's long enough.
sprintf(buffer, "voltage: %fV", voltage); // create the string containing the current voltage level
gdispDrawString(10, 10, buffer, font, Yellow); // draw the string on the screen
Please note that sprintf() is a very memory intensive call. Make sure your stack size is big enough. You will also need to include the syscalls in your makefile. Furthermore, you need to include the stubs I attached into your project.
I hope that helps a bit.
~ Tectu
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
Re: Modifying GADC example board file.
what syscalls should i add?--
ok i found syscalls.c and have added it to my makefile

ok i found syscalls.c and have added it to my makefile
Last edited by daviddawe1982 on Sun May 05, 2013 4:31 pm, edited 1 time in total.
-
- Posts: 94
- Joined: Thu Apr 11, 2013 10:35 am
Return to “LCD Driver and Graphic Framework”
Who is online
Users browsing this forum: No registered users and 2 guests