Merge branch 'Ralim:dev' into dev

This commit is contained in:
jonasius
2024-06-01 14:03:50 +02:00
committed by GitHub
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

View File

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

View File

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

View File

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

View File

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

View File

@@ -256,7 +256,7 @@ if __name__ == "__main__":
sys.exit(1)
for hexf in options.hexfiles:
ih = IntelHex(hexf)
for (address, end) in ih.segments():
for address, end in ih.segments():
try:
address = address & 0xFFFFFFFF
except ValueError:

View File

@@ -12,8 +12,12 @@ import sys
if len(sys.argv) < 2 or len(sys.argv) > 3:
print("Usage: metadata.py OUTPUT_FILE [model]")
print(" OUTPUT_FILE - the name of output file in json format with meta info about binary files")
print(" model [optional] - name of the model (as for `make model=NAME`) to scan files for explicitly (all files in source/Hexfile by default otherwise)")
print(
" OUTPUT_FILE - the name of output file in json format with meta info about binary files"
)
print(
" model [optional] - name of the model (as for `make model=NAME`) to scan files for explicitly (all files in source/Hexfile by default otherwise)"
)
exit(1)
# If model is provided explicitly to scan related files only for json output, then process the argument
@@ -30,16 +34,19 @@ HexFileFolder = os.path.join(HERE, "Hexfile")
OutputJSONPath = os.path.join(HexFileFolder, sys.argv[1])
TranslationsFilesPath = os.path.join(HERE.parent, "Translations")
def load_json(filename: str):
with open(filename) as f:
return json.loads(f.read())
def read_git_tag():
if os.environ.get("GITHUB_CI_PR_SHA", "") != "":
return os.environ["GITHUB_CI_PR_SHA"][:7].upper()
else:
return f"{subprocess.check_output(['git', 'rev-parse', '--short=7', 'HEAD']).strip().decode('ascii').upper()}"
def read_version():
with open(HERE / "version.h") as version_file:
for line in version_file:
@@ -49,9 +56,18 @@ def read_version():
return matches[0]
raise Exception("Could not parse version")
# Fetch our file listings
translation_files = [os.path.join(TranslationsFilesPath, f) for f in os.listdir(TranslationsFilesPath) if os.path.isfile(os.path.join(TranslationsFilesPath, f)) and f.endswith(".json")]
output_files = [os.path.join(HexFileFolder, f) for f in sorted(os.listdir(HexFileFolder)) if os.path.isfile(os.path.join(HexFileFolder, f))]
translation_files = [
os.path.join(TranslationsFilesPath, f)
for f in os.listdir(TranslationsFilesPath)
if os.path.isfile(os.path.join(TranslationsFilesPath, f)) and f.endswith(".json")
]
output_files = [
os.path.join(HexFileFolder, f)
for f in sorted(os.listdir(HexFileFolder))
if os.path.isfile(os.path.join(HexFileFolder, f))
]
parsed_languages = {}
for path in translation_files:
@@ -74,7 +90,9 @@ for file_path in output_files:
if not name.startswith(ModelName + "_"):
continue
# If build of interest is not multi-lang one but scanning one is not MODEL_LANG-ID here, then skip it to avoid mess in json between MODEL_LANG-ID & MODEL_multi'
if not ModelName.endswith("_multi") and not re.match(r"^" + ModelName + "_" + "([A-Z]+).*$", name):
if not ModelName.endswith("_multi") and not re.match(
r"^" + ModelName + "_" + "([A-Z]+).*$", name
):
continue
matches = re.findall(r"^([a-zA-Z0-9]+)_(.+)\.(.+)$", name)
if matches:
@@ -86,10 +104,17 @@ for file_path in output_files:
lang_file = parsed_languages.get(lang_code, None)
if lang_file is None and lang_code.startswith("multi_"):
# Multi files wont match, but we fake this by just taking the filename to it
lang_file = {"languageLocalName": lang_code.replace("multi_", "").replace("compressed_", "")}
lang_file = {
"languageLocalName": lang_code.replace("multi_", "").replace(
"compressed_", ""
)
}
if lang_file is None:
raise Exception(f"Could not match language code {lang_code}")
file_record = {"language_code": lang_code, "language_name": lang_file.get("languageLocalName", None)}
file_record = {
"language_code": lang_code,
"language_name": lang_file.get("languageLocalName", None),
}
output_json["contents"][name] = file_record
else:
print(f"failed to parse {matches}")