Converting to ASCII code

0

0310889

I am doing my honours project at uni and have to use C programming and
the IIC bus, not the best combination as I have never done that much
programming and I had never heard of the IIC bus! Anyway, I am getting
on quite well now but I have come up with a problem! I am reading GPS
data from the IIC bus as a signed short, I need to convert this 16-bit
value to ASCII code for use with my LCD display, also controlled on
the IIC bus! Any suggestion anyone? Cheers!
 
W

Walter Roberson

I am doing my honours project at uni and have to use C programming and
the IIC bus, not the best combination as I have never done that much
programming and I had never heard of the IIC bus! Anyway, I am getting
on quite well now but I have come up with a problem! I am reading GPS
data from the IIC bus as a signed short, I need to convert this 16-bit
value to ASCII code for use with my LCD display, also controlled on
the IIC bus! Any suggestion anyone?

There are a number of different encodings of GPS coordinates in
use; you need to research to find out how the particular one you
are using encodes its values. Once you know the encoding, you will
probably find that you need to use some bit operators such as >>
and | in order to extract a numeric value from the GPS coordinates.
That will give you a reading in some units (e.g., 1/6000 of a degree).
Manipulate that number to construct the readings you will want
to be displayed, and then use sprintf() or equivilent to represent
the values as a string in whatever character set your execution
environment uses. (If your execution environment doesn't happen
to use ASCII encodings for characters, you will have a little
bit of value manipulation to do.)
 
M

Malcolm McLean

I am doing my honours project at uni and have to use C programming and
the IIC bus, not the best combination as I have never done that much
programming and I had never heard of the IIC bus! Anyway, I am getting
on quite well now but I have come up with a problem! I am reading GPS
data from the IIC bus as a signed short, I need to convert this 16-bit
value to ASCII code for use with my LCD display, also controlled on
the IIC bus! Any suggestion anyone? Cheers!

char gpstoascii(short gps)
{
/* code goes here */
}

At the very worst the code is a 128-odd character switch. Probably you can
write it much more easily if letter and numbers are consecutive in the GPS
code. However I don't know the details of GPS encoding.
 
S

spacecriter \(Bill C\)

I am doing my honours project at uni and have to use C programming and
the IIC bus, not the best combination as I have never done that much
programming and I had never heard of the IIC bus! Anyway, I am getting
on quite well now but I have come up with a problem! I am reading GPS
data from the IIC bus as a signed short, I need to convert this 16-bit
value to ASCII code for use with my LCD display, also controlled on
the IIC bus! Any suggestion anyone? Cheers!

Look at the sprintf function
 
C

CBFalconer

I am doing my honours project at uni and have to use C programming and
the IIC bus, not the best combination as I have never done that much
programming and I had never heard of the IIC bus! Anyway, I am getting
on quite well now but I have come up with a problem! I am reading GPS
data from the IIC bus as a signed short, I need to convert this 16-bit
value to ASCII code for use with my LCD display, also controlled on
the IIC bus! Any suggestion anyone? Cheers!

The IIC bus, the LCD display, etc. are off-topic here. They are
topical on comp.arch.embedded.

Conversion of 16 bit integers to strings is dead easy. For example:

void writeint(unsigned int i, FILE *dest) {
if (i > 0) writeint(i / 10, dest);
putc((i % 10) + '0', dest);
}

but embedded machines may have restrictions on recursion, etc,
which is why c.a.e is appropriate.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top