Fix QC 20V support
This commit is contained in:
@@ -34,3 +34,17 @@ uint8_t usb_pd_detect() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getIsPoweredByDCIN() {
|
||||||
|
#ifdef MODEL_TS80
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODEL_TS80P
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODEL_TS100
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,11 @@
|
|||||||
#define POW_QC
|
#define POW_QC
|
||||||
#define POW_DC
|
#define POW_DC
|
||||||
#define POW_QC_20V
|
#define POW_QC_20V
|
||||||
|
#define ENABLE_QC2
|
||||||
#define TEMP_TMP36
|
#define TEMP_TMP36
|
||||||
#define ACCEL_BMA
|
#define ACCEL_BMA
|
||||||
#define HALL_SENSOR
|
#define HALL_SENSOR
|
||||||
#define HALL_SI7210
|
#define HALL_SI7210
|
||||||
|
|
||||||
#define BATTFILTERDEPTH 32
|
#define BATTFILTERDEPTH 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
|
|
||||||
if (Vx10 < 45)
|
if (Vx10 < 45)
|
||||||
return;
|
return;
|
||||||
if (xTaskGetTickCount() < 1000)
|
if (xTaskGetTickCount() < TICKS_SECOND)
|
||||||
return;
|
return;
|
||||||
#ifdef POW_QC_20V
|
#ifdef POW_QC_20V
|
||||||
if (Vx10 > 200)
|
if (Vx10 > 200)
|
||||||
@@ -89,7 +89,8 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
// Re-measure
|
// Re-measure
|
||||||
/* Disabled due to nothing to test and code space of around 1k*/
|
/* Disabled due to nothing to test and code space of around 1k*/
|
||||||
steps = vStart - getInputVoltageX10(divisor, 1);
|
steps = vStart - getInputVoltageX10(divisor, 1);
|
||||||
if (steps < 0) steps = -steps;
|
if (steps < 0)
|
||||||
|
steps = -steps;
|
||||||
if (steps > 4) {
|
if (steps > 4) {
|
||||||
// No continuous mode, so QC2
|
// No continuous mode, so QC2
|
||||||
QCMode = 2;
|
QCMode = 2;
|
||||||
@@ -111,11 +112,7 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
void startQC(uint16_t divisor) {
|
void startQC(uint16_t divisor) {
|
||||||
// Pre check that the input could be >5V already, and if so, dont both
|
// Pre check that the input could be >5V already, and if so, dont both
|
||||||
// negotiating as someone is feeding in hv
|
// negotiating as someone is feeding in hv
|
||||||
uint16_t vin = getInputVoltageX10(divisor, 1);
|
QCMode=0;
|
||||||
if (vin > 80) {
|
|
||||||
QCMode = 0; //If over 8V something else has already negotiated
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (QCTries > 10) {
|
if (QCTries > 10) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,42 +126,45 @@ static bool checkVoltageForExit() {
|
|||||||
#endif
|
#endif
|
||||||
static void gui_drawBatteryIcon() {
|
static void gui_drawBatteryIcon() {
|
||||||
#if defined(POW_PD) || defined(POW_QC)
|
#if defined(POW_PD) || defined(POW_QC)
|
||||||
|
if (!getIsPoweredByDCIN()) {
|
||||||
// On TS80 we replace this symbol with the voltage we are operating on
|
// On TS80 we replace this symbol with the voltage we are operating on
|
||||||
// If <9V then show single digit, if not show duals
|
// If <9V then show single digit, if not show dual small ones vertically stacked
|
||||||
uint8_t V = getInputVoltageX10(systemSettings.voltageDiv, 0);
|
uint8_t V = getInputVoltageX10(systemSettings.voltageDiv, 0);
|
||||||
if (V % 10 >= 5)
|
if (V % 10 >= 5)
|
||||||
V = V / 10 + 1; // round up
|
V = V / 10 + 1; // round up
|
||||||
else
|
else
|
||||||
V = V / 10;
|
V = V / 10;
|
||||||
if (V >= 10) {
|
if (V >= 10) {
|
||||||
int16_t xPos = OLED::getCursorX();
|
int16_t xPos = OLED::getCursorX();
|
||||||
OLED::setFont(1);
|
OLED::setFont(1);
|
||||||
OLED::printNumber(V / 10, 1);
|
OLED::printNumber(V / 10, 1);
|
||||||
OLED::setCursor(xPos, 8);
|
OLED::setCursor(xPos, 8);
|
||||||
OLED::printNumber(V % 10, 1);
|
OLED::printNumber(V % 10, 1);
|
||||||
OLED::setFont(0);
|
OLED::setFont(0);
|
||||||
OLED::setCursor(xPos + 12, 0); // need to reset this as if we drew a wide char
|
OLED::setCursor(xPos + 12, 0); // need to reset this as if we drew a wide char
|
||||||
} else {
|
} else {
|
||||||
OLED::printNumber(V, 1);
|
OLED::printNumber(V, 1);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#endif
|
||||||
if (systemSettings.cutoutSetting) {
|
#ifdef POW_DC
|
||||||
|
if (systemSettings.minDCVoltageCells) {
|
||||||
// User is on a lithium battery
|
// User is on a lithium battery
|
||||||
// we need to calculate which of the 10 levels they are on
|
// we need to calculate which of the 10 levels they are on
|
||||||
uint8_t cellCount = systemSettings.cutoutSetting + 2;
|
uint8_t cellCount = systemSettings.minDCVoltageCells + 2;
|
||||||
uint32_t cellV =
|
uint32_t cellV = getInputVoltageX10(systemSettings.voltageDiv, 0) / cellCount;
|
||||||
getInputVoltageX10(systemSettings.voltageDiv, 0) / cellCount;
|
|
||||||
// Should give us approx cell voltage X10
|
// Should give us approx cell voltage X10
|
||||||
// Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
|
// Range is 42 -> 33 = 9 steps therefore we will use battery 0-9
|
||||||
if (cellV < 33)
|
if (cellV < 33)
|
||||||
cellV = 33;
|
cellV = 33;
|
||||||
cellV -= 33;// Should leave us a number of 0-9
|
cellV -= 33; // Should leave us a number of 0-9
|
||||||
if (cellV > 9)
|
if (cellV > 9)
|
||||||
cellV = 9;
|
cellV = 9;
|
||||||
OLED::drawBattery(cellV + 1);
|
OLED::drawBattery(cellV + 1);
|
||||||
} else
|
} else {
|
||||||
OLED::drawSymbol(15); // Draw the DC Logo
|
OLED::drawSymbol(15); // Draw the DC Logo
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
static void gui_solderingTempAdjust() {
|
static void gui_solderingTempAdjust() {
|
||||||
@@ -410,6 +413,7 @@ static bool shouldBeSleeping() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HALL_SENSOR
|
#ifdef HALL_SENSOR
|
||||||
// If the hall effect sensor is enabled in the build, check if its over
|
// If the hall effect sensor is enabled in the build, check if its over
|
||||||
// threshold, and if so then we force sleep
|
// threshold, and if so then we force sleep
|
||||||
|
|||||||
Reference in New Issue
Block a user