Skip to content

Commit ddf2dea

Browse files
committed
chore(ArduinoAPI): update code style to webkit
1 parent 5a4fd20 commit ddf2dea

File tree

10 files changed

+634
-509
lines changed

10 files changed

+634
-509
lines changed

Keilduino/ArduinoAPI/WCharacter.h

Lines changed: 47 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
/*
2-
WCharacter.h - Character utility functions for Wiring & Arduino
3-
Copyright (c) 2010 Hernando Barragan. All right reserved.
4-
5-
This library is free software; you can redistribute it and/or
6-
modify it under the terms of the GNU Lesser General Public
7-
License as published by the Free Software Foundation; either
8-
version 2.1 of the License, or (at your option) any later version.
9-
10-
This library is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13-
Lesser General Public License for more details.
14-
15-
You should have received a copy of the GNU Lesser General Public
16-
License along with this library; if not, write to the Free Software
17-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1+
/**
2+
* WCharacter.h - Character utility functions for Wiring & Arduino
3+
* Copyright (c) 2010 Hernando Barragan. All right reserved.
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 2.1 of the License, or (at your option) any later version.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library; if not, write to the Free Software
17+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
19-
20-
#ifndef Character_h
21-
#define Character_h
19+
#ifndef CHARACTER_H
20+
#define CHARACTER_H
2221

2322
#include <ctype.h>
2423

@@ -41,131 +40,115 @@ inline bool isUpperCase(int c) __attribute__((always_inline));
4140
inline bool isHexadecimalDigit(int c) __attribute__((always_inline));
4241
inline int toAscii(int c) __attribute__((always_inline));
4342
inline int toLowerCase(int c) __attribute__((always_inline));
44-
inline int toUpperCase(int c)__attribute__((always_inline));
45-
43+
inline int toUpperCase(int c) __attribute__((always_inline));
4644

47-
// Checks for an alphanumeric character.
45+
// Checks for an alphanumeric character.
4846
// It is equivalent to (isalpha(c) || isdigit(c)).
49-
inline bool isAlphaNumeric(int c)
47+
inline bool isAlphaNumeric(int c)
5048
{
51-
return ( isalnum(c) == 0 ? false : true);
49+
return (isalnum(c) == 0 ? false : true);
5250
}
5351

54-
55-
// Checks for an alphabetic character.
52+
// Checks for an alphabetic character.
5653
// It is equivalent to (isupper(c) || islower(c)).
5754
inline bool isAlpha(int c)
5855
{
59-
return ( isalpha(c) == 0 ? false : true);
56+
return (isalpha(c) == 0 ? false : true);
6057
}
6158

62-
63-
// Checks whether c is a 7-bit unsigned char value
59+
// Checks whether c is a 7-bit unsigned char value
6460
// that fits into the ASCII character set.
6561
inline bool isAscii(int c)
6662
{
67-
return ( isascii (c) == 0 ? false : true);
63+
return (isascii(c) == 0 ? false : true);
6864
}
6965

70-
7166
// Checks for a blank character, that is, a space or a tab.
7267
inline bool isWhitespace(int c)
7368
{
74-
return ( isblank (c) == 0 ? false : true);
69+
return (isblank(c) == 0 ? false : true);
7570
}
7671

77-
7872
// Checks for a control character.
7973
inline bool isControl(int c)
8074
{
81-
return ( iscntrl (c) == 0 ? false : true);
75+
return (iscntrl(c) == 0 ? false : true);
8276
}
8377

84-
8578
// Checks for a digit (0 through 9).
8679
inline bool isDigit(int c)
8780
{
88-
return ( isdigit (c) == 0 ? false : true);
81+
return (isdigit(c) == 0 ? false : true);
8982
}
9083

91-
9284
// Checks for any printable character except space.
9385
inline bool isGraph(int c)
9486
{
95-
return ( isgraph (c) == 0 ? false : true);
87+
return (isgraph(c) == 0 ? false : true);
9688
}
9789

98-
9990
// Checks for a lower-case character.
10091
inline bool isLowerCase(int c)
10192
{
102-
return (islower (c) == 0 ? false : true);
93+
return (islower(c) == 0 ? false : true);
10394
}
10495

105-
10696
// Checks for any printable character including space.
10797
inline bool isPrintable(int c)
10898
{
109-
return ( isprint (c) == 0 ? false : true);
99+
return (isprint(c) == 0 ? false : true);
110100
}
111101

112-
113-
// Checks for any printable character which is not a space
102+
// Checks for any printable character which is not a space
114103
// or an alphanumeric character.
115104
inline bool isPunct(int c)
116105
{
117-
return ( ispunct (c) == 0 ? false : true);
106+
return (ispunct(c) == 0 ? false : true);
118107
}
119108

120-
121-
// Checks for white-space characters. For the avr-libc library,
122-
// these are: space, formfeed ('\f'), newline ('\n'), carriage
109+
// Checks for white-space characters. For the avr-libc library,
110+
// these are: space, formfeed ('\f'), newline ('\n'), carriage
123111
// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
124112
inline bool isSpace(int c)
125113
{
126-
return ( isspace (c) == 0 ? false : true);
114+
return (isspace(c) == 0 ? false : true);
127115
}
128116

129-
130117
// Checks for an uppercase letter.
131118
inline bool isUpperCase(int c)
132119
{
133-
return ( isupper (c) == 0 ? false : true);
120+
return (isupper(c) == 0 ? false : true);
134121
}
135122

136-
137-
// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7
123+
// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7
138124
// 8 9 a b c d e f A B C D E F.
139125
inline bool isHexadecimalDigit(int c)
140126
{
141-
return ( isxdigit (c) == 0 ? false : true);
127+
return (isxdigit(c) == 0 ? false : true);
142128
}
143129

144-
145-
// Converts c to a 7-bit unsigned char value that fits into the
130+
// Converts c to a 7-bit unsigned char value that fits into the
146131
// ASCII character set, by clearing the high-order bits.
147132
inline int toAscii(int c)
148133
{
149-
return toascii (c);
134+
return toascii(c);
150135
}
151136

152-
153137
// Warning:
154-
// Many people will be unhappy if you use this function.
155-
// This function will convert accented letters into random
138+
// Many people will be unhappy if you use this function.
139+
// This function will convert accented letters into random
156140
// characters.
157141

158142
// Converts the letter c to lower case, if possible.
159143
inline int toLowerCase(int c)
160144
{
161-
return tolower (c);
145+
return tolower(c);
162146
}
163147

164-
165148
// Converts the letter c to upper case, if possible.
166149
inline int toUpperCase(int c)
167150
{
168-
return toupper (c);
151+
return toupper(c);
169152
}
170153

171154
#endif

Keilduino/ArduinoAPI/WMath.cpp

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,41 @@
2020
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
* SOFTWARE.
2222
*/
23+
24+
/*********************
25+
* INCLUDES
26+
*********************/
27+
2328
#include "WMath.h"
2429
#include <stdlib.h>
2530

