Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86d60da935 | ||
|
|
e1a4418599 | ||
|
|
0402b7bd2f | ||
|
|
644a3e4349 | ||
|
|
76a3ec00d0 | ||
|
|
a4ccb3ae96 | ||
|
|
0d713ae257 | ||
|
|
26bf31ae64 | ||
|
|
0672d637a4 | ||
|
|
6b7567257b | ||
|
|
554001a2d4 | ||
|
|
d98b1aa76d | ||
|
|
7683ad155d | ||
|
|
832940353b | ||
|
|
e82c75258a | ||
|
|
3040bc5fa4 | ||
|
|
00bf5357c1 | ||
|
|
902fa7f75b | ||
|
|
3f45e6a5af |
@@ -94,7 +94,7 @@ def getConstants():
|
|||||||
consants.append(('SymbolVolts', 'V'))
|
consants.append(('SymbolVolts', 'V'))
|
||||||
consants.append(('SymbolDC', 'DC'))
|
consants.append(('SymbolDC', 'DC'))
|
||||||
consants.append(('SymbolCellCount', 'S'))
|
consants.append(('SymbolCellCount', 'S'))
|
||||||
consants.append(('SymbolVersionNumber', 'V2.06'))
|
consants.append(('SymbolVersionNumber', 'V2.07'))
|
||||||
return consants
|
return consants
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -69,11 +69,12 @@ public:
|
|||||||
cursor_y = y * fontHeight;
|
cursor_y = y * fontHeight;
|
||||||
}
|
}
|
||||||
static void setFont(uint8_t fontNumber); // (Future) Set the font that is being used
|
static void setFont(uint8_t fontNumber); // (Future) Set the font that is being used
|
||||||
|
static uint8_t getFont();
|
||||||
static void drawImage(const uint8_t* buffer, uint8_t x, uint8_t width) {
|
static void drawImage(const uint8_t* buffer, uint8_t x, uint8_t width) {
|
||||||
drawArea(x, 0, width, 16, buffer);
|
drawArea(x, 0, width, 16, buffer);
|
||||||
}
|
}
|
||||||
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
|
// Draws an image to the buffer, at x offset from top to bottom (fixed height renders)
|
||||||
static void printNumber(uint16_t number, uint8_t places);
|
static void printNumber(uint16_t number, uint8_t places,bool noLeaderZeros=true);
|
||||||
// Draws a number at the current cursor location
|
// Draws a number at the current cursor location
|
||||||
// Clears the buffer
|
// Clears the buffer
|
||||||
static void clearScreen() {
|
static void clearScreen() {
|
||||||
|
|||||||
@@ -63,12 +63,21 @@ void gui_drawTipTemp(bool symbol) {
|
|||||||
|
|
||||||
OLED::printNumber(Temp, 3); // Draw the tip temp out finally
|
OLED::printNumber(Temp, 3); // Draw the tip temp out finally
|
||||||
if (symbol) {
|
if (symbol) {
|
||||||
|
if (OLED::getFont() == 0) {
|
||||||
|
//Big font, can draw nice symbols
|
||||||
|
if (systemSettings.temperatureInF)
|
||||||
|
OLED::drawSymbol(0);
|
||||||
|
else
|
||||||
|
OLED::drawSymbol(1);
|
||||||
|
} else {
|
||||||
|
//Otherwise fall back to chars
|
||||||
if (systemSettings.temperatureInF)
|
if (systemSettings.temperatureInF)
|
||||||
OLED::print(SymbolDegF);
|
OLED::print(SymbolDegF);
|
||||||
else
|
else
|
||||||
OLED::print(SymbolDegC);
|
OLED::print(SymbolDegC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ButtonState getButtonState() {
|
ButtonState getButtonState() {
|
||||||
/*
|
/*
|
||||||
* Read in the buttons and then determine if a state change needs to occur
|
* Read in the buttons and then determine if a state change needs to occur
|
||||||
|
|||||||
@@ -155,6 +155,14 @@ void OLED::setFont(uint8_t fontNumber) {
|
|||||||
fontWidth = 12;
|
fontWidth = 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uint8_t OLED::getFont() {
|
||||||
|
if (currentFont == USER_FONT_6x8)
|
||||||
|
return 1;
|
||||||
|
else if (currentFont == ExtraFontChars)
|
||||||
|
return 2;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
inline void stripLeaderZeros(char *buffer) {
|
inline void stripLeaderZeros(char *buffer) {
|
||||||
//Removing the leading zero's by swapping them to SymbolSpace
|
//Removing the leading zero's by swapping them to SymbolSpace
|
||||||
// Stop 1 short so that we dont blank entire number if its zero
|
// Stop 1 short so that we dont blank entire number if its zero
|
||||||
@@ -167,7 +175,7 @@ inline void stripLeaderZeros(char *buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// maximum places is 5
|
// maximum places is 5
|
||||||
void OLED::printNumber(uint16_t number, uint8_t places) {
|
void OLED::printNumber(uint16_t number, uint8_t places, bool noLeaderZeros) {
|
||||||
char buffer[7] = { 0 };
|
char buffer[7] = { 0 };
|
||||||
|
|
||||||
if (places >= 5) {
|
if (places >= 5) {
|
||||||
@@ -195,6 +203,7 @@ void OLED::printNumber(uint16_t number, uint8_t places) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buffer[0] = 2 + number % 10;
|
buffer[0] = 2 + number % 10;
|
||||||
|
if (noLeaderZeros)
|
||||||
stripLeaderZeros(buffer);
|
stripLeaderZeros(buffer);
|
||||||
print(buffer);
|
print(buffer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ static void settings_setSensitivity(void) {
|
|||||||
|
|
||||||
static void settings_displaySensitivity(void) {
|
static void settings_displaySensitivity(void) {
|
||||||
printShortDescription(4, 7);
|
printShortDescription(4, 7);
|
||||||
OLED::printNumber(systemSettings.sensitivity, 1);
|
OLED::printNumber(systemSettings.sensitivity, 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void settings_setAdvancedSolderingScreens(void) {
|
static void settings_setAdvancedSolderingScreens(void) {
|
||||||
@@ -613,7 +613,7 @@ static void settings_setCalibrateVIN(void) {
|
|||||||
2);
|
2);
|
||||||
OLED::print(SymbolDot);
|
OLED::print(SymbolDot);
|
||||||
OLED::printNumber(getInputVoltageX10(systemSettings.voltageDiv, 0) % 10,
|
OLED::printNumber(getInputVoltageX10(systemSettings.voltageDiv, 0) % 10,
|
||||||
1);
|
1, false);
|
||||||
OLED::print(SymbolVolts);
|
OLED::print(SymbolVolts);
|
||||||
|
|
||||||
ButtonState buttons = getButtonState();
|
ButtonState buttons = getButtonState();
|
||||||
|
|||||||
@@ -66,7 +66,12 @@ uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
|
|||||||
// Therefore we can divide down from there
|
// Therefore we can divide down from there
|
||||||
// Multiplying ADC max by 4 for additional calibration options,
|
// Multiplying ADC max by 4 for additional calibration options,
|
||||||
// ideal term is 467
|
// ideal term is 467
|
||||||
|
#ifdef MODEL_TS100
|
||||||
#define BATTFILTERDEPTH 32
|
#define BATTFILTERDEPTH 32
|
||||||
|
#else
|
||||||
|
#define BATTFILTERDEPTH 8
|
||||||
|
|
||||||
|
#endif
|
||||||
static uint8_t preFillneeded = 10;
|
static uint8_t preFillneeded = 10;
|
||||||
static uint32_t samples[BATTFILTERDEPTH];
|
static uint32_t samples[BATTFILTERDEPTH];
|
||||||
static uint8_t index = 0;
|
static uint8_t index = 0;
|
||||||
@@ -88,6 +93,51 @@ uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
|
|||||||
return sum * 4 / divisor;
|
return sum * 4 / divisor;
|
||||||
}
|
}
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
|
void DPlusZero_Six() {
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); // pull down D+
|
||||||
|
}
|
||||||
|
void DNegZero_Six() {
|
||||||
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
void DPlusThree_Three() {
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET); // pull up D+
|
||||||
|
}
|
||||||
|
void DNegThree_Three() {
|
||||||
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
|
||||||
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QC_Seek9V() {
|
||||||
|
DNegZero_Six();
|
||||||
|
DPlusThree_Three();
|
||||||
|
}
|
||||||
|
void QC_Seek12V() {
|
||||||
|
DNegZero_Six();
|
||||||
|
DPlusZero_Six();
|
||||||
|
}
|
||||||
|
void QC_Seek20V() {
|
||||||
|
DNegThree_Three();
|
||||||
|
DPlusThree_Three();
|
||||||
|
}
|
||||||
|
void QC_SeekContMode() {
|
||||||
|
DNegThree_Three();
|
||||||
|
DPlusZero_Six();
|
||||||
|
}
|
||||||
|
void QC_SeekContPlus() {
|
||||||
|
QC_SeekContMode();
|
||||||
|
vTaskDelay(3);
|
||||||
|
QC_Seek20V();
|
||||||
|
vTaskDelay(1);
|
||||||
|
QC_SeekContMode();
|
||||||
|
}
|
||||||
|
void QC_SeekContNeg() {
|
||||||
|
QC_SeekContMode();
|
||||||
|
vTaskDelay(3);
|
||||||
|
QC_Seek12V();
|
||||||
|
vTaskDelay(1);
|
||||||
|
QC_SeekContMode();
|
||||||
|
}
|
||||||
uint8_t QCMode = 0;
|
uint8_t QCMode = 0;
|
||||||
uint8_t QCTries = 0;
|
uint8_t QCTries = 0;
|
||||||
void seekQC(int16_t Vx10, uint16_t divisor) {
|
void seekQC(int16_t Vx10, uint16_t divisor) {
|
||||||
@@ -98,142 +148,108 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
|
|
||||||
if (Vx10 < 45)
|
if (Vx10 < 45)
|
||||||
return;
|
return;
|
||||||
|
if (xTaskGetTickCount() < 100)
|
||||||
|
return;
|
||||||
if (Vx10 > 130)
|
if (Vx10 > 130)
|
||||||
Vx10 = 130; //Cap max value at 13V
|
Vx10 = 130; //Cap max value at 13V
|
||||||
// Seek the QC to the Voltage given if this adapter supports continuous mode
|
// Seek the QC to the Voltage given if this adapter supports continuous mode
|
||||||
// try and step towards the wanted value
|
// try and step towards the wanted value
|
||||||
|
|
||||||
// 1. Measure current voltage
|
// 1. Measure current voltage
|
||||||
int16_t vStart = getInputVoltageX10(divisor, 0);
|
int16_t vStart = getInputVoltageX10(divisor, 1);
|
||||||
int difference = Vx10 - vStart;
|
int difference = Vx10 - vStart;
|
||||||
|
|
||||||
// 2. calculate ideal steps (0.2V changes)
|
// 2. calculate ideal steps (0.2V changes)
|
||||||
|
|
||||||
int steps = difference / 2;
|
int steps = difference / 2;
|
||||||
if (QCMode == 3) {
|
if (QCMode == 3) {
|
||||||
|
if (steps > -2 && steps < 2)
|
||||||
|
return; // dont bother with small steps
|
||||||
while (steps < 0) {
|
while (steps < 0) {
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); //D+0.6
|
QC_SeekContNeg();
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET); //D-3.3V
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET); // D-3.3Vs
|
|
||||||
vTaskDelay(3);
|
vTaskDelay(3);
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET); //-0.6V
|
|
||||||
HAL_Delay(1);
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
HAL_Delay(1);
|
|
||||||
steps++;
|
steps++;
|
||||||
}
|
}
|
||||||
while (steps > 0) {
|
while (steps > 0) {
|
||||||
// step once up
|
QC_SeekContPlus();
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET);
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
|
|
||||||
vTaskDelay(3);
|
vTaskDelay(3);
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET);
|
|
||||||
HAL_Delay(1);
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
HAL_Delay(1);
|
|
||||||
steps--;
|
steps--;
|
||||||
}
|
}
|
||||||
|
vTaskDelay(10);
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_QC2
|
||||||
// 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*/
|
||||||
#ifdef QC2_ROUND_DOWN
|
steps = vStart - getInputVoltageX10(divisor, 1);
|
||||||
steps = vStart - getInputVoltageX10(195);
|
if (steps < 0)
|
||||||
if (steps < 0) steps = -steps;
|
steps = -steps;
|
||||||
if (steps > (difference / 2)) {
|
if (steps > 4) {
|
||||||
// No continuous mode, so QC2
|
// No continuous mode, so QC2
|
||||||
QCMode = 2;
|
QCMode = 2;
|
||||||
// Goto nearest
|
// Goto nearest
|
||||||
if (Vx10 > 10.5) {
|
if (Vx10 > 110) {
|
||||||
// request 12V
|
// request 12V
|
||||||
// D- = 0.6V, D+ = 0.6V
|
// D- = 0.6V, D+ = 0.6V
|
||||||
// Clamp PB3
|
// Clamp PB3
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET);// pull down D+
|
QC_Seek12V();
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// request 9V
|
// request 9V
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET);
|
QC_Seek9V();
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must be called after FreeRToS Starts
|
// Must be called after FreeRToS Starts
|
||||||
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);
|
uint16_t vin = getInputVoltageX10(divisor, 1);
|
||||||
if (vin > 100) {
|
if (vin > 100) {
|
||||||
QCMode = 1; // ALready at ~12V
|
QCMode = 1; // Already at 12V, user has probably over-ridden this
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_3;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_10;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
//Turn off output mode on pins that we can
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_13;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
// Tries to negotiate QC for 9V
|
// Tries to negotiate QC for 9V
|
||||||
// This is a multiple step process.
|
// This is a multiple step process.
|
||||||
// 1. Set around 0.6V on D+ for 1.25 Seconds or so
|
// 1. Set around 0.6V on D+ for 1.25 Seconds or so
|
||||||
// 2. After this It should un-short D+->D- and instead add a 20k pulldown on
|
// 2. After this It should un-short D+->D- and instead add a 20k pulldown on
|
||||||
// D-
|
// D-
|
||||||
// 3. Now set D+ to 3.3V and D- to 0.6V to request 9V
|
DPlusZero_Six();
|
||||||
// OR both at 0.6V for 12V request (if the adapter can do it).
|
|
||||||
// If 12V is implimented then should fallback to 9V after validation
|
|
||||||
// Step 1. We want to pull D+ to 0.6V
|
|
||||||
// Pull PB3 donwn to ground
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET);// pull low to put 0.6V on D+
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_RESET);
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_3;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET);// pull low to put 0.6V on D+
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_RESET);
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_13;
|
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
// Delay 1.25 seconds
|
// Delay 1.25 seconds
|
||||||
uint8_t enteredQC = 0;
|
uint8_t enteredQC = 0;
|
||||||
for (uint16_t i = 0; i < 130 && enteredQC == 0; i++) {
|
vTaskDelay(125);
|
||||||
// HAL_Delay(10);
|
|
||||||
vTaskDelay(1);
|
|
||||||
|
|
||||||
}
|
|
||||||
// Check if D- is low to spot a QC charger
|
// Check if D- is low to spot a QC charger
|
||||||
if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO_PIN_RESET)
|
if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO_PIN_RESET)
|
||||||
enteredQC = 1;
|
enteredQC = 1;
|
||||||
if (enteredQC) {
|
if (enteredQC) {
|
||||||
// We have a QC capable charger
|
// We have a QC capable charger
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET);
|
QC_Seek9V();
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
|
GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_10;
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_8;
|
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_SET);
|
QC_Seek9V();
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
// Wait for frontend ADC to stabilise
|
// Wait for frontend ADC to stabilise
|
||||||
QCMode = 4;
|
QCMode = 4;
|
||||||
for (uint8_t i = 0; i < 10; i++) {
|
for (uint8_t i = 0; i < 10; i++) {
|
||||||
if (getInputVoltageX10(divisor, 1) > 80) {
|
if (getInputVoltageX10(divisor, 1) > 80) {
|
||||||
// yay we have at least QC2.0 or QC3.0
|
// yay we have at least QC2.0 or QC3.0
|
||||||
QCMode = 3; // We have at least QC2, pray for 3
|
QCMode = 3; // We have at least QC2, pray for 3
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET);
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vTaskDelay(10); // 100mS
|
vTaskDelay(10); // 100mS
|
||||||
@@ -245,7 +261,6 @@ void startQC(uint16_t divisor) {
|
|||||||
} else {
|
} else {
|
||||||
// no QC
|
// no QC
|
||||||
QCMode = 0;
|
QCMode = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (QCTries > 10)
|
if (QCTries > 10)
|
||||||
QCMode = 0;
|
QCMode = 0;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ uint8_t PCBVersion = 0;
|
|||||||
// File local variables
|
// File local variables
|
||||||
uint32_t currentTempTargetDegC = 0; // Current temperature target in C
|
uint32_t currentTempTargetDegC = 0; // Current temperature target in C
|
||||||
uint32_t lastMovementTime = 0;
|
uint32_t lastMovementTime = 0;
|
||||||
int16_t idealQCVoltage = 0;
|
|
||||||
bool settingsWereReset = false;
|
bool settingsWereReset = false;
|
||||||
// FreeRTOS variables
|
// FreeRTOS variables
|
||||||
|
|
||||||
@@ -41,6 +41,10 @@ void startPIDTask(void const *argument);
|
|||||||
void startMOVTask(void const *argument);
|
void startMOVTask(void const *argument);
|
||||||
// End FreeRTOS
|
// End FreeRTOS
|
||||||
|
|
||||||
|
static const int maxPowerIdleTicks = 1000;
|
||||||
|
static const int powerPulseTicks = 50;
|
||||||
|
static const int x10PowerPulseWatts = 3;
|
||||||
|
|
||||||
// Main sets up the hardware then hands over to the FreeRTOS kernel
|
// Main sets up the hardware then hands over to the FreeRTOS kernel
|
||||||
int main(void) {
|
int main(void) {
|
||||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick.
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick.
|
||||||
@@ -108,9 +112,6 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
* control PWM.
|
* control PWM.
|
||||||
*/
|
*/
|
||||||
setTipX10Watts(0); // disable the output driver if the output is set to be off
|
setTipX10Watts(0); // disable the output driver if the output is set to be off
|
||||||
#ifdef MODEL_TS80
|
|
||||||
idealQCVoltage = calculateMaxVoltage(systemSettings.cutoutSetting);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
//Set power management code to the tip resistance in ohms * 10
|
//Set power management code to the tip resistance in ohms * 10
|
||||||
@@ -127,6 +128,7 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
|
|
||||||
if (ulTaskNotifyTake(pdTRUE, 2000)) {
|
if (ulTaskNotifyTake(pdTRUE, 2000)) {
|
||||||
// This is a call to block this thread until the ADC does its samples
|
// This is a call to block this thread until the ADC does its samples
|
||||||
|
int32_t x10WattsOut = 0;
|
||||||
// Do the reading here to keep the temp calculations churning along
|
// Do the reading here to keep the temp calculations churning along
|
||||||
uint32_t currentTipTempInC = TipThermoModel::getTipInC(true);
|
uint32_t currentTipTempInC = TipThermoModel::getTipInC(true);
|
||||||
|
|
||||||
@@ -148,7 +150,6 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
tempError.update(tError);
|
tempError.update(tError);
|
||||||
|
|
||||||
// Now for the PID!
|
// Now for the PID!
|
||||||
int32_t x10WattsOut = 0;
|
|
||||||
|
|
||||||
// P term - total power needed to hit target temp next cycle.
|
// P term - total power needed to hit target temp next cycle.
|
||||||
// thermal mass = 1690 milliJ/*C for my tip.
|
// thermal mass = 1690 milliJ/*C for my tip.
|
||||||
@@ -175,25 +176,20 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
// basically: temp - lastTemp
|
// basically: temp - lastTemp
|
||||||
// Unfortunately, our temp signal is too noisy to really help.
|
// Unfortunately, our temp signal is too noisy to really help.
|
||||||
|
|
||||||
setTipX10Watts(x10WattsOut);
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
//If its a TS80, we want to have the option of using an occasional pulse to keep the power bank on
|
//If its a TS80, we want to have the option of using an occasional pulse to keep the power bank on
|
||||||
// This is purely guesswork :'( as everyone implements stuff differently
|
if (((xTaskGetTickCount() - lastPowerPulse) > maxPowerIdleTicks)
|
||||||
if (xTaskGetTickCount() - lastPowerPulse < 10) {
|
&& (x10WattsOut < x10PowerPulseWatts)) {
|
||||||
// for the first 100mS turn on for a bit
|
x10WattsOut = x10PowerPulseWatts;
|
||||||
setTipX10Watts(25); // typically its around 5W to hold the current temp, so this wont raise temp much
|
}
|
||||||
} else
|
if (((xTaskGetTickCount() - lastPowerPulse)
|
||||||
setTipX10Watts(0);
|
> (maxPowerIdleTicks + powerPulseTicks))
|
||||||
//Then wait until the next 0.5 seconds
|
&& (x10WattsOut >= x10PowerPulseWatts)) {
|
||||||
if (xTaskGetTickCount() - lastPowerPulse > 50) {
|
|
||||||
lastPowerPulse = xTaskGetTickCount();
|
lastPowerPulse = xTaskGetTickCount();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
setTipX10Watts(0);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
setTipX10Watts(x10WattsOut);
|
||||||
|
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
HAL_IWDG_Refresh(&hiwdg);
|
||||||
} else {
|
} else {
|
||||||
@@ -214,7 +210,8 @@ void startMOVTask(void const *argument __unused) {
|
|||||||
while (pidTaskNotification == 0)
|
while (pidTaskNotification == 0)
|
||||||
osDelay(30); // To ensure we return after idealQCVoltage/tip resistance
|
osDelay(30); // To ensure we return after idealQCVoltage/tip resistance
|
||||||
|
|
||||||
seekQC(idealQCVoltage, systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
|
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
|
||||||
|
systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
|
||||||
|
|
||||||
#else
|
#else
|
||||||
osDelay(250); // wait for accelerometer to stabilize
|
osDelay(250); // wait for accelerometer to stabilize
|
||||||
@@ -277,9 +274,8 @@ void startMOVTask(void const *argument __unused) {
|
|||||||
|
|
||||||
osDelay(100); // Slow down update rate
|
osDelay(100); // Slow down update rate
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
// if (currentlyActiveTemperatureTarget) {
|
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
|
||||||
// seekQC(idealQCVoltage, systemSettings.voltageDiv); // Run the QC seek again to try and compensate for cable V drop
|
systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
|
||||||
// }
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user