1
0
forked from me/IronOS

clang-format implementation (#1740)

* Testing clang-format style check using github CI

* github/push: implement check-style for clang-format as a separate build step

* github/push: add missing packages for check-style/clang-format build step

* source/Makefile: check-style - reduce files of interest; update .clang-format to keep enums init

* source/Makefile: empty lines, spaces & tabs refactoring to unify style - part 1 out of N

* source/Makefile: fix formatting for multi-line variables

* source/Makefile: update formatting for multi-line variables

* source/Makefile: remove spaces on vars assignments to unify style

* source/Makefile: remove unused target style

* source/Makefile: implement exclude vars for clang-format related files

* source/Makefile: exclude configuration.h from clang-format check

* Dockerfile: add diffutils in a container to make check-style target using advanced version of diff to get more advanced output to parse & navigate log more easily

* source/Makefile: implement parser for clang-format inside check-style target to make output compatible with gcc-like error compilation format for compatibility with IDEs/editors for easy navigation over files to fix style errors

* source/Makefile: probably final touches on unifying style

* source/Makefile: implement check-style-list target to only list affected file names with wrong code style for debug purposes

* source/Makefile: fix missed spaces

* deploy.sh: add helper routine to deal with clang-format error output logging from makefile

* gitignore: add clang-format log explicitly

* Refactoring for clang-format compiance

* Dockerfile: add sed

* Dockerfile: false alarm - remove sed since busybox-sed seems fine

* source/Makefile: reduce calls of clang-format & make error log more clean, clear, and tidy

* deploy.sh:check_style() - add removal of DOS EOLs for generated log

* source/Makefile:check-style: add more empty lines between blocks with errors for readability when suggestion is too long & heavy

* source/Makefile: add STOP var to check-style for exit on first failed file

* source/Makefile: check-style: make log looks more like traditional diff/patch output

* source/Core/BSP/Pinecilv2/MemMang/heap_5.c: clang-format refactoring using reasonable advises ... and then disable it in Makefile from scanning by clang-format

* Return headers include order

* clang-format config: disable warnings about non-alphabetic include order

* clang-format refactoring

* clang-format refactoring, part 2

* clang-format refactoring, part 3

* settingsGUI.cpp: refactoring, part 1

* settingsGUI.cpp: refactoring, part 2

* settingsGUI.cpp: refactoring, part 3

* settingsGUI.cpp: refactoring, part 4

* clang-format should be happy now

* workflows/push: put readme check into separate build step & update style

* clang-format: giving SortIncludes option second chance by tweaking a couple of headers a bit

* source/Makefile: check-style: add homebrew parser to check for { } in conditional blocks

* homebrew-format: add { } for if/else, while, and for & unify some comments style; left two errors intentionally to debug & improve parser

* source/Makefile: homebrew-format: fix false negative trigger for multi-line condition in if-s

* Sleep.cpp: unify style & comments

* source/Makefile: remove unused debug target
This commit is contained in:
Ivan Zorin
2023-07-16 08:25:30 +03:00
committed by GitHub
parent ca79638a74
commit d95af7d1a0
43 changed files with 1542 additions and 1346 deletions

View File

@@ -20,8 +20,9 @@ void performCJCC(void) {
OLED::print(translatedString(Tr->CJCCalibrating), FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(SmallSymbolDot, FontStyle::SMALL);
for (uint8_t x = 0; x < (i / 4); x++)
for (uint8_t x = 0; x < (i / 4); x++) {
OLED::print(SmallSymbolDot, FontStyle::SMALL);
}
OLED::refresh();
osDelay(100);
}

View File

@@ -57,8 +57,8 @@ void showDebugMenu(void) {
case 9: // Movement Timestamp
OLED::printNumber(lastMovementTime / TICKS_100MS, 8, FontStyle::SMALL);
break;
case 10: // Tip Resistance in Ω
OLED::printNumber(getTipResistanceX10() / 10, 6, FontStyle::SMALL); // large to pad over so that we cover ID left overs
case 10: // Tip Resistance in Ω large to pad over so that we cover ID left overs
OLED::printNumber(getTipResistanceX10() / 10, 6, FontStyle::SMALL);
OLED::print(SmallSymbolDot, FontStyle::SMALL);
OLED::printNumber(getTipResistanceX10() % 10, 1, FontStyle::SMALL);
break;
@@ -82,8 +82,9 @@ void showDebugMenu(void) {
case 16: // Raw Hall Effect Value
{
int16_t hallEffectStrength = getRawHallEffect();
if (hallEffectStrength < 0)
if (hallEffectStrength < 0) {
hallEffectStrength = -hallEffectStrength;
}
OLED::printNumber(hallEffectStrength, 6, FontStyle::SMALL);
} break;
#endif
@@ -94,9 +95,9 @@ void showDebugMenu(void) {
OLED::refresh();
b = getButtonState();
if (b == BUTTON_B_SHORT)
if (b == BUTTON_B_SHORT) {
return;
else if (b == BUTTON_F_SHORT) {
} else if (b == BUTTON_F_SHORT) {
screen++;
#ifdef HALL_SENSOR
screen = screen % 17;
@@ -104,6 +105,7 @@ void showDebugMenu(void) {
screen = screen % 16;
#endif
}
GUIDelay();
}
}

View File

@@ -103,21 +103,24 @@ void drawDetailedHomeScreen(uint32_t tipTemp) {
}
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
} else {
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (tipTemp > 55) && (xTaskGetTickCount() % 1000 < 300)))
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (tipTemp > 55) && (xTaskGetTickCount() % 1000 < 300))) {
// Blink temp if setting enable and temp < 55°
// 1000 tick/sec
// OFF 300ms ON 700ms
gui_drawTipTemp(true, FontStyle::LARGE); // draw in the temp
}
if (OLED::getRotation()) {
OLED::setCursor(6, 0);
} else {
OLED::setCursor(73, 0); // top right
}
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL); // draw set temp
if (getSettingValue(SettingsOptions::TemperatureInF))
// draw set temp
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL);
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
else
} else {
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
}
if (OLED::getRotation()) {
OLED::setCursor(0, 8);
} else {
@@ -142,10 +145,11 @@ void drawSimplifiedHomeScreen(uint32_t tipTemp) {
gui_drawBatteryIcon();
}
tipDisconnectedDisplay = false;
if (tipTemp > 55)
if (tipTemp > 55) {
tempOnDisplay = true;
else if (tipTemp < 45)
} else if (tipTemp < 45) {
tempOnDisplay = false;
}
if (isTipDisconnected()) {
tempOnDisplay = false;
tipDisconnectedDisplay = true;
@@ -164,8 +168,9 @@ void drawSimplifiedHomeScreen(uint32_t tipTemp) {
// If we have a tip connected draw the temp, if not we leave it blank
if (!tipDisconnectedDisplay) {
// draw in the temp
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300)))
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300))) {
gui_drawTipTemp(false, FontStyle::LARGE); // draw in the temp
}
} else {
// Draw in missing tip symbol

View File

@@ -12,14 +12,18 @@ int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
// If in the first two seconds we disable this to let accelerometer warm up
#ifdef POW_DC
if (checkForUnderVoltage())
return 1; // return non-zero on error
if (checkForUnderVoltage()) {
// return non-zero on error
return 1;
}
#endif
if (getSettingValue(SettingsOptions::TemperatureInF)) {
currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC(min(getSettingValue(SettingsOptions::SleepTemp), getSettingValue(SettingsOptions::SolderingTemp)));
} else {
currentTempTargetDegC = stayOff ? 0 : min(getSettingValue(SettingsOptions::SleepTemp), getSettingValue(SettingsOptions::SolderingTemp));
}
// draw the lcd
uint16_t tipTemp = getSettingValue(SettingsOptions::TemperatureInF) ? TipThermoModel::getTipInF() : TipThermoModel::getTipInC();
@@ -30,9 +34,10 @@ int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
OLED::setCursor(0, 8);
OLED::print(translatedString(Tr->SleepingTipAdvancedString), FontStyle::SMALL);
OLED::printNumber(tipTemp, 3, FontStyle::SMALL);
if (getSettingValue(SettingsOptions::TemperatureInF))
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
else {
} else {
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
}
@@ -42,9 +47,10 @@ int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
} else {
OLED::print(translatedString(Tr->SleepingSimpleString), FontStyle::LARGE);
OLED::printNumber(tipTemp, 3, FontStyle::LARGE);
if (getSettingValue(SettingsOptions::TemperatureInF))
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::drawSymbol(0);
else {
} else {
OLED::drawSymbol(1);
}
}
@@ -59,9 +65,11 @@ int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
if (shouldShutdown()) {
// shutdown
currentTempTargetDegC = 0;
return 1; // we want to exit soldering mode
// we want to exit soldering mode
return 1;
}
}
#endif
return 0;
}

