Page 1 of 1

Question about SetBatteryState argument

Posted: 05 Oct 2010, 05:59
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.

Re: NXC functions

Posted: 05 Oct 2010, 08:19
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

Re: Question about SetBatteryState argument

Posted: 05 Oct 2010, 08:35
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...

Re: NXC functions

Posted: 05 Oct 2010, 16:28
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.

Re: Question about SetBatteryState argument

Posted: 05 Oct 2010, 20:25
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

Re: Question about SetBatteryState argument

Posted: 05 Oct 2010, 20:51
by mattallen37
So the command is there just because it is a valid command, though useless?

Re: Question about SetBatteryState argument

Posted: 05 Oct 2010, 21:54
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