Skip to content

Commit 14c52f3

Browse files
committed
Run examples through formatter
Clang formatter in VS Code set to Microsoft style
1 parent c0214de commit 14c52f3

File tree

10 files changed

+1118
-1038
lines changed

10 files changed

+1118
-1038
lines changed

examples/Audio_Examples/AudioExample1_PlayTone/AudioExample1_PlayTone.ino

Lines changed: 117 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -13,117 +13,133 @@ UBX_CELL_VOICE_BASE myModule; // This example works with all voice-enabled modul
1313

1414
void setup()
1515
{
16-
Serial.begin(115200); // Start the serial console
17-
18-
// Wait for user to press key to begin
19-
Serial.println(F("u-blox Cellular Audio Example 1 - Play Tone"));
20-
21-
Serial.println();
22-
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
23-
Serial.println(F("This example requires an audio codec attached to the I2S interface"));
24-
Serial.println(F("of the cellular modem. Please add one and update this example as"));
25-
Serial.println(F("needed to configure your audio codec!"));
26-
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
27-
Serial.println();
28-
29-
Serial.println(F("Press any key to begin"));
30-
31-
while (!Serial.available()) // Wait for the user to press a key (send any serial character)
32-
;
33-
while (Serial.available()) // Empty the serial RX buffer
34-
Serial.read();
35-
36-
Serial.println(F("Beginning..."));
37-
38-
// myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
39-
40-
// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
41-
// Uncomment the next line if required
42-
// myModule.invertPowerPin(true);
43-
44-
// Initialize the module
45-
if (myModule.begin(mySerial, UBX_CELL_DEFAULT_BAUD_RATE) )
46-
{
47-
Serial.println(F("Module connected!"));
48-
}
49-
else
50-
{
51-
Serial.println(F("Unable to communicate with the module."));
52-
Serial.println(F("Manually power-on (hold the module's On button for 3 seconds) and try again."));
53-
while (1) ; // Loop forever on fail
54-
}
55-
Serial.println();
16+
Serial.begin(115200); // Start the serial console
17+
18+
// Wait for user to press key to begin
19+
Serial.println(F("u-blox Cellular Audio Example 1 - Play Tone"));
20+
21+
Serial.println();
22+
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
23+
Serial.println(F("This example requires an audio codec attached to the I2S interface"));
24+
Serial.println(F("of the cellular modem. Please add one and update this example as"));
25+
Serial.println(F("needed to configure your audio codec!"));
26+
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
27+
Serial.println();
28+
29+
Serial.println(F("Press any key to begin"));
30+
31+
while (!Serial.available()) // Wait for the user to press a key (send any serial character)
32+
;
33+
while (Serial.available()) // Empty the serial RX buffer
34+
Serial.read();
35+
36+
Serial.println(F("Beginning..."));
37+
38+
// myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
39+
40+
// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
41+
// Uncomment the next line if required
42+
// myModule.invertPowerPin(true);
43+
44+
// Initialize the module
45+
if (myModule.begin(mySerial, UBX_CELL_DEFAULT_BAUD_RATE))
46+
{
47+
Serial.println(F("Module connected!"));
48+
}
49+
else
50+
{
51+
Serial.println(F("Unable to communicate with the module."));
52+
Serial.println(F("Manually power-on (hold the module's On button for 3 seconds) and try again."));
53+
while (1)
54+
; // Loop forever on fail
55+
}
56+
Serial.println();
5657
}
5758

5859
void loop()
5960
{
60-
String inputString;
61-
char dtmfChar = 0;
62-
uint16_t frequency = 0;
63-
uint16_t duration = 0;
64-
uint8_t volume = 0;
65-
66-
while(true)
67-
{
68-
while(Serial.available() != 0){Serial.read();}
69-
Serial.println(F("Enter a frequency in Hz (300-3400) or a DTMF character (0-9, *, #)"));
70-
while(Serial.available() == 0){}
71-
72-
inputString = Serial.readStringUntil('\n');
73-
74-
if(inputString.length() == 1)
61+
String inputString;
62+
char dtmfChar = 0;
63+
uint16_t frequency = 0;
64+
uint16_t duration = 0;
65+
uint8_t volume = 0;
66+
67+
while (true)
7568
{
76-
dtmfChar = inputString.charAt(0);
77-
if((dtmfChar >= '0' && dtmfChar <= '9') || dtmfChar == '*' || dtmfChar == '#')
78-
{
79-
break;
80-
}
69+
while (Serial.available() != 0)
70+
{
71+
Serial.read();
72+
}
73+
Serial.println(F("Enter a frequency in Hz (300-3400) or a DTMF character (0-9, *, #)"));
74+
while (Serial.available() == 0)
75+
{
76+
}
77+
78+
inputString = Serial.readStringUntil('\n');
79+
80+
if (inputString.length() == 1)
81+
{
82+
dtmfChar = inputString.charAt(0);
83+
if ((dtmfChar >= '0' && dtmfChar <= '9') || dtmfChar == '*' || dtmfChar == '#')
84+
{
85+
break;
86+
}
87+
}
88+
else
89+
{
90+
frequency = inputString.toInt();
91+
if (frequency >= 300 && frequency <= 3400)
92+
{
93+
dtmfChar == 0;
94+
break;
95+
}
96+
}
8197
}
82-
else
98+
99+
while (true)
83100
{
84-
frequency = inputString.toInt();
85-
if(frequency >= 300 && frequency <= 3400)
86-
{
87-
dtmfChar == 0;
88-
break;
89-
}
101+
while (Serial.available() != 0)
102+
{
103+
Serial.read();
104+
}
105+
Serial.println(F("Enter a duration in ms (50-1360)"));
106+
while (Serial.available() == 0)
107+
{
108+
}
109+
110+
inputString = Serial.readStringUntil('\n');
111+
duration = inputString.toInt();
112+
if (duration >= 50 && duration <= 1360)
113+
{
114+
break;
115+
}
90116
}
91-
}
92-
93-
while(true)
94-
{
95-
while(Serial.available() != 0){Serial.read();}
96-
Serial.println(F("Enter a duration in ms (50-1360)"));
97-
while(Serial.available() == 0){}
98-
99-
inputString = Serial.readStringUntil('\n');
100-
duration = inputString.toInt();
101-
if(duration >= 50 && duration <= 1360)
117+
118+
while (true)
102119
{
103-
break;
120+
while (Serial.available() != 0)
121+
{
122+
Serial.read();
123+
}
124+
Serial.println(F("Enter a volume (0-100)"));
125+
while (Serial.available() == 0)
126+
{
127+
}
128+
129+
inputString = Serial.readStringUntil('\n');
130+
volume = inputString.toInt();
131+
if (volume <= 100)
132+
{
133+
break;
134+
}
104135
}
105-
}
106-
107-
while(true)
108-
{
109-
while(Serial.available() != 0){Serial.read();}
110-
Serial.println(F("Enter a volume (0-100)"));
111-
while(Serial.available() == 0){}
112-
113-
inputString = Serial.readStringUntil('\n');
114-
volume = inputString.toInt();
115-
if(volume <= 100)
136+
137+
if (dtmfChar == 0)
138+
{
139+
myModule.generateToneFreq(frequency, duration, volume);
140+
}
141+
else
116142
{
117-
break;
143+
myModule.generateToneDTMF(dtmfChar, duration, volume);
118144
}
119-
}
120-
121-
if(dtmfChar == 0)
122-
{
123-
myModule.generateToneFreq(frequency, duration, volume);
124-
}
125-
else
126-
{
127-
myModule.generateToneDTMF(dtmfChar, duration, volume);
128-
}
129145
}

examples/Audio_Examples/AudioExample2_Loopback/AudioExample2_Loopback.ino

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,59 +13,70 @@ UBX_CELL_VOICE_BASE myModule; // This example works with all voice-enabled modul
1313

