temperature

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

temperature

Post by lazyprogramer » Tue Nov 02, 2010 9:12 pm

How can I read the DS temperature?
I know there are 2 sensors in the screens but what is the code for reading the temperature?

I found this in libnds/include/nds/arm7 touch:

Code: Select all

uint32 touchReadTemperature(int * t1, int * t2);
But what does it give me? What information?

Xenon
Posts: 7
Joined: Tue Jul 20, 2010 2:55 pm

Re: temperature

Post by Xenon » Fri Nov 05, 2010 4:08 am

like this:

Code: Select all

int t1,t2;
u32 temp=touchReadTemperature(&t1, &t2);
printf("%.2f\n",(double)temp/0x1000);
Of course in actual code you need to transfer temp to ARM9 using fifo or IPC.

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: temperature

Post by lazyprogramer » Sat Nov 06, 2010 2:21 pm

Of course in actual code you need to transfer temp to ARM9 using fifo or IPC.
What did you mean? Can you explain me what I have to do if I want to include this code

Code: Select all

int t1,t2;
                     u32 temp=touchReadTemperature(&t1, &t2);
                     printf("%.2f\n",(double)temp/0x1000);
in my script?

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: temperature

Post by zeromus » Sat Nov 06, 2010 11:08 pm

I just added an example of user fifo. And lucky you, I used temperature to demonstrate it.

http://devkitpro.svn.sourceforge.net/vi ... /userfifo/

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: temperature

Post by lazyprogramer » Sun Nov 07, 2010 1:37 pm

thank you very much zermorus :D

But just one last question:
When I start your example on DS I get an endless list of nubers:
739 844 112842
...

And they change very fast... Is this the temperature? And how can I make it in °C and looks better?
Please help

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: temperature

Post by zeromus » Sun Nov 07, 2010 10:53 pm

The temperature is fixed point 20.12 degrees celsius. If you can't figure out why there is an endless list of changing numbers then you've got the wrong hobby.

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: temperature

Post by lazyprogramer » Mon Nov 08, 2010 8:14 pm

The temperature is fixed point 20.12 degrees celsius.
??
What did you mean with that?

And what does these numbers mean? They're are not given in degrees celsius/fahrenheit or Reaumur!
739 844 112842

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: temperature

Post by elhobbs » Mon Nov 08, 2010 9:22 pm

I will give you a hint...

Code: Select all

int t1,t2;
u32 temp=touchReadTemperature(&t1, &t2);
then, look up "fixed point arithmetic"

lazyprogramer
Posts: 85
Joined: Mon Sep 27, 2010 5:26 pm

Re: temperature

Post by lazyprogramer » Tue Nov 09, 2010 6:51 pm

The temperature is given in detail, but what are these numbers in degrees celsius? I mean
how can get these numbers in °C???

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: temperature

Post by elhobbs » Wed Nov 10, 2010 12:02 am

Get ready here comes the baby spoon... temp is the temperature in degrees celcius in 20.12 fixed point - divide the number by 4096 (2 to the 12th power) to convert it to an integer.

Seriously though, asking for help and putting in no effort on your part is really annoying.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests