QC2Control
A simple Arduino library to set the voltage of a Quick Charge 2.0 source
QC2Control Class Reference

Main class of the QC2Control-library. More...

#include <QC2Control.h>

Public Member Functions

 QC2Control (byte DpPin, byte DmPin)
 Makes an object to control a Quick Charge 2.0 source. More...
 
void begin ()
 Starts the handshake with the QC2.0 source. More...
 
void setVoltage (byte volt)
 Sets the desired voltage of the QC2.0 source. More...
 
byte getVoltage ()
 Return the current voltage set. More...
 
void set5V ()
 Set voltage to 5V. More...
 
void set9V ()
 Set voltage to 9V. More...
 
void set12V ()
 Set voltage to 12V. More...
 

Protected Attributes

const byte _DpPin
 Data+ pin.
 
const byte _DmPin
 Data- pin.
 
bool _handshakeDone
 Is the handshake done?
 
byte _setVoltage
 Current set voltage.
 

Static Protected Attributes

static const unsigned int _WaitTime = 1500
 Wait time in the handshake. Should be at least 1,25s.
 

Detailed Description

Main class of the QC2Control-library.

The QC2Control-class includes all the functions to easily set the voltage of a Quick Charge 2.0 source..

See also
setVoltage()

Constructor & Destructor Documentation

QC2Control::QC2Control ( byte  DpPin,
byte  DmPin 
)

Makes an object to control a Quick Charge 2.0 source.

Makes it possible to set the voltage of the QC2.0 source to 5V, 9V or 12V.) See general description on how to wire it.

Parameters
[in]DpPinData+ pin
[in]DmPinData- pin

Member Function Documentation

void QC2Control::begin ( )

Starts the handshake with the QC2.0 source.

A handshake is needed to be able to set the voltage. begin() may be left out, a calling setVoltage() will call begin() if it's not already.

See also
setVoltage(), set5V(), set9V(), set12V()
byte QC2Control::getVoltage ( )
inline

Return the current voltage set.

This can be 5V, 9V or 12V

Note
The library has no notion if the voltage is really set. It just tries to set it but if you just start it all of a QC2.0 source it should set the correct voltage.
Returns
The current set voltage
void QC2Control::set12V ( )
inline

Set voltage to 12V.

Returns
Sets the output of the QC2.0 source to 12V. Short for setVoltage(12).
See also
setVoltage()
void QC2Control::set5V ( )
inline

Set voltage to 5V.

Returns
Sets the output of the QC2.0 source to 5V. Short for setVoltage(5).
See also
setVoltage()
void QC2Control::set9V ( )
inline

Set voltage to 9V.

Returns
Sets the output of the QC2.0 source to 9V. Short for setVoltage(9).
See also
setVoltage()
void QC2Control::setVoltage ( byte  volt)

Sets the desired voltage of the QC2.0 source.

Possible voltages are 5V, 9V and 12V. Any other number will result in 5V.

begin() is blocking code. It waits for a fixed period counting from the start up of the Arduino to act because the handshake needs a minimum time (1,25s minimum). But this is most likely not a problem because if you need 9V or 12V in your application, there is no gain in proceeding when the voltage isn't there yet (because of the handshake). And by putting begin() (or a call to setVoltage()) at the end of setup() (or other initialization) you can even do stuff while waiting because it counts from Arduino startup.

Note
If no handshake has been done (via begin()) with the QC2.0 source the first call to setVoltage() will result in a call to begin() to do the handshake.
Parameters
[in]voltThe desired voltage, 5, 9 or 12.

The documentation for this class was generated from the following files: