Skip to content

Commit e77817d

Browse files
committed
Fix styling
1 parent 6cd2da7 commit e77817d

File tree

15 files changed

+9445
-9433
lines changed

15 files changed

+9445
-9433
lines changed

APIs_USB/USBAudio_loopback_example/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#include "mbed.h"
1717
#include "USBAudio.h"
1818

19-
int main() {
19+
int main()
20+
{
2021

2122
USBAudio audio(true, 44100, 2, 44100, 2);
2223

APIs_USB/USBAudio_play_sound/main.cpp

Lines changed: 9372 additions & 9370 deletions
Large diffs are not rendered by default.

APIs_USB/USBAudio_square_wave/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ int16_t square_wave(uint32_t freq_hz, uint16_t amplitude, float time_s)
2727
}
2828
}
2929

30-
int main() {
30+
int main()
31+
{
3132
uint32_t tx_freq = 16000;
3233
USBAudio audio(true, 8000, 2, tx_freq, 1, 10, 0x7bb8, 0x1112, 0x0100);
3334
float cur_time = 0;

APIs_USB/USBAudio_wav_audio_player/main.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);//MOSI, MISO, SCLK, CS
2828
FATFileSystem fs("sd", &sd);
2929

30-
int main() {
30+
int main()
31+
{
3132
// Set the maximum speed so it can keep up with audio
3233
sd.frequency(FREQ_25_MHZ);
3334
// Load WAV file from SD card
@@ -38,21 +39,21 @@ int main() {
3839
}
3940
WaveAudioStream song(&file);//"song" is the audio data object
4041
// Check to see if file is a valid WAV file
41-
if(song.get_valid() == 0){
42+
if (song.get_valid() == 0) {
4243
error("ERROR: not valid WAV file\r\n");
4344
}
4445
// WAV file must be 16-bit
45-
if(song.get_bytes_per_sample() != 2){
46+
if (song.get_bytes_per_sample() != 2) {
4647
error("ERROR: WAV file not 2 bytes per sample (16-bit)\r\n");
4748
}
4849
USBAudio audio(true, 8000, song.get_channels(), song.get_sample_rate(), song.get_channels());
4950
uint8_t buffer[BUFFER_SIZE];
5051
int num_bytes_read;
5152
printf("Playing Audio\r\n");
5253
// Reads and plays data from WAV file over USB until song is over
53-
while(1){
54+
while (1) {
5455
num_bytes_read = song.read(buffer, BUFFER_SIZE);
55-
if(num_bytes_read == -1){
56+
if (num_bytes_read == -1) {
5657
printf("Song Over\r\n");
5758
break;
5859
}

APIs_USB/USBCDC/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
USBCDC cdc;
2020

21-
int main(void) {
21+
int main(void)
22+
{
2223

23-
while(1)
24-
{
24+
while (1) {
2525
char msg[] = "Hello world\r\n";
26-
cdc.send((uint8_t*)msg, strlen(msg));
26+
cdc.send((uint8_t *)msg, strlen(msg));
2727
ThisThread::sleep_for(1000);
2828
}
2929
}

APIs_USB/USBKeyboard/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ USBKeyboard key;
2020

2121
int main(void)
2222
{
23-
while (1) {
24-
key.printf("Hello World\r\n");
25-
ThisThread::sleep_for(1000);
26-
}
23+
while (1) {
24+
key.printf("Hello World\r\n");
25+
ThisThread::sleep_for(1000);
26+
}
2727
}

APIs_USB/USBMIDI/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
USBMIDI midi;
2020

21-
int main() {
21+
int main()
22+
{
2223
while (1) {
23-
for(int i=48; i<83; i++) { // send some messages!
24+
for (int i = 48; i < 83; i++) { // send some messages!
2425
midi.write(MIDIMessage::NoteOn(i));
2526
ThisThread::sleep_for(250);
2627
midi.write(MIDIMessage::NoteOff(i));

APIs_USB/USBMIDI_Take_Me_Out_to_the_Ball_Game/main.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@
5050

5151
USBMIDI midi;
5252

53-
void PlayNote(int note, int octave, uint32_t duration){
54-
if(note == REST){
53+
void PlayNote(int note, int octave, uint32_t duration)
54+
{
55+
if (note == REST) {
5556
ThisThread::sleep_for(duration);
56-
}
57-
else{
57+
} else {
5858
midi.write(MIDIMessage::NoteOn(note + octave));
5959
ThisThread::sleep_for(duration);
6060
midi.write(MIDIMessage::NoteOff(note + octave));
6161
}
6262
}
6363

64-
void TakeMeOutToTheBallGame(){
64+
void TakeMeOutToTheBallGame()
65+
{
6566
//https://www.bethsnotesplus.com/2012/09/take-me-out-to-ball-game.html
6667
PlayNote(C, OCTAVE5, HALF_NOTE);
6768
PlayNote(C, OCTAVE6, QUARTER_NOTE);
@@ -161,7 +162,8 @@ void TakeMeOutToTheBallGame(){
161162
PlayNote(REST, 0, QUARTER_NOTE);
162163
}
163164

164-
int main() {
165+
int main()
166+
{
165167
while (1) {
166168
TakeMeOutToTheBallGame();
167169
}

APIs_USB/USBMSD_HeapBlockDevice/main.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
FATFileSystem heap_fs("heap_fs");
2424
HeapBlockDevice bd(HEAP_BLOCK_DEVICE_SIZE, DEFAULT_BLOCK_SIZE);
2525

26-
int main() {
26+
int main()
27+
{
2728
bd.init();
2829

2930
FATFileSystem::format(&bd);
@@ -36,14 +37,14 @@ int main() {
3637
}
3738

3839
// If still error, then report failure
39-
if(err) {
40+
if (err) {
4041
printf("Error: Unable to format/mount the device.\r\n");
41-
while(1);
42+
while (1);
4243
}
4344

4445
USBMSD usb(&bd);
4546

46-
while(true) {
47+
while (true) {
4748
usb.process();
4849
}
4950

APIs_USB/USBMSD_SDBlockDevice/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
2121
USBMSD usb(&sd);
2222

23-
int main() {
23+
int main()
24+
{
2425

25-
while(true) {
26+
while (true) {
2627
usb.process();
2728
}
2829

APIs_USB/USBMouseKeyboard/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@ BusOut leds(LED1, LED2, LED3);
2424
//USBMouseKeyboard object
2525
USBMouseKeyboard key_mouse;
2626

27-
int main(void) {
27+
int main(void)
28+
{
2829
int16_t x = 0;
2930
int16_t y = 0;
3031
int32_t radius = 70;
3132
int32_t angle = 0;
3233
while (1) {
3334
//moves the coordinates of the mouse around in a circle
34-
x = cos((double)angle*3.14/50.0)*radius;
35-
y = sin((double)angle*3.14/50.0)*radius;
35+
x = cos((double)angle * 3.14 / 50.0) * radius;
36+
y = sin((double)angle * 3.14 / 50.0) * radius;
3637
//example of a media key press
3738
key_mouse.media_control(KEY_VOLUME_DOWN);
3839
//example of simple keyboard output

APIs_USB/USBMouse_absolute_pos/main.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,23 @@ USBMouse mouse(true, ABS_MOUSE);
2323

2424
int main(void)
2525
{
26-
uint16_t x_center = (X_MAX_ABS - X_MIN_ABS)/2;
27-
uint16_t y_center = (Y_MAX_ABS - Y_MIN_ABS)/2;
28-
uint16_t x_screen = 0;
29-
uint16_t y_screen = 0;
26+
uint16_t x_center = (X_MAX_ABS - X_MIN_ABS) / 2;
27+
uint16_t y_center = (Y_MAX_ABS - Y_MIN_ABS) / 2;
28+
uint16_t x_screen = 0;
29+
uint16_t y_screen = 0;
3030

31-
uint32_t x_origin = x_center;
32-
uint32_t y_origin = y_center;
33-
uint32_t radius = 5000;
34-
uint32_t angle = 0;
31+
uint32_t x_origin = x_center;
32+
uint32_t y_origin = y_center;
33+
uint32_t radius = 5000;
34+
uint32_t angle = 0;
3535

36-
while (1)
37-
{
38-
x_screen = x_origin + cos((double)angle*3.14/180.0)*radius;
39-
y_screen = y_origin + sin((double)angle*3.14/180.0)*radius;
36+
while (1) {
37+
x_screen = x_origin + cos((double)angle * 3.14 / 180.0) * radius;
38+
y_screen = y_origin + sin((double)angle * 3.14 / 180.0) * radius;
4039

41-
//x_screen, y_screen will be the mouse's position on the screen
42-
mouse.move(x_screen, y_screen);
43-
angle += 3;
44-
ThisThread::sleep_for(10);
45-
}
40+
//x_screen, y_screen will be the mouse's position on the screen
41+
mouse.move(x_screen, y_screen);
42+
angle += 3;
43+
ThisThread::sleep_for(10);
44+
}
4645
}

APIs_USB/USBMouse_joystick/main.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ AnalogIn ainy(A1);
2323
int16_t a_inx;
2424
int16_t a_iny;
2525

26-
int main() {
26+
int main()
27+
{
2728
int16_t x = 0;
2829
int16_t y = 0;
2930

@@ -37,32 +38,32 @@ int main() {
3738
printf("Y: %u\r\n", a_iny);
3839

3940
// move position of mouse right
40-
if(a_inx > 52){
41+
if (a_inx > 52) {
4142
x = (x - (50 - a_inx)) / 3;
4243
}
4344
// move position of mouse left
44-
else if(a_inx < 47){
45+
else if (a_inx < 47) {
4546
x = (a_inx - 50) / 2;
4647
}
4748
// keeps mouse stationary in x-axis
48-
else{
49+
else {
4950
x = 0;
5051
}
5152
// move position of mouse down
52-
if(a_iny > 52 && a_iny != 99){
53+
if (a_iny > 52 && a_iny != 99) {
5354
y = (y - (50 - a_iny)) / 3;
5455
}
5556
// move position of mouse up
56-
else if(a_iny < 47){
57+
else if (a_iny < 47) {
5758
y = (a_iny - 50) / 2;
5859
}
5960
// keeps mouse stationary in y-axis
60-
else{
61+
else {
6162
y = 0;
6263
}
6364
// if button is pressed, a_iny will be 99
6465
// performs mouse left click
65-
if(a_iny == 99){
66+
if (a_iny == 99) {
6667
//click
6768
mouse.click(MOUSE_LEFT);
6869
ThisThread::sleep_for(400);

APIs_USB/USBMouse_relative_pos/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@
1919
//create mouse object
2020
USBMouse mouse;
2121

22-
int main() {
22+
int main()
23+
{
2324
int16_t x = 0;
2425
int16_t y = 0;
2526
int32_t radius = 10;
2627
int32_t angle = 0;
2728

2829
while (1) {
2930
//will cause mouse to move in a circle
30-
x = cos((double)angle*3.14/180.0)*radius;
31-
y = sin((double)angle*3.14/180.0)*radius;
31+
x = cos((double)angle * 3.14 / 180.0) * radius;
32+
y = sin((double)angle * 3.14 / 180.0) * radius;
3233

3334
//will move mouse x, y away from its previous position on the screen
3435
mouse.move(x, y);

APIs_USB/USBSerial/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
//Virtual serial port over USB
2020
USBSerial serial;
2121

22-
int main(void) {
23-
while(1)
24-
{
22+
int main(void)
23+
{
24+
while (1) {
2525
serial.printf("I am a virtual serial port\r\n");
2626
ThisThread::sleep_for(1000);
2727
}

0 commit comments

Comments
 (0)