1414
void setup()
1515
{
16-
Serial.begin(115200); // Start the serial console
16+
Serial.begin(115200); // Start the serial console
1717

18-
// Wait for user to press key to begin
19-
Serial.println(F("u-blox Cellular Audio Example 2 - Loopback"));
18+
// Wait for user to press key to begin
19+
Serial.println(F("u-blox Cellular Audio Example 2 - Loopback"));
2020

21-
Serial.println();
22-
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
23-
Serial.println(F("This example requires an audio codec attached to the I2S interface"));
24-
Serial.println(F("of the cellular modem. Please add one and update this example as"));
25-
Serial.println(F("needed to configure your audio codec!"));
26-
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
27-
Serial.println();
21+
Serial.println();
22+
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
23+
Serial.println(F("This example requires an audio codec attached to the I2S interface"));
24+
Serial.println(F("of the cellular modem. Please add one and update this example as"));
25+
Serial.println(F("needed to configure your audio codec!"));
26+
Serial.println(F("! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! ! ATTENTION ! ! ! ! !"));
27+
Serial.println();
2828

29-
Serial.println(F("Press any key to begin"));
30-
31-
while (!Serial.available()) // Wait for the user to press a key (send any serial character)
32-
;
33-
while (Serial.available()) // Empty the serial RX buffer
34-
Serial.read();
29+
Serial.println(F("Press any key to begin"));
3530

36-
Serial.println(F("Beginning..."));
31+
while (!Serial.available()) // Wait for the user to press a key (send any serial character)
32+
;
33+
while (Serial.available()) // Empty the serial RX buffer
34+
Serial.read();
3735

38-
// myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
36+
Serial.println(F("Beginning..."));
3937

40-
// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
41-
// Uncomment the next line if required
42-
// myModule.invertPowerPin(true);
38+
// myModule.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
4339

44-
// Initialize the module
45-
if (myModule.begin(mySerial, UBX_CELL_DEFAULT_BAUD_RATE) )
46-
{
47-
Serial.println(F("Module connected!"));
48-
}
49-
else
50-
{
51-
Serial.println(F("Unable to communicate with the module."));
52-
Serial.println(F("Manually power-on (hold the module's On button for 3 seconds) and try again."));
53-
while (1) ; // Loop forever on fail
54-
}
55-
Serial.println();
40+
// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
41+
// Uncomment the next line if required
42+
// myModule.invertPowerPin(true);
43+
44+
// Initialize the module
45+
if (myModule.begin(mySerial, UBX_CELL_DEFAULT_BAUD_RATE))
46+
{
47+
Serial.println(F("Module connected!"));
48+
}
49+
else
50+
{
51+
Serial.println(F("Unable to communicate with the module."));
52+
Serial.println(F("Manually power-on (hold the module's On button for 3 seconds) and try again."));
53+
while (1)
54+
; // Loop forever on fail
55+
}
56+
Serial.println();
5657
}
5758

5859
void loop()
5960
{
60-
while(Serial.available() != 0){Serial.read();}
61-
Serial.println(F("Enter any key to begin loopback"));
62-
while(Serial.available() == 0){}
63-
64-
myModule.playAudioResource(UBX_CELL_AUDIO_RESOURCE_LOOPBACK);
65-
66-
while(Serial.available() != 0){Serial.read();}
67-
Serial.println(F("Enter any key to stop loopback"));
68-
while(Serial.available() == 0){}
69-
70-
myModule.stopAudioResource(UBX_CELL_AUDIO_RESOURCE_LOOPBACK);
61+
while (Serial.available() != 0)
62+
{
63+
Serial.read();
64+
}
65+
Serial.println(F("Enter any key to begin loopback"));
66+
while (Serial.available() == 0)
67+
{
68+
}
69+
70+
myModule.playAudioResource(UBX_CELL_AUDIO_RESOURCE_LOOPBACK);
71+
72+
while (Serial.available() != 0)
73+
{
74+
Serial.read();
75+
}
76+
Serial.println(F("Enter any key to stop loopback"));
77+
while (Serial.available() == 0)
78+
{
79+
}
80+
81+
myModule.stopAudioResource(UBX_CELL_AUDIO_RESOURCE_LOOPBACK);
7182
}

0 commit comments

Comments
 (0)