Skip to content

Commit 8be3e8d

Browse files
apply clang v12 formatting with inline ifs for #3
1 parent 7b20881 commit 8be3e8d

15 files changed

+39
-49
lines changed

.clang-format

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
# We'll use defaults from the LLVM style, but with 4 columns indentation.
3+
# see https://releases.llvm.org/12.0.1/tools/clang/docs/ClangFormatStyleOptions.html
34
BasedOnStyle: LLVM
45
IndentWidth: 4
56
---
@@ -9,6 +10,5 @@ DerivePointerAlignment: false
910
PointerAlignment: Left
1011
ColumnLimit: 120
1112
AllowShortBlocksOnASingleLine: Empty
12-
# AllowShortIfStatementsOnASingleLine: AllIfsAndElse
13-
13+
AllowShortIfStatementsOnASingleLine: WithoutElse
1414
---

src/controller.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ Mode mode;
2626
uint32_t timeout = 0;
2727

2828
void _toMode(Mode new_mode) {
29-
if (new_mode == mode)
30-
return;
29+
if (new_mode == mode) return;
3130
print(F("New Mode: "));
3231
switch (new_mode) {
3332
case OFF:

src/display.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ void setupPanel() {
5858
// initial values come from persistence/controller
5959
}
6060

61-
void colorDot(uint16_t color){
61+
void colorDot(uint16_t color) {
6262
// top right corner
63-
screen->drawPixel(screen->width()-1, 0, color);
63+
screen->drawPixel(screen->width() - 1, 0, color);
6464
}
6565

66-
void flashDot(){
66+
void flashDot() {
6767
colorDot(white);
6868
delay(200);
6969
colorDot(black);

src/inputs/touch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#include "controller.h"
44
#include "pinout.h"
5+
#include "shared/rebootManager.h"
56
#include "shared/serialWrapper.h"
67
#include <Arduino.h>
7-
#include "shared/rebootManager.h"
88

99
namespace Input_Touch {
1010

@@ -36,7 +36,7 @@ void logAllTouches() {
3636

3737
void setup() {
3838
logAllTouches();
39-
delay(10); // make sure touch pins are loaded
39+
delay(10); // make sure touch pins are loaded
4040
// touchAttachInterrupt(Pinout::TOUCH_TOP, touchedTop, TOUCH_THRESHOLD);
4141
touchAttachInterrupt(Pinout::TOUCH_LEFT, touchedLeft, TOUCH_THRESHOLD);
4242
touchAttachInterrupt(Pinout::TOUCH_RIGHT, touchedRight, TOUCH_THRESHOLD);

src/inputs/website.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void GetRoot(AsyncWebServerRequest* request) {
2727

2828
void GetAPI(AsyncWebServerRequest* request) {
2929
RebootManager::setActive();
30-
30+
3131
String message = F("Possible Commands, chain with \"&\":\n");
3232
message.reserve(200);
3333
// always show possible commands
@@ -38,7 +38,7 @@ void GetAPI(AsyncWebServerRequest* request) {
3838
}
3939
message += F("OK: \n");
4040

41-
// TODO streamline
41+
// TODO streamline
4242
String paramKey;
4343
paramKey.reserve(20);
4444
paramKey = F("mode");

src/modes/clock.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ void setup() {}
2727
uint32_t nextUpdate = 0;
2828
void loop() {
2929
uint32_t now = millis();
30-
if (now < nextUpdate)
31-
return;
30+
if (now < nextUpdate) return;
3231
nextUpdate = now + UPDATE_DELAY;
3332
updateScreen();
3433
}

src/modes/colorwave.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ namespace {
1212
const uint8_t WIDTH = Display::PANEL_RES_X;
1313
const uint8_t HEIGHT = Display::PANEL_RES_Y;
1414

15-
// heavily inspired by https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA/blob/master/examples/2_PatternPlasma/2_PatternPlasma.ino
15+
// heavily inspired by
16+
// https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA/blob/master/examples/2_PatternPlasma/2_PatternPlasma.ino
1617

1718
uint16_t time_counter = 0, cycles = 0;
1819
CRGB currentColor;

src/modes/dashboard.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ void setup() {}
3838
uint32_t nextUpdate = 0;
3939
void loop() {
4040
uint32_t now = millis();
41-
if (now < nextUpdate)
42-
return;
41+
if (now < nextUpdate) return;
4342
nextUpdate = now + UPDATE_DELAY;
4443
updateScreen();
4544
}

src/modes/fire.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ void updateScreen() {
6868
byte chgchance = 125; // higher number less chance (0-254) default: 245
6969

7070
for (int i = 0; i <= (WIDTH - 1); i++) {
71-
if (random8() > chgchance)
72-
continue;
71+
if (random8() > chgchance) continue;
7372
byte rCol = random8();
7473
if (i >= 1 && i <= (WIDTH - 2)) {
7574
if (intensity[XY(0, i - 1)] > 0 || intensity[XY(0, i + 1)] > 0) {
@@ -100,8 +99,7 @@ void updateScreen() {
10099
CRGB c = ColorFromPalette(activePalette, intensity[i]);
101100
uint8_t x = i / HEIGHT;
102101
uint8_t y = i % HEIGHT;
103-
if (true)
104-
y = HEIGHT - 1 - y;
102+
if (true) y = HEIGHT - 1 - y;
105103
Display::screen->drawPixelRGB888(x, y, c.r, c.g, c.b);
106104
}
107105
}

src/pinout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void setup() {
5252
pinMode(LED_BUILTIN, OUTPUT);
5353

5454
for (uint8_t p : Pinout::TOUCH) {
55-
pinMode(p, INPUT); // prevents shorts
55+
pinMode(p, INPUT); // prevents shorts
5656
}
5757

5858
// Matrix sets up itself

src/shared/persistence/persistenceManager.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ void callListeners() {
5757
fListener listener = listeners[i];
5858

5959
// check for value
60-
if (listener == nullptr) {
61-
println(F("Listener not initialised"));
62-
}
60+
if (listener == nullptr) { println(F("Listener not initialised")); }
6361
// unpack function pointer from list and call
6462
(*listener)();
6563
}

src/shared/persistence/persistenceStore.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ const uint16_t MAX_BYTES_USED = 127;
3939

4040
// call once at startup to reserve (emulated) storage for usage
4141
void setup() {
42-
// ESP needs to know how much storage we actually need, AVR won't
43-
EEPROM.begin(MAX_BYTES_USED);
42+
// ESP needs to know how much storage we actually need, AVR won't
43+
EEPROM.begin(MAX_BYTES_USED);
4444
}
4545

4646
// save settings to EEPROM for persistent storage
4747
void saveSettings(const Configuration settings) {
48-
EEPROM.write(EEPROM_VERSION_ADDR, VERSION);
49-
EEPROM.put(EEPROM_SETTINGS_ADDR, settings);
48+
EEPROM.write(EEPROM_VERSION_ADDR, VERSION);
49+
EEPROM.put(EEPROM_SETTINGS_ADDR, settings);
5050

51-
// commit planned changes
52-
EEPROM.commit();
51+
// commit planned changes
52+
EEPROM.commit();
5353
}
5454

5555
/**
@@ -58,21 +58,21 @@ void saveSettings(const Configuration settings) {
5858
* The chance that a random, unset combination is a match is very low.
5959
* */
6060
const Configuration loadSettings() {
61-
// could be rubbish or zeros, either way should work
62-
uint8_t savedVersion = EEPROM.read(EEPROM_VERSION_ADDR);
61+
// could be rubbish or zeros, either way should work
62+
uint8_t savedVersion = EEPROM.read(EEPROM_VERSION_ADDR);
6363

64-
if (savedVersion != VERSION) {
65-
// save new default settings as fallback, updates version for next run
66-
saveSettings(defaultConfiguration);
64+
if (savedVersion != VERSION) {
65+
// save new default settings as fallback, updates version for next run
66+
saveSettings(defaultConfiguration);
6767

68-
return defaultConfiguration;
69-
}
68+
return defaultConfiguration;
69+
}
7070

71-
// default isn't actually used, but it prevents compile warnings
72-
Configuration settings = defaultConfiguration;
73-
EEPROM.get(EEPROM_SETTINGS_ADDR, settings);
71+
// default isn't actually used, but it prevents compile warnings
72+
Configuration settings = defaultConfiguration;
73+
EEPROM.get(EEPROM_SETTINGS_ADDR, settings);
7474

75-
return settings;
75+
return settings;
7676
}
7777

7878
} // namespace PersistenceStore

src/shared/rebootManager.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ void rebootNow() {
2424
void setActive() { scheduledRestart = millis() + INACTIVITY_THRESHOLD_MS; }
2525

2626
void loop() {
27-
if (millis() > MIN_REBOOT_DELAY_MS && scheduledRestart < millis())
28-
rebootNow();
27+
if (millis() > MIN_REBOOT_DELAY_MS && scheduledRestart < millis()) rebootNow();
2928
}
3029

3130
} // namespace RebootManager

src/shared/serialWrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void heartbeatSerial() {
5353
lastCycle = time;
5454
}
5555

56-
void println(){
56+
void println() {
5757
if (!USE_SERIAL) return;
5858
Serial.println();
5959
}

src/shared/timeService.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ const long gmtOffset_sec = 3600;
1616
const int daylightOffset_sec = 3600;
1717

1818
void updateLocalTime() {
19-
if (!getLocalTime(&timeinfo)) {
20-
logError(F("Failed to obtain time"));
21-
}
19+
if (!getLocalTime(&timeinfo)) { logError(F("Failed to obtain time")); }
2220
}
2321
} // namespace
2422

@@ -27,8 +25,7 @@ void setup() { configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); }
2725
uint32_t nextUpdate = 0;
2826
void loop() {
2927
uint32_t now = millis();
30-
if (now < nextUpdate)
31-
return;
28+
if (now < nextUpdate) return;
3229
nextUpdate = now + UPDATE_DELAY;
3330
updateLocalTime();
3431
}

0 commit comments

Comments
 (0)