Page 1 of 5

temperature

Posted: Tue Nov 02, 2010 9:12 pm
by lazyprogramer
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?

Re: temperature

Posted: Fri Nov 05, 2010 4:08 am
by Xenon
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.

Re: temperature

Posted: Sat Nov 06, 2010 2:21 pm
by lazyprogramer
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?

Re: temperature

Posted: Sat Nov 06, 2010 11:08 pm
by zeromus
I just added an example of user fifo. And lucky you, I used temperature to demonstrate it.

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

Re: temperature

Posted: Sun Nov 07, 2010 1:37 pm
by lazyprogramer
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

Re: temperature

Posted: Sun Nov 07, 2010 10:53 pm
by zeromus
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.

Re: temperature

Posted: Mon Nov 08, 2010 8:14 pm
by lazyprogramer
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

Re: temperature

Posted: Mon Nov 08, 2010 9:22 pm
by elhobbs
I will give you a hint...

Code: Select all

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

Re: temperature

Posted: Tue Nov 09, 2010 6:51 pm
by lazyprogramer
The temperature is given in detail, but what are these numbers in degrees celsius? I mean
how can get these numbers in °C???

Re: temperature

Posted: Wed Nov 10, 2010 12:02 am
by elhobbs
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.