Expand USB-PD mode option (#1917)
Some checks failed
Docs / deploy-docs (push) Has been cancelled
CI / build (MHP30) (push) Has been cancelled
CI / build (Pinecil) (push) Has been cancelled
CI / build (Pinecilv2) (push) Has been cancelled
CI / build (S60) (push) Has been cancelled
CI / build (S60P) (push) Has been cancelled
CI / build (TS100) (push) Has been cancelled
CI / build (TS101) (push) Has been cancelled
CI / build (TS80) (push) Has been cancelled
CI / build (TS80P) (push) Has been cancelled
CI / build_multi-lang (Pinecil) (push) Has been cancelled
CI / build_multi-lang (Pinecilv2) (push) Has been cancelled
CI / upload_metadata (push) Has been cancelled
CI / tests (push) Has been cancelled
CI / check_c-cpp (push) Has been cancelled
CI / check_python (push) Has been cancelled
CI / check_shell (push) Has been cancelled
CI / check_readme (push) Has been cancelled

* Use PDMode to decide if we do resistance pad

* Rename PDVpdo to USBPDMode

* Add options for PD Mode

* OLED: Allow soft line-wrap x position

* Add new translation option for menu settings values

* Use new setting value for PD Mode

* Update translations for new menu setting

* Fixup! S60

* black python
This commit is contained in:
Ben V. Brown
2024-06-01 16:36:34 +10:00
committed by GitHub
parent c135732ebb
commit 442dbd982e
47 changed files with 11370 additions and 10967 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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)

View File

@@ -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;

View File

@@ -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