temperature

Jordan_Gray
Posts: 23
Joined: Sat Jun 12, 2010 3:31 am

Re: temperature

Post by Jordan_Gray » Sat Nov 27, 2010 1:46 am

elhobbs wrote:
Jordan_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
the answer is in the thread - wow indeed :)
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.

First, I thought I was informed that this would not do the trick:
uint32 touchReadTemperature(int * t1, int * t2);
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.

Xenon informs us that one should do something like this:
int t1,t2;
u32 temp=touchReadTemperature(&t1, &t2);
printf("%.2f\n",(double)temp/0x1000);
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.)

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?

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

Re: temperature

Post by lazyprogramer » Sat Nov 27, 2010 10:15 am

Am I correct?
Yes you are!
...And the problem is I don't know very much about C and I don't find any tutorial in german wich explain me what u32 is.
But I still want to know how to read the temperature.

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

Re: temperature

Post by zeromus » Sat Nov 27, 2010 6:31 pm

filling you guys in on what you don't know would take an entire textbook. the only specific guidance i can offer is to use the example in SVN and use it as a starting point, since you don't understand how to extract the relevant parts.

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

Re: temperature

Post by lazyprogramer » Sat Nov 27, 2010 6:34 pm

Sorry, what is SVN?

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

Re: temperature

Post by elhobbs » Sat Nov 27, 2010 10:42 pm

Jordan_Gray - Apparently I misunderstood the "all I can say is wow" bit. In the context it sounded like you were criticizing the original poster for not reading any of the replies. I am not sure what that means but my main intent was to point out that rereading the thread should answer your questions.

Not that it is impossible, but learning to program in C is really hard to do on the ds. If you do not understand a basic concept like the & operator then the ds is going to be really confusing.

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: temperature

Post by WinterMute » Mon Nov 29, 2010 12:42 pm

Jordan_Gray wrote:[
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.
I'm going to take issue with this. Contrary to popular belief devkitPro is not a toolchain, software package or other thing that you use. It is in fact a vendor of toolchains and libraries designed to write software for a variety of game consoles. One of those toolchains is devkitARM which, in combination with libnds, is used to write software for the Nintendo DS. While the PALib crowd would like to believe that it competes with devkitARM it's actually a poorly designed, poorly written and badly maintained library which depends on devkitARM and libnds in order to function at all.
elhobbs wrote: Not that it is impossible, but learning to program in C is really hard to do on the ds. If you do not understand a basic concept like the & operator then the ds is going to be really confusing.
I'm not entirely sure that learning C on the DS is particularly harder than it is anywhere else. Certainly testing code is a bit more instant when the platform where you're building code is also the platform where you're running it but most concepts of programming apply equally to a PC and a game console - especially when it comes to writing games.
lazyprogramer wrote:Sorry, what is SVN?
Sometimes typing these questions into google yields the best results - for instance, http://www.google.co.uk/search?q=what+is+SVN
Help keep devkitPro toolchains free, Donate today

Personal Blog

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

Re: temperature

Post by elhobbs » Mon Nov 29, 2010 2:37 pm

WinterMute wrote:I'm not entirely sure that learning C on the DS is particularly harder than it is anywhere else. Certainly testing code is a bit more instant when the platform where you're building code is also the platform where you're running it but most concepts of programming apply equally to a PC and a game console - especially when it comes to writing games.
coding in C can be portable and the concepts certainly do overlap to a large extent across different platforms, but struggling with basic concepts because you do not have access to a decent debugger is probably going to cause more than a few people to give up sooner rather than latter.

a "bit more instant"? you must have a much better development/test process than I do - not that my process is all that sophisticated (copying files to microsd cards).

relminator
Posts: 84
Joined: Sun Apr 11, 2010 10:43 am

Re: temperature

Post by relminator » Tue Nov 30, 2010 12:18 am

Speaking from experience here (I still consider myself a noob and I still suck at makefiles). I believe coding on the DS is not harder/easier than say, PC coding. In fact I have an easier time coding for the DS using libnds than MSVS on the PC (I would even go as far as the tools Devkitpro provides us are easier to use than codeblocks and its build system).

I would also recommend DS coding while learning C/C++ since it's almost like coding in DOS. No messy stuff, just the barebones. Of course we still miss a debugger, but what noob would even think of using a debugger while learning C/C++? A debugger is for experienced coders.

MSVS: At least 15minutes of setting up solutions, build.
DkA+Libnds+Pn: Click project file, build, run on emulator.

The only thing that would be hard for the noob here is the concept of an almost forgotten fixedpoint mathematics.

My thoughts here are very subjective but that's how I feel about the whole DS coding is harder than PC coding.

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

Re: temperature

Post by zeromus » Tue Nov 30, 2010 2:56 am

youre insane. the easiest possible way to learn c++ is in visual studio with its debugger. learning without a gui debugger is like learning with half your brain cut out--youre at a disadvantage from the very start.

when you outgrow printf then advance to glut or sdl. thatll keep a fellow busy for a couple of years.

Jordan_Gray
Posts: 23
Joined: Sat Jun 12, 2010 3:31 am

Re: temperature

Post by Jordan_Gray » Wed Dec 01, 2010 2:06 am

...And the problem is I don't know very much about C and I can't find any tutorial in German which explains to me what u32 is.
I don't know much about C either, but I'm willing to do research. It's really great, you can look things up on the world wide web and learn all sorts of things you never learned before. In fact, there are these things called Chatrooms and you can talk to people about things on them. Live. (I used the one on the PAlib site alot.)
filling you guys in on what you don't know would take an entire textbook. the only specific guidance i can offer is to use the example in SVN and use it as a starting point, since you don't understand how to extract the relevant parts.
How about a yes/no question: can someone just type a few lines of code (or less) to read the temp sensors? I'm not even talking about gaining a ºC value from them, just reading them directly.
Jordan_Gray - Apparently I misunderstood the "all I can say is wow" bit. In the context it sounded like you were criticizing the original poster for not reading any of the replies. I am not sure what that means but my main intent was to point out that rereading the thread should answer your questions.
I wasn't criticizing his lack of reading so much as his apparent lack of study. I did some studying (<10 min.) on Google and found a few sources of info that cleared things up (a little). I seems he was just going, "My mouth's open, people! Feed me now!" and not doing anything on his part. I did re-read the thread, but I was still lacking a decisive answer.
If you do not understand a basic concept like the & operator then the ds is going to be really confusing.
There's a big difference between not having learned something yet and not understanding something. I am aware of the & operator, but in my previous experiences it was used like so: && means and, !& means everything else, etc.
Contrary to popular belief devkitPro is not a toolchain, software package or other thing that you use. It is in fact a vendor of toolchains and libraries designed to write software for a variety of game consoles. One of those toolchains is devkitARM which, in combination with libnds, is used to write software for the Nintendo DS.
Sorry, I am still new to these types of programs to always name them correctly. (I made sure and always put "devkitPro", not devkitpro or anything, though.) What I was trying to say is this: I could write the psuedocode. But when it came time to write the real code (the stuff that would compile), I wasn't sure exactly what to put.
[PAlib is] actually a poorly designed, poorly written, and badly maintained library which depends on devkitARM and libnds in order to function at all.
I am well aware of that. It is really a simplified method of programming less-than-advanced games/apps for the DS. That's why I started with it, because I had heard it was easier for beginners.
when you outgrow printf then advance to glut or sdl. thatll keep a fellow busy for a couple of years.
Great job showing off your vocabulary. Now say something useful.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest