Flying Silicon Sensor
PwrSupply Namespace Reference

Enumerations

enum  Supply { PwrUsbOnly = 0 , PwrBattOnly = 1 , PwrConnected = 2 , PwrBattDrained = 3 }
 

Functions

int isCharging (void)
 
float getBatPct (void)
 
float getBatVolt (void)
 
int isUsbConnected (void)
 
int isUsbOnly (void)
 
int isBatPowered (void)
 
int isBatDrained (void)
 
void reset (void)
 
void updateState (void)
 

Variables

static int pwrStat = PwrUsbOnly
 Power supply status.
 
static float batVolt = 0.0
 Battery Voltage.
 
static float batPct = 0.0
 Battery charge %.
 
static int charging = 0
 Charging state.
 

Enumeration Type Documentation

◆ Supply

Enumerator
PwrUsbOnly 

Powered by USB only.

PwrBattOnly 

Powered by battery only.

PwrConnected 

Powered by battery and connected to USB.

PwrBattDrained 

Battery drained.

Definition at line 38 of file pwrSupply.cpp.

Function Documentation

◆ getBatPct()

float PwrSupply::getBatPct ( void  )

Check the power status

Returns
Last estimated remaining battery percent

Definition at line 69 of file pwrSupply.cpp.

References batPct.

Referenced by managePower().

◆ getBatVolt()

float PwrSupply::getBatVolt ( void  )

Check the power status

Returns
Last measured battery voltage (depends on charging state)

Definition at line 77 of file pwrSupply.cpp.

References batVolt.

Referenced by managePower().

◆ isBatDrained()

int PwrSupply::isBatDrained ( void  )

Check the power status

Returns
1 if the battery appears to be drained, else 0

Definition at line 109 of file pwrSupply.cpp.

References PwrBattDrained, and pwrStat.

Referenced by appLoop(), and appSetup().

◆ isBatPowered()

int PwrSupply::isBatPowered ( void  )

Check the power status

Returns
1 if the device is powered by battery without USB charging, else 0

Definition at line 101 of file pwrSupply.cpp.

References PwrBattOnly, and pwrStat.

Referenced by appLoop(), appSetup(), and managePower().

◆ isCharging()

int PwrSupply::isCharging ( void  )

Check the power status

Returns
1 if charging, else 0

Definition at line 62 of file pwrSupply.cpp.

References charging.

Referenced by managePower().

◆ isUsbConnected()

int PwrSupply::isUsbConnected ( void  )

Check the power status

Returns
1 if USB power is connected, else 0

Definition at line 85 of file pwrSupply.cpp.

References PwrConnected, and pwrStat.

Referenced by enable(), loopConnected(), and managePower().

◆ isUsbOnly()

int PwrSupply::isUsbOnly ( void  )

Check the power status

Returns
1 if the device is powered by USB only, else 0

Definition at line 93 of file pwrSupply.cpp.

References pwrStat, and PwrUsbOnly.

◆ reset()

void PwrSupply::reset ( void  )

Clear the power status

Definition at line 116 of file pwrSupply.cpp.

References pwrStat, and PwrUsbOnly.

Referenced by resetStatus().

◆ updateState()

void PwrSupply::updateState ( void  )

Update the power status

Definition at line 123 of file pwrSupply.cpp.

References batPct, batVolt, charging, DEBUG, FAST_CHARGE, LOG, LOGL, MinBattV, PIN_BATTV, PIN_CHG, PIN_HICHG, PIN_USB, PwrBattDrained, PwrBattOnly, PwrConnected, pwrStat, and PwrUsbOnly.

Referenced by managePower().

Variable Documentation

◆ batPct

float PwrSupply::batPct = 0.0
static

Battery charge %.

Definition at line 54 of file pwrSupply.cpp.

Referenced by getBatPct(), and updateState().

◆ batVolt

float PwrSupply::batVolt = 0.0
static

Battery Voltage.

Definition at line 52 of file pwrSupply.cpp.

Referenced by getBatVolt(), and updateState().

◆ charging

int PwrSupply::charging = 0
static

Charging state.

Definition at line 56 of file pwrSupply.cpp.

Referenced by isCharging(), and updateState().

◆ pwrStat

int PwrSupply::pwrStat = PwrUsbOnly
static

Power supply status.

Definition at line 50 of file pwrSupply.cpp.

Referenced by isBatDrained(), isBatPowered(), isUsbConnected(), isUsbOnly(), reset(), and updateState().