31+
/*********************
32+
* DEFINES
33+
*********************/
34+
35+
/**********************
36+
* TYPEDEFS
37+
**********************/
38+
39+
/**********************
40+
* STATIC PROTOTYPES
41+
**********************/
42+
43+
/**********************
44+
* STATIC VARIABLES
45+
**********************/
46+
47+
/**********************
48+
* MACROS
49+
**********************/
50+
51+
/**********************
52+
* GLOBAL FUNCTIONS
53+
**********************/
54+
2655
void randomSeed(unsigned long seed)
2756
{
28-
if (seed == 0)
29-
{
57+
if (seed == 0) {
3058
return;
3159
}
3260

@@ -35,8 +63,7 @@ void randomSeed(unsigned long seed)
3563

3664
long random(long howbig)
3765
{
38-
if (howbig == 0)
39-
{
66+
if (howbig == 0) {
4067
return 0;
4168
}
4269

@@ -45,21 +72,10 @@ long random(long howbig)
4572

4673
long random(long howsmall, long howbig)
4774
{
48-
if (howsmall >= howbig)
49-
{
75+
if (howsmall >= howbig) {
5076
return howsmall;
5177
}
5278

5379
long diff = howbig - howsmall;
5480
return random(diff) + howsmall;
5581
}
56-
57-
unsigned int makeWord(unsigned int w)
58-
{
59-
return w;
60-
}
61-
62-
unsigned int makeWord(unsigned char h, unsigned char l)
63-
{
64-
return (h << 8) | l;
65-
}

Keilduino/ArduinoAPI/WMath.h

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* MIT License
3-
* Copyright (c) 2017 - 2022 _VIFEXTech
3+
* Copyright (c) 2017 - 2025 _VIFEXTech
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal
@@ -20,13 +20,65 @@
2020
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
* SOFTWARE.
2222
*/
23-
#ifndef __WMATH_H
24-
#define __WMATH_H
23+
#ifndef WMATH_H
24+
#define WMATH_H
2525

26+
/*********************
27+
* INCLUDES
28+
*********************/
29+
30+
/*********************
31+
* DEFINES
32+
*********************/
33+
34+
/**********************
35+
* TYPEDEFS
36+
**********************/
37+
38+
/**********************
39+
* GLOBAL PROTOTYPES
40+
**********************/
41+
42+
/**
43+
* @brief Seed the random number generator with a specific seed value.
44+
* @param seed The seed value to initialize the random number generator.
45+
*/
2646
void randomSeed(unsigned long seed);
47+
48+
/**
49+
* @brief Generate a random number between 0 and the specified maximum value.
50+
* @param howbig The upper limit for the random number (exclusive).
51+
* @return A random number between 0 and howbig - 1.
52+
*/
2753
long random(long howbig);
54+
55+
/**
56+
* @brief Generate a random number between the specified minimum and maximum values.
57+
* @param howsmall The lower limit for the random number (inclusive).
58+
* @param howbig The upper limit for the random number (exclusive).
59+
* @return A random number between howsmall and howbig - 1.
60+
*/
2861
long random(long howsmall, long howbig);
29-
unsigned int makeWord(unsigned int w);
30-
unsigned int makeWord(unsigned char h, unsigned char l);
3162

32-
#endif
63+
/**
64+
* @brief Create a word (16-bit value) from a single unsigned integer.
65+
* @param w The unsigned integer to convert to a word.
66+
* @return The word created from the input integer.
67+
*/
68+
static inline unsigned int makeWord(unsigned int w)
69+
{
70+
return w;
71+
}
72+
73+
/**
74+
* @brief Create a word (16-bit value) from two unsigned char values.
75+
* @param h The high byte of the word.
76+
* @param l The low byte of the word.
77+
* @return The word created from the input bytes.
78+
*/
79+
static inline unsigned int makeWord(unsigned char h, unsigned char l)
80+
{
81+
return (h << 8) | l;
82+
}
83+
84+
#endif /* WMATH_H */

Keilduino/ArduinoAPI/WProgram.h

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
1-
#ifndef __WPROGRAM_H
2-
#define __WPROGRAM_H
1+
/*
2+
* MIT License
3+
* Copyright (c) 2017 - 2025 _VIFEXTech
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*/
23+
#ifndef WPROGRAM_H
24+
#define WPROGRAM_H
25+
26+
/*********************
27+
* INCLUDES
28+
*********************/
329

430
#include "Arduino.h"
531

6-
#endif
32+
#endif /* WPROGRAM_H */

0 commit comments

Comments
 (0)