Re: temperature
Posted: Sat Nov 27, 2010 1:46 am
So, you conveniently clipped that I am inexperienced with programming the DS. I am not entirely a newb, for I have used PAlib once or twice (I ditched it when I discovered there was no 3D support). I have not, however, used devkitPro before. So, being completely inexperienced with dkP's layout, libraries, etc., I was kind of lost when I saw this thread.elhobbs wrote:the answer is in the thread - wow indeedJordan_Gray wrote:All I can say is wow.
...clipped...
I just am wandering what I need to type in a homebrew app to read the temperature.
- Stryker
First, I thought I was informed that this would not do the trick:
At a glance it looked like it would return the temp of screen one, and then screen two. But apparently that's not how you do it.uint32 touchReadTemperature(int * t1, int * t2);
Xenon informs us that one should do something like this:
I was, however, unable to completely understand this code. (I haven't learned "&" yet, and I don't really know anything about "u32" other than that I think it's referring to an "unsigned 32-bit" number. I assumed the print command meant that it would display it on the screen, but "%.f\n" made no sense to me whatsoever, so I wasn't entirely sure what that part meant. The rest of the line was confusing as well, I am guessing that "0x1000" refers to a hexidecimal value, but other than that I am lost.)int t1,t2;
u32 temp=touchReadTemperature(&t1, &t2);
printf("%.2f\n",(double)temp/0x1000);
So I kept reading, hoping to stumble across an explanation. Of course, I found a curveball instead: "Of course in actual code you need to transfer temp to ARM9 using fifo or IPC." Xenon, it's great that you clearly know what you're doing and love to tell others about it. But, hate to break it to you, not everyone is on the same level as you.
Thanks to lazyprogrammer, this is pointed out. He asks, "What did you mean? Can you explain me what I have to do if I want to include [the] code[?]"
At this point, Zeromus chimes in. "I just added an example of user fifo. And lucky you, I used temperature to demonstrate it," he says. I really was lost here, for I still didn't know what fifo was, and "user fifo" was also an unknown to me. So I clicked the link, hoping to understand it better. But, alas, I have a hard time browsing the Subversion sites (something on my computer causes them to stop loading before any files are made available). So the link was useless to me.
Based on lazyprogrammer's description of what the code did, I assumed that it read some sort of value from the sensor(s) and displayed them on the screen, updating rapidly.
After reading for a while, doing some more researching, reading again, and then re-reading, it seems that this bit of program:
int t1,t2;
u32 temp=touchReadTemperature(&t1, &t2);
printf("%.2f\n",(double)temp/0x1000);
initializes some variables, tells the system what another one means, and then displays one after doing some math to it. It achieves this particular one by reading the two it initialized and combining them (I think).
Am I correct?