Skip to content

Commit 33295d3

Browse files
committed
apply clang-format
1 parent c269a12 commit 33295d3

14 files changed

+294
-309
lines changed

src/button.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#include "button.h"
66
#include "arduino.h"
77

8-
Button::Button(int port) : port(port) {
9-
pinMode(port, INPUT);
10-
}
8+
Button::Button(int port) : port(port) { pinMode(port, INPUT); }
119

12-
bool Button::isPressed() {
13-
return digitalRead(port) == LOW;
14-
}
10+
bool Button::isPressed() { return digitalRead(port) == LOW; }

src/button.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
class Button {
99
public:
10-
Button(int port);
11-
bool isPressed();
10+
Button(int port);
11+
bool isPressed();
12+
1213
private:
13-
const int port;
14+
const int port;
1415
};
1516

1617
#endif

src/led.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,21 @@
88
// public
99

1010
LED::LED(int port) : port(port) {
11-
pinMode(port, OUTPUT);
12-
off();
11+
pinMode(port, OUTPUT);
12+
off();
1313
}
1414

15-
void LED::on() {
16-
set(true);
17-
}
15+
void LED::on() { set(true); }
1816

19-
void LED::off() {
20-
set(false);
21-
}
17+
void LED::off() { set(false); }
2218

23-
void LED::toggle() {
24-
set(!get());
25-
}
19+
void LED::toggle() { set(!get()); }
2620

2721
// private
2822

29-
bool LED::get() {
30-
return onOff;
31-
}
23+
bool LED::get() { return onOff; }
3224

3325
void LED::set(bool onOff) {
34-
this->onOff = onOff;
35-
digitalWrite(port, onOff ? LOW : HIGH);
26+
this->onOff = onOff;
27+
digitalWrite(port, onOff ? LOW : HIGH);
3628
}

src/led.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99

1010
class LED {
1111
public:
12-
LED(int port);
13-
void on();
14-
void off();
15-
void toggle();
12+
LED(int port);
13+
void on();
14+
void off();
15+
void toggle();
16+
1617
private:
17-
const int port;
18-
bool onOff;
19-
bool get();
20-
void set(bool onOff);
18+
const int port;
19+
bool onOff;
20+
bool get();
21+
void set(bool onOff);
2122
};
2223

2324
#endif

src/logger.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,39 @@
88
// public
99

1010
void LoggerClass::begin(LogLevel level, int speed) {
11-
LoggerClass::level = level;
12-
Serial.begin(speed);
13-
delay(500);
11+
LoggerClass::level = level;
12+
Serial.begin(speed);
13+
delay(500);
1414
}
1515

1616
void LoggerClass::trace(const char *message) {
17-
println(LogLevel::TRACE, message);
17+
println(LogLevel::TRACE, message);
1818
}
1919

2020
void LoggerClass::debug(const char *message) {
21-
println(LogLevel::DEBUG, message);
21+
println(LogLevel::DEBUG, message);
2222
}
2323

2424
void LoggerClass::info(const char *message) {
25-
println(LogLevel::INFO, message);
25+
println(LogLevel::INFO, message);
2626
}
2727

2828
void LoggerClass::warn(const char *message) {
29-
println(LogLevel::WARN, message);
29+
println(LogLevel::WARN, message);
3030
}
3131

3232
void LoggerClass::error(const char *message) {
33-
println(LogLevel::ERROR, message);
33+
println(LogLevel::ERROR, message);
3434
}
3535

3636
// private
3737

3838
LogLevel LoggerClass::level = LogLevel::INFO;
3939

4040
void LoggerClass::println(LogLevel level, const char *message) {
41-
if(LoggerClass::level <= level) {
42-
Serial.println(message);
43-
}
41+
if (LoggerClass::level <= level) {
42+
Serial.println(message);
43+
}
4444
}
4545

4646
LoggerClass Logger;

src/logger.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,25 @@
66
#define logger_h
77

88
enum class LogLevel {
9-
TRACE = 0,
10-
DEBUG = 1,
11-
INFO = 2,
12-
WARN = 3,
13-
ERROR = 4,
9+
TRACE = 0,
10+
DEBUG = 1,
11+
INFO = 2,
12+
WARN = 3,
13+
ERROR = 4,
1414
};
1515

1616
class LoggerClass {
1717
public:
18-
static void begin(LogLevel level, int speed);
19-
static void trace(const char *message);
20-
static void debug(const char *message);
21-
static void info(const char *message);
22-
static void warn(const char *message);
23-
static void error(const char *message);
18+
static void begin(LogLevel level, int speed);
19+
static void trace(const char *message);
20+
static void debug(const char *message);
21+
static void info(const char *message);
22+
static void warn(const char *message);
23+
static void error(const char *message);
24+
2425
private:
25-
static LogLevel level;
26-
static void println(LogLevel level, const char *message);
26+
static LogLevel level;
27+
static void println(LogLevel level, const char *message);
2728
};
2829

2930
extern LoggerClass Logger;

src/osc_command.cpp

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,108 +3,108 @@
33
*/
44

55
#include "osc_command.h"
6-
#include <strings.h>
76
#include <ESP8266HTTPClient.h>
7+
#include <strings.h>
88

99
// public
1010

1111
OSCCommand::OSCCommand(const char *name) {
12-
request = aJson.createObject();
13-
aJson.addStringToObject(request, "name", name);
12+
request = aJson.createObject();
13+
aJson.addStringToObject(request, "name", name);
1414
}
1515