View File

@@ -147,15 +147,15 @@ void gui_solderingMode(uint8_t jumpToSleep) {
OLED::refresh();
// Update the setpoints for the temperature
if (boostModeOn) {
if (getSettingValue(SettingsOptions::TemperatureInF))
if (getSettingValue(SettingsOptions::TemperatureInF)) {
currentTempTargetDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::BoostTemp));
else {
} else {
currentTempTargetDegC = (getSettingValue(SettingsOptions::BoostTemp));
}
} else {
if (getSettingValue(SettingsOptions::TemperatureInF))
if (getSettingValue(SettingsOptions::TemperatureInF)) {
currentTempTargetDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::SolderingTemp));
else {
} else {
currentTempTargetDegC = (getSettingValue(SettingsOptions::SolderingTemp));
}
}
@@ -187,4 +187,3 @@ void gui_solderingMode(uint8_t jumpToSleep) {
GUIDelay();
}
}

View File

@@ -12,15 +12,15 @@ void gui_solderingProfileMode() {
* --> Long hold back button to exit
* --> Double button to exit
*/
currentMode = OperatingMode::soldering;
currentMode = OperatingMode::soldering;
TickType_t buzzerEnd = 0;
bool waitForRelease = true;
TickType_t phaseStartTime = xTaskGetTickCount();
bool waitForRelease = true;
TickType_t phaseStartTime = xTaskGetTickCount();
uint16_t tipTemp = 0;
uint8_t profilePhase = 0;
uint16_t tipTemp = 0;
uint8_t profilePhase = 0;
uint16_t phaseElapsedSeconds = 0;
uint16_t phaseTotalSeconds = 0;
@@ -32,24 +32,26 @@ void gui_solderingProfileMode() {
for (;;) {
ButtonState buttons = getButtonState();
if (buttons) {
if (waitForRelease) buttons = BUTTON_NONE;
if (waitForRelease) {
buttons = BUTTON_NONE;
}
} else {
waitForRelease = false;
}
switch (buttons) {
case BUTTON_NONE:
break;
case BUTTON_BOTH:
case BUTTON_B_LONG:
return; // exit on back long hold
case BUTTON_F_LONG:
case BUTTON_F_SHORT:
case BUTTON_B_SHORT:
// Not used yet
break;
default:
break;
case BUTTON_NONE:
break;
case BUTTON_BOTH:
case BUTTON_B_LONG:
return; // exit on back long hold
case BUTTON_F_LONG:
case BUTTON_F_SHORT:
case BUTTON_B_SHORT:
// Not used yet
break;
default:
break;
}
if (getSettingValue(SettingsOptions::TemperatureInF)) {
@@ -73,39 +75,41 @@ void gui_solderingProfileMode() {
// have we finished this phase?
if (phaseElapsedSeconds >= phaseTotalSeconds && tipTemp == phaseEndTemp) {
profilePhase++;
phaseStartTemp = phaseEndTemp;
phaseStartTime = xTaskGetTickCount();
phaseStartTemp = phaseEndTemp;
phaseStartTime = xTaskGetTickCount();
phaseElapsedSeconds = 0;
if (profilePhase > getSettingValue(SettingsOptions::ProfilePhases)) {
// done with all phases, lets go to cooldown
phaseTotalSeconds = 0;
phaseEndTemp = 0;
phaseTotalSeconds = 0;
phaseEndTemp = 0;
phaseTicksPerDegree = TICKS_SECOND / getSettingValue(SettingsOptions::ProfileCooldownSpeed);
} else {
// set up next phase
switch(profilePhase) {
case 1:
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase1Duration);
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase1Temp);
break;
case 2:
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase2Duration);
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase2Temp);
break;
case 3:
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase3Duration);
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase3Temp);
break;
case 4:
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase4Duration);
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase4Temp);
break;
case 5:
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase5Duration);
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase5Temp);
break;
default:
break;
switch (profilePhase) {
case 1:
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase1Duration);
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase1Temp);
break;
case 2:
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase2Duration);
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase2Temp);
break;
case 3:
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase3Duration);
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase3Temp);
break;
case 4:
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase4Duration);
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase4Temp);
break;
case 5:
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase5Duration);
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase5Temp);
break;
default:
break;
}
if (phaseStartTemp < phaseEndTemp) {
phaseTicksPerDegree = (phaseTotalSeconds * TICKS_SECOND) / (phaseEndTemp - phaseStartTemp);
@@ -152,10 +156,11 @@ void gui_solderingProfileMode() {
OLED::print(SmallSymbolSlash, FontStyle::SMALL);
OLED::printNumber(profileCurrentTargetTemp, 3, FontStyle::SMALL);
if (getSettingValue(SettingsOptions::TemperatureInF))
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
else
} else {
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
}
// print phase
if (profilePhase > 0 && profilePhase <= getSettingValue(SettingsOptions::ProfilePhases)) {
@@ -186,7 +191,7 @@ void gui_solderingProfileMode() {
OLED::print(SmallSymbolSlash, FontStyle::SMALL);
// blink if we can't keep up with the time goal
if (phaseElapsedSeconds < phaseTotalSeconds+2 || (xTaskGetTickCount() / TICKS_SECOND) % 2 == 0) {
if (phaseElapsedSeconds < phaseTotalSeconds + 2 || (xTaskGetTickCount() / TICKS_SECOND) % 2 == 0) {
OLED::printNumber(phaseTotalSeconds / 60, 1, FontStyle::SMALL);
OLED::print(SmallSymbolColon, FontStyle::SMALL);
OLED::printNumber(phaseTotalSeconds % 60, 2, FontStyle::SMALL, false);
@@ -225,4 +230,3 @@ void gui_solderingProfileMode() {
GUIDelay();
}
}

View File

@@ -1,12 +1,12 @@
#include "OperatingModes.h"
void gui_solderingTempAdjust(void) {
TickType_t lastChange = xTaskGetTickCount();
currentTempTargetDegC = 0; // Turn off heater while adjusting temp
TickType_t autoRepeatTimer = 0;
uint8_t autoRepeatAcceleration = 0;
TickType_t lastChange = xTaskGetTickCount();
currentTempTargetDegC = 0; // Turn off heater while adjusting temp
TickType_t autoRepeatTimer = 0;
uint8_t autoRepeatAcceleration = 0;
#ifndef PROFILE_SUPPORT
bool waitForRelease = false;
ButtonState buttons = getButtonState();
bool waitForRelease = false;
ButtonState buttons = getButtonState();
if (buttons != BUTTON_NONE) {
// Temp adjust entered by long-pressing F button.
@@ -79,20 +79,25 @@ void gui_solderingTempAdjust(void) {
newTemp = (newTemp / delta) * delta;
if (getSettingValue(SettingsOptions::TemperatureInF)) {
if (newTemp > MAX_TEMP_F)
if (newTemp > MAX_TEMP_F) {
newTemp = MAX_TEMP_F;
if (newTemp < MIN_TEMP_F)
}
if (newTemp < MIN_TEMP_F) {
newTemp = MIN_TEMP_F;
}
} else {
if (newTemp > MAX_TEMP_C)
if (newTemp > MAX_TEMP_C) {
newTemp = MAX_TEMP_C;
if (newTemp < MIN_TEMP_C)
}
if (newTemp < MIN_TEMP_C) {
newTemp = MIN_TEMP_C;
}
}
setSettingValue(SettingsOptions::SolderingTemp, (uint16_t)newTemp);
}
if (xTaskGetTickCount() - lastChange > (TICKS_SECOND * 2))
if (xTaskGetTickCount() - lastChange > (TICKS_SECOND * 2)) {
return; // exit if user just doesn't press anything for a bit
}
if (OLED::getRotation()) {
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolPlus : LargeSymbolMinus, FontStyle::LARGE);
@@ -102,9 +107,9 @@ void gui_solderingTempAdjust(void) {
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::LARGE);
if (getSettingValue(SettingsOptions::TemperatureInF))
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::drawSymbol(0);
else {
} else {
OLED::drawSymbol(1);
}
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
@@ -116,4 +121,4 @@ void gui_solderingTempAdjust(void) {
OLED::refresh();
GUIDelay();
}
}
}

View File

@@ -81,11 +81,12 @@ void showPDDebug(void) {
OLED::refresh();
b = getButtonState();
if (b == BUTTON_B_SHORT)
if (b == BUTTON_B_SHORT) {
return;
else if (b == BUTTON_F_SHORT) {
} else if (b == BUTTON_F_SHORT) {
screen++;
}
GUIDelay();
}
}

View File

@@ -43,11 +43,12 @@ void showPDDebug(void) {
OLED::refresh();
b = getButtonState();
if (b == BUTTON_B_SHORT)
if (b == BUTTON_B_SHORT) {
return;
else if (b == BUTTON_F_SHORT) {
} else if (b == BUTTON_F_SHORT) {
screen++;
}
GUIDelay();
}
}

View File

@@ -14,16 +14,18 @@ void gui_drawTipTemp(bool symbol, const FontStyle font) {
if (symbol) {
if (font == FontStyle::LARGE) {
// Big font, can draw nice symbols
if (getSettingValue(SettingsOptions::TemperatureInF))
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::drawSymbol(0);
else
} else {
OLED::drawSymbol(1);
}
} else {
// Otherwise fall back to chars
if (getSettingValue(SettingsOptions::TemperatureInF))
if (getSettingValue(SettingsOptions::TemperatureInF)) {
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
else
} else {
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
}
}
}
}
}

View File

@@ -2,8 +2,8 @@
// Created by laura on 24.04.23.
//
#include "OperatingModes.h"
#include "SolderingCommon.h"
#include "OperatingModes.h"
extern bool heaterThermalRunaway;
@@ -16,7 +16,8 @@ void detailedPowerStatus() {
// Print wattage
{
uint32_t x10Watt = x10WattHistory.average();
if (x10Watt > 999) { // If we exceed 99.9W we drop the decimal place to keep it all fitting
if (x10Watt > 999) {
// If we exceed 99.9W we drop the decimal place to keep it all fitting
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
OLED::printNumber(x10WattHistory.average() / 10, 3, FontStyle::SMALL);
} else {
@@ -42,30 +43,35 @@ void basicSolderingStatus(bool boostModeOn) {
if (OLED::getRotation()) {
// battery
gui_drawBatteryIcon();
OLED::print(LargeSymbolSpace, FontStyle::LARGE); // Space out gap between battery <-> temp
gui_drawTipTemp(true, FontStyle::LARGE); // Draw current tip temp
// Space out gap between battery <-> temp
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
// Draw current tip temp
gui_drawTipTemp(true, FontStyle::LARGE);
// We draw boost arrow if boosting, or else gap temp <-> heat
// indicator
if (boostModeOn)
// We draw boost arrow if boosting,
// or else gap temp <-> heat indicator
if (boostModeOn) {
OLED::drawSymbol(2);
else
} else {
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
}
// Draw heating/cooling symbols
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
} else {
// Draw heating/cooling symbols
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
// We draw boost arrow if boosting, or else gap temp <-> heat
// indicator
if (boostModeOn)
// We draw boost arrow if boosting,
// or else gap temp <-> heat indicator
if (boostModeOn) {
OLED::drawSymbol(2);
else
} else {
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
gui_drawTipTemp(true, FontStyle::LARGE); // Draw current tip temp
OLED::print(LargeSymbolSpace, FontStyle::LARGE); // Space out gap between battery <-> temp
}
// Draw current tip temp
gui_drawTipTemp(true, FontStyle::LARGE);
// Space out gap between battery <-> temp
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
gui_drawBatteryIcon();
}

View File

@@ -6,10 +6,11 @@ void gui_drawBatteryIcon(void) {
// On non-DC inputs we replace this symbol with the voltage we are operating on
// If <9V then show single digit, if not show dual small ones vertically stacked
uint16_t V = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
if (V % 10 >= 5)
if (V % 10 >= 5) {
V = (V / 10) + 1; // round up
else
} else {
V = V / 10;
}
if (V > 9) {
int16_t xPos = OLED::getCursorX();
OLED::printNumber(V / 10, 1, FontStyle::SMALL);
@@ -30,14 +31,16 @@ void gui_drawBatteryIcon(void) {
uint32_t cellV = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0) / cellCount;
// Should give us approx cell voltage X10
// Range is 42 -> Minimum voltage setting (systemSettings.minVoltageCells) = 9 steps therefore we will use battery 0-9
if (cellV < getSettingValue(SettingsOptions::MinVoltageCells))
if (cellV < getSettingValue(SettingsOptions::MinVoltageCells)) {
cellV = getSettingValue(SettingsOptions::MinVoltageCells);
}
cellV -= getSettingValue(SettingsOptions::MinVoltageCells); // Should leave us a number of 0-9
if (cellV > 9)
if (cellV > 9) {
cellV = 9;
}
OLED::drawBattery(cellV + 1);
} else {
OLED::drawSymbol(15); // Draw the DC Logo
}
#endif
}
}

View File

@@ -7,12 +7,13 @@ uint32_t getSleepTimeout(void) {
if (getSettingValue(SettingsOptions::Sensitivity) && getSettingValue(SettingsOptions::SleepTime)) {
uint32_t sleepThres = 0;
if (getSettingValue(SettingsOptions::SleepTime) < 6)
if (getSettingValue(SettingsOptions::SleepTime) < 6) {
sleepThres = getSettingValue(SettingsOptions::SleepTime) * 10 * 1000;
else
} else {
sleepThres = (getSettingValue(SettingsOptions::SleepTime) - 5) * 60 * 1000;
}
return sleepThres;
}
return 0;
}
#endif
#endif

View File

@@ -3,8 +3,9 @@
#include "OperatingModeUtilities.h"
#include <stdint.h>
uint16_t min(uint16_t a, uint16_t b) {
if (a > b)
if (a > b) {
return b;
else
} else {
return a;
}
}
}

View File

@@ -26,8 +26,9 @@ bool shouldBeSleeping(bool inAutoStart) {
// threshold, and if so then we force sleep
if (getHallSensorFitted() && lookupHallEffectThreshold()) {
int16_t hallEffectStrength = getRawHallEffect();
if (hallEffectStrength < 0)
if (hallEffectStrength < 0) {
hallEffectStrength = -hallEffectStrength;
}
// Have absolute value of measure of magnetic field strength
if (hallEffectStrength > lookupHallEffectThreshold()) {
if (lastHallEffectSleepStart == 0) {
@@ -43,4 +44,4 @@ bool shouldBeSleeping(bool inAutoStart) {
#endif
#endif
return false;
}
}

View File

@@ -17,7 +17,6 @@
#include "stdlib.h"
#include "task.h"
// Small worker thread to handle power (PD + QC) related steps
void startPOWTask(void const *argument __unused) {