devkitPro.org
https://devkitpro.org/

temperature
https://devkitpro.org/viewtopic.php?f=38&t=2312
Page 1 of 5

Author:  lazyprogramer [ Tue Nov 02, 2010 9:12 pm ]
Post subject:  temperature

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:
uint32 touchReadTemperature(int * t1, int * t2);

But what does it give me? What information?

Author:  Xenon [ Fri Nov 05, 2010 4:08 am ]
Post subject:  Re: temperature

like this:
Code:
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.

Author:  lazyprogramer [ Sat Nov 06, 2010 2:21 pm ]
Post subject:  Re: temperature

Quote:
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:
int t1,t2;
                     u32 temp=touchReadTemperature(&t1, &t2);
                     printf("%.2f\n",(double)temp/0x1000);

in my script?

Author:  zeromus [ Sat Nov 06, 2010 11:08 pm ]
Post subject:  Re: temperature

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

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

Author:  lazyprogramer [ Sun Nov 07, 2010 1:37 pm ]
Post subject:  Re: temperature

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

Author:  zeromus [ Sun Nov 07, 2010 10:53 pm ]
Post subject:  Re: temperature

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.

Author:  lazyprogramer [ Mon Nov 08, 2010 8:14 pm ]
Post subject:  Re: temperature

Quote:
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!
Quote:
739 844 112842

Author:  elhobbs [ Mon Nov 08, 2010 9:22 pm ]
Post subject:  Re: temperature

I will give you a hint...
Code:
int t1,t2;
u32 temp=touchReadTemperature(&t1, &t2);

then, look up "fixed point arithmetic"

Author:  lazyprogramer [ Tue Nov 09, 2010 6:51 pm ]
Post subject:  Re: temperature

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

Author:  elhobbs [ Wed Nov 10, 2010 12:02 am ]
Post subject:  Re: temperature

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.

Page 1 of 5 All times are UTC [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/