Skip to content

Commit 154f7ab

Browse files
committed
I'm making an Arduino and PlatformIO library! Haha...
0 parents  commit 154f7ab

File tree

11 files changed

+461
-0
lines changed

11 files changed

+461
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch

.vscode/extensions.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"platformio.platformio-ide"
6+
],
7+
"unwantedRecommendations": [
8+
"ms-vscode.cpptools-extension-pack"
9+
]
10+
}

.vscode/settings.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"files.associations": {
3+
"*.s": "asm-intel-x86-generic",
4+
"*.asm": "asm-intel-x86-generic",
5+
"*.luac": "lua",
6+
"initializer_list": "cpp",
7+
"map": "cpp",
8+
"utility": "cpp",
9+
"algorithm": "cpp",
10+
"associative_base": "cpp",
11+
"basic_definitions": "cpp",
12+
"bitset": "cpp",
13+
"cctype": "cpp",
14+
"char_traits": "cpp",
15+
"cmath": "cpp",
16+
"complex": "cpp",
17+
"cstddef": "cpp",
18+
"cstdio": "cpp",
19+
"cstdlib": "cpp",
20+
"cstring": "cpp",
21+
"cwchar": "cpp",
22+
"cwctype": "cpp",
23+
"deque": "cpp",
24+
"exception": "cpp",
25+
"func_exception": "cpp",
26+
"functional": "cpp",
27+
"iomanip": "cpp",
28+
"ios": "cpp",
29+
"iosfwd": "cpp",
30+
"iostream": "cpp",
31+
"istream": "cpp",
32+
"istream_helpers": "cpp",
33+
"iterator": "cpp",
34+
"iterator_base": "cpp",
35+
"limits": "cpp",
36+
"list": "cpp",
37+
"locale": "cpp",
38+
"memory": "cpp",
39+
"new": "cpp",
40+
"numeric": "cpp",
41+
"ostream": "cpp",
42+
"ostream_helpers": "cpp",
43+
"queue": "cpp",
44+
"serstream": "cpp",
45+
"set": "cpp",
46+
"sstream": "cpp",
47+
"stack": "cpp",
48+
"stdexcept": "cpp",
49+
"streambuf": "cpp",
50+
"string": "cpp",
51+
"string_iostream": "cpp",
52+
"type_traits": "cpp",
53+
"typeinfo": "cpp",
54+
"valarray": "cpp",
55+
"vector": "cpp",
56+
"debuglogging": "cpp"
57+
},
58+
"cSpell.words": [
59+
"NOPM",
60+
"NOPRE",
61+
"PRINTLNF",
62+
"PRINTNP",
63+
"PRINTNPF",
64+
"PRINTNPLN",
65+
"PRINTNPLNF",
66+
"PROGMEM"
67+
],
68+
"sonarlint.pathToCompileCommands": "${workspaceFolder}/compile_commands.json"
69+
}

compile_commands.json

Lines changed: 152 additions & 0 deletions
Large diffs are not rendered by default.

