View unanswered posts | View active topics It is currently Sun Dec 21, 2014 5:35 pm






Reply to topic  [ 2 posts ] 
Battery 
Author Message
Rookie

Joined: Thu Jul 08, 2010 3:50 pm
Posts: 18
Post Battery
Is there a way to display the remaining battery life on the LCD? I can do the LCD part I just can't find a function to retreive the remaining battery life.


Thu Jul 22, 2010 6:31 pm
Profile
Site Admin
Site Admin

Joined: Mon Jun 08, 2009 4:50 pm
Posts: 70
Post Re: Battery
Hi,

"nImmediateBatteryLevel" will return the battery level at the instant the function was called.
Code:
  while(true)
  {
    displayLCDPos(1,0);
    clearLCDLine(1);
    displayNextLCDNumber(nImmediateBatteryLevel);
    wait1Msec(2000);
  }


and

nAvgBatteryLevel will return the average of the past 20 samples (to smooth out sudden spikes).
Code:
  while(true)
  {
    displayLCDPos(1,0);
    clearLCDLine(1);
    displayNextLCDNumber(nAvgBatteryLevel);
    wait1Msec(2000);
  }


Both functions return a value in millivolts. So a reading of 11987 represent 11.987 volts.

A nice way to keep that on the screen is to make a separate task that displays the average batter level every 20 milliseconds.

Hope that this helps,

_________________
Bence Feher

Undergraduate Intern - NREC, Robotics Academy
ROBOTC - Testing/Documentation/Developer

Computer Science, Japanese, East Asian Studies
University of Pittsburgh, Konan University 甲南大学


Fri Jul 23, 2010 9:45 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.