1
0
forked from me/IronOS

Merge branch 'dev' into Short-Detection

This commit is contained in:
Ben V. Brown
2023-07-28 20:04:16 +10:00
committed by GitHub
46 changed files with 131 additions and 119 deletions

View File

@@ -208,7 +208,7 @@ bool isTipDisconnected() {
void setStatusLED(const enum StatusLED state) {}
uint8_t preStartChecks() {
if (!hub238_has_run_selection()) {
if (!hub238_has_run_selection() && (xTaskGetTickCount() < TICKS_SECOND * 5)) {
return 0;
}
// We check if we are in a "Limited" mode; where we have to run the PWM really fast

View File

@@ -215,6 +215,6 @@ uint8_t hub238_source_currentX100() {
temp &= 0b1111;
return pdo_slot_to_currentx100(temp);
}
return 10;//Failsafe to 0.1 amp
return 10; // Failsafe to 0.1 amp
}
#endif

View File

@@ -33,19 +33,19 @@ uint32_t OLED::displayChecksum;
*/
I2C_CLASS::I2C_REG OLED_Setup_Array[] = {
/**/
{0x80, OLED_OFF, 0}, /* Display off */
{0x80, OLED_DIVIDER, 0}, /* Set display clock divide ratio / osc freq */
{0x80, 0x52, 0}, /* Divide ratios */
{0x80, 0xA8, 0}, /* Set Multiplex Ratio */
{0x80, OLED_HEIGHT - 1, 0}, /* Multiplex ratio adjusts how far down the matrix it scans */
{0x80, 0xC0, 0}, /* Set COM Scan direction */
{0x80, 0xD3, 0}, /* Set vertical Display offset */
{0x80, 0x00, 0}, /* 0 Offset */
{0x80, 0x40, 0}, /* Set Display start line to 0 */
{0x80, OLED_OFF, 0}, /* Display off */
{0x80, OLED_DIVIDER, 0}, /* Set display clock divide ratio / osc freq */
{0x80, 0x52, 0}, /* Divide ratios */
{0x80, 0xA8, 0}, /* Set Multiplex Ratio */
{0x80, OLED_HEIGHT - 1, 0}, /* Multiplex ratio adjusts how far down the matrix it scans */
{0x80, 0xC0, 0}, /* Set COM Scan direction */
{0x80, 0xD3, 0}, /* Set vertical Display offset */
{0x80, 0x00, 0}, /* 0 Offset */
{0x80, 0x40, 0}, /* Set Display start line to 0 */
#ifdef OLED_SEGMENT_MAP_REVERSED
{0x80, 0xA1, 0}, /* Set Segment remap to normal */
{0x80, 0xA1, 0}, /* Set Segment remap to normal */
#else
{0x80, 0xA0, 0}, /* Set Segment remap to normal */
{0x80, 0xA0, 0}, /* Set Segment remap to normal */
#endif
{0x80, 0x8D, 0}, /* Charge Pump */
{0x80, 0x14, 0}, /* Charge Pump settings */
@@ -547,8 +547,9 @@ void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, boo
}
buffer[0] = 2 + number % 10;
if (noLeaderZeros)
if (noLeaderZeros) {
stripLeaderZeros(buffer, places);
}
print(buffer, fontStyle);
}
@@ -574,10 +575,12 @@ void OLED::drawSymbol(uint8_t symbolID) {
// Draw an area, but y must be aligned on 0/8 offset
void OLED::drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr) {
// Splat this from x->x+wide in two strides
if (x <= -wide)
if (x <= -wide) {
return; // cutoffleft
if (x > 96)
}
if (x > 96) {
return; // cutoff right
}
uint8_t visibleStart = 0;
uint8_t visibleEnd = wide;
@@ -609,10 +612,12 @@ void OLED::drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uin
// For data which has octets swapped in a 16-bit word.
void OLED::drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr) {
// Splat this from x->x+wide in two strides
if (x <= -wide)
if (x <= -wide) {
return; // cutoffleft
if (x > 96)
}
if (x > 96) {
return; // cutoff right
}
uint8_t visibleStart = 0;
uint8_t visibleEnd = wide;
@@ -643,10 +648,12 @@ void OLED::drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, co
void OLED::fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t value) {
// Splat this from x->x+wide in two strides
if (x <= -wide)
if (x <= -wide) {
return; // cutoffleft
if (x > 96)
}
if (x > 96) {
return; // cutoff right
}
uint8_t visibleStart = 0;
uint8_t visibleEnd = wide;
@@ -682,30 +689,37 @@ void OLED::drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, bool c
uint8_t mask = 0xFF;
if (y0) {
mask = mask << (y0 % 8);
for (uint8_t col = x0; col < x1; col++)
if (clear)
for (uint8_t col = x0; col < x1; col++) {
if (clear) {
stripPointers[0][(y0 / 8) * 96 + col] &= ~mask;
else
} else {
stripPointers[0][(y0 / 8) * 96 + col] |= mask;
}
}
}
// Next loop down the line the total number of solids
if (y0 / 8 != y1 / 8)
for (uint8_t col = x0; col < x1; col++)
if (y0 / 8 != y1 / 8) {
for (uint8_t col = x0; col < x1; col++) {
for (uint8_t r = (y0 / 8); r < (y1 / 8); r++) {
// This gives us the row index r
if (clear)
if (clear) {
stripPointers[0][(r * 96) + col] = 0;
else
} else {
stripPointers[0][(r * 96) + col] = 0xFF;
}
}
}
}
// Finally draw the tail
mask = ~(mask << (y1 % 8));
for (uint8_t col = x0; col < x1; col++)
if (clear)
for (uint8_t col = x0; col < x1; col++) {
if (clear) {
stripPointers[0][(y1 / 8) * 96 + col] &= ~mask;
else
} else {
stripPointers[0][(y1 / 8) * 96 + col] |= mask;
}
}
}
void OLED::drawHeatSymbol(uint8_t state) {

View File

@@ -44,10 +44,11 @@ uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC, bool ski
if (getSettingValue(SettingsOptions::CalibrationOffset) && skipCalOffset == false) {
// Remove uV tipOffset
if (valueuV > getSettingValue(SettingsOptions::CalibrationOffset))
if (valueuV > getSettingValue(SettingsOptions::CalibrationOffset)) {
valueuV -= getSettingValue(SettingsOptions::CalibrationOffset);
else
} else {
valueuV = 0;
}
}
lastuv = valueuV;
return valueuV;
@@ -78,8 +79,9 @@ uint32_t TipThermoModel::getTipInC(bool sampleNow) {
// I found a number that doesn't unbalance the existing PID, causing overshoot.
// This could be tuned in concert with PID parameters...
if (currentTipTempInC < 0)
if (currentTipTempInC < 0) {
return 0;
}
return currentTipTempInC;
}

View File

@@ -46,7 +46,7 @@ void USBPowerDelivery::IRQOccured() { pe.IRQOccured(); }
bool USBPowerDelivery::negotiationHasWorked() { return pe.pdHasNegotiated(); }
uint8_t USBPowerDelivery::getStateNumber() { return pe.currentStateCode(true); }
void USBPowerDelivery::step() {
while (pe.thread()) {}
while (pe.thread()) {}
}
void USBPowerDelivery::PPSTimerCallback() { pe.TimersCallback(); }
@@ -93,18 +93,22 @@ uint32_t *USBPowerDelivery::getLastSeenCapabilities() { return lastCapabilities;
static unsigned int sqrtI(unsigned long sqrtArg) {
unsigned int answer, x;
unsigned long temp;
if (sqrtArg == 0)
if (sqrtArg == 0) {
return 0; // undefined result
if (sqrtArg == 1)
return 1; // identity
}
if (sqrtArg == 1) {
return 1; // identity
}
answer = 0; // integer square root
for (x = 0x8000; x > 0; x = x >> 1) { // 16 bit shift
answer |= x; // possible bit in root
temp = answer * answer; //
if (temp == sqrtArg)
if (temp == sqrtArg) {
break; // exact, found it
if (temp > sqrtArg)
}
if (temp > sqrtArg) {
answer ^= x; // too large, reverse bit
}
}
return answer; // approximate root
}
@@ -225,7 +229,6 @@ bool EPREvaluateCapabilityFunc(const epr_pd_msg *capabilities, pd_msg *request)
request->hdr = PD_MSGTYPE_EPR_REQUEST | PD_NUMOBJ(2);
request->obj[1] = lastCapabilities[bestIndex]; // Copy PDO into slot 2
if (bestIsAVS) {
request->obj[0] = PD_RDO_PROG_CURRENT_SET(PD_CA2PAI(bestIndexCurrent)) | PD_RDO_PROG_VOLTAGE_SET(PD_MV2APS(bestIndexVoltage));
} else if (bestIsPPS) {

View File

@@ -107,7 +107,7 @@ enum class SettingsItemIndex : uint8_t {
};
struct TranslationIndexTable {
uint16_t CJCCalibrationDone;
uint16_t CalibrationDone;
uint16_t ResetOKMessage;
uint16_t SettingsResetMessage;
uint16_t NoAccelerometerMessage;

View File

@@ -11,6 +11,7 @@
#include "Settings.h"
#include "BSP.h"
#include "Setup.h"
#include "Translation.h"
#include "configuration.h"
#include <string.h> // for memset
bool sanitiseSettings();
@@ -65,7 +66,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
{0, 1, 1, COOLING_TEMP_BLINK}, // CoolingTempBlink
{0, 1, 1, DETAILED_IDLE}, // DetailedIDLE
{0, 1, 1, DETAILED_SOLDERING}, // DetailedSoldering
{0, 1, 1, TEMPERATURE_INF}, // TemperatureInF
{0, (uint16_t)(HasFahrenheit ? 1 : 0), 1, TEMPERATURE_INF}, // TemperatureInF
{0, 1, 1, DESCRIPTION_SCROLL_SPEED}, // DescriptionScrollSpeed
{0, 2, 1, LOCKING_MODE}, // LockingMode
{0, 99, 1, POWER_PULSE_DEFAULT}, // KeepAwakePulse

View File

@@ -884,19 +884,21 @@ static bool setCalibrateVIN(void) {
OLED::clearScreen();
for (;;) {
OLED::setCursor(0, 0);
OLED::setCursor(25, 0);
uint16_t voltage = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
OLED::printNumber(voltage / 10, 2, FontStyle::LARGE);
OLED::print(LargeSymbolDot, FontStyle::LARGE);
OLED::printNumber(voltage % 10, 1, FontStyle::LARGE, false);
OLED::print(LargeSymbolVolts, FontStyle::LARGE);
OLED::setCursor(0, 8);
OLED::printNumber(getSettingValue(SettingsOptions::VoltageDiv), 3, FontStyle::SMALL);
switch (getButtonState()) {
case BUTTON_F_SHORT:
nextSettingValue(SettingsOptions::VoltageDiv);
prevSettingValue(SettingsOptions::VoltageDiv);
break;
case BUTTON_B_SHORT:
prevSettingValue(SettingsOptions::VoltageDiv);
nextSettingValue(SettingsOptions::VoltageDiv);
break;
case BUTTON_BOTH:
case BUTTON_F_LONG:
@@ -904,9 +906,9 @@ static bool setCalibrateVIN(void) {
saveSettings();
OLED::clearScreen();
OLED::setCursor(0, 0);
OLED::printNumber(getSettingValue(SettingsOptions::VoltageDiv), 3, FontStyle::LARGE);
warnUser(translatedString(Tr->CalibrationDone), 3 * TICKS_SECOND);
OLED::refresh();
waitForButtonPressOrTimeout(1 * TICKS_SECOND);
waitForButtonPressOrTimeout(0.5 * TICKS_SECOND);
return false;
case BUTTON_NONE:
default:

View File

@@ -30,7 +30,7 @@ void performCJCC(void) {
}
setSettingValue(SettingsOptions::CalibrationOffset, setoffset);
OLED::clearScreen();
warnUser(translatedString(Tr->CJCCalibrationDone), 3 * TICKS_SECOND);
warnUser(translatedString(Tr->CalibrationDone), 3 * TICKS_SECOND);
OLED::refresh();
// Preventing to repeat calibration at boot automatically (only one shot).
setSettingValue(SettingsOptions::CalibrateCJC, 0);

View File

@@ -178,7 +178,6 @@ PD_DRIVER_DIR=./Core/Drivers/usb-pd
ALL_INCLUDES_EXCEPT:=-path $(BRIEFLZ_INC_DIR) \
-o -path $(PD_DRIVER_DIR) \
-o -path $(PINECILV2_SDK_DIR) \
-o -path $(DRIVER_INC_DIR) \
-o -path $(MINIWARE_HAL_INC_DIR) \
-o -path $(S60_HAL_INC_DIR) \
-o -path $(MHP30_HAL_INC_DIR) \
@@ -193,7 +192,6 @@ ALL_INCLUDES_EXCEPT:=-path $(BRIEFLZ_INC_DIR) \
ALL_SOURCE_EXCEPT:=-path $(SOURCE_BRIEFLZ_DIR) \
-o -path $(PD_DRIVER_DIR) \
-o -path $(PINECILV2_SDK_DIR) \
-o -path $(SOURCE_DRIVERS_DIR) \
-o -path $(MINIWARE_HAL_SRC_DIR) \
-o -path $(S60_HAL_SRC_DIR) \
-o -path $(MHP30_HAL_SRC_DIR) \
@@ -427,7 +425,9 @@ DEV_LDFLAGS=-nostartfiles \
-L $(PINECILV2_BLE_CRAPWARE_BLOB_DIR) \
-L $(PINECILV2_RF_CRAPWARE_BLOB_DIR) \
-l blecontroller_702_m0s1s \
-l bl702_rf
-l bl702_rf \
-Wl,--wrap=printf \
-Wl,--defsym=__wrap_printf=bflb_platform_printf
DEV_AFLAGS=
DEV_GLOBAL_DEFS=-DCFG_FREERTOS \
@@ -763,15 +763,15 @@ Core/Gen/Translation_brieflz.%.cpp: $(OUTPUT_DIR)/Core/Gen/translation.files/%.o
@test -d $(@D) || mkdir -p $(@D)
@echo Generating BriefLZ compressed translation for $*
@OBJCOPY=$(OBJCOPY) $(HOST_PYTHON) ../Translations/make_translation.py \
--macros $(PWD)/Core/Gen/macros.txt \
-o $(PWD)/Core/Gen/Translation_brieflz.$*.cpp \
--macros $(CURDIR)/Core/Gen/macros.txt \
-o $(CURDIR)/Core/Gen/Translation_brieflz.$*.cpp \
--input-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/$*.pickle \
--strings-obj $(OUTPUT_DIR)/Core/Gen/translation.files/$*.o \
$*
Core/Gen/Translation_brieflz_font.%.cpp: $(OUTPUT_DIR)/Core/Gen/translation.files/%.pickle $(HOST_OUTPUT_DIR)/brieflz/libbrieflz.so Core/Gen/macros.txt
@test -d $(@D) || mkdir -p $(@D)
@echo Generating BriefLZ compressed translation for $*
@echo Generating BriefLZ compressed translation font for $*
@$(HOST_PYTHON) ../Translations/make_translation.py \
--macros $(PWD)/Core/Gen/macros.txt \
-o $(PWD)/Core/Gen/Translation_brieflz_font.$*.cpp \
@@ -818,8 +818,8 @@ Core/Gen/Translation_multi.$(1).cpp: $(patsubst %,../Translations/translation_%.
@test -d $(OUTPUT_DIR)/Core/Gen/translation.files || mkdir -p $(OUTPUT_DIR)/Core/Gen/translation.files
@echo 'Generating translations for multi-language $(2)'
@$(HOST_PYTHON) ../Translations/make_translation.py \
--macros $(PWD)/Core/Gen/macros.txt \
-o $(PWD)/Core/Gen/Translation_multi.$(1).cpp \
--macros $(CURDIR)/Core/Gen/macros.txt \
-o $(CURDIR)/Core/Gen/Translation_multi.$(1).cpp \
--output-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).pickle \
$(3)
@@ -829,8 +829,8 @@ Core/Gen/Translation_brieflz_multi.$(1).cpp: $(OUTPUT_DIR)/Core/Gen/translation.
@test -d $$(@D) || mkdir -p $$(@D)
@echo Generating BriefLZ compressed translation for multi-language $(2)
@OBJCOPY=$(OBJCOPY) $(HOST_PYTHON) ../Translations/make_translation.py \
--macros $(PWD)/Core/Gen/macros.txt \
-o $(PWD)/Core/Gen/Translation_brieflz_multi.$(1).cpp \
--macros $(CURDIR)/Core/Gen/macros.txt \
-o $(CURDIR)/Core/Gen/Translation_brieflz_multi.$(1).cpp \
--input-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).pickle \
--strings-obj $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).o \
--compress-font \
@@ -873,9 +873,9 @@ style:
# * process STOP env variable
check-style:
@error=0; export LIST=$$LIST; for src in $(ALL_SOURCE) $(ALL_INCLUDES) ; do \
../scripts/deploy.sh check_style_file "$$src" ; \
test "$${?}" -eq 1 && export error=1 ; \
test "$${error}" -eq 1 && test -n "$${STOP}" && break; \
../scripts/deploy.sh check_style_file "$$src" ; \
test "$${?}" -eq 1 && export error=1 ; \
test "$${error}" -eq 1 && test -n "$${STOP}" && break; \
done; \
if [ $$error -eq 0 ] ; then echo "" && echo "" && echo "Style check: PASS" && echo "" && echo "" && exit 0 ; \
else echo "" && echo "" && echo "Style check: FAIL! Please, check the log above for the details." && echo "If there is a false-negative trigger, please, report an issue attaching the log or link to the log!" && echo "" && echo "" && exit 1 ; \