1616
OSCCommand::~OSCCommand() {
17-
aJson.deleteItem(request);
18-
aJson.deleteItem(response);
17+
aJson.deleteItem(request);
18+
aJson.deleteItem(response);
1919
}
2020

2121
int OSCCommand::execute() {
22-
char *body = aJson.print(request);
23-
24-
HTTPClient http;
25-
http.begin("192.168.1.1", 80, "/osc/commands/execute");
26-
http.addHeader("Content-Type", "application/json;charset=utf-8");
27-
http.addHeader("Accept", "application/json");
28-
statusCode = http.POST((uint8_t *)body, strlen(body));
29-
String res = http.getString();
30-
http.end();
31-
32-
strcpy(responseChars, res.c_str());
33-
response = aJson.parse(responseChars);
34-
35-
if(400 <= statusCode && statusCode <= 599) {
36-
aJsonObject *error = aJson.getObjectItem(response, "error");
37-
code = aJson.getObjectItem(error, "code")->valuestring;
38-
message = aJson.getObjectItem(error, "message")->valuestring;
39-
return 1;
40-
}
41-
42-
return 0;
22+
char *body = aJson.print(request);
23+
24+
HTTPClient http;
25+
http.begin("192.168.1.1", 80, "/osc/commands/execute");
26+
http.addHeader("Content-Type", "application/json;charset=utf-8");
27+
http.addHeader("Accept", "application/json");
28+
statusCode = http.POST((uint8_t *)body, strlen(body));
29+
String res = http.getString();
30+
http.end();
31+
32+
strcpy(responseChars, res.c_str());
33+
response = aJson.parse(responseChars);
34+
35+
if (400 <= statusCode && statusCode <= 599) {
36+
aJsonObject *error = aJson.getObjectItem(response, "error");
37+
code = aJson.getObjectItem(error, "code")->valuestring;
38+
message = aJson.getObjectItem(error, "message")->valuestring;
39+
return 1;
40+
}
41+
42+
return 0;
4343
}
4444

4545
// public Request
4646

4747
void OSCCommand::addParameter(const char *name, aJsonObject *value) {
48-
if(parameters == NULL) {
49-
parameters = aJson.createObject();
50-
aJson.addItemToObject(request, "parameters", parameters);
51-
}
48+
if (parameters == NULL) {
49+
parameters = aJson.createObject();
50+
aJson.addItemToObject(request, "parameters", parameters);
51+
}
5252

53-
aJson.addItemToObject(parameters, name, value);
53+
aJson.addItemToObject(parameters, name, value);
5454
}
5555

5656
void OSCCommand::addParameter(const char *name, const char *value) {
57-
addParameter(name, aJson.createItem(value));
57+
addParameter(name, aJson.createItem(value));
5858
}
5959

6060
void OSCCommand::addParameter(const char *name, int value) {
61-
addParameter(name, aJson.createItem(value));
61+
addParameter(name, aJson.createItem(value));
6262
}
6363

6464
void OSCCommand::addParameter(const char *name, float value) {
65-
addParameter(name, aJson.createItem(value));
65+
addParameter(name, aJson.createItem(value));
6666
}
6767

6868
// public Response
6969

7070
aJsonObject *OSCCommand::getResultObject(const char *name) {
71-
if(response == NULL) {
72-
return NULL;
73-
}
71+
if (response == NULL) {
72+
return NULL;
73+
}
7474

75-
if(results == NULL) {
76-
results = aJson.getObjectItem(response, "results");
77-
}
75+
if (results == NULL) {
76+
results = aJson.getObjectItem(response, "results");
77+
}
7878

79-
if(results == NULL) {
80-
return NULL;
81-
}
79+
if (results == NULL) {
80+
return NULL;
81+
}
8282

83-
aJson.getObjectItem(results, name);
83+
aJson.getObjectItem(results, name);
8484
}
8585

8686
aJsonObject *OSCCommand::getResultArray(const char *name) {
87-
return getResultObject(name);
87+
return getResultObject(name);
8888
}
8989

9090
char *OSCCommand::getResultString(const char *name) {
91-
aJsonObject *obj = getResultObject(name);
92-
return obj == NULL ? NULL : obj->valuestring;
91+
aJsonObject *obj = getResultObject(name);
92+
return obj == NULL ? NULL : obj->valuestring;
9393
}
9494

9595
bool OSCCommand::getResultBool(const char *name) {
96-
aJsonObject *obj = getResultObject(name);
97-
return obj == NULL ? false : obj->valuebool;
96+
aJsonObject *obj = getResultObject(name);
97+
return obj == NULL ? false : obj->valuebool;
9898
}
9999

100100
int OSCCommand::getResultNumber(const char *name) {
101-
aJsonObject *obj = getResultObject(name);
102-
return obj == NULL ? 0 : obj->valueint;
101+
aJsonObject *obj = getResultObject(name);
102+
return obj == NULL ? 0 : obj->valueint;
103103
}
104104

105105
float OSCCommand::getResultFloat(const char *name) {
106-
aJsonObject *obj = getResultObject(name);
107-
return obj == NULL ? 0 : obj->valuefloat;
106+
aJsonObject *obj = getResultObject(name);
107+
return obj == NULL ? 0 : obj->valuefloat;
108108
}
109109

110110
// private

0 commit comments

Comments
 (0)