QC2Control
A simple Arduino library to set the voltage of a Quick Charge 2.0 source
|
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. | |
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..
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.
[in] | DpPin | Data+ pin |
[in] | DmPin | Data- pin |
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.
|
inline |
Return the current voltage set.
This can be 5V, 9V or 12V
|
inline |
Set voltage to 12V.
|
inline |
Set voltage to 5V.
|
inline |
Set voltage to 9V.
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.
[in] | volt | The desired voltage, 5, 9 or 12. |