C Language Development Kit/Functions/BatteryVoltage
From OptiWiki
< C Language Development Kit | Functions(Redirected from C Language Development Kit/Functions/Batteryvoltage)
| Description | Returns the output voltage level of the battery pack. | ||||||||||||||||||
| Syntax | unsigned int batteryvoltage(void); | ||||||||||||||||||
| Arguments | None | ||||||||||||||||||
| Returns | The output voltage level of the battery pack as an unsigned integer value between 0 and MAX_AD. A value of zero corresponds to 0 Volt. A value of MAX_AD corresponds to the operating voltage of the handheld terminal. The conversion between the return value of batteryvoltage() and the battery voltage is: battery voltage = (return value) * (operating voltage) / MAX_AD. MAX_AD and the operating voltage are hardware dependant and are shown below:
| ||||||||||||||||||
| Remarks | The relation between battery pack output voltage level and remaining battery capacity depends on the type of batteries, and on the charging and discharging history. It is difficult if not impossible to determine the remaining battery capacity from the battery voltage.
The batteryvoltage() function is not available on some models of the PHL1700. On the models that do not support batteryvoltage(), the value 0 is returned. | ||||||||||||||||||
| Example | #include <stdio.h> #include <stdlib.h> #include "lib.h" #define MAXBATTVOLT 330L #define MAX_AD 255L void main( void ) { unsigned int voltage; cursor( NOWRAP ); printf("\fBattery voltage:"); while( 1 ) { voltage = ((long) batteryvoltage() * MAXBATTVOLT ) / MAX_AD; gotoxy(0,1); printf("%1d.%02d V", (voltage/100), (voltage-100*(voltage/100))); sound( TCLICK, VMEDIUM, SHIGH, 0); goodreadled( GREEN, TCLICK); delay(5*50); } } |
