Skip to content

Commit f9e72db

Browse files
Add style check matching RP2040 core (#740)
Will let us backport the BackgroundAudio patches to libhelix easier and clean up some ugly formatting we've let develop.
1 parent 62dd23a commit f9e72db

File tree

434 files changed

+97515
-95993
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

434 files changed

+97515
-95993
lines changed

.github/workflows/pr-or-master-push.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,10 @@ jobs:
120120
with:
121121
library-manager: 'update'
122122

123-
# Validate orthography
123+
# Style and spelling
124124
code-spell:
125-
name: Check spelling
125+
name: Spelling, Style
126126
runs-on: ubuntu-latest
127-
defaults:
128-
run:
129-
shell: bash
130127
steps:
131128
- uses: actions/checkout@v4
132129
with:
@@ -136,3 +133,10 @@ jobs:
136133
with:
137134
skip: ./src/libmad,./src/libhelix-aac,./src/libopus,./src/libflac
138135
ignore_words_list: ESP8266,esp8266,esp,dout,DOUT,ser,ans,inout,numer,hist
136+
- name: Run astyle on all code/examples
137+
run: |
138+
sudo apt update
139+
sudo apt install astyle
140+
./tests/restyle.sh
141+
# If anything changed, GIT should return an error and fail the test
142+
git diff --exit-code

examples/MixerSample/MixerSample.ino

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#include <Arduino.h>
22

33
#if defined(ARDUINO_ARCH_RP2040)
4-
#define WIFI_OFF
5-
class __x { public: __x() {}; void mode() {}; };
6-
__x WiFi;
4+
#define WIFI_OFF
5+
class __x {
6+
public: __x() {};
7+
void mode() {};
8+
};
9+
__x WiFi;
710
#elif defined(ESP32)
8-
#include <WiFi.h>
11+
#include <WiFi.h>
912
#else
10-
#include <ESP8266WiFi.h>
13+
#include <ESP8266WiFi.h>
1114
#endif
1215

1316
#include "AudioFileSourcePROGMEM.h"
@@ -24,15 +27,14 @@ AudioOutputI2S *out;
2427
AudioOutputMixer *mixer;
2528
AudioOutputMixerStub *stub[2];
2629

27-
void setup()
28-
{
29-
WiFi.mode(WIFI_OFF);
30+
void setup() {
31+
WiFi.mode(WIFI_OFF);
3032
Serial.begin(115200);
3133
delay(1000);
3234
Serial.printf("WAV start\n");
3335

3436
audioLogger = &Serial;
35-
file[0] = new AudioFileSourcePROGMEM( viola, sizeof(viola) );
37+
file[0] = new AudioFileSourcePROGMEM(viola, sizeof(viola));
3638
out = new AudioOutputI2S();
3739
mixer = new AudioOutputMixer(32, out);
3840
stub[0] = mixer->NewInput();
@@ -43,29 +45,38 @@ void setup()
4345
Serial.printf("starting 1\n");
4446
}
4547

46-
void loop()
47-
{
48+
void loop() {
4849
static uint32_t start = 0;
4950
static bool go = false;
50-
51-
if (!start) start = millis();
51+
52+
if (!start) {
53+
start = millis();
54+
}
5255

5356
if (wav[0]->isRunning()) {
54-
if (!wav[0]->loop()) { wav[0]->stop(); stub[0]->stop(); Serial.printf("stopping 1\n"); }
57+
if (!wav[0]->loop()) {
58+
wav[0]->stop();
59+
stub[0]->stop();
60+
Serial.printf("stopping 1\n");
61+
}
5562
}
5663

57-
if (millis()-start > 3000) {
64+
if (millis() - start > 3000) {
5865
if (!go) {
5966
Serial.printf("starting 2\n");
6067
stub[1] = mixer->NewInput();
6168
stub[1]->SetGain(0.4);
6269
wav[1] = new AudioGeneratorWAV();
63-
file[1] = new AudioFileSourcePROGMEM( viola, sizeof(viola) );
70+
file[1] = new AudioFileSourcePROGMEM(viola, sizeof(viola));
6471
wav[1]->begin(file[1], stub[1]);
6572
go = true;
6673
}
6774
if (wav[1]->isRunning()) {
68-
if (!wav[1]->loop()) { wav[1]->stop(); stub[1]->stop(); Serial.printf("stopping 2\n");}
75+
if (!wav[1]->loop()) {
76+
wav[1]->stop();
77+
stub[1]->stop();
78+
Serial.printf("stopping 2\n");
79+
}
6980
}
7081
}
7182

examples/PlayAACFromPROGMEM/PlayAACFromPROGMEM.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ AudioFileSourcePROGMEM *in;
88
AudioGeneratorAAC *aac;
99
AudioOutputI2S *out;
1010

11-
void setup()
12-
{
11+
void setup() {
1312
Serial.begin(115200);
1413

1514
audioLogger = &Serial;
@@ -21,8 +20,7 @@ void setup()
2120
}
2221

2322

24-
void loop()
25-
{
23+
void loop() {
2624
if (aac->isRunning()) {
2725
aac->loop();
2826
} else {

examples/PlayFLAC-SD-SPDIF/PlayFLAC-SD-SPDIF.ino

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ void loop() {}
88
#include "AudioGeneratorFLAC.h"
99

1010
// For this sketch, you need connected SD card with '.flac' music files in the root
11-
// directory. Some samples with various sampling rates are available from i.e.
11+
// directory. Some samples with various sampling rates are available from i.e.
1212
// Espressif Audio Development Framework at:
1313
// https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/audio-samples.html
1414
//
15-
// On ESP8266 you might need to re-encode FLAC files with max '-2' compression level
16-
// (i.e. 1152 maximum block size) or you will run out of memory. FLAC files will be
15+
// On ESP8266 you might need to re-encode FLAC files with max '-2' compression level
16+
// (i.e. 1152 maximum block size) or you will run out of memory. FLAC files will be
1717
// slightly bigger but you don't loose audio quality with reencoding (lossles codec).
1818

1919
// You may need a fast SD card. Set this as high as it will work (40MHz max).
2020
#define SPI_SPEED SD_SCK_MHZ(40)
2121

22-
// On ESP32 you can adjust the SPDIF_OUT_PIN (GPIO number).
22+
// On ESP32 you can adjust the SPDIF_OUT_PIN (GPIO number).
2323
// On ESP8266 it is fixed to GPIO3/RX0 and this setting has no effect
2424
#define SPDIF_OUT_PIN 27
2525

@@ -33,41 +33,43 @@ void setup() {
3333
Serial.println();
3434
delay(1000);
3535

36-
audioLogger = &Serial;
36+
audioLogger = &Serial;
3737
source = new AudioFileSourceSD();
3838
output = new AudioOutputSPDIF(SPDIF_OUT_PIN);
3939
decoder = new AudioGeneratorFLAC();
4040

41-
// NOTE: SD.begin(...) should be called AFTER AudioOutputSPDIF()
41+
// NOTE: SD.begin(...) should be called AFTER AudioOutputSPDIF()
4242
// to takover the the SPI pins if they share some with I2S
4343
// (i.e. D8 on Wemos D1 mini is both I2S BCK and SPI SS)
44-
#if defined(ESP8266)
45-
SD.begin(SS, SPI_SPEED);
46-
#else
47-
SD.begin();
48-
#endif
49-
dir = SD.open("/");
44+
#if defined(ESP8266)
45+
SD.begin(SS, SPI_SPEED);
46+
#else
47+
SD.begin();
48+
#endif
49+
dir = SD.open("/");
5050
}
5151

5252
void loop() {
5353
if ((decoder) && (decoder->isRunning())) {
54-
if (!decoder->loop()) decoder->stop();
54+
if (!decoder->loop()) {
55+
decoder->stop();
56+
}
5557
} else {
5658
File file = dir.openNextFile();
57-
if (file) {
59+
if (file) {
5860
if (String(file.name()).endsWith(".flac")) {
5961
source->close();
60-
if (source->open(file.name())) {
62+
if (source->open(file.name())) {
6163
Serial.printf_P(PSTR("Playing '%s' from SD card...\n"), file.name());
6264
decoder->begin(source, output);
6365
} else {
6466
Serial.printf_P(PSTR("Error opening '%s'\n"), file.name());
6567
}
66-
}
68+
}
6769
} else {
6870
Serial.println(F("Playback from SD card done\n"));
6971
delay(1000);
70-
}
72+
}
7173
}
7274
}
7375
#endif

examples/PlayFLACFromPROGMEMToDAC/PlayFLACFromPROGMEMToDAC.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ AudioOutputI2S *out;
99
AudioFileSourcePROGMEM *file;
1010
AudioGeneratorFLAC *flac;
1111

12-
void setup()
13-
{
12+
void setup() {
1413
Serial.begin(115200);
1514
Serial.println("Starting up...\n");
1615

1716
audioLogger = &Serial;
18-
file = new AudioFileSourcePROGMEM( sample_flac, sizeof(sample_flac) );
17+
file = new AudioFileSourcePROGMEM(sample_flac, sizeof(sample_flac));
1918
out = new AudioOutputI2S();
2019
flac = new AudioGeneratorFLAC();
2120
flac->begin(file, out);
2221
}
2322

24-
void loop()
25-
{
23+
void loop() {
2624
if (flac->isRunning()) {
27-
if (!flac->loop()) flac->stop();
25+
if (!flac->loop()) {
26+
flac->stop();
27+
}
2828
} else {
2929
Serial.printf("FLAC done\n");
3030
delay(1000);

examples/PlayMIDIFromLittleFS/PlayMIDIFromLittleFS.ino

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
#include <Arduino.h>
22
#ifdef ESP32
3-
void setup() {
4-
Serial.begin(115200);
5-
Serial.printf("ERROR - ESP32 does not support LittleFS\n");
6-
}
7-
void loop() {}
3+
void setup() {
4+
Serial.begin(115200);
5+
Serial.printf("ERROR - ESP32 does not support LittleFS\n");
6+
}
7+
void loop() {}
88
#else
99
#if defined(ARDUINO_ARCH_RP2040)
10-
#define WIFI_OFF
11-
class __x { public: __x() {}; void mode() {}; };
12-
__x WiFi;
10+
#define WIFI_OFF
11+
class __x {
12+
public: __x() {};
13+
void mode() {};
14+
};
15+
__x WiFi;
1316
#else
14-
#include <ESP8266WiFi.h>
17+
#include <ESP8266WiFi.h>
1518
#endif
1619
#include <AudioOutputI2S.h>
1720
#include <AudioGeneratorMIDI.h>
@@ -22,20 +25,19 @@ AudioFileSourceLittleFS *mid;
2225
AudioOutputI2S *dac;
2326
AudioGeneratorMIDI *midi;
2427

25-
void setup()
26-
{
28+
void setup() {
2729
const char *soundfont = "/1mgm.sf2";
2830
const char *midifile = "/furelise.mid";
2931

30-
WiFi.mode(WIFI_OFF);
32+
WiFi.mode(WIFI_OFF);
3133

3234
Serial.begin(115200);
3335
Serial.println("Starting up...\n");
3436

3537
audioLogger = &Serial;
3638
sf2 = new AudioFileSourceLittleFS(soundfont);
3739
mid = new AudioFileSourceLittleFS(midifile);
38-
40+
3941
dac = new AudioOutputI2S();
4042
midi = new AudioGeneratorMIDI();
4143
midi->SetSoundfont(sf2);
@@ -44,8 +46,7 @@ void setup()
4446
midi->begin(mid, dac);
4547
}
4648

47-
void loop()
48-
{
49+
void loop() {
4950
if (midi->isRunning()) {
5051
if (!midi->loop()) {
5152
midi->stop();

examples/PlayMIDIFromSPIFFS/PlayMIDIFromSPIFFS.ino

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ void setup() {}
77
void loop() {}
88
#else
99
#ifdef ESP32
10-
#include <WiFi.h>
11-
#include "SPIFFS.h"
10+
#include <WiFi.h>
11+
#include "SPIFFS.h"
1212
#else
13-
#include <ESP8266WiFi.h>
13+
#include <ESP8266WiFi.h>
1414
#endif
1515

1616

@@ -24,12 +24,11 @@ AudioFileSourceSPIFFS *mid;
2424
AudioOutputI2S *dac;
2525
AudioGeneratorMIDI *midi;
2626

27-
void setup()
28-
{
27+
void setup() {
2928
const char *soundfont = "/1mgm.sf2";
3029
const char *midifile = "/furelise.mid";
3130

32-
WiFi.mode(WIFI_OFF);
31+
WiFi.mode(WIFI_OFF);
3332

3433
Serial.begin(115200);
3534
SPIFFS.begin();
@@ -38,7 +37,7 @@ void setup()
3837
audioLogger = &Serial;
3938
sf2 = new AudioFileSourceSPIFFS(soundfont);
4039
mid = new AudioFileSourceSPIFFS(midifile);
41-
40+
4241
dac = new AudioOutputI2S();
4342
midi = new AudioGeneratorMIDI();
4443
midi->SetSoundfont(sf2);
@@ -47,8 +46,7 @@ void setup()
4746
midi->begin(mid, dac);
4847
}
4948

50-
void loop()
51-
{
49+
void loop() {
5250
if (midi->isRunning()) {
5351
if (!midi->loop()) {
5452
midi->stop();

0 commit comments

Comments
 (0)