Add Core/Drivers to the scope of style check by clang-format (#1754)

* clang-format: add ./Core/Drivers (except usb-pd) to the scope of style check

* Fix missed suggestion

---------

Co-authored-by: discip <53649486+discip@users.noreply.github.com>
Co-authored-by: Ben V. Brown <5425387+Ralim@users.noreply.github.com>
This commit is contained in:
Ivan Zorin
2023-07-28 12:39:01 +03:00
committed by GitHub
parent ea1906e499
commit 65ac2e25a6
5 changed files with 58 additions and 41 deletions

View File

@@ -547,8 +547,9 @@ void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, boo
} }
buffer[0] = 2 + number % 10; buffer[0] = 2 + number % 10;
if (noLeaderZeros) if (noLeaderZeros) {
stripLeaderZeros(buffer, places); stripLeaderZeros(buffer, places);
}
print(buffer, fontStyle); 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 // 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) { 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 // Splat this from x->x+wide in two strides
if (x <= -wide) if (x <= -wide) {
return; // cutoffleft return; // cutoffleft
if (x > 96) }
if (x > 96) {
return; // cutoff right return; // cutoff right
}
uint8_t visibleStart = 0; uint8_t visibleStart = 0;
uint8_t visibleEnd = wide; 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. // 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) { 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 // Splat this from x->x+wide in two strides
if (x <= -wide) if (x <= -wide) {
return; // cutoffleft return; // cutoffleft
if (x > 96) }
if (x > 96) {
return; // cutoff right return; // cutoff right
}
uint8_t visibleStart = 0; uint8_t visibleStart = 0;
uint8_t visibleEnd = wide; 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) { 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 // Splat this from x->x+wide in two strides
if (x <= -wide) if (x <= -wide) {
return; // cutoffleft return; // cutoffleft
if (x > 96) }
if (x > 96) {
return; // cutoff right return; // cutoff right
}
uint8_t visibleStart = 0; uint8_t visibleStart = 0;
uint8_t visibleEnd = wide; uint8_t visibleEnd = wide;
@@ -682,31 +689,38 @@ void OLED::drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, bool c
uint8_t mask = 0xFF; uint8_t mask = 0xFF;
if (y0) { if (y0) {
mask = mask << (y0 % 8); mask = mask << (y0 % 8);
for (uint8_t col = x0; col < x1; col++) for (uint8_t col = x0; col < x1; col++) {
if (clear) if (clear) {
stripPointers[0][(y0 / 8) * 96 + col] &= ~mask; stripPointers[0][(y0 / 8) * 96 + col] &= ~mask;
else } else {
stripPointers[0][(y0 / 8) * 96 + col] |= mask; stripPointers[0][(y0 / 8) * 96 + col] |= mask;
} }
}
}
// Next loop down the line the total number of solids // Next loop down the line the total number of solids
if (y0 / 8 != y1 / 8) if (y0 / 8 != y1 / 8) {
for (uint8_t col = x0; col < x1; col++) for (uint8_t col = x0; col < x1; col++) {
for (uint8_t r = (y0 / 8); r < (y1 / 8); r++) { for (uint8_t r = (y0 / 8); r < (y1 / 8); r++) {
// This gives us the row index r // This gives us the row index r
if (clear) if (clear) {
stripPointers[0][(r * 96) + col] = 0; stripPointers[0][(r * 96) + col] = 0;
else } else {
stripPointers[0][(r * 96) + col] = 0xFF; stripPointers[0][(r * 96) + col] = 0xFF;
} }
}
}
}
// Finally draw the tail // Finally draw the tail
mask = ~(mask << (y1 % 8)); mask = ~(mask << (y1 % 8));
for (uint8_t col = x0; col < x1; col++) for (uint8_t col = x0; col < x1; col++) {
if (clear) if (clear) {
stripPointers[0][(y1 / 8) * 96 + col] &= ~mask; stripPointers[0][(y1 / 8) * 96 + col] &= ~mask;
else } else {
stripPointers[0][(y1 / 8) * 96 + col] |= mask; stripPointers[0][(y1 / 8) * 96 + col] |= mask;
} }
}
}
void OLED::drawHeatSymbol(uint8_t state) { void OLED::drawHeatSymbol(uint8_t state) {
// Draw symbol 14 // Draw symbol 14

View File

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

View File

@@ -93,19 +93,23 @@ uint32_t *USBPowerDelivery::getLastSeenCapabilities() { return lastCapabilities;
static unsigned int sqrtI(unsigned long sqrtArg) { static unsigned int sqrtI(unsigned long sqrtArg) {
unsigned int answer, x; unsigned int answer, x;
unsigned long temp; unsigned long temp;
if (sqrtArg == 0) if (sqrtArg == 0) {
return 0; // undefined result return 0; // undefined result
if (sqrtArg == 1) }
if (sqrtArg == 1) {
return 1; // identity return 1; // identity
}
answer = 0; // integer square root answer = 0; // integer square root
for (x = 0x8000; x > 0; x = x >> 1) { // 16 bit shift for (x = 0x8000; x > 0; x = x >> 1) { // 16 bit shift
answer |= x; // possible bit in root answer |= x; // possible bit in root
temp = answer * answer; // temp = answer * answer; //
if (temp == sqrtArg) if (temp == sqrtArg) {
break; // exact, found it break; // exact, found it
if (temp > sqrtArg) }
if (temp > sqrtArg) {
answer ^= x; // too large, reverse bit answer ^= x; // too large, reverse bit
} }
}
return answer; // approximate root return answer; // approximate root
} }
#endif #endif
@@ -225,7 +229,6 @@ bool EPREvaluateCapabilityFunc(const epr_pd_msg *capabilities, pd_msg *request)
request->hdr = PD_MSGTYPE_EPR_REQUEST | PD_NUMOBJ(2); request->hdr = PD_MSGTYPE_EPR_REQUEST | PD_NUMOBJ(2);
request->obj[1] = lastCapabilities[bestIndex]; // Copy PDO into slot 2 request->obj[1] = lastCapabilities[bestIndex]; // Copy PDO into slot 2
if (bestIsAVS) { if (bestIsAVS) {
request->obj[0] = PD_RDO_PROG_CURRENT_SET(PD_CA2PAI(bestIndexCurrent)) | PD_RDO_PROG_VOLTAGE_SET(PD_MV2APS(bestIndexVoltage)); request->obj[0] = PD_RDO_PROG_CURRENT_SET(PD_CA2PAI(bestIndexCurrent)) | PD_RDO_PROG_VOLTAGE_SET(PD_MV2APS(bestIndexVoltage));
} else if (bestIsPPS) { } else if (bestIsPPS) {

View File

@@ -178,7 +178,6 @@ PD_DRIVER_DIR=./Core/Drivers/usb-pd
ALL_INCLUDES_EXCEPT:=-path $(BRIEFLZ_INC_DIR) \ ALL_INCLUDES_EXCEPT:=-path $(BRIEFLZ_INC_DIR) \
-o -path $(PD_DRIVER_DIR) \ -o -path $(PD_DRIVER_DIR) \
-o -path $(PINECILV2_SDK_DIR) \ -o -path $(PINECILV2_SDK_DIR) \
-o -path $(DRIVER_INC_DIR) \
-o -path $(MINIWARE_HAL_INC_DIR) \ -o -path $(MINIWARE_HAL_INC_DIR) \
-o -path $(S60_HAL_INC_DIR) \ -o -path $(S60_HAL_INC_DIR) \
-o -path $(MHP30_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) \ ALL_SOURCE_EXCEPT:=-path $(SOURCE_BRIEFLZ_DIR) \
-o -path $(PD_DRIVER_DIR) \ -o -path $(PD_DRIVER_DIR) \
-o -path $(PINECILV2_SDK_DIR) \ -o -path $(PINECILV2_SDK_DIR) \
-o -path $(SOURCE_DRIVERS_DIR) \
-o -path $(MINIWARE_HAL_SRC_DIR) \ -o -path $(MINIWARE_HAL_SRC_DIR) \
-o -path $(S60_HAL_SRC_DIR) \ -o -path $(S60_HAL_SRC_DIR) \
-o -path $(MHP30_HAL_SRC_DIR) \ -o -path $(MHP30_HAL_SRC_DIR) \