include/DebugLogging.hpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#pragma once
2+
3+
#ifdef DEBUG_LOGS_PREFIX
4+
#include <Arduino.h>
5+
6+
#pragma region // Logging without a prefix.
7+
/** @brief Simply logs whatever is passed. */
8+
#define DEBUG_PRINT_NOPRE_NOPM(...) \
9+
Serial.print(__VA_ARGS__)
10+
11+
/** @brief Logs whatever is passed, storing the input into flash memory using `F()`. */
12+
#define DEBUG_PRINT_NOPRE(string) \
13+
Serial.print(F(string))
14+
15+
/** @brief Logs whatever is passed, with a new-line at the end. */
16+
#define DEBUG_PRINT_NOPRE_LN_NOPM(...) \
17+
Serial.println(__VA_ARGS__)
18+
19+
/** @brief Logs whatever is passed, with a new-line at the end, storing the input into flash memory using `F()`. */
20+
#define DEBUG_PRINT_NOPRE_LN(string) \
21+
Serial.println(F(string))
22+
#pragma endregion
23+
24+
#pragma region // Logging with a prefix.
25+
/** @brief Logs with the prefix, and a new-line at the end, storing the input into flash memory using `F()`. */
26+
#define DEBUG_PRINT_LN(string) \
27+
Serial.print(F(DEBUG_LOGS_PREFIX)); \
28+
Serial.println(F(string))
29+
30+
/** @brief Simply logs whatever is passed with the prefix. */
31+
#define DEBUG_PRINT_NOPM(...) \
32+
Serial.print(DEBUG_LOGS_PREFIX); \
33+
Serial.print(__VA_ARGS__)
34+
35+
/** @brief Logs with the prefix, storing the input into flash memory using `F()`. */
36+
#define DEBUG_PRINT(string) \
37+
Serial.print(F(DEBUG_LOGS_PREFIX)); \
38+
Serial.print(F(string))
39+
40+
/** @brief Logs with the prefix, and a new-line at the end. */
41+
#define DEBUG_PRINT_LN_NOPM(...) \
42+
Serial.print(F(DEBUG_LOGS_PREFIX)); \
43+
Serial.println(__VA_ARGS__)
44+
#pragma endregion
45+
46+
#else // Else, we define these as empty:
47+
48+
// Without a prefix:
49+
#define DEBUG_PRINT_NOPRE_NOPM(...)
50+
#define DEBUG_PRINT_NOPRE(string)
51+
#define DEBUG_PRINT_NOPRE_LN_NOPM(...)
52+
#define DEBUG_PRINT_NOPRE_LN(string)
53+
54+
// With a prefix:
55+
#define DEBUG_PRINT_NOPM(...)
56+
#define DEBUG_PRINT(string)
57+
#define DEBUG_PRINT_LN_NOPM(...)
58+
#define DEBUG_PRINT_LN(string)
59+
60+
#endif

include/ErrorLogging.hpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#pragma once
2+
3+
#ifdef ERROR_LOGS_PREFIX
4+
#include <Arduino.h>
5+
6+
#pragma region // Logging without a prefix.
7+
/** @brief Simply logs whatever is passed. */
8+
#define ERROR_PRINT_NOPRE_NOPM(...) \
9+
Serial.print(__VA_ARGS__)
10+
11+
/** @brief Logs whatever is passed, storing the input into flash memory using `F()`. */
12+
#define ERROR_PRINT_NOPRE(string) \
13+
Serial.print(F(string))
14+
15+
/** @brief Logs whatever is passed, with a new-line at the end. */
16+
#define ERROR_PRINT_NOPRE_LN_NOPM(...) \
17+
Serial.println(__VA_ARGS__)
18+
19+
/** @brief Logs whatever is passed, with a new-line at the end, storing the input into flash memory using `F()`. */
20+
#define ERROR_PRINT_NOPRE_LN(string) \
21+
Serial.println(F(string))
22+
#pragma endregion
23+
24+
#pragma region // Logging with a prefix.
25+
/** @brief Logs with the prefix, and a new-line at the end, storing the input into flash memory using `F()`. */
26+
#define ERROR_PRINT_LN(string) \
27+
Serial.print(F(ERROR_LOGS_PREFIX)); \
28+
Serial.println(F(string))
29+
30+
/** @brief Simply logs whatever is passed with the prefix. */
31+
#define ERROR_PRINT_NOPM(...) \
32+
Serial.print(ERROR_LOGS_PREFIX); \
33+
Serial.print(__VA_ARGS__)
34+
35+
/** @brief Logs with the prefix, storing the input into flash memory using `F()`. */
36+
#define ERROR_PRINT(string) \
37+
Serial.print(F(ERROR_LOGS_PREFIX)); \
38+
Serial.print(F(string))
39+
40+
/** @brief Logs with the prefix, and a new-line at the end. */
41+
#define ERROR_PRINT_LN_NOPM(...) \
42+
Serial.print(F(ERROR_LOGS_PREFIX)); \
43+
Serial.println(__VA_ARGS__)
44+
#pragma endregion
45+
46+
#else // Else, we define these as empty:
47+
48+
// Without a prefix:
49+
#define ERROR_PRINT_NOPRE_NOPM(...)
50+
#define ERROR_PRINT_NOPRE(string)
51+
#define ERROR_PRINT_NOPRE_LN_NOPM(...)
52+
#define ERROR_PRINT_NOPRE_LN(string)
53+
54+
// With a prefix:
55+
#define ERROR_PRINT_NOPM(...)
56+
#define ERROR_PRINT(string)
57+
#define ERROR_PRINT_LN_NOPM(...)
58+
#define ERROR_PRINT_LN(string)
59+
60+
#endif

