Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
hdw-battmon.h File Reference

Detailed Description

Design Philosophy

The battery monitor uses the Analog to Digital Converter (ADC) Oneshot Mode Driver.

The battery monitor code is based on the ADC Single Read Example.

Warning
The battery monitor and microphone (hdw-mic.h) cannot be used at the same time! Each mode can either continuously sample the microphone or measure the battery voltage, not both.

Usage

You don't need to call initBattmon() or deinitBattmon(). The system does at the appropriate times.

readBattmon() should be called to read the instantaneous battery voltage.

Example

printf("%d\n", readBattmon());
int readBattmon(void)
Read and return the battery voltage.
Definition hdw-battmon.c:102

Go to the source code of this file.

Functions

void initBattmon (gpio_num_t gpio)
 Initialize a oneshot analog-to-digital unit to read the battery voltage.
 
void deinitBattmon (void)
 Deinitialize the analog-to-digital unit used to read the battery voltage.
 
int readBattmon (void)
 Read and return the battery voltage.
 

Function Documentation

◆ initBattmon()

void initBattmon ( gpio_num_t gpio)

Initialize a oneshot analog-to-digital unit to read the battery voltage.

Parameters
gpioThe GPIO to initialize the ADC on

◆ deinitBattmon()

void deinitBattmon ( void )

Deinitialize the analog-to-digital unit used to read the battery voltage.

◆ readBattmon()

int readBattmon ( void )

Read and return the battery voltage.

Returns
The voltage if read, or -1 if there was an error