diff --git a/workspace/TS100/Core/BSP/Miniware/Power.cpp b/workspace/TS100/Core/BSP/Miniware/Power.cpp index 23b02783..7d3d28eb 100644 --- a/workspace/TS100/Core/BSP/Miniware/Power.cpp +++ b/workspace/TS100/Core/BSP/Miniware/Power.cpp @@ -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 +} + diff --git a/workspace/TS100/Core/BSP/Pine64/Model_Config.h b/workspace/TS100/Core/BSP/Pine64/Model_Config.h index c4675a40..13846fc5 100644 --- a/workspace/TS100/Core/BSP/Pine64/Model_Config.h +++ b/workspace/TS100/Core/BSP/Pine64/Model_Config.h @@ -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 diff --git a/workspace/TS100/Core/Src/QC3.cpp b/workspace/TS100/Core/Src/QC3.cpp index 4eb7e1e1..719f2c72 100644 --- a/workspace/TS100/Core/Src/QC3.cpp +++ b/workspace/TS100/Core/Src/QC3.cpp @@ -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; } diff --git a/workspace/TS100/Core/Threads/GUIThread.cpp b/workspace/TS100/Core/Threads/GUIThread.cpp index daa3f51b..5af727c8 100644 --- a/workspace/TS100/Core/Threads/GUIThread.cpp +++ b/workspace/TS100/Core/Threads/GUIThread.cpp @@ -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