IsCharging

Availability All terminals
Description This function checks whether the device is being charged.
Syntax int IsCharging( void );
Arguments None
Returns
0 The device is not connected to USB nor placed on a wireless charger (OPN6000 only)
1 The device is connected to USB or placed on a wireless charger (OPN6000 only)
2 The device is connected to USB or placed on a wireless charger and the charging is complete.
3 The devicex is connected to USB or placed on a wireless charger, but not able to charge (i.e. temperature out of range)
Example
#include <stdio.h>
#include "lib.h"

void main( void )
{
    int previous_state, current_state;

    previous_state = -1;    // Not equal to 0, 1, etc. 

    for(;;)
    {
        current_state = IsCharging();
        if( current_state != previous_state)
        {
            previous_state = current_state;
            switch( current_state )
            {
                case 0:
                    printf("Not charging\n");
                    break;
                case 1:
                    printf("Charging\n");
                    break;
                case 2:
                    printf("Completed\n");
                    break;
                case 3:
                    printf("Charging error\n");
                    break;
            }
        }
        Idle();
    }
}