Skip to content

Commit 942ffe6

Browse files
committed
Use consistent formatting of all code
Inconsistent code formatting is confusing to beginners who may not understand which code differences are purely aesthetic. Inconsistency also breeds more inconsistency and inefficiency as contributers of example code struggle to determine any style convention to follow in their work. AStyle (the tool used for the Arduino IDE's Auto Format feature) was used to automatically format the example code in the reference pages according to the standard Arduino style established in the official example sketches bundled with the Arduino IDE. The Auto Format formatting settings were used in addition to Arduino example formatter configuration: https://github.com/arduino/Arduino/blob/1.8.8/build/shared/examples_formatter.conf I used the latest version of AStyle, which offers some new configuration settings that allow enhanced compliance with the Arduino code style: mode=c style=attach break-closing-braces attach-closing-while attach-namespaces attach-classes attach-inlines attach-extern-c indent=spaces=2 indent-classes indent-switches indent-cases indent-col1-comments indent-modifiers indent-namespaces indent-labels indent-preproc-define pad-header pad-oper unpad-paren add-braces remove-comment-prefix convert-tabs align-pointer=name
1 parent 89fc002 commit 942ffe6

File tree

116 files changed

+555
-656
lines changed

Some content is hidden

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

116 files changed

+555
-656
lines changed

AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Single_Entity.adoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,11 @@ int ledPin = 9; // LED connected to digital pin 9
7676
int analogPin = 3; // potentiometer connected to analog pin 3
7777
int val = 0; // variable to store the read value
7878
79-
void setup()
80-
{
79+
void setup() {
8180
pinMode(ledPin, OUTPUT); // sets the pin as output
8281
}
8382
84-
void loop()
85-
{
83+
void loop() {
8684
val = analogRead(analogPin); // read the input pin
8785
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
8886
}

Language/Functions/Advanced IO/pulseIn.adoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ subCategories: [ "고급 입출력" ]
6565
int pin = 7;
6666
unsigned long duration;
6767
68-
void setup()
69-
{
68+
void setup() {
7069
pinMode(pin, INPUT);
7170
}
7271
73-
void loop()
74-
{
72+
void loop() {
7573
duration = pulseIn(pin, HIGH);
7674
}
7775
----

Language/Functions/Analog IO/analogRead.adoc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,17 @@ int(0 에서 1023)
5353

5454
[source,arduino]
5555
----
56-
int analogPin = 3; // 가변 저항의 가운데 핀이 아날로그 핀 3에 연결됨
57-
// 바깥쪽은 그라운드와 +5V에 연결됨
58-
int val = 0; // 읽은 값을 저장할 변수
56+
int analogPin = 3; // 가변 저항의 가운데 핀이 아날로그 핀 3에 연결됨
57+
// 바깥쪽은 그라운드와 +5V에 연결됨
58+
int val = 0; // 읽은 값을 저장할 변수
5959
60-
void setup()
61-
{
62-
Serial.begin(9600); // 시리얼 설정
60+
void setup() {
61+
Serial.begin(9600); // 시리얼 설정
6362
}
6463
65-
void loop()
66-
{
67-
val = analogRead(analogPin); // 입력 핀 읽기
68-
Serial.println(val); // 값 디버그
64+
void loop() {
65+
val = analogRead(analogPin); // 입력 핀 읽기
66+
Serial.println(val); // 값 디버그
6967
}
7068
----
7169
[%hardbreaks]

Language/Functions/Analog IO/analogWrite.adoc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,17 @@ PWM 핀과 달리, DAC0과 DAC1은 디지털을 아날로그로 바꾸는 컨버
5252

5353
[source,arduino]
5454
----
55-
int ledPin = 9; // LED는 디지털 핀 9번에 연결
56-
int analogPin = 3; // 가변저항은 아날로그 핀 3번에 연결
57-
int val = 0; // 읽은 값을 저장할 변수
55+
int ledPin = 9; // LED는 디지털 핀 9번에 연결
56+
int analogPin = 3; // 가변저항은 아날로그 핀 3번에 연결
57+
int val = 0; // 읽은 값을 저장할 변수
5858
59-
void setup()
60-
{
61-
pinMode(ledPin, OUTPUT); // 핀을 출력으로 설정
59+
void setup() {
60+
pinMode(ledPin, OUTPUT); // 핀을 출력으로 설정
6261
}
6362
64-
void loop()
65-
{
66-
val = analogRead(analogPin); // 입력 핀에서 값 읽기
67-
analogWrite(ledPin, val / 4); // analogRead 값은 0부터 1023까지, analogWrite 값은 0 부터 255까지
63+
void loop() {
64+
val = analogRead(analogPin); // 입력 핀에서 값 읽기
65+
analogWrite(ledPin, val / 4); // analogRead 값은 0부터 1023까지, analogWrite 값은 0 부터 255까지
6866
}
6967
----
7068
[%hardbreaks]

Language/Functions/Characters/isAlpha.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isAlpha(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isAlpha(myChar)) // myChar가 알파벳인지 테스트
54-
{
55-
Serial.println("The character is a letter");
53+
if (isAlpha(myChar)) { // myChar가 알파벳인지 테스트
54+
Serial.println("The character is a letter");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not a letter");
56+
else {
57+
Serial.println("The character is not a letter");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isAlphaNumeric.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isAlphaNumeric(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isAlphaNumeric(myChar)) // myChar가 문자 혹은 숫자인지 테스트
54-
{
55-
Serial.println("The character is alphanumeric");
53+
if (isAlphaNumeric(myChar)) { // myChar가 문자 혹은 숫자인지 테스트
54+
Serial.println("The character is alphanumeric");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not alphanumeric");
56+
else {
57+
Serial.println("The character is not alphanumeric");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isAscii.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isAscii(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isAscii(myChar)) // myChar가 아스키 문자인지 테스트
54-
{
55-
Serial.println("The character is Ascii");
53+
if (isAscii(myChar)) { // myChar가 아스키 문자인지 테스트
54+
Serial.println("The character is Ascii");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not Ascii");
56+
else {
57+
Serial.println("The character is not Ascii");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isControl.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isControl(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isControl(myChar)) // tests if myChar is a control character
54-
{
55-
Serial.println("The character is a control character");
53+
if (isControl(myChar)) { // tests if myChar is a control character
54+
Serial.println("The character is a control character");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not a control character");
56+
else {
57+
Serial.println("The character is not a control character");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isDigit.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isDigit(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isDigit(myChar)) // tests if myChar is a digit
54-
{
55-
Serial.println("The character is a number");
53+
if (isDigit(myChar)) { // tests if myChar is a digit
54+
Serial.println("The character is a number");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not a number");
56+
else {
57+
Serial.println("The character is not a number");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isGraph.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isGraph(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isGraph(myChar)) // tests if myChar is a printable character but not a blank space.
54-
{
55-
Serial.println("The character is printable");
53+
if (isGraph(myChar)) { // tests if myChar is a printable character but not a blank space.
54+
Serial.println("The character is printable");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not printable");
56+
else {
57+
Serial.println("The character is not printable");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isHexadecimalDigit.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isHexadecimalDigit(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isHexadecimalDigit(myChar)) // tests if myChar is an hexadecimal digit
54-
{
55-
Serial.println("The character is an hexadecimal digit");
53+
if (isHexadecimalDigit(myChar)) { // tests if myChar is an hexadecimal digit
54+
Serial.println("The character is an hexadecimal digit");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not an hexadecimal digit");
56+
else {
57+
Serial.println("The character is not an hexadecimal digit");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isLowerCase.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isLowerCase(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isLowerCase(myChar)) // tests if myChar is a lower case letter
54-
{
55-
Serial.println("The character is lower case");
53+
if (isLowerCase(myChar)) { // tests if myChar is a lower case letter
54+
Serial.println("The character is lower case");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not lower case");
56+
else {
57+
Serial.println("The character is not lower case");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isPrintable.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isPrintable(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isPrintable(myChar)) // 출력 가능한 문자인지 테스트.
54-
{
55-
Serial.println("The character is printable");
53+
if (isPrintable(myChar)) { // 출력 가능한 문자인지 테스트.
54+
Serial.println("The character is printable");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not printable");
56+
else {
57+
Serial.println("The character is not printable");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isPunct.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isPunct(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isPunct(myChar)) // tests if myChar is a punctuation character
54-
{
55-
Serial.println("The character is a punctuation");
53+
if (isPunct(myChar)) { // tests if myChar is a punctuation character
54+
Serial.println("The character is a punctuation");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not a punctuation");
56+
else {
57+
Serial.println("The character is not a punctuation");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isSpace.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ isSpace(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isSpace(myChar)) // tests if myChar is the space character
54-
{
55-
Serial.println("The character is a space");
53+
if (isSpace(myChar)) { // tests if myChar is the space character
54+
Serial.println("The character is a space");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not a space");
56+
else {
57+
Serial.println("The character is not a space");
6058
}
61-
6259
----
6360

6461
--

Language/Functions/Characters/isUpperCase.adoc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ isUpperCase(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isUpperCase(myChar)) // tests if myChar is an upeer case letter
54-
{
55-
Serial.println("The character is upper case");
53+
if (isUpperCase(myChar)) { // tests if myChar is an upeer case letter
54+
Serial.println("The character is upper case");
5655
}
57-
else
58-
{
59-
Serial.println("The character is not upper case");
56+
else {
57+
Serial.println("The character is not upper case");
6058
}
6159
6260
----

Language/Functions/Characters/isWhitespace.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,12 @@ isWhitespace(thisChar)
4949

5050
[source,arduino]
5151
----
52-
if (isWhitespace(myChar)) // tests if myChar is a white space
53-
{
54-
Serial.println("The character is a white space");
52+
if (isWhitespace(myChar)) { // tests if myChar is a white space
53+
Serial.println("The character is a white space");
5554
}
56-
else
57-
{
58-
Serial.println("The character is not a white space");
55+
else {
56+
Serial.println("The character is not a white space");
5957
}
60-
6158
----
6259

6360
--

Language/Functions/Communication/Serial/available.adoc

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,22 @@ The number of bytes available to read .
5050

5151
[source,arduino]
5252
----
53-
int incomingByte = 0; // for incoming serial data
53+
int incomingByte = 0; // for incoming serial data
5454
5555
void setup() {
56-
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
56+
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
5757
}
5858
5959
void loop() {
60-
61-
// send data only when you receive data:
62-
if (Serial.available() > 0) {
63-
// read the incoming byte:
64-
incomingByte = Serial.read();
65-
66-
// say what you got:
67-
Serial.print("I received: ");
68-
Serial.println(incomingByte, DEC);
69-
}
60+
// send data only when you receive data:
61+
if (Serial.available() > 0) {
62+
// read the incoming byte:
63+
incomingByte = Serial.read();
64+
65+
// say what you got:
66+
Serial.print("I received: ");
67+
Serial.println(incomingByte, DEC);
68+
}
7069
}
7170
----
7271
[%hardbreaks]
@@ -77,15 +76,13 @@ void loop() {
7776
void setup() {
7877
Serial.begin(9600);
7978
Serial1.begin(9600);
80-
8179
}
8280
8381
void loop() {
8482
// read from port 0, send to port 1:
8583
if (Serial.available()) {
8684
int inByte = Serial.read();
8785
Serial1.print(inByte, DEC);
88-
8986
}
9087
// read from port 1, send to port 0:
9188
if (Serial1.available()) {

0 commit comments

Comments
 (0)