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