diff options
Diffstat (limited to 'source/Core')
-rw-r--r-- | source/Core/Drivers/FS2711.cpp | 5 | ||||
-rw-r--r-- | source/Core/Drivers/OLED.cpp | 12 | ||||
-rw-r--r-- | source/Core/Drivers/OLED.hpp | 9 | ||||
-rw-r--r-- | source/Core/Drivers/USBPD.cpp | 7 | ||||
-rw-r--r-- | source/Core/Drivers/Utils.cpp | 5 | ||||
-rw-r--r-- | source/Core/Inc/Settings.h | 2 | ||||
-rw-r--r-- | source/Core/Inc/Translation.h | 5 | ||||
-rw-r--r-- | source/Core/Src/Settings.cpp | 2 | ||||
-rw-r--r-- | source/Core/Src/settingsGUI.cpp | 29 |
9 files changed, 52 insertions, 24 deletions
diff --git a/source/Core/Drivers/FS2711.cpp b/source/Core/Drivers/FS2711.cpp index 9b192d03..1aec92e8 100644 --- a/source/Core/Drivers/FS2711.cpp +++ b/source/Core/Drivers/FS2711.cpp @@ -157,7 +157,10 @@ void FS2711::negotiate() { // FS2711 uses mV instead of V const uint16_t vmax = USB_PD_VMAX * 1000; - const uint8_t tip_resistance = getTipResistanceX10() + 5; + uint8_t tip_resistance = getTipResistanceX10(); + if (getSettingValue(SettingsOptions::USBPDMode) == 1) { + tip_resistance += 5; + } uint16_t pdo_min_mv = 0, pdo_max_mv = 0, pdo_max_curr = 0, pdo_type = 0; diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index d8f046d1..76742890 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -160,7 +160,7 @@ void OLED::setFramebuffer(uint8_t *buffer) { * UTF font handling is done using the two input chars. * Precursor is the command char that is used to select the table. */ -void OLED::drawChar(const uint16_t charCode, const FontStyle fontStyle) { +void OLED::drawChar(const uint16_t charCode, const FontStyle fontStyle, const uint8_t soft_x_limit) { const uint8_t *currentFont; static uint8_t fontWidth, fontHeight; uint16_t index; @@ -175,7 +175,7 @@ void OLED::drawChar(const uint16_t charCode, const FontStyle fontStyle) { case FontStyle::LARGE: default: if (charCode == '\x01' && cursor_y == 0) { // 0x01 is used as new line char - setCursor(0, 8); + setCursor(soft_x_limit, 8); return; } else if (charCode <= 0x01) { return; @@ -505,7 +505,7 @@ void OLED::setInverseDisplay(bool inverse) { } // print a string to the current cursor location, len chars MAX -void OLED::print(const char *const str, FontStyle fontStyle, uint8_t len) { +void OLED::print(const char *const str, FontStyle fontStyle, uint8_t len, const uint8_t soft_x_limit) { const uint8_t *next = reinterpret_cast<const uint8_t *>(str); if (next[0] == 0x01) { fontStyle = FontStyle::LARGE; @@ -523,7 +523,7 @@ void OLED::print(const char *const str, FontStyle fontStyle, uint8_t len) { index = (next[0] - 0xF0) * 0xFF - 15 + next[1]; next += 2; } - drawChar(index, fontStyle); + drawChar(index, fontStyle, soft_x_limit); } } @@ -580,7 +580,7 @@ void OLED::drawHex(uint32_t x, FontStyle fontStyle, uint8_t digits) { // print number to hex for (uint_fast8_t i = 0; i < digits; i++) { uint16_t value = (x >> (4 * (7 - i))) & 0b1111; - drawChar(value + 2, fontStyle); + drawChar(value + 2, fontStyle, 0); } } @@ -635,7 +635,7 @@ void OLED::debugNumber(int32_t val, FontStyle fontStyle) { void OLED::drawSymbol(uint8_t symbolID) { // draw a symbol to the current cursor location - drawChar(symbolID, FontStyle::EXTRAS); + drawChar(symbolID, FontStyle::EXTRAS, 0); } // Draw an area, but y must be aligned on 0/8 offset diff --git a/source/Core/Drivers/OLED.hpp b/source/Core/Drivers/OLED.hpp index 40811948..65bf8e58 100644 --- a/source/Core/Drivers/OLED.hpp +++ b/source/Core/Drivers/OLED.hpp @@ -78,10 +78,7 @@ enum class FontStyle { class OLED {
public:
- enum DisplayState : bool {
- OFF = false,
- ON = true
- };
+ enum DisplayState : bool { OFF = false, ON = true };
static void initialize(); // Startup the I2C coms (brings screen out of reset etc)
static bool isInitDone();
@@ -120,7 +117,7 @@ public: static void setInverseDisplay(bool inverted);
static int16_t getCursorX() { return cursor_x; }
// Draw a string to the current location, with selected font; optionally - with MAX length only
- static void print(const char *string, FontStyle fontStyle, uint8_t length = 255);
+ static void print(const char *string, FontStyle fontStyle, uint8_t length = 255, const uint8_t soft_x_limit = 0);
static void printWholeScreen(const char *string);
// Print *F or *C - in font style of Small, Large (by default) or Extra based on input arg
static void printSymbolDeg(FontStyle fontStyle = FontStyle::LARGE);
@@ -166,7 +163,7 @@ private: displayChecksum = hash;
return result;
}
- static void drawChar(uint16_t charCode, FontStyle fontStyle); // Draw a character to the current cursor location
+ static void drawChar(uint16_t charCode, FontStyle fontStyle, const uint8_t soft_x_limit); // Draw a character to the current cursor location
static void setFramebuffer(uint8_t *buffer);
static uint8_t *stripPointers[4]; // Pointers to the strips to allow for buffer having extra content
static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
diff --git a/source/Core/Drivers/USBPD.cpp b/source/Core/Drivers/USBPD.cpp index 5e114d16..1f154080 100644 --- a/source/Core/Drivers/USBPD.cpp +++ b/source/Core/Drivers/USBPD.cpp @@ -135,7 +135,10 @@ bool parseCapabilitiesArray(const uint8_t numCaps, uint8_t *bestIndex, uint16_t *bestVoltage = 5000; // Default 5V // Fudge of 0.5 ohms to round up a little to account for us always having off periods in PWM - uint8_t tipResistance = getTipResistanceX10() + 5; + uint8_t tipResistance = getTipResistanceX10(); + if (getSettingValue(SettingsOptions::USBPDMode) == 1) { + tipResistance += 5; + } #ifdef MODEL_HAS_DCDC // If this device has step down DC/DC inductor to smooth out current spikes // We can instead ignore resistance and go for max voltage we can accept; and rely on the DC/DC regulation to keep under current limit @@ -167,7 +170,7 @@ bool parseCapabilitiesArray(const uint8_t numCaps, uint8_t *bestIndex, uint16_t } } } - } else if ((lastCapabilities[i] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED && getSettingValue(SettingsOptions::PDVpdo)) { + } else if ((lastCapabilities[i] & PD_PDO_TYPE) == PD_PDO_TYPE_AUGMENTED && getSettingValue(SettingsOptions::USBPDMode)) { bool sourceIsEPRCapable = lastCapabilities[0] & PD_PDO_SRC_FIXED_EPR_CAPABLE; bool isPPS = false; bool isAVS = false; diff --git a/source/Core/Drivers/Utils.cpp b/source/Core/Drivers/Utils.cpp index b65922f3..b560fd3a 100644 --- a/source/Core/Drivers/Utils.cpp +++ b/source/Core/Drivers/Utils.cpp @@ -22,7 +22,10 @@ int32_t Utils::InterpolateLookupTable(const int32_t *lookupTable, const int noIt int32_t Utils::LinearInterpolate(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x) { return y1 + (((((x - x1) * 1000) / (x2 - x1)) * (y2 - y1))) / 1000; }
uint16_t Utils::RequiredCurrentForTipAtVoltage(uint16_t voltageX10) {
- uint8_t tipResistancex10 = getTipResistanceX10() + 5;
+ uint8_t tipResistancex10 = getTipResistanceX10();
+ if (getSettingValue(SettingsOptions::USBPDMode) == 1) {
+ tipResistancex10 += 5;
+ }
#ifdef MODEL_HAS_DCDC
// If this device has step down DC/DC inductor to smooth out current spikes
// We can instead ignore resistance and go for max voltage we can accept; and rely on the DC/DC regulation to keep under current limit
diff --git a/source/Core/Inc/Settings.h b/source/Core/Inc/Settings.h index e332580e..72eb7d8d 100644 --- a/source/Core/Inc/Settings.h +++ b/source/Core/Inc/Settings.h @@ -52,7 +52,7 @@ enum SettingsOptions { LOGOTime = 35, // Duration the logo will be displayed for CalibrateCJC = 36, // Toggle calibrate CJC at next boot BluetoothLE = 37, // Toggle BLE if present - PDVpdo = 38, // Toggle PPS & EPR + USBPDMode = 38, // Toggle PPS & EPR ProfilePhases = 39, // Number of profile mode phases ProfilePreheatTemp = 40, // Temperature to preheat to before the first phase ProfilePreheatSpeed = 41, // Maximum allowed preheat speed in degrees per second diff --git a/source/Core/Inc/Translation.h b/source/Core/Inc/Translation.h index 82c4fbff..1e48b129 100644 --- a/source/Core/Inc/Translation.h +++ b/source/Core/Inc/Translation.h @@ -59,7 +59,7 @@ enum class SettingsItemIndex : uint8_t { MinVolCell,
QCMaxVoltage,
PDNegTimeout,
- PDVpdo,
+ USBPDMode,
BoostTemperature,
AutoStart,
TempChangeShortStep,
@@ -145,6 +145,9 @@ struct TranslationIndexTable { uint16_t SettingStartSleepOffChar;
uint16_t SettingLockBoostChar;
uint16_t SettingLockFullChar;
+ uint16_t USBPDModeDefault;
+ uint16_t USBPDModeNoDynamic;
+ uint16_t USBPDModeSafe;
uint16_t SettingsDescriptions[static_cast<uint32_t>(SettingsItemIndex::NUM_ITEMS)];
uint16_t SettingsShortNames[static_cast<uint32_t>(SettingsItemIndex::NUM_ITEMS)];
diff --git a/source/Core/Src/Settings.cpp b/source/Core/Src/Settings.cpp index 540c6154..77512b9d 100644 --- a/source/Core/Src/Settings.cpp +++ b/source/Core/Src/Settings.cpp @@ -89,7 +89,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp { 0, 6, 1, 1}, // LOGOTime { 0, 1, 1, 0}, // CalibrateCJC { 0, 1, 1, 0}, // BluetoothLE - { 0, 1, 1, 1}, // PDVpdo + { 0, 2, 1, 1}, // USBPDMode { 1, 5, 1, 4}, // ProfilePhases { MIN_TEMP_C, MAX_TEMP_F, 5, 90}, // ProfilePreheatTemp { 1, 10, 1, 1}, // ProfilePreheatSpeed diff --git a/source/Core/Src/settingsGUI.cpp b/source/Core/Src/settingsGUI.cpp index 05fc6c63..b9ded285 100644 --- a/source/Core/Src/settingsGUI.cpp +++ b/source/Core/Src/settingsGUI.cpp @@ -26,7 +26,7 @@ static void displayQCInputV(void); #ifdef POW_PD static void displayPDNegTimeout(void); -static void displayPDVpdo(void); +static void displayUSBPDMode(void); #endif /* POW_PD */ static void displaySensitivity(void); @@ -131,7 +131,7 @@ static void displayAdvancedMenu(void); * -Minimum Voltage * QC Voltage * PD Timeout - * PDVpdo + * USBPDMode * * Soldering * Boost Mode Temp @@ -232,7 +232,7 @@ const menuitem powerMenu[] = { * -Minimum Voltage * QC Voltage * PD Timeout - * PDVpdo + * USBPDMode */ #ifdef POW_DC /* Voltage input */ @@ -248,7 +248,7 @@ const menuitem powerMenu[] = { /* PD timeout setup */ {SETTINGS_DESC(SettingsItemIndex::PDNegTimeout), nullptr, displayPDNegTimeout, nullptr, SettingsOptions::PDNegTimeout, SettingsItemIndex::PDNegTimeout, 6}, /* Toggle PPS & EPR */ - {SETTINGS_DESC(SettingsItemIndex::PDVpdo), nullptr, displayPDVpdo, nullptr, SettingsOptions::PDVpdo, SettingsItemIndex::PDVpdo, 7}, + {SETTINGS_DESC(SettingsItemIndex::USBPDMode), nullptr, displayUSBPDMode, nullptr, SettingsOptions::USBPDMode, SettingsItemIndex::USBPDMode, 4}, #endif /* vvvv end of menu marker. DO NOT REMOVE vvvv */ {0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0} @@ -529,7 +529,26 @@ static void displayPDNegTimeout(void) { } } -static void displayPDVpdo(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::PDVpdo)); } +static void displayUSBPDMode(void) { + /* + * PD Mode + * 0 = Safe mode, no PPS, no EPR + * 1 = Default mode, tolerant + PPS + EPR + * 2 = Strict mode + PPS + EPR + */ + + switch (getSettingValue(SettingsOptions::USBPDMode)) { + case 1: + OLED::print(translatedString(Tr->USBPDModeDefault), FontStyle::SMALL, 255, OLED::getCursorX()); + break; + case 2: + OLED::print(translatedString(Tr->USBPDModeSafe), FontStyle::SMALL, 255, OLED::getCursorX()); + break; + default: + OLED::print(translatedString(Tr->USBPDModeNoDynamic), FontStyle::SMALL, 255, OLED::getCursorX()); + break; + } +} #endif /* POW_PD */ |