Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/Core/Drivers/HUB238.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
70 changes: 42 additions & 28 deletions source/Core/Drivers/OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 5 additions & 3 deletions source/Core/Drivers/TipThermoModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
17 changes: 10 additions & 7 deletions source/Core/Drivers/USBPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand All @@ -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) \
Expand Down