1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Question about SetBatteryState argument

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.

Question about SetBatteryState argument

Postby mattallen37 » 05 Oct 2010, 05:59

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 ;)
User avatar
mattallen37
 
Posts: 1769
Joined: 02 Oct 2010, 02:19
Location: Michigan USA

Re: NXC functions

Postby mightor » 05 Oct 2010, 08:19

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)
User avatar
mightor
Site Admin
 
Posts: 942
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands

Re: Question about SetBatteryState argument

Postby spillerrec » 05 Oct 2010, 08:35

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...
User avatar
spillerrec
 
Posts: 357
Joined: 01 Oct 2010, 06:37
Location: Denmark

Re: NXC functions

Postby mattallen37 » 05 Oct 2010, 16:28

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 ;)
User avatar
mattallen37
 
Posts: 1769
Joined: 02 Oct 2010, 02:19
Location: Michigan USA

Re: Question about SetBatteryState argument

Postby afanofosc » 05 Oct 2010, 20:25

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/
User avatar
afanofosc
Site Admin
 
Posts: 1111
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN

Re: Question about SetBatteryState argument

Postby mattallen37 » 05 Oct 2010, 20:51

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 ;)
User avatar
mattallen37
 
Posts: 1769
Joined: 02 Oct 2010, 02:19
Location: Michigan USA

Re: Question about SetBatteryState argument

Postby afanofosc » 05 Oct 2010, 21:54

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/
User avatar
afanofosc
Site Admin
 
Posts: 1111
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN


Return to Mindstorms Software

Who is online

Users browsing this forum: No registered users and 3 guests

cron