Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
BasedOnStyle: LLVM
ColumnLimit: 100
BinPackArguments: false
BinPackParameters: false
AllowAllArgumentsOnNextLine: false
AlignAfterOpenBracket: BlockIndent
UseTab: ForIndentation
IndentWidth: 4
TabWidth: 4
ContinuationIndentWidth: 4
AllowShortFunctionsOnASingleLine: None
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

[*.{c,cc,cpp,h,hpp,ino}]
indent_style = tab
indent_size = tab
tab_width = 4
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.venv
build/
build_prev_runner/
.vscode
19 changes: 19 additions & 0 deletions .vscode/bin/clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -euo pipefail

if command -v clang-format >/dev/null 2>&1; then
exec clang-format "$@"
fi

_home_dir="${HOME:-}"
if [ -n "$_home_dir" ]; then
_candidate="$(ls -1d "$_home_dir"/.vscode/extensions/ms-vscode.cpptools-*-linux-x64/LLVM/bin/clang-format 2>/dev/null | tail -n 1 || true)"
if [ -n "$_candidate" ] && [ -x "$_candidate" ]; then
exec "$_candidate" "$@"
fi
fi

echo "clang-format executable not found." >&2
echo "Install clang-format system-wide or install/update ms-vscode.cpptools." >&2
exit 127
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"pioarduino.pioarduino-ide",
"xaver.clang-format"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
30 changes: 30 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"files.associations": {
"*.ino": "cpp"
},
"editor.defaultFormatter": "xaver.clang-format",
"C_Cpp.formatting": "Disabled",
"clang-format.style": "file",
"clang-format.executable": "${workspaceRoot}/.vscode/bin/clang-format",
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format",
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"editor.tabSize": 4,
"editor.formatOnSave": true
},
"[c]": {
"editor.defaultFormatter": "xaver.clang-format",
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"editor.tabSize": 4,
"editor.formatOnSave": true
},
"[arduino]": {
"editor.defaultFormatter": "xaver.clang-format",
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"editor.tabSize": 4,
"editor.formatOnSave": true
}
}
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Format Firmware Sources",
"type": "shell",
"command": "bash ${workspaceFolder}/scripts/format_cpp.sh",
"group": "build",
"problemMatcher": []
}
]
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@ Example sketches in this repo:
- Host-side CTest is intentionally skipped because the scheduler relies on ESP32 FreeRTOS and ESPDate wall-clock helpers.
- CI also compiles all examples through PlatformIO and Arduino CLI across ESP32, S3, C3, and P4 boards.

## Formatting Baseline

This repository follows the firmware formatting baseline from `esptoolkit-template`:
- `.clang-format` is the source of truth for C/C++/INO layout.
- `.editorconfig` enforces tabs (`tab_width = 4`), LF endings, and final newline.
- Format all tracked firmware sources with `bash scripts/format_cpp.sh`.

## License
MIT — see `LICENSE.md`.

Expand Down
18 changes: 7 additions & 11 deletions examples/custom_fields/custom_fields.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,15 @@ void setup() {

int weekdays[] = {1, 3, 5}; // Mon, Wed, Fri (0 = Sun)
Schedule custom = Schedule::custom(
ScheduleField::every(5), // every 5 minutes
ScheduleField::range(9, 17), // during hours 9..17
ScheduleField::any(), // any day of month
ScheduleField::any(), // any month
ScheduleField::list(weekdays, 3) // selected weekdays
ScheduleField::every(5), // every 5 minutes
ScheduleField::range(9, 17), // during hours 9..17
ScheduleField::any(), // any day of month
ScheduleField::any(), // any month
ScheduleField::list(weekdays, 3) // selected weekdays
);

scheduler.addJob(
custom,
SchedulerJobMode::Inline,
&customInline,
(void *)"MWF 9-17 every 5min"
);
scheduler
.addJob(custom, SchedulerJobMode::Inline, &customInline, (void *)"MWF 9-17 every 5min");
}