include/WarnLogging.hpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#pragma once
2+
3+
#ifdef WARN_LOGS_PREFIX
4+
#include <Arduino.h>
5+
6+
#pragma region // Logging without a prefix.
7+
/** @brief Simply logs whatever is passed. */
8+
#define WARN_PRINT_NOPRE_NOPM(...) \
9+
Serial.print(__VA_ARGS__)
10+
11+
/** @brief Logs whatever is passed, storing the input into flash memory using `F()`. */
12+
#define WARN_PRINT_NOPRE(string) \
13+
Serial.print(F(string))
14+
15+
/** @brief Logs whatever is passed, with a new-line at the end. */
16+
#define WARN_PRINT_NOPRE_LN_NOPM(...) \
17+
Serial.println(__VA_ARGS__)
18+
19+
/** @brief Logs whatever is passed, with a new-line at the end, storing the input into flash memory using `F()`. */
20+
#define WARN_PRINT_NOPRE_LN(string) \
21+
Serial.println(F(string))
22+
#pragma endregion
23+
24+
#pragma region // Logging with a prefix.
25+
/** @brief Logs with the prefix, and a new-line at the end, storing the input into flash memory using `F()`. */
26+
#define WARN_PRINT_LN(string) \
27+
Serial.print(F(WARN_LOGS_PREFIX)); \
28+
Serial.println(F(string))
29+
30+
/** @brief Simply logs whatever is passed with the prefix. */
31+
#define WARN_PRINT_NOPM(...) \
32+
Serial.print(WARN_LOGS_PREFIX); \
33+
Serial.print(__VA_ARGS__)
34+
35+
/** @brief Logs with the prefix, storing the input into flash memory using `F()`. */
36+
#define WARN_PRINT(string) \
37+
Serial.print(F(WARN_LOGS_PREFIX)); \
38+
Serial.print(F(string))
39+
40+
/** @brief Logs with the prefix, and a new-line at the end. */
41+
#define WARN_PRINT_LN_NOPM(...) \
42+
Serial.print(F(WARN_LOGS_PREFIX)); \
43+
Serial.println(__VA_ARGS__)
44+
#pragma endregion
45+
46+
#else // Else, we define these as empty:
47+
48+
// Without a prefix:
49+
#define WARN_PRINT_NOPRE_NOPM(...)
50+
#define WARN_PRINT_NOPRE(string)
51+
#define WARN_PRINT_NOPRE_LN_NOPM(...)
52+
#define WARN_PRINT_NOPRE_LN(string)
53+
54+
// With a prefix:
55+
#define WARN_PRINT_NOPM(...)
56+
#define WARN_PRINT(string)
57+
#define WARN_PRINT_LN_NOPM(...)
58+
#define WARN_PRINT_LN(string)
59+
60+
#endif

library.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "PerFileLogging",
3+
"version": "0.1.0",
4+
"description": "A header-library to assist with logging.",
5+
"keywords": [
6+
"logging"
7+
],
8+
"authors": [
9+
{
10+
"name": "Brahvim",
11+
"maintainer": true
12+
}
13+
],
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/Brahvim/PerFileLogging"
17+
},
18+
"frameworks": "*"
19+
}

library.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version=0.1.0
2+
author=Brahvim
3+
architecture=*
4+
maintainer=Brahvim
5+
name=PerFileLogging
6+
; url=https://github.com/Brahvim/ArduinoRoutinesApi
7+
sentence=A header-library to assist with logging.

platformio.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env:uno]
12+
board = uno
13+
platform = atmelavr
14+
framework = arduino
15+
monitor_encoding = ascii
16+
; lib_deps = mike-matera/ArduinoSTL@1.3.3
17+
; build_unflags = -fno-rtti
18+
; build_flags = -DROUTINES_API_ENABLE_DEBUG_LOGS

0 commit comments

Comments
 (0)