Skip to content

Commit 15d7a1b

Browse files
committed
Fix styling
1 parent 009947c commit 15d7a1b

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
@@ -6,7 +6,8 @@
66
#include "mbed.h"
77
#include "USBAudio.h"
88

9-
int main() {
9+
int main()
10+
{
1011

1112
USBAudio audio(true, 44100, 2, 44100, 2);
1213

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
@@ -14,7 +14,8 @@ int16_t square_wave(uint32_t freq_hz, uint16_t amplitude, float time_s)
1414
}
1515
}
1616

17-
int main() {
17+
int main()
18+
{
1819
uint32_t tx_freq = 16000;
1920
USBAudio audio(true, 8000, 2, tx_freq, 1, 10, 0x7bb8, 0x1112, 0x0100);
2021
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
@@ -13,7 +13,8 @@
1313
SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);//MOSI, MISO, SCLK, CS
1414
FATFileSystem fs("sd", &sd);
1515

16-
int main() {
16+
int main()
17+
{
1718
// Set the maximum speed so it can keep up with audio
1819
sd.frequency(FREQ_25_MHZ);
1920
// Load WAV file from SD card
@@ -24,21 +25,21 @@ int main() {
2425
}
2526
WaveAudioStream song(&file);//"song" is the audio data object
2627
// Check to see if file is a valid WAV file
27-
if(song.get_valid() == 0){
28+
if (song.get_valid() == 0) {
2829
error("ERROR: not valid WAV file\r\n");
2930
}
3031
// WAV file must be 16-bit
31-
if(song.get_bytes_per_sample() != 2){
32+
if (song.get_bytes_per_sample() != 2) {
3233
error("ERROR: WAV file not 2 bytes per sample (16-bit)\r\n");
3334
}
3435
USBAudio audio(true, 8000, song.get_channels(), song.get_sample_rate(), song.get_channels());
3536
uint8_t buffer[BUFFER_SIZE];
3637
int num_bytes_read;
3738
printf("Playing Audio\r\n");
3839
// Reads and plays data from WAV file over USB until song is over
39-
while(1){
40+
while (1) {
4041
num_bytes_read = song.read(buffer, BUFFER_SIZE);
41-
if(num_bytes_read == -1){
42+
if (num_bytes_read == -1) {
4243
printf("Song Over\r\n");
4344
break;
4445
}

APIs_USB/USBCDC/main.cpp

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

44
USBCDC cdc;
55

6-
int main(void) {
6+
int main(void)
7+
{
78

8-
while(1)
9-
{
9+
while (1) {
1010
char msg[] = "Hello world\r\n";
11-
cdc.send((uint8_t*)msg, strlen(msg));
11+
cdc.send((uint8_t *)msg, strlen(msg));
1212
ThisThread::sleep_for(1000);
1313
}
1414
}

APIs_USB/USBKeyboard/main.cpp

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

66
int main(void)
77
{
8-
while (1) {
9-
key.printf("Hello World\r\n");
10-
ThisThread::sleep_for(1000);
11-
}
8+
while (1) {
9+
key.printf("Hello World\r\n");
10+
ThisThread::sleep_for(1000);
11+
}
1212
}

APIs_USB/USBMIDI/main.cpp

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

44
USBMIDI midi;
55

6-
int main() {
6+
int main()
7+
{
78
while (1) {
8-
for(int i=48; i<83; i++) { // send some messages!
9+
for (int i = 48; i < 83; i++) { // send some messages!
910
midi.write(MIDIMessage::NoteOn(i));
1011
ThisThread::sleep_for(250);
1112
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
@@ -35,18 +35,19 @@
3535

3636
USBMIDI midi;
3737

38-
void PlayNote(int note, int octave, uint32_t duration){
39-
if(note == REST){
38+
void PlayNote(int note, int octave, uint32_t duration)
39+
{
40+
if (note == REST) {
4041
ThisThread::sleep_for(duration);
41-
}
42-
else{
42+
} else {
4343
midi.write(MIDIMessage::NoteOn(note + octave));
4444
ThisThread::sleep_for(duration);
4545
midi.write(MIDIMessage::NoteOff(note + octave));
4646
}
4747
}
4848

49-
void TakeMeOutToTheBallGame(){
49+
void TakeMeOutToTheBallGame()
50+
{
5051
//https://www.bethsnotesplus.com/2012/09/take-me-out-to-ball-game.html
5152
PlayNote(C, OCTAVE5, HALF_NOTE);
5253
PlayNote(C, OCTAVE6, QUARTER_NOTE);
@@ -146,7 +147,8 @@ void TakeMeOutToTheBallGame(){
146147
PlayNote(REST, 0, QUARTER_NOTE);
147148
}
148149

149-
int main() {
150+
int main()
151+
{
150152
while (1) {
151153
TakeMeOutToTheBallGame();
152154
}

APIs_USB/USBMSD_HeapBlockDevice/main.cpp

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

11-
int main() {
11+
int main()
12+
{
1213
bd.init();
1314

1415
FATFileSystem::format(&bd);
@@ -21,14 +22,14 @@ int main() {
2122
}
2223

2324
// If still error, then report failure
24-
if(err) {
25+
if (err) {
2526
printf("Error: Unable to format/mount the device.\r\n");
26-
while(1);
27+
while (1);
2728
}
2829

2930
USBMSD usb(&bd);
3031

31-
while(true) {
32+
while (true) {
3233
usb.process();
3334
}
3435

APIs_USB/USBMSD_SDBlockDevice/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
SDBlockDevice sd(PTE3, PTE1, PTE2, PTE4);
66
USBMSD usb(&sd);
77

8-
int main() {
8+
int main()
9+
{
910

10-
while(true) {
11+
while (true) {
1112
usb.process();
1213
}
1314

APIs_USB/USBMouseKeyboard/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ BusOut leds(LED1, LED2, LED3);
99
//USBMouseKeyboard object
1010
USBMouseKeyboard key_mouse;
1111

12-
int main(void) {
12+
int main(void)
13+
{
1314
int16_t x = 0;
1415
int16_t y = 0;
1516
int32_t radius = 70;
1617
int32_t angle = 0;
1718
while (1) {
1819
//moves the coordinates of the mouse around in a circle
19-
x = cos((double)angle*3.14/50.0)*radius;
20-
y = sin((double)angle*3.14/50.0)*radius;
20+
x = cos((double)angle * 3.14 / 50.0) * radius;
21+
y = sin((double)angle * 3.14 / 50.0) * radius;
2122
//example of a media key press
2223
key_mouse.media_control(KEY_VOLUME_DOWN);
2324
//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
@@ -8,24 +8,23 @@ USBMouse mouse(true, ABS_MOUSE);
88

99
int main(void)
1010
{
11-
uint16_t x_center = (X_MAX_ABS - X_MIN_ABS)/2;
12-
uint16_t y_center = (Y_MAX_ABS - Y_MIN_ABS)/2;
13-
uint16_t x_screen = 0;
14-
uint16_t y_screen = 0;
11+
uint16_t x_center = (X_MAX_ABS - X_MIN_ABS) / 2;
12+
uint16_t y_center = (Y_MAX_ABS - Y_MIN_ABS) / 2;
13+
uint16_t x_screen = 0;
14+
uint16_t y_screen = 0;
1515

16-
uint32_t x_origin = x_center;
17-
uint32_t y_origin = y_center;
18-
uint32_t radius = 5000;
19-
uint32_t angle = 0;
16+
uint32_t x_origin = x_center;
17+
uint32_t y_origin = y_center;
18+
uint32_t radius = 5000;
19+
uint32_t angle = 0;
2020

21-
while (1)
22-
{
23-
x_screen = x_origin + cos((double)angle*3.14/180.0)*radius;
24-
y_screen = y_origin + sin((double)angle*3.14/180.0)*radius;
21+
while (1) {
22+
x_screen = x_origin + cos((double)angle * 3.14 / 180.0) * radius;
23+
y_screen = y_origin + sin((double)angle * 3.14 / 180.0) * radius;
2524

26-
//x_screen, y_screen will be the mouse's position on the screen
27-
mouse.move(x_screen, y_screen);
28-
angle += 3;
29-
ThisThread::sleep_for(10);
30-
}
25+
//x_screen, y_screen will be the mouse's position on the screen
26+
mouse.move(x_screen, y_screen);
27+
angle += 3;
28+
ThisThread::sleep_for(10);
29+
}
3130
}

APIs_USB/USBMouse_joystick/main.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ AnalogIn ainy(A1);
1010
int16_t a_inx;
1111
int16_t a_iny;
1212

13-
int main() {
13+
int main()
14+
{
1415
int16_t x = 0;
1516
int16_t y = 0;
1617

@@ -24,32 +25,32 @@ int main() {
2425
printf("Y: %u\r\n", a_iny);
2526

2627
// move position of mouse right
27-
if(a_inx > 52){
28+
if (a_inx > 52) {
2829
x = (x - (50 - a_inx)) / 3;
2930
}
3031
// move position of mouse left
31-
else if(a_inx < 47){
32+
else if (a_inx < 47) {
3233
x = (a_inx - 50) / 2;
3334
}
3435
// keeps mouse stationary in x-axis
35-
else{
36+
else {
3637
x = 0;
3738
}
3839
// move position of mouse down
39-
if(a_iny > 52 && a_iny != 99){
40+
if (a_iny > 52 && a_iny != 99) {
4041
y = (y - (50 - a_iny)) / 3;
4142
}
4243
// move position of mouse up
43-
else if(a_iny < 47){
44+
else if (a_iny < 47) {
4445
y = (a_iny - 50) / 2;
4546
}
4647
// keeps mouse stationary in y-axis
47-
else{
48+
else {
4849
y = 0;
4950
}
5051
// if button is pressed, a_iny will be 99
5152
// performs mouse left click
52-
if(a_iny == 99){
53+
if (a_iny == 99) {
5354
//click
5455
mouse.click(MOUSE_LEFT);
5556
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
@@ -4,16 +4,17 @@
44
//create mouse object
55
USBMouse mouse;
66

7-
int main() {
7+
int main()
8+
{
89
int16_t x = 0;
910
int16_t y = 0;
1011
int32_t radius = 10;
1112
int32_t angle = 0;
1213

1314
while (1) {
1415
//will cause mouse to move in a circle
15-
x = cos((double)angle*3.14/180.0)*radius;
16-
y = sin((double)angle*3.14/180.0)*radius;
16+
x = cos((double)angle * 3.14 / 180.0) * radius;
17+
y = sin((double)angle * 3.14 / 180.0) * radius;
1718

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

APIs_USB/USBSerial/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
//Virtual serial port over USB
55
USBSerial serial;
66

7-
int main(void) {
8-
while(1)
9-
{
7+
int main(void)
8+
{
9+
while (1) {
1010
serial.printf("I am a virtual serial port\r\n");
1111
ThisThread::sleep_for(1000);
1212
}

0 commit comments

Comments
 (0)