void loop() {
Expand Down
32 changes: 14 additions & 18 deletions examples/inline_astronomical/inline_astronomical.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,25 @@ void setup() {

scheduler.setMinValidUtc(date.fromUtc(2020, 1, 1, 0, 0, 0));

scheduler
.addJob(Schedule::sunrise(), SchedulerJobMode::Inline, &astroCallback, (void *)"sunrise");
scheduler.addJob(
Schedule::sunrise(),
SchedulerJobMode::Inline,
&astroCallback,
(void *)"sunrise"
Schedule::sunset(15),
SchedulerJobMode::Inline,
&astroCallback,
(void *)"sunset +15m"
);
scheduler.addJob(
Schedule::sunset(15),
SchedulerJobMode::Inline,
&astroCallback,
(void *)"sunset +15m"
Schedule::moonPhase(MoonPhaseName::LastQuarter, 2),
SchedulerJobMode::Inline,
&astroCallback,
(void *)"last quarter"
);
scheduler.addJob(
Schedule::moonPhase(MoonPhaseName::LastQuarter, 2),
SchedulerJobMode::Inline,
&astroCallback,
(void *)"last quarter"
);
scheduler.addJob(
Schedule::moonIlluminationPercent(75.0, 0.5),
SchedulerJobMode::Inline,
&astroCallback,
(void *)"illumination 75%"
Schedule::moonIlluminationPercent(75.0, 0.5),
SchedulerJobMode::Inline,
&astroCallback,
(void *)"illumination 75%"
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ void setup() {

// Useful for periodic checks while staff is active.
Schedule schedule = Schedule::custom(
ScheduleField::every(15), // minute: 0,15,30,45
ScheduleField::range(9, 17),
ScheduleField::any(),
ScheduleField::any(),
ScheduleField::any()
);
ScheduleField::every(15), // minute: 0,15,30,45
ScheduleField::range(9, 17),
ScheduleField::any(),
ScheduleField::any(),
ScheduleField::any()
);

scheduler.addJob(schedule, SchedulerJobMode::Inline, &workHoursPulse, nullptr);
}
Expand Down
12 changes: 6 additions & 6 deletions examples/inline_every_hour/inline_every_hour.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ void setup() {

// Fires at HH:00 every day.
Schedule schedule = Schedule::custom(
ScheduleField::only(0), // minute
ScheduleField::any(), // hour
ScheduleField::any(), // day of month
ScheduleField::any(), // month
ScheduleField::any() // day of week
);
ScheduleField::only(0), // minute
ScheduleField::any(), // hour
ScheduleField::any(), // day of month
ScheduleField::any(), // month
ScheduleField::any() // day of week
);

scheduler.addJob(schedule, SchedulerJobMode::Inline, &everyHour, nullptr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ void setup() {

int selectedDays[] = {2, 4, 6}; // Tue, Thu, Sat
Schedule schedule = Schedule::custom(
ScheduleField::only(0), // minute
ScheduleField::any(), // hour
ScheduleField::any(), // day of month
ScheduleField::any(), // month
ScheduleField::list(selectedDays, 3) // day of week
ScheduleField::only(0), // minute
ScheduleField::any(), // hour
ScheduleField::any(), // day of month
ScheduleField::any(), // month
ScheduleField::list(selectedDays, 3) // day of week
);

scheduler.addJob(schedule, SchedulerJobMode::Inline, &hourOnSelectedDays, nullptr);
Expand Down
12 changes: 6 additions & 6 deletions examples/inline_every_minute/inline_every_minute.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ void setup() {
Serial.println("ESPScheduler inline every-minute example");

Schedule schedule = Schedule::custom(
ScheduleField::every(1), // minute
ScheduleField::any(), // hour
ScheduleField::any(), // day of month
ScheduleField::any(), // month
ScheduleField::any() // day of week
);
ScheduleField::every(1), // minute
ScheduleField::any(), // hour
ScheduleField::any(), // day of month
ScheduleField::any(), // month
ScheduleField::any() // day of week
);

scheduler.addJob(schedule, SchedulerJobMode::Inline, &everyMinute, nullptr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ void setup() {

int selectedDays[] = {1, 3, 5}; // 0=Sun, 1=Mon, ... 6=Sat
Schedule schedule = Schedule::custom(
ScheduleField::every(1), // minute
ScheduleField::any(), // hour
ScheduleField::any(), // day of month
ScheduleField::any(), // month
ScheduleField::list(selectedDays, 3) // day of week
ScheduleField::every(1), // minute
ScheduleField::any(), // hour
ScheduleField::any(), // day of month
ScheduleField::any(), // month
ScheduleField::list(selectedDays, 3) // day of week
);

scheduler.addJob(schedule, SchedulerJobMode::Inline, &minuteOnSelectedDays, nullptr);
Expand Down
12 changes: 6 additions & 6 deletions examples/inline_pause_resume/inline_pause_resume.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ void setup() {

// Every minute (all hours/days) using custom cron fields
Schedule everyMinute = Schedule::custom(
ScheduleField::every(1), // minute
ScheduleField::any(), // hour
ScheduleField::any(), // day of month
ScheduleField::any(), // month
ScheduleField::any() // day of week
);
ScheduleField::every(1), // minute
ScheduleField::any(), // hour
ScheduleField::any(), // day of month
ScheduleField::any(), // month
ScheduleField::any() // day of week
);

jobId = scheduler.addJob(everyMinute, SchedulerJobMode::Inline, &recurringInline, nullptr);
}
Expand Down
12 changes: 6 additions & 6 deletions examples/worker_weekly/worker_weekly.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ void setup() {
cfg.usePsramStack = true;

scheduler.addJob(
Schedule::weeklyAtLocal(weekdaysMask, 18, 30),
SchedulerJobMode::WorkerTask,
&weeklyReport,
nullptr,
&cfg
);
Schedule::weeklyAtLocal(weekdaysMask, 18, 30),
SchedulerJobMode::WorkerTask,
&weeklyReport,
nullptr,
&cfg
);
}

void loop() {
Expand Down
24 changes: 24 additions & 0 deletions scripts/format_cpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -euo pipefail

_repo_root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
_clang_format="${_repo_root}/.vscode/bin/clang-format"

if [ ! -x "${_clang_format}" ]; then
echo "clang-format wrapper not found: ${_clang_format}" >&2
exit 1
fi

mapfile -d '' _format_files < <(
git -C "${_repo_root}" ls-files -z -- '*.c' '*.cc' '*.cpp' '*.h' '*.hpp' '*.ino'
)

if [ "${#_format_files[@]}" -eq 0 ]; then
echo "No tracked C/C++/INO files found to format."
exit 0
fi

"${_clang_format}" -i --style=file "${_format_files[@]}"

echo "Formatted ${#_format_files[@]} files."
Loading