Skip to content

Commit 8dc44b5

Browse files
Astyle format variants format (#1295)
1 parent 7851dc8 commit 8dc44b5

File tree

35 files changed

+661
-645
lines changed

35 files changed

+661
-645
lines changed

tests/restyle.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ for dir in ./cores/rp2040 ./libraries/EEPROM ./libraries/I2S ./libraries/SingleF
1010
./libraries/Updater ./libraries/HTTPClient ./libraries/HTTPUpdate \
1111
./libraries/WebServer ./libraries/HTTPUpdateServer ./libraries/DNSServer \
1212
./libraries/Joystick ./libraries/Keyboard ./libraries/Mouse \
13-
./libraries/JoystickBT ./libraries/KeyboardBT \
13+
./libraries/JoystickBT ./libraries/KeyboardBT ./variants \
1414
./libraries/MouseBT ./libraries/SerialBT ./libraries/HID_Bluetooth \
1515
./libraries/JoystickBLE ./libraries/KeyboardBLE ./libraries/MouseBLE ; do
1616
find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" \) -a \! -path '*api*' -exec astyle --suffix=none --options=./tests/astyle_core.conf \{\} \;

variants/arduino_nano_connect/nina_pins.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
#define _NINA_PINS_
55

66
/******************************************************************************
7-
* INCLUDE
7+
INCLUDE
88
******************************************************************************/
99

1010
#include "Arduino.h"
1111

1212
/******************************************************************************
13-
* TYPEDEF
13+
TYPEDEF
1414
******************************************************************************/
1515

1616
int getAnalogReadResolution();
1717

1818
class NinaPin {
1919
public:
20-
NinaPin(int _pin) : pin(_pin) {};
21-
int get() {
22-
return pin;
23-
};
24-
int analogReadResolution() {
25-
return getAnalogReadResolution();
26-
};
27-
bool operator== (NinaPin const & other) const {
28-
return pin == other.pin;
29-
}
30-
//operator int() = delete;
31-
__attribute__ ((error("Change me to a #define"))) operator int();
20+
NinaPin(int _pin) : pin(_pin) {};
21+
int get() {
22+
return pin;
23+
};
24+
int analogReadResolution() {
25+
return getAnalogReadResolution();
26+
};
27+
bool operator== (NinaPin const & other) const {
28+
return pin == other.pin;
29+
}
30+
//operator int() = delete;
31+
__attribute__((error("Change me to a #define"))) operator int();
3232
private:
33-
int pin;
33+
int pin;
3434
};
3535

3636
extern NinaPin LEDR;
@@ -44,13 +44,13 @@ extern NinaPin A7;
4444
#define NINA_PINS_AS_CLASS
4545

4646
/******************************************************************************
47-
* FUNCTION DECLARATION
47+
FUNCTION DECLARATION
4848
******************************************************************************/
4949

50-
void pinMode (NinaPin pin, PinMode mode);
51-
PinStatus digitalRead (NinaPin pin);
50+
void pinMode(NinaPin pin, PinMode mode);
51+
PinStatus digitalRead(NinaPin pin);
5252
void digitalWrite(NinaPin pin, PinStatus value);
53-
int analogRead (NinaPin pin);
54-
void analogWrite (NinaPin pin, int value);
53+
int analogRead(NinaPin pin);
54+
void analogWrite(NinaPin pin, int value);
5555

5656
#endif /* _NINA_PINS_ */

variants/arduino_nano_connect/pins_arduino.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ static const uint8_t D13 = (6u);
2121
static const uint8_t D14 = (26u);
2222
static const uint8_t D15 = (27u);
2323
static const uint8_t D16 = (28u);
24-
static const uint8_t D17 = (29u);
25-
static const uint8_t D18 = (12u);
26-
static const uint8_t D19 = (13u);
24+
static const uint8_t D17 = (29u);
25+
static const uint8_t D18 = (12u);
26+
static const uint8_t D19 = (13u);
2727
static const uint8_t D20 = (2u);
2828
static const uint8_t D21 = (24u);
2929
static const uint8_t D22 = (22u);

variants/challenger_2040_lora/pins_arduino.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@
4747

4848
#define LED_BUILTIN PIN_LED
4949

50-
static const uint8_t D0 = (16u);
51-
static const uint8_t D1 = (17u);
52-
static const uint8_t D2 = (20u);
53-
static const uint8_t D3 = (23u);
54-
static const uint8_t D4 = (22u);
55-
static const uint8_t D5 = (2u);
56-
static const uint8_t D6 = (3u);
57-
static const uint8_t D7 = (0u);
58-
static const uint8_t D8 = (1u);
59-
static const uint8_t D9 = (4u);
60-
static const uint8_t D10 = (5u);
61-
static const uint8_t D11 = (6u);
62-
static const uint8_t D12 = (7u);
63-
static const uint8_t D13 = (8u);
50+
static const uint8_t D0 = (16u);
51+
static const uint8_t D1 = (17u);
52+
static const uint8_t D2 = (20u);
53+
static const uint8_t D3 = (23u);
54+
static const uint8_t D4 = (22u);
55+
static const uint8_t D5 = (2u);
56+
static const uint8_t D6 = (3u);
57+
static const uint8_t D7 = (0u);
58+
static const uint8_t D8 = (1u);
59+
static const uint8_t D9 = (4u);
60+
static const uint8_t D10 = (5u);
61+
static const uint8_t D11 = (6u);
62+
static const uint8_t D12 = (7u);
63+
static const uint8_t D13 = (8u);
6464
static const uint8_t D14 = (13u);
6565
static const uint8_t D15 = (14u);
6666
static const uint8_t D16 = (15u);

variants/challenger_2040_lte/ChallengerLTE.cpp

Lines changed: 78 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -22,92 +22,99 @@
2222
#include <ChallengerLTE.h>
2323

2424
Challenger2040LTEClass::Challenger2040LTEClass() {
25-
pinMode(PIN_SARA_ON, OUTPUT);
26-
digitalWrite(PIN_SARA_ON, LOW); // Output register must always be low
27-
pinMode(PIN_SARA_ON, INPUT_PULLUP);
25+
pinMode(PIN_SARA_ON, OUTPUT);
26+
digitalWrite(PIN_SARA_ON, LOW); // Output register must always be low
27+
pinMode(PIN_SARA_ON, INPUT_PULLUP);
2828

29-
pinMode(PIN_SARA_RST, INPUT_PULLUP); // Keep as input for now
29+
pinMode(PIN_SARA_RST, INPUT_PULLUP); // Keep as input for now
3030

31-
pinMode(PIN_SARA_PWR, OUTPUT);
32-
digitalWrite(PIN_SARA_PWR, LOW); // No power to SARA yet
33-
serialPortConfigured = false;
31+
pinMode(PIN_SARA_PWR, OUTPUT);
32+
digitalWrite(PIN_SARA_PWR, LOW); // No power to SARA yet
33+
serialPortConfigured = false;
3434
}
3535

3636
// Do a HW reset by applying a low pulse to the reset line for 1mSec
3737
bool Challenger2040LTEClass::doPowerOn() {
38-
bool ret;
39-
digitalWrite(PIN_SARA_PWR, HIGH); // Make sure LDO is on
40-
delay(100); // let the power stabilize
41-
pinMode(PIN_SARA_ON, OUTPUT); // Pull power on control low
42-
delay(150); // For 150mS
43-
pinMode(PIN_SARA_ON, INPUT_PULLUP); // before releasing it again.
44-
delay(1000); // Now wait for 1 second
45-
SARA_SERIAL_PORT.begin(DEFAULT_SARA_BAUDRATE);
46-
serialPortConfigured = true;
47-
ret = isAlive(); // Makie sure the modem is
48-
// up and running
49-
50-
delay(250); // Allow for any extra characters
51-
// before flushing the input buffer
52-
while(SARA_SERIAL_PORT.available()) SARA_SERIAL_PORT.read();
53-
54-
return ret;
38+
bool ret;
39+
digitalWrite(PIN_SARA_PWR, HIGH); // Make sure LDO is on
40+
delay(100); // let the power stabilize
41+
pinMode(PIN_SARA_ON, OUTPUT); // Pull power on control low
42+
delay(150); // For 150mS
43+
pinMode(PIN_SARA_ON, INPUT_PULLUP); // before releasing it again.
44+
delay(1000); // Now wait for 1 second
45+
SARA_SERIAL_PORT.begin(DEFAULT_SARA_BAUDRATE);
46+
serialPortConfigured = true;
47+
ret = isAlive(); // Makie sure the modem is
48+
// up and running
49+
50+
delay(250); // Allow for any extra characters
51+
// before flushing the input buffer
52+
while (SARA_SERIAL_PORT.available()) {
53+
SARA_SERIAL_PORT.read();
54+
}
55+
56+
return ret;
5557
}
5658

5759
// Checks to see if the modem responds to the "AT" poll command.
5860
bool Challenger2040LTEClass::isAlive(uint32_t timeout) {
59-
SARA_SERIAL_PORT.setTimeout(100);
60-
SARA_SERIAL_PORT.println(F("AT"));
61-
String rdy = SARA_SERIAL_PORT.readStringUntil('\n');
62-
while(!rdy.startsWith(F("OK")) && --timeout) {
61+
SARA_SERIAL_PORT.setTimeout(100);
6362
SARA_SERIAL_PORT.println(F("AT"));
64-
rdy = SARA_SERIAL_PORT.readStringUntil('\n');
65-
//Serial.println(rdy);
66-
}
67-
SARA_SERIAL_PORT.setTimeout(1000); // Restore serial timeout
68-
if (timeout)
69-
return true;
70-
return false;
63+
String rdy = SARA_SERIAL_PORT.readStringUntil('\n');
64+
while (!rdy.startsWith(F("OK")) && --timeout) {
65+
SARA_SERIAL_PORT.println(F("AT"));
66+
rdy = SARA_SERIAL_PORT.readStringUntil('\n');
67+
//Serial.println(rdy);
68+
}
69+
SARA_SERIAL_PORT.setTimeout(1000); // Restore serial timeout
70+
if (timeout) {
71+
return true;
72+
}
73+
return false;
7174
}
7275

7376
// Return the current MNO profile
7477
// Returns -1 if the serial port is not yet setup or the number of the current
7578
// MNO profile setting from the modem.
7679
int Challenger2040LTEClass::getMNOProfile() {
77-
if (!serialPortConfigured)
78-
return -1;
79-
SARA_SERIAL_PORT.println(F("AT+UMNOPROF?"));
80-
String resp = getResponse();
81-
return resp.substring(resp.indexOf("+UMNOPROF: ") + 11).toInt();
80+
if (!serialPortConfigured) {
81+
return -1;
82+
}
83+
SARA_SERIAL_PORT.println(F("AT+UMNOPROF?"));
84+
String resp = getResponse();
85+
return resp.substring(resp.indexOf("+UMNOPROF: ") + 11).toInt();
8286
}
8387

8488
// Set a new MNO profile
8589
// Returns false if the serial port is not yet setup
8690
bool Challenger2040LTEClass::setMNOProfile(int profile) {
87-
if (!serialPortConfigured)
88-
return false;
89-
String cmd = "AT+UMNOPROF=" + String(profile) + ",1";
90-
SARA_SERIAL_PORT.println(cmd);
91-
92-
if (!getResponse().endsWith("OK")) {
93-
return false;
94-
}
95-
return true;
91+
if (!serialPortConfigured) {
92+
return false;
93+
}
94+
String cmd = "AT+UMNOPROF=" + String(profile) + ",1";
95+
SARA_SERIAL_PORT.println(cmd);
96+
97+
if (!getResponse().endsWith("OK")) {
98+
return false;
99+
}
100+
return true;
96101
}
97102

98103
// Disable power save features
99104
bool Challenger2040LTEClass::enablePS(bool enable) {
100-
if (!serialPortConfigured)
101-
return false;
102-
if (enable)
103-
SARA_SERIAL_PORT.println(F("AT+CPSMS=1"));
104-
else
105-
SARA_SERIAL_PORT.println(F("AT+CPSMS=0"));
106-
107-
if (!getResponse().endsWith("OK")) {
108-
return false;
109-
}
110-
return true;
105+
if (!serialPortConfigured) {
106+
return false;
107+
}
108+
if (enable) {
109+
SARA_SERIAL_PORT.println(F("AT+CPSMS=1"));
110+
} else {
111+
SARA_SERIAL_PORT.println(F("AT+CPSMS=0"));
112+
}
113+
114+
if (!getResponse().endsWith("OK")) {
115+
return false;
116+
}
117+
return true;
111118
}
112119

113120
// Get a response from SARA
@@ -116,18 +123,19 @@ bool Challenger2040LTEClass::enablePS(bool enable) {
116123
// from control characters and appended with a tab character as a separator.
117124
//
118125
String Challenger2040LTEClass::getResponse(int timeout) {
119-
SARA_SERIAL_PORT.setTimeout(2000); // allow for really slow responses
126+
SARA_SERIAL_PORT.setTimeout(2000); // allow for really slow responses
120127

121-
String resp = SARA_SERIAL_PORT.readStringUntil('\n');
122-
resp.trim();
123-
String acc = resp;
124-
while(resp.indexOf("OK") == -1 && resp.indexOf("ERROR") == -1 && --timeout) {
125-
resp = SARA_SERIAL_PORT.readStringUntil('\n');
128+
String resp = SARA_SERIAL_PORT.readStringUntil('\n');
126129
resp.trim();
127-
if (resp.length())
128-
acc += "\t" + resp;
129-
}
130-
return acc;
130+
String acc = resp;
131+
while (resp.indexOf("OK") == -1 && resp.indexOf("ERROR") == -1 && --timeout) {
132+
resp = SARA_SERIAL_PORT.readStringUntil('\n');
133+
resp.trim();
134+
if (resp.length()) {
135+
acc += "\t" + resp;
136+
}
137+
}
138+
return acc;
131139
}
132140

133141
Challenger2040LTEClass Challenger2040LTE;

variants/challenger_2040_lte/ChallengerLTE.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define DEFAULT_SARA_BAUDRATE 115200
2323

2424
class Challenger2040LTEClass {
25-
public:
25+
public:
2626
Challenger2040LTEClass();
2727
bool doPowerOn();
2828
bool isAlive(uint32_t timeout = 50);
@@ -31,7 +31,7 @@ class Challenger2040LTEClass {
3131
bool enablePS(bool enable = true);
3232
String getResponse(int timeout = 5);
3333

34-
private:
34+
private:
3535
bool serialPortConfigured;
3636
};
3737

variants/challenger_2040_lte/pins_arduino.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,28 @@
4949

5050
#define LED_BUILTIN PIN_LED
5151

52-
static const uint8_t D0 = (16u);
53-
static const uint8_t D1 = (17u);
54-
static const uint8_t D2 = (24u);
55-
static const uint8_t D3 = (23u);
56-
static const uint8_t D4 = (22u);
57-
static const uint8_t D5 = (2u);
58-
static const uint8_t D6 = (3u);
59-
static const uint8_t D7 = (0u);
60-
static const uint8_t D8 = (1u);
61-
static const uint8_t D9 = (12u);
62-
static const uint8_t D10 = (11u);
63-
static const uint8_t D11 = (10u);
64-
static const uint8_t D12 = (9u);
65-
static const uint8_t D13 = (8u);
66-
static const uint8_t D14 = (13u);
67-
static const uint8_t D15 = (14u);
68-
static const uint8_t D16 = (15u);
69-
static const uint8_t D17 = (19u);
52+
static const uint8_t D0 = (16u);
53+
static const uint8_t D1 = (17u);
54+
static const uint8_t D2 = (24u);
55+
static const uint8_t D3 = (23u);
56+
static const uint8_t D4 = (22u);
57+
static const uint8_t D5 = (2u);
58+
static const uint8_t D6 = (3u);
59+
static const uint8_t D7 = (0u);
60+
static const uint8_t D8 = (1u);
61+
static const uint8_t D9 = (12u);
62+
static const uint8_t D10 = (11u);
63+
static const uint8_t D11 = (10u);
64+
static const uint8_t D12 = (9u);
65+
static const uint8_t D13 = (8u);
66+
static const uint8_t D14 = (13u);
67+
static const uint8_t D15 = (14u);
68+
static const uint8_t D16 = (15u);
69+
static const uint8_t D17 = (19u);
7070

71-
static const uint8_t A0 = (29u);
72-
static const uint8_t A1 = (28u);
73-
static const uint8_t A2 = (27u);
74-
static const uint8_t A3 = (26u);
75-
static const uint8_t A4 = (25u);
76-
static const uint8_t A5 = (21u);
71+
static const uint8_t A0 = (29u);
72+
static const uint8_t A1 = (28u);
73+
static const uint8_t A2 = (27u);
74+
static const uint8_t A3 = (26u);
75+
static const uint8_t A4 = (25u);
76+
static const uint8_t A5 = (21u);

0 commit comments

Comments
 (0)