Question about SetBatteryState argument

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Question about SetBatteryState argument

Post by mattallen37 »

While searching in the NXC guide, I came across this function "SetBatteryState(4);" (actually, the parameter number range is 0-4), and it didn't say what it was for, and I can not figure out 1, how to use it, or 2, what it would be used for.
Last edited by mattallen37 on 05 Oct 2010, 16:31, edited 1 time in total.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC functions

Post by mightor »

mattallen37 wrote:Instead of starting multiple threads from now, I'll just post my "NXC function" questions in this topic, as I am sure I will be having more questions.
No, it would be preferable to have one subject per thread, rather than multiple. This makes it easier to find things and to search. I have renamed this thread.

- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
spillerrec
Posts: 358
Joined: 01 Oct 2010, 06:37
Location: Denmark
Contact:

Re: Question about SetBatteryState argument

Post by spillerrec »

As far as I understand from the NXC API this function belongs to the User interface module. It changes the little battery icon in the corner that shows how much battery there is back. So with this function you can manually change this icon for some reason, if I understood this correctly.

I agree though that many functions need better explanations...
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC functions

Post by mattallen37 »

mightor wrote:No, it would be preferable to have one subject per thread, rather than multiple. This makes it easier to find things and to search. I have renamed this thread.

- Xander
Ok, that's fine, I just though that if people don't want a bunch of topics regarding a lot of NXC functions, then I would just combine them. I get your point though about searching. I'll edit my post as well.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Question about SetBatteryState argument

Post by afanofosc »

I accept contributions for improving the NXC help files so if you have any suggestions I will update the help accordingly. There are several functions that I do not fully understand myself and some which really don't do anything useful.

You can set pretty much any IOMap field to a new value whether it makes sense to do that or not. For example, setting some of the fields in the Button IOMap structure to different values makes no difference since the firmware overwrites those values with information it reads from the hardware about a millisecond later. The battery state field will be overwritten by the UI module with what it thinks is the correct battery state the next time it runs (once every millisecond). It sets this field to a value based on these voltage limits: 6100,6500,7000,7500.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Question about SetBatteryState argument

Post by mattallen37 »

So the command is there just because it is a valid command, though useless?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Question about SetBatteryState argument

Post by afanofosc »

Yes. The firmware doesn't enforce a read-only state for any of the IOMap fields. It just uses some of them internally in a read-only manner (i.e., it overwrites the value so that someone can read it from the IOMap). I should go through the API and remove any of the "Set" functions which currently allow you to write to what amounts to a read-only IOMap field.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests