diff --git a/workspace/TS100/inc/hardware.h b/workspace/TS100/inc/hardware.h index aa6de11d..c3c416a4 100644 --- a/workspace/TS100/inc/hardware.h +++ b/workspace/TS100/inc/hardware.h @@ -18,6 +18,7 @@ enum Orientation { ORIENTATION_RIGHT_HAND = 1, ORIENTATION_FLAT = 3 }; +#define MODEL_TS80 #ifndef MODEL_TS100 #ifndef MODEL_TS80 #error "Please Define the model you are building for! MODEL=TS100 or MODEL=TS80" @@ -124,12 +125,12 @@ uint16_t ctoTipMeasurement(uint16_t temp); uint16_t tipMeasurementToC(uint16_t raw); uint16_t ftoTipMeasurement(uint16_t temp); uint16_t tipMeasurementToF(uint16_t raw); -void seekQC(int16_t Vx10); +void seekQC(int16_t Vx10,uint16_t divisor); void setCalibrationOffset(int16_t offSet); void setTipType(enum TipType tipType, uint8_t manualCalGain); uint32_t calculateTipR(uint8_t useFilter); int16_t calculateMaxVoltage(uint8_t useFilter, uint8_t useHP); -void startQC(); // Tries to negotiate QC for highest voltage, must be run after +void startQC(uint16_t divisor); // Tries to negotiate QC for highest voltage, must be run after // RToS // This will try for 12V, failing that 9V, failing that 5V // If input is over 12V returns -1 diff --git a/workspace/TS100/src/hardware.c b/workspace/TS100/src/hardware.c index 603cb04b..9b281cf2 100644 --- a/workspace/TS100/src/hardware.c +++ b/workspace/TS100/src/hardware.c @@ -169,19 +169,21 @@ uint16_t getInputVoltageX10(uint16_t divisor) { #ifdef MODEL_TS80 uint8_t QCMode = 0; uint8_t QCTries = 0; -void seekQC(int16_t Vx10) { +void seekQC(int16_t Vx10,uint16_t divisor) { if (QCMode == 5) - startQC(); + startQC(divisor); if (QCMode == 0) return; // NOT connected to a QC Charger if (Vx10 < 50) return; + if(Vx10>130) + Vx10=130;//Cap max value at 13V // Seek the QC to the Voltage given if this adapter supports continuous mode // try and step towards the wanted value // 1. Measure current voltage - int16_t vStart = getInputVoltageX10(780); + int16_t vStart = getInputVoltageX10(divisor); int difference = Vx10 - vStart; // 2. calculate ideal steps (0.2V changes) @@ -243,10 +245,10 @@ void seekQC(int16_t Vx10) { } // Must be called after FreeRToS Starts -void startQC() { +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(780); + uint16_t vin = getInputVoltageX10(divisor); if (vin > 150) return; // Over voltage if (vin > 100) { @@ -308,7 +310,7 @@ void startQC() { // Wait for frontend ADC to stabilise QCMode = 4; for (uint8_t i = 0; i < 10; i++) { - if (getInputVoltageX10(195) > 80) { + if (getInputVoltageX10(divisor) > 80) { // yay we have at least QC2.0 or QC3.0 QCMode = 3; // We have at least QC2, pray for 3 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); diff --git a/workspace/TS100/src/main.cpp b/workspace/TS100/src/main.cpp index 0eb15a87..722a61d9 100644 --- a/workspace/TS100/src/main.cpp +++ b/workspace/TS100/src/main.cpp @@ -787,7 +787,7 @@ void startGUITask(void const *argument __unused) { if (idealQCVoltage < 90) idealQCVoltage = calculateMaxVoltage(1, systemSettings.cutoutSetting); // 1 means use filtered values rather than do its own - seekQC(idealQCVoltage); + seekQC(idealQCVoltage,systemSettings.voltageDiv); #endif gui_solderingMode(0); // enter soldering mode buttonLockout = true; @@ -1011,11 +1011,11 @@ void startMOVTask(void const *argument __unused) { OLED::setRotation(false); #ifdef MODEL_TS80 - startQC(); + startQC(systemSettings.voltageDiv); while (idealQCVoltage == 0) osDelay(20); // To ensure we return after idealQCVoltage is setup - seekQC(idealQCVoltage); // this will move the QC output to the preferred voltage to start with + seekQC(idealQCVoltage,systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with #else osDelay(250); // wait for accelerometer to stabilize @@ -1102,7 +1102,7 @@ void startMOVTask(void const *argument __unused) { osDelay(100); // Slow down update rate #ifdef MODEL_TS80 if (currentlyActiveTemperatureTarget) { - seekQC(idealQCVoltage); // Run the QC seek again to try and compensate for cable V drop + seekQC(idealQCVoltage,systemSettings.voltageDiv); // Run the QC seek again to try and compensate for cable V drop } #endif }