From b7ebad177de0c294a75cb76d4eecc1b020a3fda4 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Sun, 1 Feb 2026 00:11:38 +0100 Subject: [PATCH 01/26] Implement clang-tidy + changes to clang-format --- .clang-format | 6 +- .clang-tidy | 30 +++++ .github/workflows/clang.yml | 221 ++++++++++++++++++++++++++++++++++++ .vscode/extensions.json | 3 +- .vscode/settings.json | 5 +- 5 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 .clang-tidy create mode 100644 .github/workflows/clang.yml diff --git a/.clang-format b/.clang-format index e18f3d5a..ec21e3ba 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,7 @@ +--- +Language: Cpp AccessModifierOffset: -4 AllowShortFunctionsOnASingleLine: Empty -AllowShortIfStatementsOnASingleLine: Never -AllowShortLambdasOnASingleLine: Empty BreakBeforeBraces: Allman ColumnLimit: 0 FixNamespaceComments: false @@ -9,3 +9,5 @@ IncludeBlocks: Regroup IndentWidth: 4 InsertBraces: true NamespaceIndentation: All +PackConstructorInitializers: NextLine +... diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..075564c7 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,30 @@ +Checks: > + boost-*, + bugprone-*, + clang-analyzer-*, + cppcoreguidelines-*, + modernize-*, + performance-*, + portability-*, + readability-*, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-macro-to-enum, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-pro-type-member-init, + -cppcoreguidelines-special-member-functions, + -cppcoreguidelines-use-enum-class, + -cppcoreguidelines-virtual-class-destructor, + -modernize-avoid-c-arrays, + -modernize-deprecated-headers, + -modernize-macro-to-enum, + -modernize-use-nodiscard, + -modernize-use-std-numbers, + -modernize-use-trailing-return-type, + -performance-enum-size, + -portability-avoid-pragma-once, + -readability-avoid-const-params-in-decls, + -readability-identifier-length, + -readability-uppercase-literal-suffix diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml new file mode 100644 index 00000000..a477b0a4 --- /dev/null +++ b/.github/workflows/clang.yml @@ -0,0 +1,221 @@ +name: Clang + +on: + pull_request: + branches: + - main + + workflow_dispatch: + +permissions: + contents: read + pull-requests: write + +jobs: + platformio: + name: PlatformIO variable extract + runs-on: ubuntu-latest + outputs: + environments: ${{ steps.print.outputs.environments }} + version: ${{ steps.print.outputs.version }} + + steps: + - name: Checkout + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 + + - name: Set up Python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + with: + python-version: 3.13 + cache: pip + cache-dependency-path: .github/platformio/requirements.txt + + - name: Set up PlatformIO + run: pip install -r .github/platformio/requirements.txt + + - name: PlatformIO extract + id: print + run: | + echo "environments=$(pio project config --json-output | jq -c '[.[] | .[0] | select(startswith("env:")) | sub("^env:"; "")]')" >> "$GITHUB_OUTPUT" + echo "version=$(pio --version | awk '{print $NF}')" >> "$GITHUB_OUTPUT" + + format: + name: Format + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 + + - name: Clang format + uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 + id: format + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + version: 21 + format-review: true + passive-reviews: true + repo-root: ./firmware + step-summary: true + style: file + tidy-checks: -* + + - name: Clang format checks failed? + if: steps.format.outputs.clang-format-checks-failed != 0 + run: exit 1 + + tidy: + name: Tidy + needs: platformio + runs-on: ubuntu-latest + + strategy: + max-parallel: 1 + matrix: + environment: ${{ fromJson(needs.platformio.outputs.environments) }} + + steps: + - name: Checkout + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 + + - name: Set up Python + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + with: + python-version: 3.13 + cache: pip + cache-dependency-path: | + .github/platformio/requirements.txt + scripts/requirements.txt + + - name: Set up PlatformIO + run: pip install -r .github/platformio/requirements.txt + + - name: Set up Cache + continue-on-error: true + uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + key: platformio-cache-${{ runner.os }}-${{ runner.arch }}-${{ needs.platformio.outputs.version }}-${{ hashFiles('platformio.ini') }} + path: | + .platformio/.cache/downloads + .platformio/.cache/http + + - name: PlatformIO Compilation database + run: | + cat <<'EOL' > .env + EXTENSION_ALEXA='true' + EXTENSION_BUTTON='true' + EXTENSION_HEAP='true' + EXTENSION_HOMEASSISTANT='true' + EXTENSION_INFRARED='true' + EXTENSION_MESSAGE='true' + EXTENSION_MICROPHONE='true' + EXTENSION_MQTT='true' + EXTENSION_OTA='true' + EXTENSION_PHOTOCELL='true' + EXTENSION_PLAYLIST='true' + EXTENSION_RESTFUL='true' + EXTENSION_RTC='true' + EXTENSION_SERVERSENTEVENTS='true' + EXTENSION_SIGNAL='true' + EXTENSION_WEBAPP='true' + EXTENSION_WEBSOCKET='true' + FONT_BRAILLE='true' + HOSTNAME='frekvens' + IKEA_FREKVENS='true' + MODE_ANIMATION='true' + MODE_ARROW='true' + MODE_BINARYCLOCK='true' + MODE_BINARYEPOCH='true' + MODE_BLINDS='true' + MODE_BLINK='true' + MODE_BREAKOUTCLOCK='true' + MODE_BRIGHT='true' + MODE_CIRCLE='true' + MODE_COUNTDOWN='true' + MODE_DRAW='true' + MODE_EQUALIZER='true' + MODE_FIREWORK='true' + MODE_FLIES='true' + MODE_GAMEOFLIFE='true' + MODE_GLITTER='true' + MODE_GOOGLEWEATHER='true' + MODE_HOMEASSISTANTWEATHER='true' + MODE_HOMETHERMOMETER='true' + MODE_JAGGEDWAVEFORM='true' + MODE_LARGECLOCK='true' + MODE_LEAFFALL='true' + MODE_LINES='true' + MODE_METABALLS='true' + MODE_NOISE='true' + MODE_OPENMETEO='true' + MODE_OPENWEATHER='true' + MODE_PINGPONG='true' + MODE_PIXELSEQUENCE='true' + MODE_RAIN='true' + MODE_RING='true' + MODE_SCAN='true' + MODE_SMALLCLOCK='true' + MODE_SMOOTHWAVEFORM='true' + MODE_SNAKE='true' + MODE_STARS='true' + MODE_STREAM='true' + MODE_TICKER='true' + MODE_WAVEFORM='true' + MODE_WORLDWEATHERONLINE='true' + MODE_WTTRIN='true' + MODE_YR='true' + NAME='Frekvens' + EOL + + cat <<'EOL' > firmware/include/config/secrets.h + #pragma once + #define GOOGLEWEATHER_KEY "redacted" + #define HOMEASSISTANT_HOST "homeassistant.local" + #define HOMEASSISTANT_KEY "redacted" + #define LATITUDE "0.000" + #define LOCATION "redacted" + #define LONGITUDE "0.000" + #define MQTT_HOST "mqtt.local" + #define MQTT_USER "redacted" + #define MQTT_KEY "redacted" + #define OPENMETEO_KEY "redacted" + #define OPENWEATHER_KEY "redacted" + #define PIN_CS 1 + #define PIN_INT 2 + #define PIN_IR 3 + #define PIN_LDR 4 + #define PIN_MIC 5 + #define PIN_MOSI 6 + #define PIN_OE 7 + #define PIN_SCL 8 + #define PIN_SCLK 9 + #define PIN_SDA 10 + #define PIN_SW1 11 + #define PIN_SW2 12 + #define RTC_DS3232 + #define WIFI_KEY "redacted" + #define WIFI_SSID "redacted" + #define WORLDWEATHERONLINE_KEY "redacted" + EOL + + pio run -t compiledb -e ${{ matrix.environment }} + + - name: Clang tidy + uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 + id: tidy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + version: 21 + extra-args: -p=compile_commands.json + passive-reviews: true + repo-root: ./firmware + step-summary: true + style: '' + tidy-checks: '' + tidy-review: true + + - name: Clang tidy checks failed? + if: steps.tidy.outputs.clang-tidy-checks-failed != 0 + run: exit 1 diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 39761e4a..36a185a1 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -9,6 +9,7 @@ "ms-vscode.cpptools", "platformio.platformio-ide", "redhat.vscode-yaml", - "tamasfe.even-better-toml" + "tamasfe.even-better-toml", + "xaver.clang-format" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 9482a4fa..e52ad260 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,9 @@ { "[c]": { - "editor.defaultFormatter": "ms-vscode.cpptools" + "editor.defaultFormatter": "xaver.clang-format" }, "[cpp]": { - "editor.defaultFormatter": "ms-vscode.cpptools" + "editor.defaultFormatter": "xaver.clang-format" }, "[css]": { "editor.defaultFormatter": "biomejs.biome" @@ -35,7 +35,6 @@ "linux-x64-musl": "webapp/node_modules/@biomejs/cli-linux-x64-musl/biome", "win32-x64": "webapp/node_modules/@biomejs/cli-win32-x64/biome.exe" }, - "C_Cpp.clang_format_style": "file", "files.associations": { "*.css": "tailwindcss", "*.yaml": "esphome" From 199393923ead4e4c56053e52dd63ada8f5fdbd1a Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Sun, 1 Feb 2026 01:42:47 +0100 Subject: [PATCH 02/26] Remove redundant config options --- .github/workflows/clang.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index a477b0a4..a2b100e6 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -56,7 +56,6 @@ jobs: version: 21 format-review: true passive-reviews: true - repo-root: ./firmware step-summary: true style: file tidy-checks: -* @@ -208,9 +207,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: version: 21 - extra-args: -p=compile_commands.json passive-reviews: true - repo-root: ./firmware step-summary: true style: '' tidy-checks: '' From 537464d1907067f2e8aec834324a73f3a2c3a2cd Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Sun, 1 Feb 2026 13:28:18 +0100 Subject: [PATCH 03/26] Parameter tuning (WIP) --- .clang-tidy | 19 ++++++++++++++++++- .github/workflows/clang.yml | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 075564c7..70c80a4d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,9 +7,16 @@ Checks: > performance-*, portability-*, readability-*, - -cppcoreguidelines-avoid-non-const-global-variables, + -bugprone-branch-clone, + -bugprone-easily-swappable-parameters, + -bugprone-narrowing-conversions, -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-const-or-ref-data-members, + -cppcoreguidelines-avoid-do-while, -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-explicit-virtual-functions, + -cppcoreguidelines-init-variables, -cppcoreguidelines-macro-to-enum, -cppcoreguidelines-macro-usage, -cppcoreguidelines-non-private-member-variables-in-classes, @@ -24,7 +31,17 @@ Checks: > -modernize-use-std-numbers, -modernize-use-trailing-return-type, -performance-enum-size, + -performance-unnecessary-value-param, -portability-avoid-pragma-once, -readability-avoid-const-params-in-decls, + -readability-const-return-type, + -readability-convert-member-functions-to-static, + -readability-else-after-return, -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-isolate-declaration, + -readability-make-member-function-const, + -readability-magic-numbers, + -readability-math-missing-parentheses, + -readability-static-accessed-through-instance, -readability-uppercase-literal-suffix diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index a2b100e6..2af6a31f 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -54,6 +54,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: version: 21 + files-changed-only: false format-review: true passive-reviews: true step-summary: true @@ -207,6 +208,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: version: 21 + files-changed-only: false passive-reviews: true step-summary: true style: '' From 4edc97f662ddd9222da50c30ca5446f6e05ba95b Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Sun, 1 Feb 2026 13:50:09 +0100 Subject: [PATCH 04/26] More config tuning --- .clang-format | 6 +----- .clang-tidy | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.clang-format b/.clang-format index ec21e3ba..b64a7734 100644 --- a/.clang-format +++ b/.clang-format @@ -1,13 +1,9 @@ --- Language: Cpp AccessModifierOffset: -4 -AllowShortFunctionsOnASingleLine: Empty BreakBeforeBraces: Allman -ColumnLimit: 0 -FixNamespaceComments: false +ColumnLimit: 120 IncludeBlocks: Regroup IndentWidth: 4 InsertBraces: true -NamespaceIndentation: All -PackConstructorInitializers: NextLine ... diff --git a/.clang-tidy b/.clang-tidy index 70c80a4d..ca86032c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -9,6 +9,8 @@ Checks: > readability-*, -bugprone-branch-clone, -bugprone-easily-swappable-parameters, + -bugprone-infinite-loop, + -bugprone-integer-division, -bugprone-narrowing-conversions, -cppcoreguidelines-avoid-c-arrays, -cppcoreguidelines-avoid-const-or-ref-data-members, @@ -19,29 +21,41 @@ Checks: > -cppcoreguidelines-init-variables, -cppcoreguidelines-macro-to-enum, -cppcoreguidelines-macro-usage, + -cppcoreguidelines-narrowing-conversions, -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -cppcoreguidelines-pro-bounds-constant-array-index, + -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -cppcoreguidelines-pro-type-cstyle-cast, -cppcoreguidelines-pro-type-member-init, + -cppcoreguidelines-pro-type-reinterpret-cast, + -cppcoreguidelines-pro-type-vararg, -cppcoreguidelines-special-member-functions, -cppcoreguidelines-use-enum-class, -cppcoreguidelines-virtual-class-destructor, -modernize-avoid-c-arrays, -modernize-deprecated-headers, -modernize-macro-to-enum, + -modernize-use-auto, -modernize-use-nodiscard, + -modernize-use-override, -modernize-use-std-numbers, -modernize-use-trailing-return-type, -performance-enum-size, -performance-unnecessary-value-param, -portability-avoid-pragma-once, -readability-avoid-const-params-in-decls, + -readability-avoid-nested-conditional-operator, -readability-const-return-type, -readability-convert-member-functions-to-static, -readability-else-after-return, + -readability-function-cognitive-complexity, -readability-identifier-length, -readability-implicit-bool-conversion, -readability-isolate-declaration, -readability-make-member-function-const, -readability-magic-numbers, -readability-math-missing-parentheses, + -readability-misplaced-array-index, -readability-static-accessed-through-instance, -readability-uppercase-literal-suffix From 3a4ffdf89bfea9bac6a658b3b0e5b61e5d8f80cd Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Sun, 1 Feb 2026 14:15:27 +0100 Subject: [PATCH 05/26] Add checks to Python generated fonts/modes --- .github/workflows/generate.yml | 62 +++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index e77ab637..fa71fc20 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -115,6 +115,24 @@ jobs: pio run -e esp32dev + pio run -e esp32dev -t compiledb + + - name: Clang + uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 + id: clang + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + version: 21 + files-changed-only: false + format-review: true + ignore: '*|!firmware/src/fonts/DejaVuSansFont.cpp|!firmware/include/fonts/DejaVuSansFont.h' + passive-reviews: true + step-summary: true + style: file + tidy-checks: '' + tidy-review: true + mode-dynamic: name: Dynamic mode needs: platformio @@ -190,8 +208,8 @@ jobs: python extra/Python/ModeGenerator.py -i Dynamic.csv - mv DynamicMode.cpp firmware/src/modes/DynamicMode.cpp - mv DynamicMode.h firmware/include/modes/DynamicMode.h + mv DynamicMode.cpp firmware/src/modes + mv DynamicMode.h firmware/include/modes sed -i '/^#pragma once$/a\#include "modes/DynamicMode.h"' firmware/include/services/ModesService.h sed -i '/^ const std::vector modes = {$/a\ new DynamicMode(),' firmware/include/services/ModesService.h @@ -225,6 +243,24 @@ jobs: pio run -e esp32dev + pio run -e esp32dev -t compiledb + + - name: Clang + uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 + id: clang + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + version: 21 + files-changed-only: false + format-review: true + ignore: '*|!firmware/src/modes/DynamicMode.cpp|!firmware/include/modes/DynamicMode.h' + passive-reviews: true + step-summary: true + style: file + tidy-checks: '' + tidy-review: true + mode-static: name: Static mode needs: platformio @@ -284,8 +320,8 @@ jobs: python extra/Python/ModeGenerator.py -i Static.csv - mv StaticMode.cpp firmware/src/modes/StaticMode.cpp - mv StaticMode.h firmware/include/modes/StaticMode.h + mv StaticMode.cpp firmware/src/modes + mv StaticMode.h firmware/include/modes sed -i '/^#pragma once$/a\#include "modes/StaticMode.h"' firmware/include/services/ModesService.h sed -i '/^ const std::vector modes = {$/a\ new StaticMode(),' firmware/include/services/ModesService.h @@ -318,3 +354,21 @@ jobs: EOL pio run -e esp32dev + + pio run -e esp32dev -t compiledb + + - name: Clang + uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 + id: clang + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + version: 21 + files-changed-only: false + format-review: true + ignore: '*|!firmware/src/modes/StaticMode.cpp|!firmware/include/modes/StaticMode.h' + passive-reviews: true + step-summary: true + style: file + tidy-checks: '' + tidy-review: true From b3e5c832db93d62fa56aa93dcbf8d96c1a5ae3ac Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Sun, 1 Feb 2026 14:31:19 +0100 Subject: [PATCH 06/26] Optimized "Generated" workflow --- .github/workflows/generate.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index fa71fc20..49620b78 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -115,9 +115,12 @@ jobs: pio run -e esp32dev - pio run -e esp32dev -t compiledb + - name: PlatformIO Compilation database + if: matrix.python-version == 3.13 + run: pio run -e esp32dev -t compiledb - name: Clang + if: matrix.python-version == 3.13 uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 id: clang env: @@ -243,9 +246,12 @@ jobs: pio run -e esp32dev - pio run -e esp32dev -t compiledb + - name: PlatformIO Compilation database + if: matrix.python-version == 3.13 + run: pio run -e esp32dev -t compiledb - name: Clang + if: matrix.python-version == 3.13 uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 id: clang env: @@ -355,9 +361,12 @@ jobs: pio run -e esp32dev - pio run -e esp32dev -t compiledb + - name: PlatformIO Compilation database + if: matrix.python-version == 3.13 + run: pio run -e esp32dev -t compiledb - name: Clang + if: matrix.python-version == 3.13 uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 id: clang env: From b9389b649d08ad30df8be9a6f1c49551ad5e7022 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Sun, 1 Feb 2026 14:56:31 +0100 Subject: [PATCH 07/26] Matrix finetuning --- .github/workflows/clang.yml | 17 ++++++--- .github/workflows/generate.yml | 69 +++++++++++++++++++--------------- 2 files changed, 51 insertions(+), 35 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 2af6a31f..34729401 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -43,6 +43,11 @@ jobs: name: Format runs-on: ubuntu-latest + strategy: + matrix: + include: + - clang-version: 21 + steps: - name: Checkout uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -53,7 +58,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: 21 + version: ${{ matrix.clang-version }} files-changed-only: false format-review: true passive-reviews: true @@ -74,6 +79,8 @@ jobs: max-parallel: 1 matrix: environment: ${{ fromJson(needs.platformio.outputs.environments) }} + include: + - clang-version: 21 steps: - name: Checkout @@ -100,7 +107,7 @@ jobs: .platformio/.cache/downloads .platformio/.cache/http - - name: PlatformIO Compilation database + - name: PlatformIO compilation database run: | cat <<'EOL' > .env EXTENSION_ALEXA='true' @@ -207,12 +214,12 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: 21 + version: ${{ matrix.clang-version }} files-changed-only: false passive-reviews: true step-summary: true - style: '' - tidy-checks: '' + style: "" + tidy-checks: "" tidy-review: true - name: Clang tidy checks failed? diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 49620b78..0668936c 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -42,9 +42,12 @@ jobs: strategy: matrix: - include: - - python-version: 3.11 - - python-version: 3.13 + toolchain: + - clang-version: false + python-version: 3.11 + + - clang-version: 21 + python-version: 3.13 steps: - name: Checkout @@ -53,7 +56,7 @@ jobs: - name: Set up Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.toolchain.python-version }} cache: pip cache-dependency-path: | .github/platformio/requirements.txt @@ -115,25 +118,25 @@ jobs: pio run -e esp32dev - - name: PlatformIO Compilation database - if: matrix.python-version == 3.13 + - name: PlatformIO compilation database + if: matrix.toolchain.clang-version run: pio run -e esp32dev -t compiledb - name: Clang - if: matrix.python-version == 3.13 + if: matrix.toolchain.clang-version uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 id: clang env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: 21 + version: ${{ matrix.toolchain.clang-version }} files-changed-only: false format-review: true - ignore: '*|!firmware/src/fonts/DejaVuSansFont.cpp|!firmware/include/fonts/DejaVuSansFont.h' + ignore: "*|!firmware/src/fonts/DejaVuSansFont.cpp|!firmware/include/fonts/DejaVuSansFont.h" passive-reviews: true step-summary: true style: file - tidy-checks: '' + tidy-checks: "" tidy-review: true mode-dynamic: @@ -143,9 +146,12 @@ jobs: strategy: matrix: - include: - - python-version: 3.11 - - python-version: 3.13 + toolchain: + - clang-version: false + python-version: 3.11 + + - clang-version: 21 + python-version: 3.13 steps: - name: Checkout @@ -154,7 +160,7 @@ jobs: - name: Set up Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.toolchain.python-version }} cache: pip cache-dependency-path: | .github/platformio/requirements.txt @@ -246,25 +252,25 @@ jobs: pio run -e esp32dev - - name: PlatformIO Compilation database - if: matrix.python-version == 3.13 + - name: PlatformIO compilation database + if: matrix.toolchain.clang-version run: pio run -e esp32dev -t compiledb - name: Clang - if: matrix.python-version == 3.13 + if: matrix.toolchain.clang-version uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 id: clang env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: 21 + version: ${{ matrix.toolchain.clang-version }} files-changed-only: false format-review: true - ignore: '*|!firmware/src/modes/DynamicMode.cpp|!firmware/include/modes/DynamicMode.h' + ignore: "*|!firmware/src/modes/DynamicMode.cpp|!firmware/include/modes/DynamicMode.h" passive-reviews: true step-summary: true style: file - tidy-checks: '' + tidy-checks: "" tidy-review: true mode-static: @@ -274,9 +280,12 @@ jobs: strategy: matrix: - include: - - python-version: 3.11 - - python-version: 3.13 + toolchain: + - clang-version: false + python-version: 3.11 + + - clang-version: 21 + python-version: 3.13 steps: - name: Checkout @@ -285,7 +294,7 @@ jobs: - name: Set up Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.toolchain.python-version }} cache: pip cache-dependency-path: | .github/platformio/requirements.txt @@ -361,23 +370,23 @@ jobs: pio run -e esp32dev - - name: PlatformIO Compilation database - if: matrix.python-version == 3.13 + - name: PlatformIO compilation database + if: matrix.toolchain.clang-version run: pio run -e esp32dev -t compiledb - name: Clang - if: matrix.python-version == 3.13 + if: matrix.toolchain.clang-version uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 id: clang env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: 21 + version: ${{ matrix.toolchain.clang-version }} files-changed-only: false format-review: true - ignore: '*|!firmware/src/modes/StaticMode.cpp|!firmware/include/modes/StaticMode.h' + ignore: "*|!firmware/src/modes/StaticMode.cpp|!firmware/include/modes/StaticMode.h" passive-reviews: true step-summary: true style: file - tidy-checks: '' + tidy-checks: "" tidy-review: true From 0ba9a9b6374c2734382747a32ea1a05397f8ce20 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Sun, 1 Feb 2026 15:33:15 +0100 Subject: [PATCH 08/26] More clang-tidy exclusions + some formatted code (draft) --- .clang-tidy | 9 +++++++++ firmware/src/extensions/SignalExtension.cpp | 4 +--- firmware/src/services/ModesService.cpp | 8 ++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index ca86032c..225a3b08 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,11 +7,16 @@ Checks: > performance-*, portability-*, readability-*, + -bugprone-assignment-in-if-condition, -bugprone-branch-clone, -bugprone-easily-swappable-parameters, + -bugprone-incorrect-roundings, -bugprone-infinite-loop, -bugprone-integer-division, -bugprone-narrowing-conversions, + -bugprone-suspicious-string-compare, + -bugprone-too-small-loop-variable, + -clang-diagnostic-error, -cppcoreguidelines-avoid-c-arrays, -cppcoreguidelines-avoid-const-or-ref-data-members, -cppcoreguidelines-avoid-do-while, @@ -37,11 +42,14 @@ Checks: > -modernize-deprecated-headers, -modernize-macro-to-enum, -modernize-use-auto, + -modernize-use-designated-initializers, + -modernize-use-integer-sign-comparison, -modernize-use-nodiscard, -modernize-use-override, -modernize-use-std-numbers, -modernize-use-trailing-return-type, -performance-enum-size, + -performance-type-promotion-in-math-fn, -performance-unnecessary-value-param, -portability-avoid-pragma-once, -readability-avoid-const-params-in-decls, @@ -57,5 +65,6 @@ Checks: > -readability-magic-numbers, -readability-math-missing-parentheses, -readability-misplaced-array-index, + -readability-non-const-parameter, -readability-static-accessed-through-instance, -readability-uppercase-literal-suffix diff --git a/firmware/src/extensions/SignalExtension.cpp b/firmware/src/extensions/SignalExtension.cpp index 98e87edc..19135e4c 100644 --- a/firmware/src/extensions/SignalExtension.cpp +++ b/firmware/src/extensions/SignalExtension.cpp @@ -96,9 +96,7 @@ void SignalExtension::onReceive(const JsonDocument doc, const char *const source { std::string bits = bitset.as(); bits.erase(std::remove_if(bits.begin(), bits.end(), [](char bit) - { - return bit < 0x30 || bit > 0x31; - }), + { return bit < 0x30 || bit > 0x31; }), bits.end()); sign.push_back(std::stoi(bits, nullptr, 2)); } diff --git a/firmware/src/services/ModesService.cpp b/firmware/src/services/ModesService.cpp index 85f56d79..c8c06abe 100644 --- a/firmware/src/services/ModesService.cpp +++ b/firmware/src/services/ModesService.cpp @@ -188,9 +188,7 @@ void ModesService::setModeNext() { const char *const _name = mode ? mode->name : scheduled->name; std::vector::const_iterator _mode = std::find_if(modes.begin(), modes.end(), [_name](const ModeModule *_mode) - { - return !strcmp(_mode->name, _name); - }); + { return !strcmp(_mode->name, _name); }); if (!Display.getPower()) { Display.setPower(true); @@ -210,9 +208,7 @@ void ModesService::setModePrevious() { const char *const _name = mode ? mode->name : scheduled->name; std::vector::const_iterator _mode = std::find_if(modes.begin(), modes.end(), [_name](const ModeModule *_mode) - { - return !strcmp(_mode->name, _name); - }); + { return !strcmp(_mode->name, _name); }); if (!Display.getPower()) { Display.setPower(true); From 31636094ee50d6e592b0d6213e65e08f5c799e77 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Sun, 1 Feb 2026 17:27:39 +0100 Subject: [PATCH 09/26] WIP: Formatting and minor refactors --- .clang-format | 2 + firmware/include/config/IkeaFrekvens.h | 16 +- firmware/include/config/IkeaObegransad.h | 16 +- firmware/include/extensions/ButtonExtension.h | 12 +- .../extensions/HomeAssistantExtension.h | 552 +++++++++--------- .../include/extensions/InfraredExtension.h | 19 +- .../include/extensions/MessageExtension.h | 15 +- .../include/extensions/MicrophoneExtension.h | 23 +- firmware/include/extensions/MqttExtension.h | 8 +- firmware/include/extensions/OtaExtension.h | 3 +- .../include/extensions/PhotocellExtension.h | 12 +- firmware/include/extensions/SignalExtension.h | 5 +- .../include/extensions/WebSocketExtension.h | 3 +- firmware/include/handlers/BitmapHandler.h | 5 +- firmware/include/handlers/TextHandler.h | 9 +- firmware/include/handlers/WeatherHandler.h | 195 +++---- firmware/include/modes/BinaryClockMode.h | 7 +- firmware/include/modes/BreakoutClockMode.h | 14 +- firmware/include/modes/CircleMode.h | 13 +- firmware/include/modes/CountdownMode.h | 5 +- firmware/include/modes/DrawMode.h | 5 +- firmware/include/modes/EqualizerMode.h | 5 +- firmware/include/modes/FireworkMode.h | 13 +- firmware/include/modes/FliesMode.h | 5 +- firmware/include/modes/GameOfLifeMode.h | 14 +- firmware/include/modes/GoogleWeatherMode.h | 9 +- .../include/modes/HomeAssistantWeatherMode.h | 14 +- firmware/include/modes/LargeClockMode.h | 14 +- firmware/include/modes/LeafFallMode.h | 7 +- firmware/include/modes/MetaballsMode.h | 18 +- firmware/include/modes/NoiseMode.h | 7 +- firmware/include/modes/OpenMeteoMode.h | 18 +- firmware/include/modes/OpenWeatherMode.h | 21 +- firmware/include/modes/PingPongMode.h | 24 +- firmware/include/modes/RainMode.h | 10 +- firmware/include/modes/SmallClockMode.h | 14 +- firmware/include/modes/SnakeMode.h | 40 +- firmware/include/modes/StarsMode.h | 9 +- firmware/include/modes/TickerMode.h | 5 +- .../include/modes/WorldWeatherOnlineMode.h | 6 +- firmware/include/modules/FontModule.h | 5 +- .../include/services/ConnectivityService.h | 13 +- firmware/include/services/DisplayService.h | 20 +- firmware/src/extensions/AlexaExtension.cpp | 32 +- firmware/src/extensions/ButtonExtension.cpp | 11 +- firmware/src/extensions/HeapExtension.cpp | 5 +- .../src/extensions/HomeAssistantExtension.cpp | 22 +- firmware/src/extensions/InfraredExtension.cpp | 49 +- firmware/src/extensions/MessageExtension.cpp | 5 +- .../src/extensions/MicrophoneExtension.cpp | 15 +- firmware/src/extensions/MqttExtension.cpp | 20 +- firmware/src/extensions/OtaExtension.cpp | 21 +- .../src/extensions/PhotocellExtension.cpp | 10 +- firmware/src/extensions/PlaylistExtension.cpp | 16 +- firmware/src/extensions/RestfulExtension.cpp | 8 +- firmware/src/extensions/RtcExtension.cpp | 13 +- firmware/src/extensions/SignalExtension.cpp | 8 +- firmware/src/extensions/WebAppExtension.cpp | 5 +- .../src/extensions/WebSocketExtension.cpp | 13 +- firmware/src/fonts/BrailleFont.cpp | 5 +- firmware/src/fonts/LargeFont.cpp | 5 +- firmware/src/fonts/MediumBoldFont.cpp | 5 +- firmware/src/fonts/MediumFont.cpp | 5 +- firmware/src/fonts/MicroFont.cpp | 5 +- firmware/src/fonts/MiniFont.cpp | 5 +- firmware/src/fonts/SmallFont.cpp | 5 +- firmware/src/handlers/BitmapHandler.cpp | 15 +- firmware/src/handlers/TextHandler.cpp | 23 +- firmware/src/handlers/WeatherHandler.cpp | 5 +- firmware/src/main.cpp | 5 +- firmware/src/modes/AnimationMode.cpp | 3 +- firmware/src/modes/BinaryClockMode.cpp | 5 +- firmware/src/modes/BinaryEpochMode.cpp | 5 +- firmware/src/modes/BreakoutClockMode.cpp | 5 +- firmware/src/modes/BrightMode.cpp | 5 +- firmware/src/modes/CountdownMode.cpp | 29 +- firmware/src/modes/DrawMode.cpp | 8 +- firmware/src/modes/EqualizerMode.cpp | 3 +- firmware/src/modes/FireworkMode.cpp | 5 +- firmware/src/modes/GameOfLifeMode.cpp | 14 +- firmware/src/modes/GlitterMode.cpp | 5 +- firmware/src/modes/GoogleWeatherMode.cpp | 6 +- .../src/modes/HomeAssistantWeatherMode.cpp | 6 +- firmware/src/modes/HomeThermometerMode.cpp | 29 +- firmware/src/modes/LargeClockMode.cpp | 20 +- firmware/src/modes/MetaballsMode.cpp | 26 +- firmware/src/modes/OpenMeteoMode.cpp | 6 +- firmware/src/modes/OpenWeatherMode.cpp | 3 +- firmware/src/modes/PingPongMode.cpp | 6 +- firmware/src/modes/SmallClockMode.cpp | 5 +- firmware/src/modes/SnakeMode.cpp | 41 +- firmware/src/modes/StarsMode.cpp | 5 +- firmware/src/modes/StreamMode.cpp | 11 +- firmware/src/modes/TickerMode.cpp | 10 +- firmware/src/modes/WorldWeatherOnlineMode.cpp | 12 +- firmware/src/modes/WttrInMode.cpp | 12 +- firmware/src/modes/YrMode.cpp | 14 +- firmware/src/services/ConnectivityService.cpp | 13 +- firmware/src/services/DeviceService.cpp | 8 +- firmware/src/services/DisplayService.cpp | 120 ++-- firmware/src/services/ExtensionsService.cpp | 5 +- firmware/src/services/FontsService.cpp | 10 +- firmware/src/services/ModesService.cpp | 13 +- firmware/src/services/WebServerService.cpp | 10 +- 104 files changed, 993 insertions(+), 1051 deletions(-) diff --git a/.clang-format b/.clang-format index b64a7734..597fbad7 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,9 @@ --- Language: Cpp AccessModifierOffset: -4 +BinPackArguments: false BreakBeforeBraces: Allman +BreakStringLiterals: false ColumnLimit: 120 IncludeBlocks: Regroup IndentWidth: 4 diff --git a/firmware/include/config/IkeaFrekvens.h b/firmware/include/config/IkeaFrekvens.h index 2b5620be..f938b096 100644 --- a/firmware/include/config/IkeaFrekvens.h +++ b/firmware/include/config/IkeaFrekvens.h @@ -12,7 +12,21 @@ #define GAMMA 2.8f // γ #define GRID_COLUMNS 16 // px #define GRID_ROWS 16 // px -#define LED_MAP {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF} +#define LED_MAP \ + {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x08, 0x09, 0x0A, \ + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, \ + 0x16, 0x17, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x98, \ + 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0xA0, 0xA1, 0xA2, 0xA3, \ + 0xA4, 0xA5, 0xA6, 0xA7, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, \ + 0xAF, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0x38, 0x39, \ + 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0x40, 0x41, 0x42, 0x43, 0x44, \ + 0x45, 0x46, 0x47, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, \ + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0xD0, 0xD1, 0xD2, \ + 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, \ + 0xDE, 0xDF, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0x68, \ + 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0x70, 0x71, 0x72, 0x73, \ + 0x74, 0x75, 0x76, 0x77, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, \ + 0x7F, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF} #define PITCH_HORIZONTAL 6 // mm #define PITCH_VERTICAL 6 // mm #define PWM_WIDTH 180e-9f // s diff --git a/firmware/include/config/IkeaObegransad.h b/firmware/include/config/IkeaObegransad.h index 5f6a096a..9f0989f2 100644 --- a/firmware/include/config/IkeaObegransad.h +++ b/firmware/include/config/IkeaObegransad.h @@ -12,7 +12,21 @@ #define GAMMA 2.8f // γ #define GRID_COLUMNS 16 // px #define GRID_ROWS 16 // px -#define LED_MAP {0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x60, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0xA7, 0xA6, 0xA5, 0xA4, 0xA3, 0xA2, 0xA1, 0xA0, 0xB7, 0xB6, 0xB5, 0xB4, 0xB3, 0xB2, 0xB1, 0xB0, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xD7, 0xD6, 0xD5, 0xD4, 0xD3, 0xD2, 0xD1, 0xD0, 0xC7, 0xC6, 0xC5, 0xC4, 0xC3, 0xC2, 0xC1, 0xC0, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xE7, 0xE6, 0xE5, 0xE4, 0xE3, 0xE2, 0xE1, 0xE0, 0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF} +#define LED_MAP \ + {0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x18, 0x19, 0x1A, \ + 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, \ + 0x21, 0x20, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x38, \ + 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x47, 0x46, 0x45, 0x44, \ + 0x43, 0x42, 0x41, 0x40, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, \ + 0x4F, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x60, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x71, 0x70, 0x68, 0x69, \ + 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x97, 0x96, 0x95, 0x94, 0x93, \ + 0x92, 0x91, 0x90, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x80, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, \ + 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0xA7, 0xA6, 0xA5, 0xA4, 0xA3, 0xA2, 0xA1, 0xA0, 0xB7, 0xB6, 0xB5, \ + 0xB4, 0xB3, 0xB2, 0xB1, 0xB0, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, \ + 0xBE, 0xBF, 0xD7, 0xD6, 0xD5, 0xD4, 0xD3, 0xD2, 0xD1, 0xD0, 0xC7, 0xC6, 0xC5, 0xC4, 0xC3, 0xC2, 0xC1, 0xC0, 0xD8, \ + 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xE7, 0xE6, 0xE5, 0xE4, \ + 0xE3, 0xE2, 0xE1, 0xE0, 0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, \ + 0xEF, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF} #define PITCH_HORIZONTAL 20 // mm #define PITCH_VERTICAL 30 // mm #define PWM_WIDTH 180e-9f // s diff --git a/firmware/include/extensions/ButtonExtension.h b/firmware/include/extensions/ButtonExtension.h index 339bba20..35388ade 100644 --- a/firmware/include/extensions/ButtonExtension.h +++ b/firmware/include/extensions/ButtonExtension.h @@ -9,15 +9,13 @@ class ButtonExtension : public ExtensionModule { private: #ifdef PIN_SW1 - bool - brightnessIncrease = false, - powerLong = false, - powerShort = false; + bool brightnessIncrease = false; + bool powerLong = false; + bool powerShort = false; #endif #ifdef PIN_SW2 - bool - modeLong = false, - modeShort = false; + bool modeLong = false; + bool modeShort = false; #endif #ifdef PIN_SW1 diff --git a/firmware/include/extensions/HomeAssistantExtension.h b/firmware/include/extensions/HomeAssistantExtension.h index 6d73f3f2..682dfac2 100644 --- a/firmware/include/extensions/HomeAssistantExtension.h +++ b/firmware/include/extensions/HomeAssistantExtension.h @@ -13,9 +13,8 @@ class HomeAssistantExtension : public ExtensionModule const std::string discoveryTopic = std::format("homeassistant/device/0x{:x}/config", ESP.getEfuseMac()); - static constexpr std::string_view - payloadOff = "{\"power\":false}", - payloadOn = "{\"power\":true}"; + static constexpr std::string_view payloadOff = "{\"power\":false}"; + static constexpr std::string_view payloadOn = "{\"power\":true}"; void transmit(); @@ -39,279 +38,278 @@ extern HomeAssistantExtension *HomeAssistant; namespace HomeAssistantAbbreviations { - static constexpr std::string_view - action_template = "act_tpl", - action_topic = "act_t", - automation_type = "atype", - aux_command_topic = "aux_cmd_t", - aux_state_template = "aux_stat_tpl", - aux_state_topic = "aux_stat_t", - availability = "avty", - availability_mode = "avty_mode", - availability_template = "avty_tpl", - availability_topic = "avty_t", - available_tones = "av_tones", - away_mode_command_topic = "away_mode_cmd_t", - away_mode_state_template = "away_mode_stat_tpl", - away_mode_state_topic = "away_mode_stat_t", - blue_template = "b_tpl", - brightness_command_template = "bri_cmd_tpl", - brightness_command_topic = "bri_cmd_t", - brightness_scale = "bri_scl", - brightness_state_topic = "bri_stat_t", - brightness_template = "bri_tpl", - brightness_value_template = "bri_val_tpl", - code_arm_required = "cod_arm_req", - code_disarm_required = "cod_dis_req", - code_trigger_required = "cod_trig_req", - color_mode = "clrm", - color_mode_state_topic = "clrm_stat_t", - color_mode_value_template = "clrm_val_tpl", - color_temp_command_template = "clr_temp_cmd_tpl", - color_temp_command_topic = "clr_temp_cmd_t", - color_temp_kelvin = "clr_temp_k", - color_temp_state_topic = "clr_temp_stat_t", - color_temp_template = "clr_temp_tpl", - color_temp_value_template = "clr_temp_val_tpl", - command_off_template = "cmd_off_tpl", - command_on_template = "cmd_on_tpl", - command_template = "cmd_tpl", - command_topic = "cmd_t", - components = "cmps", - configuration_url = "cu", - connections = "cns", - content_type = "cont_type", - current_temperature_template = "curr_temp_tpl", - current_temperature_topic = "curr_temp_t", - device = "dev", - device_class = "dev_cla", - direction_command_template = "dir_cmd_tpl", - direction_command_topic = "dir_cmd_t", - direction_state_topic = "dir_stat_t", - direction_value_template = "dir_val_tpl", - display_precision = "dsp_prc", - effect_command_template = "fx_cmd_tpl", - effect_command_topic = "fx_cmd_t", - effect_list = "fx_list", - effect_state_topic = "fx_stat_t", - effect_template = "fx_tpl", - effect_value_template = "fx_val_tpl", - enabled_by_default = "en", - encoding = "e", - entity_category = "ent_cat", - entity_picture = "ent_pic", - event_types = "evt_typ", - expire_after = "exp_aft", - fan_mode_command_template = "fan_mode_cmd_tpl", - fan_mode_command_topic = "fan_mode_cmd_t", - fan_mode_state_template = "fan_mode_stat_tpl", - fan_mode_state_topic = "fan_mode_stat_t", - fan_speed_list = "fanspd_lst", - flash = "flsh", - flash_time_long = "flsh_tlng", - flash_time_short = "flsh_tsht", - force_update = "frc_upd", - green_template = "g_tpl", - hs_command_template = "hs_cmd_tpl", - hs_command_topic = "hs_cmd_t", - hs_state_topic = "hs_stat_t", - hs_value_template = "hs_val_tpl", - hw_version = "hw", - icon = "ic", - identifiers = "ids", - image_encoding = "img_e", - image_topic = "img_t", - initial = "init", - json_attributes = "json_attr", - json_attributes_template = "json_attr_tpl", - json_attributes_topic = "json_attr_t", - last_reset_topic = "lrst_t", - last_reset_value_template = "lrst_val_tpl", - latest_version_template = "l_ver_tpl", - latest_version_topic = "l_ver_t", - manufacturer = "mf", - max = "max", - max_humidity = "max_hum", - max_kelvin = "max_k", - max_mireds = "max_mirs", - max_temp = "max_temp", - migrate_discovery = "migr_discvry", - min = "min", - min_humidity = "min_hum", - min_kelvin = "min_k", - min_mireds = "min_mirs", - min_temp = "min_temp", - mode = "mode", - mode_command_template = "mode_cmd_tpl", - mode_command_topic = "mode_cmd_t", - mode_state_template = "mode_stat_tpl", - mode_state_topic = "mode_stat_t", - model = "mdl", - model_id = "mdl_id", - modes = "modes", - name = "name", - object_id = "obj_id", - off_delay = "off_dly", - on_command_type = "on_cmd_type", - optimistic = "opt", - options = "ops", - origin = "o", - oscillation_command_template = "osc_cmd_tpl", - oscillation_command_topic = "osc_cmd_t", - oscillation_state_topic = "osc_stat_t", - oscillation_value_template = "osc_val_tpl", - pattern = "ptrn", - payload = "pl", - payload_arm_away = "pl_arm_away", - payload_arm_custom_bypass = "pl_arm_custom_b", - payload_arm_home = "pl_arm_home", - payload_arm_night = "pl_arm_nite", - payload_arm_vacation = "pl_arm_vacation", - payload_available = "pl_avail", - payload_clean_spot = "pl_cln_sp", - payload_close = "pl_cls", - payload_direction_forward = "pl_dir_fwd", - payload_direction_reverse = "pl_dir_rev", - payload_disarm = "pl_disarm", - payload_home = "pl_home", - payload_install = "pl_inst", - payload_locate = "pl_loc", - payload_lock = "pl_lock", - payload_not_available = "pl_not_avail", - payload_not_home = "pl_not_home", - payload_off = "pl_off", - payload_on = "pl_on", - payload_open = "pl_open", - payload_oscillation_off = "pl_osc_off", - payload_oscillation_on = "pl_osc_on", - payload_pause = "pl_paus", - payload_press = "pl_prs", - payload_reset = "pl_rst", - payload_reset_humidity = "pl_rst_hum", - payload_reset_mode = "pl_rst_mode", - payload_reset_percentage = "pl_rst_pct", - payload_reset_preset_mode = "pl_rst_pr_mode", - payload_return_to_base = "pl_ret", - payload_start = "pl_strt", - payload_start_pause = "pl_stpa", - payload_stop = "pl_stop", - payload_stop_tilt = "pl_stop_tilt", - payload_trigger = "pl_trig", - payload_turn_off = "pl_toff", - payload_turn_on = "pl_ton", - payload_unlock = "pl_unlk", - percentage_command_template = "pct_cmd_tpl", - percentage_command_topic = "pct_cmd_t", - percentage_state_topic = "pct_stat_t", - percentage_value_template = "pct_val_tpl", - platform = "p", - position_closed = "pos_clsd", - position_open = "pos_open", - position_template = "pos_tpl", - position_topic = "pos_t", - preset_mode_command_template = "pr_mode_cmd_tpl", - preset_mode_command_topic = "pr_mode_cmd_t", - preset_mode_state_topic = "pr_mode_stat_t", - preset_mode_value_template = "pr_mode_val_tpl", - preset_modes = "pr_modes", - red_template = "r_tpl", - release_summary = "rel_s", - release_url = "rel_u", - reports_position = "pos", - retain = "ret", - rgb_command_template = "rgb_cmd_tpl", - rgb_command_topic = "rgb_cmd_t", - rgb_state_topic = "rgb_stat_t", - rgb_value_template = "rgb_val_tpl", - rgbw_command_template = "rgbw_cmd_tpl", - rgbw_command_topic = "rgbw_cmd_t", - rgbw_state_topic = "rgbw_stat_t", - rgbw_value_template = "rgbw_val_tpl", - rgbww_command_template = "rgbww_cmd_tpl", - rgbww_command_topic = "rgbww_cmd_t", - rgbww_state_topic = "rgbww_stat_t", - rgbww_value_template = "rgbww_val_tpl", - schema = "schema", - send_command_topic = "send_cmd_t", - send_if_off = "send_if_off", - serial_number = "sn", - set_fan_speed_topic = "set_fan_spd_t", - set_position_template = "set_pos_tpl", - set_position_topic = "set_pos_t", - source_type = "src_type", - speed_range_max = "spd_rng_max", - speed_range_min = "spd_rng_min", - state_class = "stat_cla", - state_closed = "stat_clsd", - state_closing = "stat_closing", - state_jammed = "stat_jam", - state_locked = "stat_locked", - state_locking = "stat_locking", - state_off = "stat_off", - state_on = "stat_on", - state_open = "stat_open", - state_opening = "stat_opening", - state_stopped = "stat_stopped", - state_template = "stat_tpl", - state_topic = "stat_t", - state_unlocked = "stat_unlocked", - state_unlocking = "stat_unlocking", - state_value_template = "stat_val_tpl", - step = "step", - subtype = "stype", - suggested_area = "sa", - suggested_display_precision = "sug_dsp_prc", - support_duration = "sup_dur", - support_url = "url", - support_volume_set = "sup_vol", - supported_color_modes = "sup_clrm", - supported_features = "sup_feat", - sw_version = "sw", - swing_mode_command_template = "swing_mode_cmd_tpl", - swing_mode_command_topic = "swing_mode_cmd_t", - swing_mode_state_template = "swing_mode_stat_tpl", - swing_mode_state_topic = "swing_mode_stat_t", - target_humidity_command_template = "hum_cmd_tpl", - target_humidity_command_topic = "hum_cmd_t", - target_humidity_state_template = "hum_state_tpl", - target_humidity_state_topic = "hum_stat_t", - temperature_command_template = "temp_cmd_tpl", - temperature_command_topic = "temp_cmd_t", - temperature_high_command_template = "temp_hi_cmd_tpl", - temperature_high_command_topic = "temp_hi_cmd_t", - temperature_high_state_template = "temp_hi_stat_tpl", - temperature_high_state_topic = "temp_hi_stat_t", - temperature_low_command_template = "temp_lo_cmd_tpl", - temperature_low_command_topic = "temp_lo_cmd_t", - temperature_low_state_template = "temp_lo_stat_tpl", - temperature_low_state_topic = "temp_lo_stat_t", - temperature_state_template = "temp_stat_tpl", - temperature_state_topic = "temp_stat_t", - temperature_unit = "temp_unit", - tilt_closed_value = "tilt_clsd_val", - tilt_command_template = "tilt_cmd_tpl", - tilt_command_topic = "tilt_cmd_t", - tilt_max = "tilt_max", - tilt_min = "tilt_min", - tilt_opened_value = "tilt_opnd_val", - tilt_optimistic = "tilt_opt", - tilt_status_template = "tilt_status_tpl", - tilt_status_topic = "tilt_status_t", - title = "tit", - topic = "t", - transition = "trns", - type = "type", - unique_id = "uniq_id", - unit_of_measurement = "unit_of_meas", - url_template = "url_tpl", - url_topic = "url_t", - value_template = "val_tpl", - white_command_topic = "whit_cmd_t", - white_scale = "whit_scl", - xy_command_template = "xy_cmd_tpl", - xy_command_topic = "xy_cmd_t", - xy_state_topic = "xy_stat_t", - xy_value_template = "xy_val_tpl"; -}; +static constexpr std::string_view action_template = "act_tpl"; +static constexpr std::string_view action_topic = "act_t"; +static constexpr std::string_view automation_type = "atype"; +static constexpr std::string_view aux_command_topic = "aux_cmd_t"; +static constexpr std::string_view aux_state_template = "aux_stat_tpl"; +static constexpr std::string_view aux_state_topic = "aux_stat_t"; +static constexpr std::string_view availability = "avty"; +static constexpr std::string_view availability_mode = "avty_mode"; +static constexpr std::string_view availability_template = "avty_tpl"; +static constexpr std::string_view availability_topic = "avty_t"; +static constexpr std::string_view available_tones = "av_tones"; +static constexpr std::string_view away_mode_command_topic = "away_mode_cmd_t"; +static constexpr std::string_view away_mode_state_template = "away_mode_stat_tpl"; +static constexpr std::string_view away_mode_state_topic = "away_mode_stat_t"; +static constexpr std::string_view blue_template = "b_tpl"; +static constexpr std::string_view brightness_command_template = "bri_cmd_tpl"; +static constexpr std::string_view brightness_command_topic = "bri_cmd_t"; +static constexpr std::string_view brightness_scale = "bri_scl"; +static constexpr std::string_view brightness_state_topic = "bri_stat_t"; +static constexpr std::string_view brightness_template = "bri_tpl"; +static constexpr std::string_view brightness_value_template = "bri_val_tpl"; +static constexpr std::string_view code_arm_required = "cod_arm_req"; +static constexpr std::string_view code_disarm_required = "cod_dis_req"; +static constexpr std::string_view code_trigger_required = "cod_trig_req"; +static constexpr std::string_view color_mode = "clrm"; +static constexpr std::string_view color_mode_state_topic = "clrm_stat_t"; +static constexpr std::string_view color_mode_value_template = "clrm_val_tpl"; +static constexpr std::string_view color_temp_command_template = "clr_temp_cmd_tpl"; +static constexpr std::string_view color_temp_command_topic = "clr_temp_cmd_t"; +static constexpr std::string_view color_temp_kelvin = "clr_temp_k"; +static constexpr std::string_view color_temp_state_topic = "clr_temp_stat_t"; +static constexpr std::string_view color_temp_template = "clr_temp_tpl"; +static constexpr std::string_view color_temp_value_template = "clr_temp_val_tpl"; +static constexpr std::string_view command_off_template = "cmd_off_tpl"; +static constexpr std::string_view command_on_template = "cmd_on_tpl"; +static constexpr std::string_view command_template = "cmd_tpl"; +static constexpr std::string_view command_topic = "cmd_t"; +static constexpr std::string_view components = "cmps"; +static constexpr std::string_view configuration_url = "cu"; +static constexpr std::string_view connections = "cns"; +static constexpr std::string_view content_type = "cont_type"; +static constexpr std::string_view current_temperature_template = "curr_temp_tpl"; +static constexpr std::string_view current_temperature_topic = "curr_temp_t"; +static constexpr std::string_view device = "dev"; +static constexpr std::string_view device_class = "dev_cla"; +static constexpr std::string_view direction_command_template = "dir_cmd_tpl"; +static constexpr std::string_view direction_command_topic = "dir_cmd_t"; +static constexpr std::string_view direction_state_topic = "dir_stat_t"; +static constexpr std::string_view direction_value_template = "dir_val_tpl"; +static constexpr std::string_view display_precision = "dsp_prc"; +static constexpr std::string_view effect_command_template = "fx_cmd_tpl"; +static constexpr std::string_view effect_command_topic = "fx_cmd_t"; +static constexpr std::string_view effect_list = "fx_list"; +static constexpr std::string_view effect_state_topic = "fx_stat_t"; +static constexpr std::string_view effect_template = "fx_tpl"; +static constexpr std::string_view effect_value_template = "fx_val_tpl"; +static constexpr std::string_view enabled_by_default = "en"; +static constexpr std::string_view encoding = "e"; +static constexpr std::string_view entity_category = "ent_cat"; +static constexpr std::string_view entity_picture = "ent_pic"; +static constexpr std::string_view event_types = "evt_typ"; +static constexpr std::string_view expire_after = "exp_aft"; +static constexpr std::string_view fan_mode_command_template = "fan_mode_cmd_tpl"; +static constexpr std::string_view fan_mode_command_topic = "fan_mode_cmd_t"; +static constexpr std::string_view fan_mode_state_template = "fan_mode_stat_tpl"; +static constexpr std::string_view fan_mode_state_topic = "fan_mode_stat_t"; +static constexpr std::string_view fan_speed_list = "fanspd_lst"; +static constexpr std::string_view flash = "flsh"; +static constexpr std::string_view flash_time_long = "flsh_tlng"; +static constexpr std::string_view flash_time_short = "flsh_tsht"; +static constexpr std::string_view force_update = "frc_upd"; +static constexpr std::string_view green_template = "g_tpl"; +static constexpr std::string_view hs_command_template = "hs_cmd_tpl"; +static constexpr std::string_view hs_command_topic = "hs_cmd_t"; +static constexpr std::string_view hs_state_topic = "hs_stat_t"; +static constexpr std::string_view hs_value_template = "hs_val_tpl"; +static constexpr std::string_view hw_version = "hw"; +static constexpr std::string_view icon = "ic"; +static constexpr std::string_view identifiers = "ids"; +static constexpr std::string_view image_encoding = "img_e"; +static constexpr std::string_view image_topic = "img_t"; +static constexpr std::string_view initial = "init"; +static constexpr std::string_view json_attributes = "json_attr"; +static constexpr std::string_view json_attributes_template = "json_attr_tpl"; +static constexpr std::string_view json_attributes_topic = "json_attr_t"; +static constexpr std::string_view last_reset_topic = "lrst_t"; +static constexpr std::string_view last_reset_value_template = "lrst_val_tpl"; +static constexpr std::string_view latest_version_template = "l_ver_tpl"; +static constexpr std::string_view latest_version_topic = "l_ver_t"; +static constexpr std::string_view manufacturer = "mf"; +static constexpr std::string_view max = "max"; +static constexpr std::string_view max_humidity = "max_hum"; +static constexpr std::string_view max_kelvin = "max_k"; +static constexpr std::string_view max_mireds = "max_mirs"; +static constexpr std::string_view max_temp = "max_temp"; +static constexpr std::string_view migrate_discovery = "migr_discvry"; +static constexpr std::string_view min = "min"; +static constexpr std::string_view min_humidity = "min_hum"; +static constexpr std::string_view min_kelvin = "min_k"; +static constexpr std::string_view min_mireds = "min_mirs"; +static constexpr std::string_view min_temp = "min_temp"; +static constexpr std::string_view mode = "mode"; +static constexpr std::string_view mode_command_template = "mode_cmd_tpl"; +static constexpr std::string_view mode_command_topic = "mode_cmd_t"; +static constexpr std::string_view mode_state_template = "mode_stat_tpl"; +static constexpr std::string_view mode_state_topic = "mode_stat_t"; +static constexpr std::string_view model = "mdl"; +static constexpr std::string_view model_id = "mdl_id"; +static constexpr std::string_view modes = "modes"; +static constexpr std::string_view name = "name"; +static constexpr std::string_view object_id = "obj_id"; +static constexpr std::string_view off_delay = "off_dly"; +static constexpr std::string_view on_command_type = "on_cmd_type"; +static constexpr std::string_view optimistic = "opt"; +static constexpr std::string_view options = "ops"; +static constexpr std::string_view origin = "o"; +static constexpr std::string_view oscillation_command_template = "osc_cmd_tpl"; +static constexpr std::string_view oscillation_command_topic = "osc_cmd_t"; +static constexpr std::string_view oscillation_state_topic = "osc_stat_t"; +static constexpr std::string_view oscillation_value_template = "osc_val_tpl"; +static constexpr std::string_view pattern = "ptrn"; +static constexpr std::string_view payload = "pl"; +static constexpr std::string_view payload_arm_away = "pl_arm_away"; +static constexpr std::string_view payload_arm_custom_bypass = "pl_arm_custom_b"; +static constexpr std::string_view payload_arm_home = "pl_arm_home"; +static constexpr std::string_view payload_arm_night = "pl_arm_nite"; +static constexpr std::string_view payload_arm_vacation = "pl_arm_vacation"; +static constexpr std::string_view payload_available = "pl_avail"; +static constexpr std::string_view payload_clean_spot = "pl_cln_sp"; +static constexpr std::string_view payload_close = "pl_cls"; +static constexpr std::string_view payload_direction_forward = "pl_dir_fwd"; +static constexpr std::string_view payload_direction_reverse = "pl_dir_rev"; +static constexpr std::string_view payload_disarm = "pl_disarm"; +static constexpr std::string_view payload_home = "pl_home"; +static constexpr std::string_view payload_install = "pl_inst"; +static constexpr std::string_view payload_locate = "pl_loc"; +static constexpr std::string_view payload_lock = "pl_lock"; +static constexpr std::string_view payload_not_available = "pl_not_avail"; +static constexpr std::string_view payload_not_home = "pl_not_home"; +static constexpr std::string_view payload_off = "pl_off"; +static constexpr std::string_view payload_on = "pl_on"; +static constexpr std::string_view payload_open = "pl_open"; +static constexpr std::string_view payload_oscillation_off = "pl_osc_off"; +static constexpr std::string_view payload_oscillation_on = "pl_osc_on"; +static constexpr std::string_view payload_pause = "pl_paus"; +static constexpr std::string_view payload_press = "pl_prs"; +static constexpr std::string_view payload_reset = "pl_rst"; +static constexpr std::string_view payload_reset_humidity = "pl_rst_hum"; +static constexpr std::string_view payload_reset_mode = "pl_rst_mode"; +static constexpr std::string_view payload_reset_percentage = "pl_rst_pct"; +static constexpr std::string_view payload_reset_preset_mode = "pl_rst_pr_mode"; +static constexpr std::string_view payload_return_to_base = "pl_ret"; +static constexpr std::string_view payload_start = "pl_strt"; +static constexpr std::string_view payload_start_pause = "pl_stpa"; +static constexpr std::string_view payload_stop = "pl_stop"; +static constexpr std::string_view payload_stop_tilt = "pl_stop_tilt"; +static constexpr std::string_view payload_trigger = "pl_trig"; +static constexpr std::string_view payload_turn_off = "pl_toff"; +static constexpr std::string_view payload_turn_on = "pl_ton"; +static constexpr std::string_view payload_unlock = "pl_unlk"; +static constexpr std::string_view percentage_command_template = "pct_cmd_tpl"; +static constexpr std::string_view percentage_command_topic = "pct_cmd_t"; +static constexpr std::string_view percentage_state_topic = "pct_stat_t"; +static constexpr std::string_view percentage_value_template = "pct_val_tpl"; +static constexpr std::string_view platform = "p"; +static constexpr std::string_view position_closed = "pos_clsd"; +static constexpr std::string_view position_open = "pos_open"; +static constexpr std::string_view position_template = "pos_tpl"; +static constexpr std::string_view position_topic = "pos_t"; +static constexpr std::string_view preset_mode_command_template = "pr_mode_cmd_tpl"; +static constexpr std::string_view preset_mode_command_topic = "pr_mode_cmd_t"; +static constexpr std::string_view preset_mode_state_topic = "pr_mode_stat_t"; +static constexpr std::string_view preset_mode_value_template = "pr_mode_val_tpl"; +static constexpr std::string_view preset_modes = "pr_modes"; +static constexpr std::string_view red_template = "r_tpl"; +static constexpr std::string_view release_summary = "rel_s"; +static constexpr std::string_view release_url = "rel_u"; +static constexpr std::string_view reports_position = "pos"; +static constexpr std::string_view retain = "ret"; +static constexpr std::string_view rgb_command_template = "rgb_cmd_tpl"; +static constexpr std::string_view rgb_command_topic = "rgb_cmd_t"; +static constexpr std::string_view rgb_state_topic = "rgb_stat_t"; +static constexpr std::string_view rgb_value_template = "rgb_val_tpl"; +static constexpr std::string_view rgbw_command_template = "rgbw_cmd_tpl"; +static constexpr std::string_view rgbw_command_topic = "rgbw_cmd_t"; +static constexpr std::string_view rgbw_state_topic = "rgbw_stat_t"; +static constexpr std::string_view rgbw_value_template = "rgbw_val_tpl"; +static constexpr std::string_view rgbww_command_template = "rgbww_cmd_tpl"; +static constexpr std::string_view rgbww_command_topic = "rgbww_cmd_t"; +static constexpr std::string_view rgbww_state_topic = "rgbww_stat_t"; +static constexpr std::string_view rgbww_value_template = "rgbww_val_tpl"; +static constexpr std::string_view schema = "schema"; +static constexpr std::string_view send_command_topic = "send_cmd_t"; +static constexpr std::string_view send_if_off = "send_if_off"; +static constexpr std::string_view serial_number = "sn"; +static constexpr std::string_view set_fan_speed_topic = "set_fan_spd_t"; +static constexpr std::string_view set_position_template = "set_pos_tpl"; +static constexpr std::string_view set_position_topic = "set_pos_t"; +static constexpr std::string_view source_type = "src_type"; +static constexpr std::string_view speed_range_max = "spd_rng_max"; +static constexpr std::string_view speed_range_min = "spd_rng_min"; +static constexpr std::string_view state_class = "stat_cla"; +static constexpr std::string_view state_closed = "stat_clsd"; +static constexpr std::string_view state_closing = "stat_closing"; +static constexpr std::string_view state_jammed = "stat_jam"; +static constexpr std::string_view state_locked = "stat_locked"; +static constexpr std::string_view state_locking = "stat_locking"; +static constexpr std::string_view state_off = "stat_off"; +static constexpr std::string_view state_on = "stat_on"; +static constexpr std::string_view state_open = "stat_open"; +static constexpr std::string_view state_opening = "stat_opening"; +static constexpr std::string_view state_stopped = "stat_stopped"; +static constexpr std::string_view state_template = "stat_tpl"; +static constexpr std::string_view state_topic = "stat_t"; +static constexpr std::string_view state_unlocked = "stat_unlocked"; +static constexpr std::string_view state_unlocking = "stat_unlocking"; +static constexpr std::string_view state_value_template = "stat_val_tpl"; +static constexpr std::string_view step = "step"; +static constexpr std::string_view subtype = "stype"; +static constexpr std::string_view suggested_area = "sa"; +static constexpr std::string_view suggested_display_precision = "sug_dsp_prc"; +static constexpr std::string_view support_duration = "sup_dur"; +static constexpr std::string_view support_url = "url"; +static constexpr std::string_view support_volume_set = "sup_vol"; +static constexpr std::string_view supported_color_modes = "sup_clrm"; +static constexpr std::string_view supported_features = "sup_feat"; +static constexpr std::string_view sw_version = "sw"; +static constexpr std::string_view swing_mode_command_template = "swing_mode_cmd_tpl"; +static constexpr std::string_view swing_mode_command_topic = "swing_mode_cmd_t"; +static constexpr std::string_view swing_mode_state_template = "swing_mode_stat_tpl"; +static constexpr std::string_view swing_mode_state_topic = "swing_mode_stat_t"; +static constexpr std::string_view target_humidity_command_template = "hum_cmd_tpl"; +static constexpr std::string_view target_humidity_command_topic = "hum_cmd_t"; +static constexpr std::string_view target_humidity_state_template = "hum_state_tpl"; +static constexpr std::string_view target_humidity_state_topic = "hum_stat_t"; +static constexpr std::string_view temperature_command_template = "temp_cmd_tpl"; +static constexpr std::string_view temperature_command_topic = "temp_cmd_t"; +static constexpr std::string_view temperature_high_command_template = "temp_hi_cmd_tpl"; +static constexpr std::string_view temperature_high_command_topic = "temp_hi_cmd_t"; +static constexpr std::string_view temperature_high_state_template = "temp_hi_stat_tpl"; +static constexpr std::string_view temperature_high_state_topic = "temp_hi_stat_t"; +static constexpr std::string_view temperature_low_command_template = "temp_lo_cmd_tpl"; +static constexpr std::string_view temperature_low_command_topic = "temp_lo_cmd_t"; +static constexpr std::string_view temperature_low_state_template = "temp_lo_stat_tpl"; +static constexpr std::string_view temperature_low_state_topic = "temp_lo_stat_t"; +static constexpr std::string_view temperature_state_template = "temp_stat_tpl"; +static constexpr std::string_view temperature_state_topic = "temp_stat_t"; +static constexpr std::string_view temperature_unit = "temp_unit"; +static constexpr std::string_view tilt_closed_value = "tilt_clsd_val"; +static constexpr std::string_view tilt_command_template = "tilt_cmd_tpl"; +static constexpr std::string_view tilt_command_topic = "tilt_cmd_t"; +static constexpr std::string_view tilt_max = "tilt_max"; +static constexpr std::string_view tilt_min = "tilt_min"; +static constexpr std::string_view tilt_opened_value = "tilt_opnd_val"; +static constexpr std::string_view tilt_optimistic = "tilt_opt"; +static constexpr std::string_view tilt_status_template = "tilt_status_tpl"; +static constexpr std::string_view tilt_status_topic = "tilt_status_t"; +static constexpr std::string_view title = "tit"; +static constexpr std::string_view topic = "t"; +static constexpr std::string_view transition = "trns"; +static constexpr std::string_view type = "type"; +static constexpr std::string_view unique_id = "uniq_id"; +static constexpr std::string_view unit_of_measurement = "unit_of_meas"; +static constexpr std::string_view url_template = "url_tpl"; +static constexpr std::string_view url_topic = "url_t"; +static constexpr std::string_view value_template = "val_tpl"; +static constexpr std::string_view white_command_topic = "whit_cmd_t"; +static constexpr std::string_view white_scale = "whit_scl"; +static constexpr std::string_view xy_command_template = "xy_cmd_tpl"; +static constexpr std::string_view xy_command_topic = "xy_cmd_t"; +static constexpr std::string_view xy_state_topic = "xy_stat_t"; +static constexpr std::string_view xy_value_template = "xy_val_tpl"; +}; // namespace HomeAssistantAbbreviations #endif // EXTENSION_HOMEASSISTANT diff --git a/firmware/include/extensions/InfraredExtension.h b/firmware/include/extensions/InfraredExtension.h index ba51ac45..9f8b3ff2 100644 --- a/firmware/include/extensions/InfraredExtension.h +++ b/firmware/include/extensions/InfraredExtension.h @@ -18,22 +18,21 @@ class InfraredExtension : public ExtensionModule struct Code { const decode_type_t protocol; - const std::vector - displayBrightnessDecrease, - displayBrightnessIncrease, - displayPowerToggle, + const std::vector displayBrightnessDecrease; + const std::vector displayBrightnessIncrease; + const std::vector displayPowerToggle; #if EXTENSION_MICROPHONE - extensionMicrophoneToggle, + const std::vector extensionMicrophoneToggle; #endif // EXTENSION_MICROPHONE #if EXTENSION_PHOTOCELL - extensionPhotocellToggle, + const std::vector extensionPhotocellToggle; #endif // EXTENSION_PHOTOCELL #if EXTENSION_PLAYLIST - extensionPlaylistStart, - extensionPlaylistStop, + const std::vector extensionPlaylistStart; + const std::vector extensionPlaylistStop; #endif // EXTENSION_PLAYLIST - modeNext, - modePrevious; + const std::vector modeNext; + const std::vector modePrevious; }; const std::vector codes = { diff --git a/firmware/include/extensions/MessageExtension.h b/firmware/include/extensions/MessageExtension.h index 3a5c6cf9..da904f2a 100644 --- a/firmware/include/extensions/MessageExtension.h +++ b/firmware/include/extensions/MessageExtension.h @@ -12,19 +12,16 @@ class MessageExtension : public ExtensionModule { private: - bool - active = false, - pending = false; + bool active = false; + bool pending = false; int8_t offsetY = 0; - int16_t - offsetX = GRID_COLUMNS, - width = 0; + int16_t offsetX = GRID_COLUMNS; + int16_t width = 0; - uint8_t - frame[GRID_COLUMNS * GRID_ROWS], - repeat = 3; + uint8_t frame[GRID_COLUMNS * GRID_ROWS]; + uint8_t repeat = 3; unsigned long lastMillis = 0; diff --git a/firmware/include/extensions/MicrophoneExtension.h b/firmware/include/extensions/MicrophoneExtension.h index e54c9d84..3a1a56a2 100644 --- a/firmware/include/extensions/MicrophoneExtension.h +++ b/firmware/include/extensions/MicrophoneExtension.h @@ -7,19 +7,16 @@ class MicrophoneExtension : public ExtensionModule { private: - bool - active = false, - detected = false, - pending = false; - - uint16_t - levelMax = UINT8_MAX, - mic = 0, - threshold = INT8_MAX; - - unsigned long - lastMillis = 0, - _lastMillis = 0; + bool active = false; + bool detected = false; + bool pending = false; + + uint16_t levelMax = UINT8_MAX; + uint16_t mic = 0; + uint16_t threshold = INT8_MAX; + + unsigned long lastMillis = 0; + unsigned long _lastMillis = 0; void transmit(); diff --git a/firmware/include/extensions/MqttExtension.h b/firmware/include/extensions/MqttExtension.h index 3f03ced7..db1fba72 100644 --- a/firmware/include/extensions/MqttExtension.h +++ b/firmware/include/extensions/MqttExtension.h @@ -13,13 +13,13 @@ class MqttExtension : public ExtensionModule static inline bool subscribed = false; - static constexpr size_t - prefixLength = sizeof("frekvens/" HOSTNAME "/") - 1, - suffixLength = sizeof("/set") - 1; + static constexpr size_t prefixLength = sizeof("frekvens/" HOSTNAME "/") - 1; + static constexpr size_t suffixLength = sizeof("/set") - 1; static void onConnect(bool sessionPresent); static void onDisconnect(espMqttClientTypes::DisconnectReason reason); - static void onMessage(const espMqttClientTypes::MessageProperties &properties, const char *topic, const uint8_t *payload, size_t len, size_t index, size_t total); + static void onMessage(const espMqttClientTypes::MessageProperties &properties, const char *topic, + const uint8_t *payload, size_t len, size_t index, size_t total); public: MqttExtension(); diff --git a/firmware/include/extensions/OtaExtension.h b/firmware/include/extensions/OtaExtension.h index 891d83d4..1b365284 100644 --- a/firmware/include/extensions/OtaExtension.h +++ b/firmware/include/extensions/OtaExtension.h @@ -16,7 +16,8 @@ class OtaExtension : public ExtensionModule static void onEnd(); #ifndef OTA_KEY - static void onPost(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final); + static void onPost(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, + bool final); #endif public: diff --git a/firmware/include/extensions/PhotocellExtension.h b/firmware/include/extensions/PhotocellExtension.h index c53aac53..740cc0a1 100644 --- a/firmware/include/extensions/PhotocellExtension.h +++ b/firmware/include/extensions/PhotocellExtension.h @@ -7,10 +7,9 @@ class PhotocellExtension : public ExtensionModule { private: - bool - active = false, - direction = false, - pending = false; + bool active = false; + bool direction = false; + bool pending = false; float gamma = 1.0f; @@ -20,9 +19,8 @@ class PhotocellExtension : public ExtensionModule uint16_t raw = 0; - unsigned long - lastMillis = 0, - _lastMillis = 0; + unsigned long lastMillis = 0; + unsigned long _lastMillis = 0; void setGamma(float _gamma); diff --git a/firmware/include/extensions/SignalExtension.h b/firmware/include/extensions/SignalExtension.h index 9bd43500..22841d58 100644 --- a/firmware/include/extensions/SignalExtension.h +++ b/firmware/include/extensions/SignalExtension.h @@ -13,9 +13,8 @@ class SignalExtension : public ExtensionModule unsigned long lastMillis = 0; - uint8_t - duration = 30, - frame[GRID_COLUMNS * GRID_ROWS] = {0}; + uint8_t duration = 30; + uint8_t frame[GRID_COLUMNS * GRID_ROWS] = {0}; std::vector> signals; diff --git a/firmware/include/extensions/WebSocketExtension.h b/firmware/include/extensions/WebSocketExtension.h index e67e2e8c..93df1cb9 100644 --- a/firmware/include/extensions/WebSocketExtension.h +++ b/firmware/include/extensions/WebSocketExtension.h @@ -9,7 +9,8 @@ class WebSocketExtension : public ExtensionModule { private: - static void onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len); + static void onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, + uint8_t *data, size_t len); public: WebSocketExtension(); diff --git a/firmware/include/handlers/BitmapHandler.h b/firmware/include/handlers/BitmapHandler.h index 4f554c64..42af1efc 100644 --- a/firmware/include/handlers/BitmapHandler.h +++ b/firmware/include/handlers/BitmapHandler.h @@ -11,9 +11,8 @@ class BitmapHandler const std::vector bitmap; - uint8_t - height = 0, - width = 0; + uint8_t height = 0; + uint8_t width = 0; public: BitmapHandler(std::vector bitmap); diff --git a/firmware/include/handlers/TextHandler.h b/firmware/include/handlers/TextHandler.h index b53ec6a4..600d14e7 100644 --- a/firmware/include/handlers/TextHandler.h +++ b/firmware/include/handlers/TextHandler.h @@ -14,11 +14,10 @@ class TextHandler FontModule *font = nullptr; - uint8_t - height = 0, - i = 0, - tracking = 1, - width = 0; + uint8_t height = 0; + uint8_t i = 0; + uint8_t tracking = 1; + uint8_t width = 0; uint8_t calcMsbMax(const FontModule::Symbol &character) const; diff --git a/firmware/include/handlers/WeatherHandler.h b/firmware/include/handlers/WeatherHandler.h index a71508ad..e5c148fe 100644 --- a/firmware/include/handlers/WeatherHandler.h +++ b/firmware/include/handlers/WeatherHandler.h @@ -49,104 +49,103 @@ class WeatherHandler private: static constexpr std::string_view _name = "WeatherHandler"; - const std::vector - conditionClear = { - 0b0011100, - 0b0111110, - 0b1111111, - 0b1111111, - 0b1111111, - 0b0111110, - 0b0011100, - }, - conditionClearTall = { - 0b001100, - 0b011110, - 0b111111, - 0b111111, - 0b111111, - 0b111111, - 0b011110, - 0b001100, - }, - conditionClearWide = { - 0b00111100, - 0b01111110, - 0b11111111, - 0b11111111, - 0b01111110, - 0b00111100, - }, - conditionCloudy = { - 0b0000111000000, - 0b0001100111000, - 0b0111000001100, - 0b1100100000011, - 0b0111111111110, - }, - conditionCloudyPartly = { - 0b0000000001110, - 0b0000111011111, - 0b0001100111111, - 0b0111000001110, - 0b1100010000011, - 0b0111111111110, - }, - conditionExceptional = { - 0b00000100000, - 0b00001010000, - 0b00010001000, - 0b00100000100, - 0b01000000010, - 0b11111111111, - }, - conditionFog = { - 0b00000111111110, - 0b01111110000000, - 0b00001111111111, - 0b11111110000000, - 0b00000111111100, - 0b01111111000000, - }, - conditionRain = { - 0b0000111000000, - 0b0001100111000, - 0b0111000001100, - 0b1100100000011, - 0b0111111111110, - 0b0010100100100, - 0b0010100100100, - 0b0010100100100, - }, - conditionSnow = { - 0b0000111000000, - 0b0001100111000, - 0b0111000001100, - 0b1100100000011, - 0b0111111111110, - 0b0001010010000, - 0b0010000100100, - 0b0000100010000, - }, - conditionThunder = { - 0b0000111000000, - 0b0001100111000, - 0b0111000001100, - 0b1100000100011, - 0b0111001001110, - 0b0000011100000, - 0b0000001000000, - 0b0000010000000, - }, - conditionWind = { - 0b10111000000, - 0b10100111000, - 0b11100000111, - 0b10100111000, - 0b10111000000, - 0b10000000000, - 0b10000000000, - 0b10000000000, + const std::vector conditionClear = { + 0b0011100, + 0b0111110, + 0b1111111, + 0b1111111, + 0b1111111, + 0b0111110, + 0b0011100, + }; + const std::vector conditionClearTall = { + 0b001100, + 0b011110, + 0b111111, + 0b111111, + 0b111111, + 0b111111, + 0b011110, + 0b001100, + }; + const std::vector conditionClearWide = { + 0b00111100, + 0b01111110, + 0b11111111, + 0b11111111, + 0b01111110, + 0b00111100, + }; + const std::vector conditionCloudy = { + 0b0000111000000, + 0b0001100111000, + 0b0111000001100, + 0b1100100000011, + 0b0111111111110, + }; + const std::vector conditionCloudyPartly = { + 0b0000000001110, + 0b0000111011111, + 0b0001100111111, + 0b0111000001110, + 0b1100010000011, + 0b0111111111110, + }; + const std::vector conditionExceptional = { + 0b00000100000, + 0b00001010000, + 0b00010001000, + 0b00100000100, + 0b01000000010, + 0b11111111111, + }; + const std::vector conditionFog = { + 0b00000111111110, + 0b01111110000000, + 0b00001111111111, + 0b11111110000000, + 0b00000111111100, + 0b01111111000000, + }; + const std::vector conditionRain = { + 0b0000111000000, + 0b0001100111000, + 0b0111000001100, + 0b1100100000011, + 0b0111111111110, + 0b0010100100100, + 0b0010100100100, + 0b0010100100100, + }; + const std::vector conditionSnow = { + 0b0000111000000, + 0b0001100111000, + 0b0111000001100, + 0b1100100000011, + 0b0111111111110, + 0b0001010010000, + 0b0010000100100, + 0b0000100010000, + }; + const std::vector conditionThunder = { + 0b0000111000000, + 0b0001100111000, + 0b0111000001100, + 0b1100000100011, + 0b0111001001110, + 0b0000011100000, + 0b0000001000000, + 0b0000010000000, + }; + const std::vector conditionWind = { + 0b10111000000, + 0b10100111000, + 0b11100000111, + 0b10100111000, + 0b10111000000, + 0b10000000000, + 0b10000000000, + 0b10000000000, }; void setSign(Conditions condition); diff --git a/firmware/include/modes/BinaryClockMode.h b/firmware/include/modes/BinaryClockMode.h index 9fa1ce9b..58068f97 100644 --- a/firmware/include/modes/BinaryClockMode.h +++ b/firmware/include/modes/BinaryClockMode.h @@ -11,10 +11,9 @@ class BinaryClockMode : public ModeModule bool pending = false; - uint8_t - hour, - minute, - second; + uint8_t hour; + uint8_t minute; + uint8_t second; void draw(uint8_t col, uint8_t value); diff --git a/firmware/include/modes/BreakoutClockMode.h b/firmware/include/modes/BreakoutClockMode.h index 5b776965..400328bf 100644 --- a/firmware/include/modes/BreakoutClockMode.h +++ b/firmware/include/modes/BreakoutClockMode.h @@ -12,19 +12,17 @@ class BreakoutClockMode : public ModeModule private: static constexpr float speed = 7e-4 * GRID_ROWS; - float - xDec = GRID_COLUMNS / 2, - yDec = GRID_ROWS - 2; + float xDec = GRID_COLUMNS / 2; + float yDec = GRID_ROWS - 2; std::deque paddle; tm local; - uint8_t - hour, - minute, - x = GRID_COLUMNS / 2, - y = GRID_ROWS - 2; + uint8_t hour; + uint8_t minute; + uint8_t x = GRID_COLUMNS / 2; + uint8_t y = GRID_ROWS - 2; uint16_t deg = 90; diff --git a/firmware/include/modes/CircleMode.h b/firmware/include/modes/CircleMode.h index 629a3363..501dc2ee 100644 --- a/firmware/include/modes/CircleMode.h +++ b/firmware/include/modes/CircleMode.h @@ -8,11 +8,14 @@ class CircleMode : public ModeModule { private: - static constexpr float - x = (GRID_COLUMNS - 1) / 2.0f, - y = (GRID_ROWS - 1) / 2.0f; - - const uint8_t maxRadius = 3 + ceil((max(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, GRID_ROWS *PITCH_VERTICAL / (float)PITCH_HORIZONTAL) / M_SQRT2 + M_SQRT1_2) / 2.0f); + static constexpr float x = (GRID_COLUMNS - 1) / 2.0f; + static constexpr float y = (GRID_ROWS - 1) / 2.0f; + + const uint8_t maxRadius = 3 + ceil((max(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, + GRID_ROWS *PITCH_VERTICAL / (float)PITCH_HORIZONTAL) / + M_SQRT2 + + M_SQRT1_2) / + 2.0f); bool lit = true; diff --git a/firmware/include/modes/CountdownMode.h b/firmware/include/modes/CountdownMode.h index e71c8aaf..21d890cc 100644 --- a/firmware/include/modes/CountdownMode.h +++ b/firmware/include/modes/CountdownMode.h @@ -11,9 +11,8 @@ class CountdownMode : public ModeModule private: bool done = false; - uint8_t - upper = 0, - lower = 0; + uint8_t lower = 0; + uint8_t upper = 0; std::chrono::time_point epoch; diff --git a/firmware/include/modes/DrawMode.h b/firmware/include/modes/DrawMode.h index 87280b51..0ea012cb 100644 --- a/firmware/include/modes/DrawMode.h +++ b/firmware/include/modes/DrawMode.h @@ -8,9 +8,8 @@ class DrawMode : public ModeModule { private: - bool - pending = false, - render = false; + bool pending = false; + bool render = false; uint8_t drawing[GRID_COLUMNS * GRID_ROWS] = {0}; diff --git a/firmware/include/modes/EqualizerMode.h b/firmware/include/modes/EqualizerMode.h index 3fa2a3a5..9738b645 100644 --- a/firmware/include/modes/EqualizerMode.h +++ b/firmware/include/modes/EqualizerMode.h @@ -12,9 +12,8 @@ class EqualizerMode : public ModeModule struct Bar { - uint8_t - level = GRID_ROWS - 1, - target = GRID_ROWS - 1; + uint8_t level = GRID_ROWS - 1; + uint8_t target = GRID_ROWS - 1; }; Bar bars[GRID_COLUMNS / (width + 1)]; diff --git a/firmware/include/modes/FireworkMode.h b/firmware/include/modes/FireworkMode.h index 9fdae56b..668f9340 100644 --- a/firmware/include/modes/FireworkMode.h +++ b/firmware/include/modes/FireworkMode.h @@ -10,13 +10,12 @@ class FireworkMode : public ModeModule private: unsigned long lastMillis = 0; - uint8_t - brightness = UINT8_MAX, - maxRadius = 1, - radius = 0, - rocketX = 0, - rocketY = GRID_ROWS, - stage = 0; + uint8_t brightness = UINT8_MAX; + uint8_t maxRadius = 1; + uint8_t radius = 0; + uint8_t rocketX = 0; + uint8_t rocketY = GRID_ROWS; + uint8_t stage = 0; void pad(); void launching(); diff --git a/firmware/include/modes/FliesMode.h b/firmware/include/modes/FliesMode.h index 04484078..4ff5c661 100644 --- a/firmware/include/modes/FliesMode.h +++ b/firmware/include/modes/FliesMode.h @@ -12,9 +12,8 @@ class FliesMode : public ModeModule private: struct Dot { - uint8_t - x, - y; + uint8_t x; + uint8_t y; }; bool pending = false; diff --git a/firmware/include/modes/GameOfLifeMode.h b/firmware/include/modes/GameOfLifeMode.h index b3adce22..e0a7864e 100644 --- a/firmware/include/modes/GameOfLifeMode.h +++ b/firmware/include/modes/GameOfLifeMode.h @@ -9,14 +9,12 @@ class GameOfLifeMode : public ModeModule private: tm local; - bool - clock = true, - pending = false; - - uint8_t - active = 0, - hour, - minute; + bool clock = true; + bool pending = false; + + uint8_t active = 0; + uint8_t hour; + uint8_t minute; unsigned long lastMillis = 0; diff --git a/firmware/include/modes/GoogleWeatherMode.h b/firmware/include/modes/GoogleWeatherMode.h index 9d951e27..4b7cc37c 100644 --- a/firmware/include/modes/GoogleWeatherMode.h +++ b/firmware/include/modes/GoogleWeatherMode.h @@ -17,11 +17,14 @@ class GoogleWeatherMode : public ModeModule // https://developers.google.com/maps/documentation/weather std::vector urls = { - "https://weather.googleapis.com/v1/currentConditions:lookup?location.latitude=" LATITUDE "&location.longitude=" LONGITUDE "&key=" GOOGLEWEATHER_KEY, + "https://weather.googleapis.com/v1/currentConditions:lookup?location.latitude=" LATITUDE + "&location.longitude=" LONGITUDE "&key=" GOOGLEWEATHER_KEY, #if TEMPERATURE_CELSIUS - "https://weather.googleapis.com/v1/currentConditions:lookup?location.latitude=" LATITUDE "&location.longitude=" LONGITUDE "&unitsSystem=METRIC&key=" GOOGLEWEATHER_KEY, + "https://weather.googleapis.com/v1/currentConditions:lookup?location.latitude=" LATITUDE + "&location.longitude=" LONGITUDE "&unitsSystem=METRIC&key=" GOOGLEWEATHER_KEY, #elif TEMPERATURE_FAHRENHEIT - "https://weather.googleapis.com/v1/currentConditions:lookup?location.latitude=" LATITUDE "&location.longitude=" LONGITUDE "&unitsSystem=IMPERIAL&key=" GOOGLEWEATHER_KEY, + "https://weather.googleapis.com/v1/currentConditions:lookup?location.latitude=" LATITUDE + "&location.longitude=" LONGITUDE "&unitsSystem=IMPERIAL&key=" GOOGLEWEATHER_KEY, #endif // TEMPERATURE_CELSIUS }; diff --git a/firmware/include/modes/HomeAssistantWeatherMode.h b/firmware/include/modes/HomeAssistantWeatherMode.h index 23e6c585..18ebc2f8 100644 --- a/firmware/include/modes/HomeAssistantWeatherMode.h +++ b/firmware/include/modes/HomeAssistantWeatherMode.h @@ -33,9 +33,19 @@ class HomeAssistantWeatherMode : public ModeModule // https://developers.home-assistant.io/docs/api/rest std::vector urls = { - std::string(protocol).append("//").append(host).append(":").append(std::to_string(port)).append("/api/states/weather.forecast_home"), + std::string(protocol) + .append("//") + .append(host) + .append(":") + .append(std::to_string(port)) + .append("/api/states/weather.forecast_home"), #ifdef HOMEASSISTANT_ENTITY - std::string(protocol).append("//").append(host).append(":").append(std::to_string(port)).append("/api/states/" HOMEASSISTANT_ENTITY), + std::string(protocol) + .append("//") + .append(host) + .append(":") + .append(std::to_string(port)) + .append("/api/states/" HOMEASSISTANT_ENTITY), #endif }; diff --git a/firmware/include/modes/LargeClockMode.h b/firmware/include/modes/LargeClockMode.h index 1a625d5e..b3801514 100644 --- a/firmware/include/modes/LargeClockMode.h +++ b/firmware/include/modes/LargeClockMode.h @@ -12,14 +12,12 @@ class LargeClockMode : public ModeModule private: tm local; - bool - pending = false, - ticking = false; - - uint8_t - hour, - minute, - second = 0; + bool pending = false; + bool ticking = false; + + uint8_t hour; + uint8_t minute; + uint8_t second = 0; FontModule *font = nullptr; diff --git a/firmware/include/modes/LeafFallMode.h b/firmware/include/modes/LeafFallMode.h index 7a9b0861..a3e4d74f 100644 --- a/firmware/include/modes/LeafFallMode.h +++ b/firmware/include/modes/LeafFallMode.h @@ -10,10 +10,9 @@ class LeafFallMode : public ModeModule private: struct Leaf { - uint8_t - x, - y, - brightness; + uint8_t x; + uint8_t y; + uint8_t brightness; uint16_t delay; unsigned long lastMillis = 0; }; diff --git a/firmware/include/modes/MetaballsMode.h b/firmware/include/modes/MetaballsMode.h index f03a06b4..996ca352 100644 --- a/firmware/include/modes/MetaballsMode.h +++ b/firmware/include/modes/MetaballsMode.h @@ -8,20 +8,20 @@ class MetaballsMode : public ModeModule { private: - static constexpr float - radius = min(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, GRID_ROWS *PITCH_VERTICAL / (float)PITCH_HORIZONTAL) / PI, - radiusSq = radius * radius, - speed = 5e-6 * GRID_COLUMNS * GRID_ROWS; + static constexpr float radius = min(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, + GRID_ROWS *PITCH_VERTICAL / (float)PITCH_HORIZONTAL) / + PI; + static constexpr float radiusSq = radius * radius; + static constexpr float speed = 5e-6 * GRID_COLUMNS * GRID_ROWS; static constexpr uint8_t multiplier = 1 << 3; struct Ball { - float - x, - y, - xVelocity, - yVelocity; + float x; + float y; + float xVelocity; + float yVelocity; }; uint8_t contributions[1 << 8]; diff --git a/firmware/include/modes/NoiseMode.h b/firmware/include/modes/NoiseMode.h index 609c0d60..1b21ae3d 100644 --- a/firmware/include/modes/NoiseMode.h +++ b/firmware/include/modes/NoiseMode.h @@ -10,10 +10,9 @@ class NoiseMode : public ModeModule private: struct Dot { - uint8_t - x = 0, - y = 0, - delay = 0; + uint8_t x = 0; + uint8_t y = 0; + uint8_t delay = 0; unsigned long lastMillis = 0; }; diff --git a/firmware/include/modes/OpenMeteoMode.h b/firmware/include/modes/OpenMeteoMode.h index 810a5ef0..79568edf 100644 --- a/firmware/include/modes/OpenMeteoMode.h +++ b/firmware/include/modes/OpenMeteoMode.h @@ -17,19 +17,25 @@ class OpenMeteoMode : public ModeModule // https://open-meteo.com/en/docs#api-documentation std::vector urls = { - "https://api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE "¤t=temperature_2m,weather_code", + "https://api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE + "¤t=temperature_2m,weather_code", #if TEMPERATURE_CELSIUS - "https://api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE "¤t=temperature_2m,weather_code&temperature_unit=celsius", + "https://api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE + "¤t=temperature_2m,weather_code&temperature_unit=celsius", #elif TEMPERATURE_FAHRENHEIT - "https://api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE "¤t=temperature_2m,weather_code&temperature_unit=fahrenheit", + "https://api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE + "¤t=temperature_2m,weather_code&temperature_unit=fahrenheit", #endif // TEMPERATURE_CELSIUS #ifdef OPENMETEO_KEY - "https://customer-api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE "¤t=temperature_2m,weather_code&apikey=" OPENMETEO_KEY, + "https://customer-api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE + "¤t=temperature_2m,weather_code&apikey=" OPENMETEO_KEY, #endif // OPENMETEO_KEY #if defined(OPENMETEO_KEY) && TEMPERATURE_CELSIUS - "https://customer-api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE "¤t=temperature_2m,weather_code&temperature_unit=celsius&apikey=" OPENMETEO_KEY, + "https://customer-api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE + "¤t=temperature_2m,weather_code&temperature_unit=celsius&apikey=" OPENMETEO_KEY, #elif defined(OPENMETEO_KEY) && TEMPERATURE_FAHRENHEIT - "https://customer-api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE "¤t=temperature_2m,weather_code&temperature_unit=fahrenheit&apikey=" OPENMETEO_KEY, + "https://customer-api.open-meteo.com/v1/forecast?latitude=" LATITUDE "&longitude=" LONGITUDE + "¤t=temperature_2m,weather_code&temperature_unit=fahrenheit&apikey=" OPENMETEO_KEY, #endif // defined(OPENMETEO_KEY) && TEMPERATURE_CELSIUS }; diff --git a/firmware/include/modes/OpenWeatherMode.h b/firmware/include/modes/OpenWeatherMode.h index 63a25912..0824d064 100644 --- a/firmware/include/modes/OpenWeatherMode.h +++ b/firmware/include/modes/OpenWeatherMode.h @@ -18,17 +18,24 @@ class OpenWeatherMode : public ModeModule // https://openweathermap.org/api/one-call-3#current // https://openweathermap.org/current#one std::vector urls = { - "https://api.openweathermap.org/data/3.0/onecall?lat=" LATITUDE "&lon=" LONGITUDE "&exclude=alerts,daily,hourly,minutely&appid=" OPENWEATHER_KEY, + "https://api.openweathermap.org/data/3.0/onecall?lat=" LATITUDE "&lon=" LONGITUDE + "&exclude=alerts,daily,hourly,minutely&appid=" OPENWEATHER_KEY, "https://api.openweathermap.org/data/2.5/weather?lat=" LATITUDE "&lon=" LONGITUDE "&appid=" OPENWEATHER_KEY, #if TEMPERATURE_KELVIN - "https://api.openweathermap.org/data/3.0/onecall?lat=" LATITUDE "&lon=" LONGITUDE "&exclude=alerts,daily,hourly,minutely&units=standard&appid=" OPENWEATHER_KEY, - "https://api.openweathermap.org/data/2.5/weather?lat=" LATITUDE "&lon=" LONGITUDE "&units=standard&appid=" OPENWEATHER_KEY, + "https://api.openweathermap.org/data/3.0/onecall?lat=" LATITUDE "&lon=" LONGITUDE + "&exclude=alerts,daily,hourly,minutely&units=standard&appid=" OPENWEATHER_KEY, + "https://api.openweathermap.org/data/2.5/weather?lat=" LATITUDE "&lon=" LONGITUDE + "&units=standard&appid=" OPENWEATHER_KEY, #elif TEMPERATURE_CELSIUS - "https://api.openweathermap.org/data/3.0/onecall?lat=" LATITUDE "&lon=" LONGITUDE "&exclude=alerts,daily,hourly,minutely&units=metric&appid=" OPENWEATHER_KEY, - "https://api.openweathermap.org/data/2.5/weather?lat=" LATITUDE "&lon=" LONGITUDE "&units=metric&appid=" OPENWEATHER_KEY, + "https://api.openweathermap.org/data/3.0/onecall?lat=" LATITUDE "&lon=" LONGITUDE + "&exclude=alerts,daily,hourly,minutely&units=metric&appid=" OPENWEATHER_KEY, + "https://api.openweathermap.org/data/2.5/weather?lat=" LATITUDE "&lon=" LONGITUDE + "&units=metric&appid=" OPENWEATHER_KEY, #elif TEMPERATURE_FAHRENHEIT - "https://api.openweathermap.org/data/3.0/onecall?lat=" LATITUDE "&lon=" LONGITUDE "&exclude=alerts,daily,hourly,minutely&units=imperial&appid=" OPENWEATHER_KEY, - "https://api.openweathermap.org/data/2.5/weather?lat=" LATITUDE "&lon=" LONGITUDE "&units=imperial&appid=" OPENWEATHER_KEY, + "https://api.openweathermap.org/data/3.0/onecall?lat=" LATITUDE "&lon=" LONGITUDE + "&exclude=alerts,daily,hourly,minutely&units=imperial&appid=" OPENWEATHER_KEY, + "https://api.openweathermap.org/data/2.5/weather?lat=" LATITUDE "&lon=" LONGITUDE + "&units=imperial&appid=" OPENWEATHER_KEY, #endif // TEMPERATURE_KELVIN }; diff --git a/firmware/include/modes/PingPongMode.h b/firmware/include/modes/PingPongMode.h index 8e7b2a99..481b892b 100644 --- a/firmware/include/modes/PingPongMode.h +++ b/firmware/include/modes/PingPongMode.h @@ -12,25 +12,21 @@ class PingPongMode : public ModeModule private: static constexpr float speed = 1e-3 * GRID_COLUMNS; - bool - clock = true, - pending = false; + bool clock = true; + bool pending = false; - float - xDec, - yDec; + float xDec; + float yDec; - std::deque - paddleA, - paddleB; + std::deque paddleA; + std::deque paddleB; tm local; - uint8_t - hour, - minute, - x = GRID_COLUMNS - 2, - y = GRID_ROWS / 2; + uint8_t hour; + uint8_t minute; + uint8_t x = GRID_COLUMNS - 2; + uint8_t y = GRID_ROWS / 2; uint16_t deg = 135; diff --git a/firmware/include/modes/RainMode.h b/firmware/include/modes/RainMode.h index 13620f43..e3f687ab 100644 --- a/firmware/include/modes/RainMode.h +++ b/firmware/include/modes/RainMode.h @@ -10,11 +10,11 @@ class RainMode : public ModeModule private: struct Drop { - uint8_t - x, - y, - length, - delay; + uint8_t delay; + uint8_t length; + uint8_t x; + uint8_t y; + unsigned long lastMillis = 0; }; diff --git a/firmware/include/modes/SmallClockMode.h b/firmware/include/modes/SmallClockMode.h index 544abd53..2ccf396e 100644 --- a/firmware/include/modes/SmallClockMode.h +++ b/firmware/include/modes/SmallClockMode.h @@ -9,14 +9,12 @@ class SmallClockMode : public ModeModule private: tm local; - bool - pending = false, - ticking = true; - - uint8_t - hour, - minute, - second; + bool pending = false; + bool ticking = true; + + uint8_t hour; + uint8_t minute; + uint8_t second; void setTicking(const bool _ticking); void transmit(); diff --git a/firmware/include/modes/SnakeMode.h b/firmware/include/modes/SnakeMode.h index 3da9ca8a..bd0d6f58 100644 --- a/firmware/include/modes/SnakeMode.h +++ b/firmware/include/modes/SnakeMode.h @@ -5,52 +5,44 @@ #include "modules/ModeModule.h" #include +#include class SnakeMode : public ModeModule { private: struct Pixel { - uint8_t - x, - y; - - bool operator==(const Pixel &pixel) const - { - return x == pixel.x && y == pixel.y; - } - - bool operator<(const Pixel &pixel) const - { - return (y < pixel.y) || (y == pixel.y && x < pixel.x); - } + uint8_t x; + uint8_t y; + + bool operator==(const Pixel &pixel) const { return x == pixel.x && y == pixel.y; } + bool operator!=(const Pixel &pixel) const { return x != pixel.x || y != pixel.y; } + bool operator<(const Pixel &pixel) const { return (y < pixel.y) || (y == pixel.y && x < pixel.x); } }; tm local; - bool - clock = true, - pending = false; + bool clock = true; + bool pending = false; unsigned long lastMillis = 0; - uint8_t - blink = 0, - hour, - minute, - stage = 0; + uint8_t blink = 0; + uint8_t hour; + uint8_t minute; + uint8_t stage = 0; + + Pixel dot; std::deque snake; - Pixel dot; + std::optional next(); void idle(); void move(); void end(); void clean(); - bool findPath(Pixel start, Pixel goal, Pixel &next); - void setClock(const bool _clock); void setDot(); void transmit(); diff --git a/firmware/include/modes/StarsMode.h b/firmware/include/modes/StarsMode.h index bc8378b5..ff149532 100644 --- a/firmware/include/modes/StarsMode.h +++ b/firmware/include/modes/StarsMode.h @@ -10,11 +10,10 @@ class StarsMode : public ModeModule private: struct Star { - uint8_t - x = 0, - y = 0, - brightness = 0, - delay = 0; + uint8_t brightness = 0; + uint8_t delay = 0; + uint8_t x = 0; + uint8_t y = 0; unsigned long lastMillis = 0; bool direction = true; }; diff --git a/firmware/include/modes/TickerMode.h b/firmware/include/modes/TickerMode.h index b6f12cc3..76d554cc 100644 --- a/firmware/include/modes/TickerMode.h +++ b/firmware/include/modes/TickerMode.h @@ -17,9 +17,8 @@ class TickerMode : public ModeModule int8_t offsetY = GRID_ROWS / 2; - int16_t - offsetX = GRID_COLUMNS, - width = 0; + int16_t offsetX = GRID_COLUMNS; + int16_t width = 0; unsigned long lastMillis = 0; diff --git a/firmware/include/modes/WorldWeatherOnlineMode.h b/firmware/include/modes/WorldWeatherOnlineMode.h index 623dde18..44d3b476 100644 --- a/firmware/include/modes/WorldWeatherOnlineMode.h +++ b/firmware/include/modes/WorldWeatherOnlineMode.h @@ -18,10 +18,12 @@ class WorldWeatherOnlineMode : public ModeModule // https://www.worldweatheronline.com/weather-api/api/docs/local-city-town-weather-api.aspx std::vector urls = { #ifdef LOCATION - "https://api.worldweatheronline.com/premium/v1/weather.ashx?q=" LOCATION "&cc=yes&fx=no&mca=no&format=json&key=" WORLDWEATHERONLINE_KEY, + "https://api.worldweatheronline.com/premium/v1/weather.ashx?q=" LOCATION + "&cc=yes&fx=no&mca=no&format=json&key=" WORLDWEATHERONLINE_KEY, #endif #if defined(LATITUDE) && defined(LONGITUDE) - "https://api.worldweatheronline.com/premium/v1/weather.ashx?q=" LATITUDE "," LONGITUDE "&cc=yes&fx=no&mca=no&format=json&key=" WORLDWEATHERONLINE_KEY, + "https://api.worldweatheronline.com/premium/v1/weather.ashx?q=" LATITUDE "," LONGITUDE + "&cc=yes&fx=no&mca=no&format=json&key=" WORLDWEATHERONLINE_KEY, #endif }; diff --git a/firmware/include/modules/FontModule.h b/firmware/include/modules/FontModule.h index c8e0f4e8..8e299d8e 100644 --- a/firmware/include/modules/FontModule.h +++ b/firmware/include/modules/FontModule.h @@ -15,9 +15,8 @@ class FontModule struct Symbol { const std::vector bitmap; - const int8_t - offsetX, - offsetY; + const int8_t offsetX; + const int8_t offsetY; }; struct SymbolExtended diff --git a/firmware/include/services/ConnectivityService.h b/firmware/include/services/ConnectivityService.h index f5596d2b..83b0ca7e 100644 --- a/firmware/include/services/ConnectivityService.h +++ b/firmware/include/services/ConnectivityService.h @@ -13,10 +13,9 @@ class ConnectivityService : public ServiceModule ConnectivityService() : ServiceModule(_name.data()) {}; - bool - mDNS = false, - pending = false, - routable = false; + bool mDNS = false; + bool pending = false; + bool routable = false; unsigned long lastMillis = 0; @@ -52,6 +51,6 @@ extern ConnectivityService &Connectivity; namespace Certificates { - extern const uint8_t x509_crt_bundle_start[] asm("_binary_" BOARD_BUILD__EMBED_FILES__X509_CRT_BUNDLE "_start"); - extern const uint8_t x509_crt_bundle_end[] asm("_binary_" BOARD_BUILD__EMBED_FILES__X509_CRT_BUNDLE "_end"); -} +extern const uint8_t x509_crt_bundle_start[] asm("_binary_" BOARD_BUILD__EMBED_FILES__X509_CRT_BUNDLE "_start"); +extern const uint8_t x509_crt_bundle_end[] asm("_binary_" BOARD_BUILD__EMBED_FILES__X509_CRT_BUNDLE "_end"); +} // namespace Certificates diff --git a/firmware/include/services/DisplayService.h b/firmware/include/services/DisplayService.h index 434ae39e..1033885b 100644 --- a/firmware/include/services/DisplayService.h +++ b/firmware/include/services/DisplayService.h @@ -41,17 +41,15 @@ class DisplayService : public ServiceModule 0b0011111100, }; - bool - pending = false, - power = false; + bool pending = false; + bool power = false; float ratio = PITCH_HORIZONTAL / (float)PITCH_VERTICAL; - uint8_t - brightness = 0, - _frame[GRID_COLUMNS * GRID_ROWS] = {0}, - frame[GRID_COLUMNS * GRID_ROWS] = {0}, - pixel[GRID_COLUMNS * GRID_ROWS] = LED_MAP; + uint8_t brightness = 0; + uint8_t _frame[GRID_COLUMNS * GRID_ROWS] = {0}; + uint8_t frame[GRID_COLUMNS * GRID_ROWS] = {0}; + uint8_t pixel[GRID_COLUMNS * GRID_ROWS] = LED_MAP; Orientation orientation = Orientation::deg0; @@ -89,8 +87,10 @@ class DisplayService : public ServiceModule uint8_t getPixel(uint8_t x, uint8_t y) const; void setPixel(uint8_t x, uint8_t y, uint8_t brightness = UINT8_MAX); - void drawEllipse(float x, float y, float radius, float ratio = 1, bool fill = false, uint8_t brightness = UINT8_MAX); - void drawRectangle(uint8_t minX, uint8_t minY, uint8_t maxX, uint8_t maxY, bool fill = true, uint8_t brightness = UINT8_MAX); + void drawEllipse(float x, float y, float radius, float ratio = 1, bool fill = false, + uint8_t brightness = UINT8_MAX); + void drawRectangle(uint8_t minX, uint8_t minY, uint8_t maxX, uint8_t maxY, bool fill = true, + uint8_t brightness = UINT8_MAX); void flush(); diff --git a/firmware/src/extensions/AlexaExtension.cpp b/firmware/src/extensions/AlexaExtension.cpp index 26d93866..1a4d631c 100644 --- a/firmware/src/extensions/AlexaExtension.cpp +++ b/firmware/src/extensions/AlexaExtension.cpp @@ -10,10 +10,7 @@ AlexaExtension *Alexa = nullptr; -AlexaExtension::AlexaExtension() : ExtensionModule("Alexa") -{ - Alexa = this; -} +AlexaExtension::AlexaExtension() : ExtensionModule("Alexa") { Alexa = this; } void AlexaExtension::begin() { @@ -22,20 +19,26 @@ void AlexaExtension::begin() fauxmo.addDevice(NAME); fauxmo.onSetState(&onSetState); - WebServer.http->on(AsyncURIMatcher::exact("/api"), WebRequestMethod::HTTP_POST, &WebServer.onEmpty, nullptr, &onSet); - WebServer.http->on(AsyncURIMatcher::exact("/api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights"), WebRequestMethod::HTTP_GET, &onGet); - WebServer.http->on(AsyncURIMatcher::exact("/api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/1"), WebRequestMethod::HTTP_GET, &onGet); - WebServer.http->on(AsyncURIMatcher::exact("/api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/1/state"), WebRequestMethod::HTTP_PUT, &WebServer.onEmpty, nullptr, &onSet); + WebServer.http->on( + AsyncURIMatcher::exact("/api"), WebRequestMethod::HTTP_POST, &WebServer.onEmpty, nullptr, &onSet); + WebServer.http->on(AsyncURIMatcher::exact("/api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights"), + WebRequestMethod::HTTP_GET, + &onGet); + WebServer.http->on(AsyncURIMatcher::exact("/api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/1"), + WebRequestMethod::HTTP_GET, + &onGet); + WebServer.http->on(AsyncURIMatcher::exact("/api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/1/state"), + WebRequestMethod::HTTP_PUT, + &WebServer.onEmpty, + nullptr, + &onSet); WebServer.http->on(AsyncURIMatcher::exact("/description.xml"), WebRequestMethod::HTTP_GET, &onGet); fauxmo.setState(NAME, Display.getPower(), static_cast(Display.getBrightness())); fauxmo.enable(true); } -void AlexaExtension::handle() -{ - fauxmo.handle(); -} +void AlexaExtension::handle() { fauxmo.handle(); } void AlexaExtension::onSetState(unsigned char deviceId, const char *deviceName, bool state, unsigned char value) { @@ -68,7 +71,10 @@ void AlexaExtension::onTransmit(const JsonDocument &doc, const char *const sourc // Display: Power if (!strcmp(source, Display.name) && (doc["brightness"].is() || doc["power"].is())) { - fauxmo.setState(NAME, doc["power"].is() ? doc["power"].as() : Display.getPower(), static_cast(doc["brightness"].is() ? doc["brightness"].as() : Display.getBrightness())); + fauxmo.setState(NAME, + doc["power"].is() ? doc["power"].as() : Display.getPower(), + static_cast(doc["brightness"].is() ? doc["brightness"].as() + : Display.getBrightness())); } } diff --git a/firmware/src/extensions/ButtonExtension.cpp b/firmware/src/extensions/ButtonExtension.cpp index 40a88885..e34685df 100644 --- a/firmware/src/extensions/ButtonExtension.cpp +++ b/firmware/src/extensions/ButtonExtension.cpp @@ -9,10 +9,7 @@ ButtonExtension *Button = nullptr; -ButtonExtension::ButtonExtension() : ExtensionModule("Button") -{ - Button = this; -} +ButtonExtension::ButtonExtension() : ExtensionModule("Button") { Button = this; } void ButtonExtension::configure() { @@ -41,7 +38,8 @@ void ButtonExtension::configure() #ifdef PIN_SW1 { const std::string id = std::string(name).append("_power_").append(payload); - JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); + JsonObject component = + (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); component[HomeAssistantAbbreviations::automation_type] = "trigger"; component[HomeAssistantAbbreviations::payload] = payload; component[HomeAssistantAbbreviations::platform] = "device_automation"; @@ -54,7 +52,8 @@ void ButtonExtension::configure() #ifdef PIN_SW2 { const std::string id = std::string(name).append("_mode_").append(payload); - JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); + JsonObject component = + (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); component[HomeAssistantAbbreviations::automation_type] = "trigger"; component[HomeAssistantAbbreviations::payload] = payload; component[HomeAssistantAbbreviations::platform] = "device_automation"; diff --git a/firmware/src/extensions/HeapExtension.cpp b/firmware/src/extensions/HeapExtension.cpp index d23e769f..ee59a5d4 100644 --- a/firmware/src/extensions/HeapExtension.cpp +++ b/firmware/src/extensions/HeapExtension.cpp @@ -10,10 +10,7 @@ HeapExtension *Heap = nullptr; -HeapExtension::HeapExtension() : ExtensionModule("Heap") -{ - Heap = this; -} +HeapExtension::HeapExtension() : ExtensionModule("Heap") { Heap = this; } #if EXTENSION_HOMEASSISTANT void HeapExtension::configure() diff --git a/firmware/src/extensions/HomeAssistantExtension.cpp b/firmware/src/extensions/HomeAssistantExtension.cpp index f409a89e..00f108ec 100644 --- a/firmware/src/extensions/HomeAssistantExtension.cpp +++ b/firmware/src/extensions/HomeAssistantExtension.cpp @@ -15,18 +15,14 @@ HomeAssistantExtension *HomeAssistant = nullptr; -HomeAssistantExtension::HomeAssistantExtension() : ExtensionModule("Home Assistant") -{ - HomeAssistant = this; -} +HomeAssistantExtension::HomeAssistantExtension() : ExtensionModule("Home Assistant") { HomeAssistant = this; } void HomeAssistantExtension::configure() { const std::string topic = std::string("frekvens/" HOSTNAME "/").append(name); { - const std::string - id = std::regex_replace(name, std::regex("\\s+"), "").append("_main"), - topicDisplay = std::string("frekvens/" HOSTNAME "/").append(Display.name); + const std::string id = std::regex_replace(name, std::regex("\\s+"), "").append("_main"); + const std::string topicDisplay = std::string("frekvens/" HOSTNAME "/").append(Display.name); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); component[HomeAssistantAbbreviations::brightness_command_template] = "{\"brightness\":{{value}}}"; component[HomeAssistantAbbreviations::brightness_command_topic] = topicDisplay + "/set"; @@ -34,13 +30,15 @@ void HomeAssistantExtension::configure() component[HomeAssistantAbbreviations::brightness_value_template] = "{{value_json.brightness}}"; component[HomeAssistantAbbreviations::command_topic] = topicDisplay + "/set"; component[HomeAssistantAbbreviations::effect_command_template] = "{\"mode\":\"{{value}}\"}"; - component[HomeAssistantAbbreviations::effect_command_topic] = std::string("frekvens/" HOSTNAME "/").append(Modes.name).append("/set"); + component[HomeAssistantAbbreviations::effect_command_topic] = + std::string("frekvens/" HOSTNAME "/").append(Modes.name).append("/set"); JsonArray effectList = component[HomeAssistantAbbreviations::effect_list].to(); for (const ModeModule *mode : Modes.getAll()) { effectList.add(mode->name); } - component[HomeAssistantAbbreviations::effect_state_topic] = std::string("frekvens/" HOSTNAME "/").append(Modes.name); + component[HomeAssistantAbbreviations::effect_state_topic] = + std::string("frekvens/" HOSTNAME "/").append(Modes.name); component[HomeAssistantAbbreviations::effect_value_template] = "{{value_json.mode}}"; component[HomeAssistantAbbreviations::icon] = "mdi:dots-grid"; component[HomeAssistantAbbreviations::name] = ""; @@ -50,7 +48,8 @@ void HomeAssistantExtension::configure() component[HomeAssistantAbbreviations::payload_on] = payloadOn; component[HomeAssistantAbbreviations::platform] = "light"; component[HomeAssistantAbbreviations::state_topic] = topic; - component[HomeAssistantAbbreviations::state_value_template] = std::string("{{value_json.").append(Display.name).append(".power}}"); + component[HomeAssistantAbbreviations::state_value_template] = + std::string("{{value_json.").append(Display.name).append(".power}}"); component[HomeAssistantAbbreviations::unique_id] = HomeAssistant->uniquePrefix + id; } } @@ -84,7 +83,8 @@ void HomeAssistantExtension::begin() { JsonObject origin = (*discovery)[HomeAssistantAbbreviations::origin].to(); origin[HomeAssistantAbbreviations::name] = "Frekvens"; - origin[HomeAssistantAbbreviations::support_url] = "https://github.com/VIPnytt/Frekvens/blob/main/docs/SUPPORT.md"; + origin[HomeAssistantAbbreviations::support_url] = + "https://github.com/VIPnytt/Frekvens/blob/main/docs/SUPPORT.md"; origin[HomeAssistantAbbreviations::sw_version] = VERSION; } } diff --git a/firmware/src/extensions/InfraredExtension.cpp b/firmware/src/extensions/InfraredExtension.cpp index 4d8b56f4..88329618 100644 --- a/firmware/src/extensions/InfraredExtension.cpp +++ b/firmware/src/extensions/InfraredExtension.cpp @@ -16,10 +16,7 @@ InfraredExtension *Infrared = nullptr; -InfraredExtension::InfraredExtension() : ExtensionModule("Infrared") -{ - Infrared = this; -} +InfraredExtension::InfraredExtension() : ExtensionModule("Infrared") { Infrared = this; } void InfraredExtension::configure() { @@ -74,26 +71,36 @@ void InfraredExtension::parse() { if (code.protocol == IrReceiver.decodedIRData.protocol) { - if (t > INT8_MAX && std::find(code.displayBrightnessDecrease.begin(), code.displayBrightnessDecrease.end(), IrReceiver.decodedIRData.command) != code.displayBrightnessDecrease.end()) + if (t > INT8_MAX && std::find(code.displayBrightnessDecrease.begin(), + code.displayBrightnessDecrease.end(), + IrReceiver.decodedIRData.command) != code.displayBrightnessDecrease.end()) { Display.setBrightness(max(1, Display.getBrightness() - 5)); lastMillis = millis(); return; } - else if (t > INT8_MAX && std::find(code.displayBrightnessIncrease.begin(), code.displayBrightnessIncrease.end(), IrReceiver.decodedIRData.command) != code.displayBrightnessIncrease.end()) + else if (t > INT8_MAX && + std::find(code.displayBrightnessIncrease.begin(), + code.displayBrightnessIncrease.end(), + IrReceiver.decodedIRData.command) != code.displayBrightnessIncrease.end()) { Display.setBrightness(min(UINT8_MAX, Display.getBrightness() + 5)); lastMillis = millis(); return; } - else if (t > (1 << 10) && std::find(code.displayPowerToggle.begin(), code.displayPowerToggle.end(), IrReceiver.decodedIRData.command) != code.displayPowerToggle.end()) + else if (t > (1 << 10) && std::find(code.displayPowerToggle.begin(), + code.displayPowerToggle.end(), + IrReceiver.decodedIRData.command) != code.displayPowerToggle.end()) { Display.setPower(!Display.getPower()); lastMillis = millis(); return; } #if EXTENSION_MICROPHONE - else if (t > (1 << 10) && std::find(code.extensionMicrophoneToggle.begin(), code.extensionMicrophoneToggle.end(), IrReceiver.decodedIRData.command) != code.extensionMicrophoneToggle.end()) + else if (t > (1 << 10) && + std::find(code.extensionMicrophoneToggle.begin(), + code.extensionMicrophoneToggle.end(), + IrReceiver.decodedIRData.command) != code.extensionMicrophoneToggle.end()) { Microphone->setActive(!Microphone->getActive()); lastMillis = millis(); @@ -101,7 +108,10 @@ void InfraredExtension::parse() } #endif // EXTENSION_MICROPHONE #if EXTENSION_PHOTOCELL - else if (t > (1 << 10) && std::find(code.extensionPhotocellToggle.begin(), code.extensionPhotocellToggle.end(), IrReceiver.decodedIRData.command) != code.extensionPhotocellToggle.end()) + else if (t > (1 << 10) && + std::find(code.extensionPhotocellToggle.begin(), + code.extensionPhotocellToggle.end(), + IrReceiver.decodedIRData.command) != code.extensionPhotocellToggle.end()) { Photocell->setActive(!Photocell->getActive()); lastMillis = millis(); @@ -109,26 +119,34 @@ void InfraredExtension::parse() } #endif // EXTENSION_PHOTOCELL #if EXTENSION_PLAYLIST - else if (t > (1 << 10) && std::find(code.extensionPlaylistStart.begin(), code.extensionPlaylistStart.end(), IrReceiver.decodedIRData.command) != code.extensionPlaylistStart.end()) + else if (t > (1 << 10) && std::find(code.extensionPlaylistStart.begin(), + code.extensionPlaylistStart.end(), + IrReceiver.decodedIRData.command) != code.extensionPlaylistStart.end()) { Playlist->setActive(true); lastMillis = millis(); return; } - else if (t > (1 << 10) && std::find(code.extensionPlaylistStop.begin(), code.extensionPlaylistStop.end(), IrReceiver.decodedIRData.command) != code.extensionPlaylistStop.end()) + else if (t > (1 << 10) && std::find(code.extensionPlaylistStop.begin(), + code.extensionPlaylistStop.end(), + IrReceiver.decodedIRData.command) != code.extensionPlaylistStop.end()) { Playlist->setActive(false); lastMillis = millis(); return; } #endif // EXTENSION_PLAYLIST - else if (t > (1 << 9) && std::find(code.modeNext.begin(), code.modeNext.end(), IrReceiver.decodedIRData.command) != code.modeNext.end()) + else if (t > (1 << 9) && + std::find(code.modeNext.begin(), code.modeNext.end(), IrReceiver.decodedIRData.command) != + code.modeNext.end()) { Modes.setModeNext(); lastMillis = millis(); return; } - else if (t > (1 << 9) && std::find(code.modePrevious.begin(), code.modePrevious.end(), IrReceiver.decodedIRData.command) != code.modePrevious.end()) + else if (t > (1 << 9) && + std::find(code.modePrevious.begin(), code.modePrevious.end(), IrReceiver.decodedIRData.command) != + code.modePrevious.end()) { Modes.setModePrevious(); lastMillis = millis(); @@ -143,10 +161,7 @@ void InfraredExtension::parse() } } -bool InfraredExtension::getActive() -{ - return active; -} +bool InfraredExtension::getActive() { return active; } void InfraredExtension::setActive(bool active) { diff --git a/firmware/src/extensions/MessageExtension.cpp b/firmware/src/extensions/MessageExtension.cpp index c50479b4..63d8e549 100644 --- a/firmware/src/extensions/MessageExtension.cpp +++ b/firmware/src/extensions/MessageExtension.cpp @@ -12,10 +12,7 @@ MessageExtension *Message = nullptr; -MessageExtension::MessageExtension() : ExtensionModule("Message") -{ - Message = this; -} +MessageExtension::MessageExtension() : ExtensionModule("Message") { Message = this; } #if EXTENSION_HOMEASSISTANT void MessageExtension::configure() diff --git a/firmware/src/extensions/MicrophoneExtension.cpp b/firmware/src/extensions/MicrophoneExtension.cpp index 5c146979..29d919ba 100644 --- a/firmware/src/extensions/MicrophoneExtension.cpp +++ b/firmware/src/extensions/MicrophoneExtension.cpp @@ -11,10 +11,7 @@ MicrophoneExtension *Microphone = nullptr; -MicrophoneExtension::MicrophoneExtension() : ExtensionModule("Microphone") -{ - Microphone = this; -} +MicrophoneExtension::MicrophoneExtension() : ExtensionModule("Microphone") { Microphone = this; } void MicrophoneExtension::configure() { @@ -137,10 +134,7 @@ void MicrophoneExtension::handle() } } -bool MicrophoneExtension::getActive() -{ - return active; -} +bool MicrophoneExtension::getActive() { return active; } void MicrophoneExtension::setActive(bool active) { @@ -180,10 +174,7 @@ void MicrophoneExtension::setThreshold(uint16_t _threshold) } } -bool MicrophoneExtension::isTriggered() const -{ - return detected || !active; -} +bool MicrophoneExtension::isTriggered() const { return detected || !active; } void MicrophoneExtension::transmit() { diff --git a/firmware/src/extensions/MqttExtension.cpp b/firmware/src/extensions/MqttExtension.cpp index 4738d892..143014d3 100644 --- a/firmware/src/extensions/MqttExtension.cpp +++ b/firmware/src/extensions/MqttExtension.cpp @@ -11,10 +11,7 @@ MqttExtension *Mqtt = nullptr; -MqttExtension::MqttExtension() : ExtensionModule("MQTT") -{ - Mqtt = this; -} +MqttExtension::MqttExtension() : ExtensionModule("MQTT") { Mqtt = this; } void MqttExtension::configure() { @@ -63,7 +60,8 @@ void MqttExtension::disconnect() void MqttExtension::onConnect(bool sessionPresent) { ESP_LOGD(Mqtt->name, "connected"); - if (!sessionPresent || (!subscribed && esp_sleep_get_wakeup_cause() == esp_sleep_source_t::ESP_SLEEP_WAKEUP_UNDEFINED)) + if (!sessionPresent || + (!subscribed && esp_sleep_get_wakeup_cause() == esp_sleep_source_t::ESP_SLEEP_WAKEUP_UNDEFINED)) { Mqtt->client.subscribe("frekvens/" HOSTNAME "/+/set", 2); subscribed = true; @@ -71,14 +69,16 @@ void MqttExtension::onConnect(bool sessionPresent) Mqtt->client.publish("frekvens/" HOSTNAME "/availability", 1, true, "online"); } -void MqttExtension::onMessage(const espMqttClientTypes::MessageProperties &properties, const char *topic, const uint8_t *payload, size_t len, size_t index, size_t total) +void MqttExtension::onMessage(const espMqttClientTypes::MessageProperties &properties, const char *topic, + const uint8_t *payload, size_t len, size_t index, size_t total) { JsonDocument doc; if (deserializeJson(doc, payload, len)) { return; } - Device.receive(doc, Mqtt->name, std::string(topic).substr(prefixLength, strlen(topic) - prefixLength - suffixLength).c_str()); + Device.receive( + doc, Mqtt->name, std::string(topic).substr(prefixLength, strlen(topic) - prefixLength - suffixLength).c_str()); } void MqttExtension::onDisconnect(espMqttClientTypes::DisconnectReason reason) @@ -92,7 +92,11 @@ void MqttExtension::onTransmit(const JsonDocument &doc, const char *const source const size_t length = measureJson(doc); std::vector payload(length + 1); serializeJson(doc, payload.data(), length + 1); - client.publish(std::string("frekvens/" HOSTNAME "/").append(source).c_str(), doc["event"].isUnbound() ? 0 : 2, false, reinterpret_cast(payload.data()), length); + client.publish(std::string("frekvens/" HOSTNAME "/").append(source).c_str(), + doc["event"].isUnbound() ? 0 : 2, + false, + reinterpret_cast(payload.data()), + length); } #endif // EXTENSION_MQTT diff --git a/firmware/src/extensions/OtaExtension.cpp b/firmware/src/extensions/OtaExtension.cpp index fff377ca..374ae1e0 100644 --- a/firmware/src/extensions/OtaExtension.cpp +++ b/firmware/src/extensions/OtaExtension.cpp @@ -14,10 +14,7 @@ OtaExtension *Ota = nullptr; -OtaExtension::OtaExtension() : ExtensionModule("OTA") -{ - Ota = this; -} +OtaExtension::OtaExtension() : ExtensionModule("OTA") { Ota = this; } void OtaExtension::configure() { @@ -41,10 +38,7 @@ void OtaExtension::begin() #endif // OTA_KEY } -void OtaExtension::handle() -{ - ArduinoOTA.handle(); -} +void OtaExtension::handle() { ArduinoOTA.handle(); } void OtaExtension::onStart() { @@ -57,19 +51,18 @@ void OtaExtension::onStart() timerWrite(Display.timer, 1'000'000 / (1 << 8)); // 1 fps } -void OtaExtension::onEnd() -{ - ESP_LOGI(Ota->name, "complete"); -} +void OtaExtension::onEnd() { ESP_LOGI(Ota->name, "complete"); } #ifndef OTA_KEY -void OtaExtension::onPost(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) +void OtaExtension::onPost(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, + size_t len, bool final) { if (!index) { onStart(); } - if ((!index && !Update.begin(UPDATE_SIZE_UNKNOWN, filename.indexOf("littlefs") >= 0 ? U_LITTLEFS : U_FLASH)) || Update.write(data, len) != len || (final && !Update.end(true))) + if ((!index && !Update.begin(UPDATE_SIZE_UNKNOWN, filename.indexOf("littlefs") >= 0 ? U_LITTLEFS : U_FLASH)) || + Update.write(data, len) != len || (final && !Update.end(true))) { ESP_LOGE(Ota->name, "%s", Update.errorString()); request->send(t_http_codes::HTTP_CODE_INTERNAL_SERVER_ERROR); diff --git a/firmware/src/extensions/PhotocellExtension.cpp b/firmware/src/extensions/PhotocellExtension.cpp index aec18dce..5e83a7b7 100644 --- a/firmware/src/extensions/PhotocellExtension.cpp +++ b/firmware/src/extensions/PhotocellExtension.cpp @@ -11,10 +11,7 @@ PhotocellExtension *Photocell = nullptr; -PhotocellExtension::PhotocellExtension() : ExtensionModule("Photocell") -{ - Photocell = this; -} +PhotocellExtension::PhotocellExtension() : ExtensionModule("Photocell") { Photocell = this; } void PhotocellExtension::configure() { @@ -99,10 +96,7 @@ void PhotocellExtension::handle() } } -bool PhotocellExtension::getActive() const -{ - return active; -} +bool PhotocellExtension::getActive() const { return active; } void PhotocellExtension::setActive(bool active) { diff --git a/firmware/src/extensions/PlaylistExtension.cpp b/firmware/src/extensions/PlaylistExtension.cpp index 8c2ef8fa..67fee552 100644 --- a/firmware/src/extensions/PlaylistExtension.cpp +++ b/firmware/src/extensions/PlaylistExtension.cpp @@ -11,10 +11,7 @@ PlaylistExtension *Playlist = nullptr; -PlaylistExtension::PlaylistExtension() : ExtensionModule("Playlist") -{ - Playlist = this; -} +PlaylistExtension::PlaylistExtension() : ExtensionModule("Playlist") { Playlist = this; } void PlaylistExtension::configure() { @@ -50,7 +47,8 @@ void PlaylistExtension::configure() component[HomeAssistantAbbreviations::command_template] = "{\"active\":{{value}}}"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::icon] = "mdi:format-list-bulleted"; - component[HomeAssistantAbbreviations::json_attributes_template] = "{%set ns=namespace(d={})%}{%for i in value_json.playlist%}{%set ns.d=ns.d|combine({i.mode:i.duration})%}{%endfor%}{{ns.d}}"; + component[HomeAssistantAbbreviations::json_attributes_template] = + "{%set ns=namespace(d={})%}{%for i in value_json.playlist%}{%set ns.d=ns.d|combine({i.mode:i.duration})%}{%endfor%}{{ns.d}}"; component[HomeAssistantAbbreviations::json_attributes_topic] = topic; component[HomeAssistantAbbreviations::name] = name; component[HomeAssistantAbbreviations::object_id] = HOSTNAME "_" + id; @@ -107,10 +105,7 @@ void PlaylistExtension::handle() } } -bool PlaylistExtension::getActive() const -{ - return active; -} +bool PlaylistExtension::getActive() const { return active; } void PlaylistExtension::setActive(bool active) { @@ -175,7 +170,8 @@ void PlaylistExtension::transmit() void PlaylistExtension::onTransmit(const JsonDocument &doc, const char *const source) { // Modes: Mode - if (active && !strcmp(source, Modes.name) && doc["mode"].is() && doc["mode"].as() != playlist[step].mode) + if (active && !strcmp(source, Modes.name) && doc["mode"].is() && + doc["mode"].as() != playlist[step].mode) { setActive(false); } diff --git a/firmware/src/extensions/RestfulExtension.cpp b/firmware/src/extensions/RestfulExtension.cpp index 838ce0d1..11cecae3 100644 --- a/firmware/src/extensions/RestfulExtension.cpp +++ b/firmware/src/extensions/RestfulExtension.cpp @@ -10,15 +10,13 @@ RestfulExtension *Restful = nullptr; -RestfulExtension::RestfulExtension() : ExtensionModule("RESTful") -{ - Restful = this; -} +RestfulExtension::RestfulExtension() : ExtensionModule("RESTful") { Restful = this; } void RestfulExtension::begin() { WebServer.http->on(AsyncURIMatcher::dir("/restful/"), WebRequestMethod::HTTP_GET, &onGet); - WebServer.http->on(AsyncURIMatcher::dir("/restful/"), WebRequestMethod::HTTP_PATCH, &WebServer.onEmpty, nullptr, &onPatch); + WebServer.http->on( + AsyncURIMatcher::dir("/restful/"), WebRequestMethod::HTTP_PATCH, &WebServer.onEmpty, nullptr, &onPatch); } void RestfulExtension::onGet(AsyncWebServerRequest *request) diff --git a/firmware/src/extensions/RtcExtension.cpp b/firmware/src/extensions/RtcExtension.cpp index 403a49fc..3a2b22e4 100644 --- a/firmware/src/extensions/RtcExtension.cpp +++ b/firmware/src/extensions/RtcExtension.cpp @@ -10,10 +10,7 @@ RtcExtension *Rtc = nullptr; -RtcExtension::RtcExtension() : ExtensionModule("RTC") -{ - Rtc = this; -} +RtcExtension::RtcExtension() : ExtensionModule("RTC") { Rtc = this; } void RtcExtension::configure() { @@ -95,10 +92,7 @@ void RtcExtension::handle() #endif // defined(RTC_DS3231) || defined(RTC_DS3232) || defined(RTC_PCF8563) #ifdef PIN_INT -IRAM_ATTR void RtcExtension::onInterrupt() -{ - Rtc->pending = true; -} +IRAM_ATTR void RtcExtension::onInterrupt() { Rtc->pending = true; } #endif // PIN_INT #if defined(RTC_DS3231) || defined(RTC_DS3232) @@ -114,7 +108,8 @@ void RtcExtension::sntpSetTimeSyncNotificationCallback(struct timeval *tv) { time_t timer = tv->tv_sec; tm *local = gmtime(&timer); - RtcDateTime dt = RtcDateTime(local->tm_year + 1900, local->tm_mon + 1, local->tm_mday, local->tm_hour, local->tm_min, local->tm_sec); + RtcDateTime dt = RtcDateTime( + local->tm_year + 1900, local->tm_mon + 1, local->tm_mday, local->tm_hour, local->tm_min, local->tm_sec); Rtc->rtc.SetDateTime(dt); ESP_LOGV(Rtc->name, "NTP sync"); } diff --git a/firmware/src/extensions/SignalExtension.cpp b/firmware/src/extensions/SignalExtension.cpp index 19135e4c..d0bd262c 100644 --- a/firmware/src/extensions/SignalExtension.cpp +++ b/firmware/src/extensions/SignalExtension.cpp @@ -10,10 +10,7 @@ SignalExtension *Signal = nullptr; -SignalExtension::SignalExtension() : ExtensionModule("Signal") -{ - Signal = this; -} +SignalExtension::SignalExtension() : ExtensionModule("Signal") { Signal = this; } void SignalExtension::begin() { @@ -95,8 +92,7 @@ void SignalExtension::onReceive(const JsonDocument doc, const char *const source else if (bitset.is()) { std::string bits = bitset.as(); - bits.erase(std::remove_if(bits.begin(), bits.end(), [](char bit) - { return bit < 0x30 || bit > 0x31; }), + bits.erase(std::remove_if(bits.begin(), bits.end(), [](char bit) { return bit < 0x30 || bit > 0x31; }), bits.end()); sign.push_back(std::stoi(bits, nullptr, 2)); } diff --git a/firmware/src/extensions/WebAppExtension.cpp b/firmware/src/extensions/WebAppExtension.cpp index 62e416f5..9a35ef5e 100644 --- a/firmware/src/extensions/WebAppExtension.cpp +++ b/firmware/src/extensions/WebAppExtension.cpp @@ -9,10 +9,7 @@ WebAppExtension *WebApp = nullptr; -WebAppExtension::WebAppExtension() : ExtensionModule("Web app") -{ - WebApp = this; -} +WebAppExtension::WebAppExtension() : ExtensionModule("Web app") { WebApp = this; } void WebAppExtension::configure() { diff --git a/firmware/src/extensions/WebSocketExtension.cpp b/firmware/src/extensions/WebSocketExtension.cpp index f570b776..d81375af 100644 --- a/firmware/src/extensions/WebSocketExtension.cpp +++ b/firmware/src/extensions/WebSocketExtension.cpp @@ -7,10 +7,7 @@ WebSocketExtension *WebSocket = nullptr; -WebSocketExtension::WebSocketExtension() : ExtensionModule("WebSocket") -{ - WebSocket = this; -} +WebSocketExtension::WebSocketExtension() : ExtensionModule("WebSocket") { WebSocket = this; } void WebSocketExtension::begin() { @@ -18,10 +15,7 @@ void WebSocketExtension::begin() WebServer.http->addHandler(server); } -void WebSocketExtension::handle() -{ - server->cleanupClients(); -} +void WebSocketExtension::handle() { server->cleanupClients(); } void WebSocketExtension::onTransmit(const JsonDocument &doc, const char *const source) { @@ -33,7 +27,8 @@ void WebSocketExtension::onTransmit(const JsonDocument &doc, const char *const s server->textAll(payload.data(), length); } -void WebSocketExtension::onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len) +void WebSocketExtension::onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, + uint8_t *data, size_t len) { switch (type) { diff --git a/firmware/src/fonts/BrailleFont.cpp b/firmware/src/fonts/BrailleFont.cpp index 6a708440..dcad40f7 100644 --- a/firmware/src/fonts/BrailleFont.cpp +++ b/firmware/src/fonts/BrailleFont.cpp @@ -4,10 +4,7 @@ BrailleFont *FontBraille = nullptr; -BrailleFont::BrailleFont() : FontModule("Braille") -{ - FontBraille = this; -} +BrailleFont::BrailleFont() : FontModule("Braille") { FontBraille = this; } FontModule::Symbol BrailleFont::getChar(uint32_t character) const { diff --git a/firmware/src/fonts/LargeFont.cpp b/firmware/src/fonts/LargeFont.cpp index 9271acfe..916238ed 100644 --- a/firmware/src/fonts/LargeFont.cpp +++ b/firmware/src/fonts/LargeFont.cpp @@ -2,10 +2,7 @@ LargeFont *FontLarge = nullptr; -LargeFont::LargeFont() : FontModule("Large") -{ - FontLarge = this; -} +LargeFont::LargeFont() : FontModule("Large") { FontLarge = this; } FontModule::Symbol LargeFont::getChar(uint32_t character) const { diff --git a/firmware/src/fonts/MediumBoldFont.cpp b/firmware/src/fonts/MediumBoldFont.cpp index 9fcd8469..ce2d26e5 100644 --- a/firmware/src/fonts/MediumBoldFont.cpp +++ b/firmware/src/fonts/MediumBoldFont.cpp @@ -4,10 +4,7 @@ MediumBoldFont *FontMediumBold = nullptr; -MediumBoldFont::MediumBoldFont() : FontModule("Medium bold") -{ - FontMediumBold = this; -} +MediumBoldFont::MediumBoldFont() : FontModule("Medium bold") { FontMediumBold = this; } FontModule::Symbol MediumBoldFont::getChar(uint32_t character) const { diff --git a/firmware/src/fonts/MediumFont.cpp b/firmware/src/fonts/MediumFont.cpp index eccf7822..0877f600 100644 --- a/firmware/src/fonts/MediumFont.cpp +++ b/firmware/src/fonts/MediumFont.cpp @@ -2,10 +2,7 @@ MediumFont *FontMedium = nullptr; -MediumFont::MediumFont() : FontModule("Medium") -{ - FontMedium = this; -} +MediumFont::MediumFont() : FontModule("Medium") { FontMedium = this; } FontModule::Symbol MediumFont::getChar(uint32_t character) const { diff --git a/firmware/src/fonts/MicroFont.cpp b/firmware/src/fonts/MicroFont.cpp index 115b2fa9..a2368ba3 100644 --- a/firmware/src/fonts/MicroFont.cpp +++ b/firmware/src/fonts/MicroFont.cpp @@ -2,10 +2,7 @@ MicroFont *FontMicro = nullptr; -MicroFont::MicroFont() : FontModule("Micro") -{ - FontMicro = this; -} +MicroFont::MicroFont() : FontModule("Micro") { FontMicro = this; } FontModule::Symbol MicroFont::getChar(uint32_t character) const { diff --git a/firmware/src/fonts/MiniFont.cpp b/firmware/src/fonts/MiniFont.cpp index bcc40b23..7d78fb35 100644 --- a/firmware/src/fonts/MiniFont.cpp +++ b/firmware/src/fonts/MiniFont.cpp @@ -2,10 +2,7 @@ MiniFont *FontMini = nullptr; -MiniFont::MiniFont() : FontModule("Mini") -{ - FontMini = this; -} +MiniFont::MiniFont() : FontModule("Mini") { FontMini = this; } FontModule::Symbol MiniFont::getChar(uint32_t character) const { diff --git a/firmware/src/fonts/SmallFont.cpp b/firmware/src/fonts/SmallFont.cpp index e1bb8f41..6b3f35ac 100644 --- a/firmware/src/fonts/SmallFont.cpp +++ b/firmware/src/fonts/SmallFont.cpp @@ -2,10 +2,7 @@ SmallFont *FontSmall = nullptr; -SmallFont::SmallFont() : FontModule("Small") -{ - FontSmall = this; -} +SmallFont::SmallFont() : FontModule("Small") { FontSmall = this; } FontModule::Symbol SmallFont::getChar(uint32_t character) const { diff --git a/firmware/src/handlers/BitmapHandler.cpp b/firmware/src/handlers/BitmapHandler.cpp index f161541a..f1608b97 100644 --- a/firmware/src/handlers/BitmapHandler.cpp +++ b/firmware/src/handlers/BitmapHandler.cpp @@ -25,10 +25,7 @@ BitmapHandler::BitmapHandler(std::vector bitmap) : bitmap(bitmap) } } -void BitmapHandler::draw(uint8_t brightness) -{ - draw((GRID_COLUMNS - width) / 2, (GRID_ROWS - height) / 2, brightness); -} +void BitmapHandler::draw(uint8_t brightness) { draw((GRID_COLUMNS - width) / 2, (GRID_ROWS - height) / 2, brightness); } void BitmapHandler::draw(uint8_t x, uint8_t y, uint8_t brightness) { @@ -57,12 +54,6 @@ void BitmapHandler::draw(uint8_t x, uint8_t y, uint8_t brightness) } } -uint8_t BitmapHandler::getHeight() const -{ - return height; -} +uint8_t BitmapHandler::getHeight() const { return height; } -uint8_t BitmapHandler::getWidth() const -{ - return width; -} +uint8_t BitmapHandler::getWidth() const { return width; } diff --git a/firmware/src/handlers/TextHandler.cpp b/firmware/src/handlers/TextHandler.cpp index c53f8071..2d070878 100644 --- a/firmware/src/handlers/TextHandler.cpp +++ b/firmware/src/handlers/TextHandler.cpp @@ -8,9 +8,8 @@ TextHandler::TextHandler(std::string text, FontModule *font) : text(text), font( if (text.length()) { { - uint8_t - yMax = 0, - yMin = 0; + uint8_t yMax = 0; + uint8_t yMin = 0; for (uint32_t codepoint; nextCodepoint(codepoint);) { FontModule::Symbol character = font->getChar(codepoint); @@ -70,9 +69,13 @@ void TextHandler::draw(int16_t x, int8_t y, uint8_t brightness) { for (uint8_t _y = 0; _y < _height; ++_y) { - if ((x + character.offsetX + _x) >= 0 && (x + character.offsetX + _x) < GRID_COLUMNS && (int16_t)(y + height - _height - character.offsetY + _y) >= 0 && (int16_t)(y + height - _height - character.offsetY + _y) < GRID_ROWS && (character.bitmap[_y] >> (msbMax - _x)) & 1) + if ((x + character.offsetX + _x) >= 0 && (x + character.offsetX + _x) < GRID_COLUMNS && + (int16_t)(y + height - _height - character.offsetY + _y) >= 0 && + (int16_t)(y + height - _height - character.offsetY + _y) < GRID_ROWS && + (character.bitmap[_y] >> (msbMax - _x)) & 1) { - Display.setPixel(x + character.offsetX + _x, y + height - _height - character.offsetY + _y, brightness); + Display.setPixel( + x + character.offsetX + _x, y + height - _height - character.offsetY + _y, brightness); } } } @@ -85,15 +88,9 @@ void TextHandler::draw(int16_t x, int8_t y, uint8_t brightness) } } -uint8_t TextHandler::getHeight() const -{ - return height; -} +uint8_t TextHandler::getHeight() const { return height; } -uint8_t TextHandler::getWidth() const -{ - return width; -} +uint8_t TextHandler::getWidth() const { return width; } bool TextHandler::nextCodepoint(uint32_t &buffer) { diff --git a/firmware/src/handlers/WeatherHandler.cpp b/firmware/src/handlers/WeatherHandler.cpp index e06ea349..12629da2 100644 --- a/firmware/src/handlers/WeatherHandler.cpp +++ b/firmware/src/handlers/WeatherHandler.cpp @@ -89,9 +89,8 @@ void WeatherHandler::draw() TextHandler text = TextHandler(std::to_string(temperature) + "°", FontMini); BitmapHandler bitmap = BitmapHandler(sign); - const uint8_t - textHeight = text.getHeight(), - marginsY = max(0, GRID_ROWS - bitmap.getHeight() - textHeight) / 3; + const uint8_t textHeight = text.getHeight(); + const uint8_t marginsY = max(0, GRID_ROWS - bitmap.getHeight() - textHeight) / 3; Display.clearFrame(); bitmap.draw((GRID_COLUMNS - bitmap.getWidth()) / 2, marginsY); diff --git a/firmware/src/main.cpp b/firmware/src/main.cpp index a073b4de..3c9ba0bc 100644 --- a/firmware/src/main.cpp +++ b/firmware/src/main.cpp @@ -2,10 +2,7 @@ #include "services/DeviceService.h" -void setup() -{ - Device.begin(); -} +void setup() { Device.begin(); } void loop() { diff --git a/firmware/src/modes/AnimationMode.cpp b/firmware/src/modes/AnimationMode.cpp index 59f2b50e..f8466c73 100644 --- a/firmware/src/modes/AnimationMode.cpp +++ b/firmware/src/modes/AnimationMode.cpp @@ -107,7 +107,8 @@ void AnimationMode::onReceive(const JsonDocument doc, const char *const source) pending = true; } // Frame - if (doc["frame"].is() && doc["frame"].size() == GRID_COLUMNS * GRID_ROWS && doc["index"].is()) + if (doc["frame"].is() && doc["frame"].size() == GRID_COLUMNS * GRID_ROWS && + doc["index"].is()) { uint8_t frame[GRID_COLUMNS * GRID_ROWS]; #if GRID_COLUMNS * GRID_ROWS > (1 << 8) diff --git a/firmware/src/modes/BinaryClockMode.cpp b/firmware/src/modes/BinaryClockMode.cpp index bf113d5d..b8d58678 100644 --- a/firmware/src/modes/BinaryClockMode.cpp +++ b/firmware/src/modes/BinaryClockMode.cpp @@ -5,10 +5,7 @@ #include "config/constants.h" #include "services/DisplayService.h" -void BinaryClockMode::begin() -{ - pending = true; -} +void BinaryClockMode::begin() { pending = true; } void BinaryClockMode::handle() { diff --git a/firmware/src/modes/BinaryEpochMode.cpp b/firmware/src/modes/BinaryEpochMode.cpp index f22a37cb..69a7fa60 100644 --- a/firmware/src/modes/BinaryEpochMode.cpp +++ b/firmware/src/modes/BinaryEpochMode.cpp @@ -13,9 +13,8 @@ void BinaryEpochMode::handle() epoch = _epoch; for (uint8_t i = 0; i < GRID_COLUMNS * GRID_ROWS / 8; ++i) { - const uint8_t - x = GRID_COLUMNS - 2 - i % (GRID_COLUMNS / 2) * 2, - y = GRID_ROWS - 4 - i / (GRID_COLUMNS / 2) * 4; + const uint8_t x = GRID_COLUMNS - 2 - i % (GRID_COLUMNS / 2) * 2; + const uint8_t y = GRID_ROWS - 4 - i / (GRID_COLUMNS / 2) * 4; Display.drawRectangle(x, y, x + 1, y + 3, true, epoch & (1 << i) ? UINT8_MAX : 0); } } diff --git a/firmware/src/modes/BreakoutClockMode.cpp b/firmware/src/modes/BreakoutClockMode.cpp index 8391abe6..895b690c 100644 --- a/firmware/src/modes/BreakoutClockMode.cpp +++ b/firmware/src/modes/BreakoutClockMode.cpp @@ -25,9 +25,8 @@ void BreakoutClockMode::begin() void BreakoutClockMode::handle() { - const uint8_t - nextX = xDec + cos(deg * DEG_TO_RAD) * speed + .5f, - nextY = yDec - sin(deg * DEG_TO_RAD) * speed + .5f; + const uint8_t nextX = xDec + cos(deg * DEG_TO_RAD) * speed + .5f; + const uint8_t nextY = yDec - sin(deg * DEG_TO_RAD) * speed + .5f; if (y <= 0 && deg < 180) { // Top diff --git a/firmware/src/modes/BrightMode.cpp b/firmware/src/modes/BrightMode.cpp index 37715e3b..bb08f4b7 100644 --- a/firmware/src/modes/BrightMode.cpp +++ b/firmware/src/modes/BrightMode.cpp @@ -4,9 +4,6 @@ #include "services/DisplayService.h" -void BrightMode::begin() -{ - Display.clearFrame(UINT8_MAX); -} +void BrightMode::begin() { Display.clearFrame(UINT8_MAX); } #endif // MODE_BRIGHT diff --git a/firmware/src/modes/CountdownMode.cpp b/firmware/src/modes/CountdownMode.cpp index 1aa8f1c7..43cb44b3 100644 --- a/firmware/src/modes/CountdownMode.cpp +++ b/firmware/src/modes/CountdownMode.cpp @@ -27,7 +27,8 @@ void CountdownMode::configure() component[HomeAssistantAbbreviations::icon] = "mdi:timer-sand-full"; component[HomeAssistantAbbreviations::name] = name; component[HomeAssistantAbbreviations::object_id] = HOSTNAME "_" + id; - component[HomeAssistantAbbreviations::pattern] = R"(^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])T([01]\d|2[0-3]):[0-5]\d:[0-5]\d$)"; + component[HomeAssistantAbbreviations::pattern] = + R"(^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])T([01]\d|2[0-3]):[0-5]\d:[0-5]\d$)"; component[HomeAssistantAbbreviations::platform] = "text"; component[HomeAssistantAbbreviations::state_topic] = topic; component[HomeAssistantAbbreviations::unique_id] = HomeAssistant->uniquePrefix + id; @@ -50,23 +51,18 @@ void CountdownMode::configure() } } -void CountdownMode::begin() -{ - done = false; -} +void CountdownMode::begin() { done = false; } void CountdownMode::handle() { const std::chrono::nanoseconds _nanoseconds = epoch - std::chrono::system_clock::now(); const std::chrono::hours _hours = std::chrono::duration_cast(_nanoseconds); const std::chrono::minutes _minutes = std::chrono::duration_cast(_nanoseconds - _hours); - const int64_t - hours = _hours.count(), - minutes = _minutes.count(), - seconds = std::chrono::duration_cast(_nanoseconds - _hours - _minutes).count(); - const uint8_t - _upper = hours > 99 ? 99 : (hours > 0 ? hours % 100 : minutes), - _lower = hours > 99 ? 99 : (hours > 0 ? minutes : seconds); + const int64_t hours = _hours.count(); + const int64_t minutes = _minutes.count(); + const int64_t seconds = std::chrono::duration_cast(_nanoseconds - _hours - _minutes).count(); + const uint8_t _upper = hours > 99 ? 99 : (hours > 0 ? hours % 100 : minutes); + const uint8_t _lower = hours > 99 ? 99 : (hours > 0 ? minutes : seconds); if (_lower != lower || _upper != upper) { upper = _upper; @@ -76,15 +72,18 @@ void CountdownMode::handle() Display.clearFrame(); { TextHandler tl = TextHandler(std::to_string(upper / 10), FontMedium); - tl.draw(GRID_COLUMNS / 2 - 1 - (7 - tl.getWidth()) / 2 - tl.getWidth(), GRID_ROWS / 2 - 1 - (7 - tl.getHeight()) / 2 - tl.getHeight()); + tl.draw(GRID_COLUMNS / 2 - 1 - (7 - tl.getWidth()) / 2 - tl.getWidth(), + GRID_ROWS / 2 - 1 - (7 - tl.getHeight()) / 2 - tl.getHeight()); } { TextHandler tr = TextHandler(std::to_string(upper % 10), FontMedium); - tr.draw(GRID_COLUMNS / 2 + 1 + (7 - tr.getWidth()) / 2, GRID_ROWS / 2 - 1 + (7 - tr.getHeight()) / 2 - tr.getHeight()); + tr.draw(GRID_COLUMNS / 2 + 1 + (7 - tr.getWidth()) / 2, + GRID_ROWS / 2 - 1 + (7 - tr.getHeight()) / 2 - tr.getHeight()); } { TextHandler bl = TextHandler(std::to_string(lower / 10), FontMedium); - bl.draw(GRID_COLUMNS / 2 - 1 - (7 - bl.getWidth()) / 2 - bl.getWidth(), GRID_ROWS / 2 + 1 - (7 - bl.getHeight()) / 2); + bl.draw(GRID_COLUMNS / 2 - 1 - (7 - bl.getWidth()) / 2 - bl.getWidth(), + GRID_ROWS / 2 + 1 - (7 - bl.getHeight()) / 2); } { TextHandler br = TextHandler(std::to_string(lower % 10), FontMedium); diff --git a/firmware/src/modes/DrawMode.cpp b/firmware/src/modes/DrawMode.cpp index 64598d38..ca334bdd 100644 --- a/firmware/src/modes/DrawMode.cpp +++ b/firmware/src/modes/DrawMode.cpp @@ -40,10 +40,7 @@ void DrawMode::handle() } } -void DrawMode::end() -{ - save(true); -} +void DrawMode::end() { save(true); } void DrawMode::load(const bool cache) { @@ -148,7 +145,8 @@ void DrawMode::onReceive(const JsonDocument doc, const char *const source) { if (pixel["x"].is() && pixel["y"].is() && pixel["brightness"].is()) { - drawing[pixel["x"].as() + pixel["y"].as() * GRID_COLUMNS] = pixel["brightness"].as(); + drawing[pixel["x"].as() + pixel["y"].as() * GRID_COLUMNS] = + pixel["brightness"].as(); } } render = true; diff --git a/firmware/src/modes/EqualizerMode.cpp b/firmware/src/modes/EqualizerMode.cpp index f51363de..c4801184 100644 --- a/firmware/src/modes/EqualizerMode.cpp +++ b/firmware/src/modes/EqualizerMode.cpp @@ -50,7 +50,8 @@ void EqualizerMode::handle() { --bar.level; } - Display.drawRectangle(minX, bar.level, maxX, GRID_ROWS - 1, true, UINT8_MAX * (GRID_ROWS - bar.level) / GRID_ROWS); + Display.drawRectangle( + minX, bar.level, maxX, GRID_ROWS - 1, true, UINT8_MAX * (GRID_ROWS - bar.level) / GRID_ROWS); } minX += width + 1; } diff --git a/firmware/src/modes/FireworkMode.cpp b/firmware/src/modes/FireworkMode.cpp index c6aa1bdf..56a76898 100644 --- a/firmware/src/modes/FireworkMode.cpp +++ b/firmware/src/modes/FireworkMode.cpp @@ -53,7 +53,10 @@ void FireworkMode::launching() #if PITCH_VERTICAL == PITCH_HORIZONTAL maxRadius = random(1, min(GRID_COLUMNS, GRID_ROWS) / 2); #else - maxRadius = random(2, min(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, GRID_ROWS / (float)PITCH_HORIZONTAL * PITCH_VERTICAL) / 2); + maxRadius = random(2, + min(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, + GRID_ROWS / (float)PITCH_HORIZONTAL * PITCH_VERTICAL) / + 2); #endif // PITCH_VERTICAL == PITCH_HORIZONTAL stage = 2; } diff --git a/firmware/src/modes/GameOfLifeMode.cpp b/firmware/src/modes/GameOfLifeMode.cpp index 8764ebd8..6848a1c0 100644 --- a/firmware/src/modes/GameOfLifeMode.cpp +++ b/firmware/src/modes/GameOfLifeMode.cpp @@ -46,10 +46,7 @@ void GameOfLifeMode::configure() transmit(); } -void GameOfLifeMode::begin() -{ - pending = true; -} +void GameOfLifeMode::begin() { pending = true; } void GameOfLifeMode::handle() { @@ -69,7 +66,8 @@ void GameOfLifeMode::handle() bool seeds[GRID_COLUMNS * (GRID_ROWS - (clock ? 5 : 0))] = {false}; for (uint8_t i = active; i < GRID_COLUMNS * (GRID_ROWS - (clock ? 5 : 0)) / (1 << 4); ++i) { - seeds[random(1, GRID_COLUMNS - 1) + random(clock ? 6 : 1, GRID_ROWS - 1) * (GRID_COLUMNS - (clock ? 5 : 0))] = true; + seeds[random(1, GRID_COLUMNS - 1) + + random(clock ? 6 : 1, GRID_ROWS - 1) * (GRID_COLUMNS - (clock ? 5 : 0))] = true; } lastMillis = millis(); active = 0; @@ -80,9 +78,11 @@ void GameOfLifeMode::handle() uint8_t n = 0; for (uint8_t _x = x <= 0 ? 0 : x - 1; _x <= x + 1 && _x < GRID_COLUMNS; ++_x) { - for (uint8_t _y = y <= (clock ? 5 : 0) ? (clock ? 5 : 0) : y - 1; _y <= y + 1 && _y < GRID_ROWS; ++_y) + for (uint8_t _y = y <= (clock ? 5 : 0) ? (clock ? 5 : 0) : y - 1; _y <= y + 1 && _y < GRID_ROWS; + ++_y) { - if ((_x != x || _y != y) && (seeds[_x + _y * (GRID_COLUMNS - (clock ? 5 : 0))] || Display.getPixel(_x, _y))) + if ((_x != x || _y != y) && + (seeds[_x + _y * (GRID_COLUMNS - (clock ? 5 : 0))] || Display.getPixel(_x, _y))) { ++n; } diff --git a/firmware/src/modes/GlitterMode.cpp b/firmware/src/modes/GlitterMode.cpp index f627e6b7..29fd097a 100644 --- a/firmware/src/modes/GlitterMode.cpp +++ b/firmware/src/modes/GlitterMode.cpp @@ -5,9 +5,6 @@ #include "config/constants.h" #include "services/DisplayService.h" -void GlitterMode::handle() -{ - Display.setPixel(random(GRID_COLUMNS), random(GRID_ROWS), random(1, 1 << 8)); -} +void GlitterMode::handle() { Display.setPixel(random(GRID_COLUMNS), random(GRID_ROWS), random(1, 1 << 8)); } #endif // MODE_GLITTER diff --git a/firmware/src/modes/GoogleWeatherMode.cpp b/firmware/src/modes/GoogleWeatherMode.cpp index 98d12406..67d1697e 100644 --- a/firmware/src/modes/GoogleWeatherMode.cpp +++ b/firmware/src/modes/GoogleWeatherMode.cpp @@ -31,7 +31,8 @@ void GoogleWeatherMode::update() { lastMillis = millis(); NetworkClientSecure client; - client.setCACertBundle(Certificates::x509_crt_bundle_start, Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); + client.setCACertBundle(Certificates::x509_crt_bundle_start, + Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); HTTPClient http; http.begin(client, urls.back()); http.addHeader("Accept", "application/json"); @@ -43,7 +44,8 @@ void GoogleWeatherMode::update() filter["temperature"]["degrees"] = true; filter["weatherCondition"]["type"] = true; JsonDocument doc; - if (deserializeJson(doc, http.getString(), DeserializationOption::Filter(filter)) || !doc["temperature"]["degrees"].is() || !doc["weatherCondition"]["type"].is()) + if (deserializeJson(doc, http.getString(), DeserializationOption::Filter(filter)) || + !doc["temperature"]["degrees"].is() || !doc["weatherCondition"]["type"].is()) { urls.pop_back(); lastMillis = millis() - interval + (1 << 14); diff --git a/firmware/src/modes/HomeAssistantWeatherMode.cpp b/firmware/src/modes/HomeAssistantWeatherMode.cpp index 1c235324..07acf3d5 100644 --- a/firmware/src/modes/HomeAssistantWeatherMode.cpp +++ b/firmware/src/modes/HomeAssistantWeatherMode.cpp @@ -32,7 +32,8 @@ void HomeAssistantWeatherMode::update() lastMillis = millis(); #ifdef HOMEASSISTANT_PROTOCOL NetworkClientSecure client; - client.setCACertBundle(Certificates::x509_crt_bundle_start, Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); + client.setCACertBundle(Certificates::x509_crt_bundle_start, + Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); HTTPClient http; http.begin(client, urls.back().c_str()); #else @@ -57,7 +58,8 @@ void HomeAssistantWeatherMode::update() filter["attributes"]["temperature"] = true; filter["state"] = true; JsonDocument doc; - if (deserializeJson(doc, stream, DeserializationOption::Filter(filter)) || !doc["attributes"]["temperature"].is() || !doc["state"].is()) + if (deserializeJson(doc, stream, DeserializationOption::Filter(filter)) || + !doc["attributes"]["temperature"].is() || !doc["state"].is()) { urls.pop_back(); lastMillis = millis() - interval + (1 << 14); diff --git a/firmware/src/modes/HomeThermometerMode.cpp b/firmware/src/modes/HomeThermometerMode.cpp index 1aa30f27..e8123ab7 100644 --- a/firmware/src/modes/HomeThermometerMode.cpp +++ b/firmware/src/modes/HomeThermometerMode.cpp @@ -25,8 +25,10 @@ void HomeThermometerMode::configure() }) { const std::string id = std::regex_replace(name, std::regex("\\s+"), "").append("_").append(where); - JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = std::string("{\"").append(where).append("\":{{value}}}"); + JsonObject component = + (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); + component[HomeAssistantAbbreviations::command_template] = + std::string("{\"").append(where).append("\":{{value}}}"); component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::device_class] = "temperature"; component[HomeAssistantAbbreviations::entity_category] = "config"; @@ -57,17 +59,15 @@ void HomeThermometerMode::configure() #elif TEMPERATURE_FAHRENHEIT component[HomeAssistantAbbreviations::unit_of_measurement] = "°F"; #endif // TEMPERATURE_KELVIN - component[HomeAssistantAbbreviations::value_template] = std::string("{{value_json.").append(where).append("}}"); + component[HomeAssistantAbbreviations::value_template] = + std::string("{{value_json.").append(where).append("}}"); } } #endif // EXTENSION_HOMEASSISTANT transmit(); } -void HomeThermometerMode::begin() -{ - pending = true; -} +void HomeThermometerMode::begin() { pending = true; } void HomeThermometerMode::handle() { @@ -88,16 +88,13 @@ void HomeThermometerMode::update() Storage.end(); return; } - const int16_t - indoor = Storage.getShort("indoor"), - outdoor = Storage.getShort("outdoor"); + const int16_t indoor = Storage.getShort("indoor"); + const int16_t outdoor = Storage.getShort("outdoor"); Storage.end(); - TextHandler - _indoor = TextHandler(std::to_string(indoor).append("°"), FontMini), - _outdoor = TextHandler(std::to_string(outdoor).append("°"), FontMini); - const uint8_t - _height = _outdoor.getHeight(), - marginsY = (GRID_ROWS - _indoor.getHeight() - _height) / 3; + TextHandler _indoor = TextHandler(std::to_string(indoor).append("°"), FontMini); + TextHandler _outdoor = TextHandler(std::to_string(outdoor).append("°"), FontMini); + const uint8_t _height = _outdoor.getHeight(); + const uint8_t marginsY = (GRID_ROWS - _indoor.getHeight() - _height) / 3; Display.clearFrame(); _indoor.draw((GRID_COLUMNS - _indoor.getWidth()) / 2, marginsY); _outdoor.draw((GRID_COLUMNS - _outdoor.getWidth()) / 2, GRID_ROWS - marginsY - _height); diff --git a/firmware/src/modes/LargeClockMode.cpp b/firmware/src/modes/LargeClockMode.cpp index bdf97c54..daf0b866 100644 --- a/firmware/src/modes/LargeClockMode.cpp +++ b/firmware/src/modes/LargeClockMode.cpp @@ -84,10 +84,7 @@ void LargeClockMode::configure() transmit(); } -void LargeClockMode::begin() -{ - pending = true; -} +void LargeClockMode::begin() { pending = true; } void LargeClockMode::handle() { @@ -100,15 +97,18 @@ void LargeClockMode::handle() Display.clearFrame(); { TextHandler h1 = TextHandler(std::to_string(hour / 10), font); - h1.draw(GRID_COLUMNS / 2 - 1 - (7 - h1.getWidth()) / 2 - h1.getWidth(), GRID_ROWS / 2 - 1 - (7 - h1.getHeight()) / 2 - h1.getHeight()); + h1.draw(GRID_COLUMNS / 2 - 1 - (7 - h1.getWidth()) / 2 - h1.getWidth(), + GRID_ROWS / 2 - 1 - (7 - h1.getHeight()) / 2 - h1.getHeight()); } { TextHandler h2 = TextHandler(std::to_string(hour % 10), font); - h2.draw(GRID_COLUMNS / 2 + 1 + (7 - h2.getWidth()) / 2, GRID_ROWS / 2 - 1 + (7 - h2.getHeight()) / 2 - h2.getHeight()); + h2.draw(GRID_COLUMNS / 2 + 1 + (7 - h2.getWidth()) / 2, + GRID_ROWS / 2 - 1 + (7 - h2.getHeight()) / 2 - h2.getHeight()); } { TextHandler m1 = TextHandler(std::to_string(minute / 10), font); - m1.draw(GRID_COLUMNS / 2 - 1 - (7 - m1.getWidth()) / 2 - m1.getWidth(), GRID_ROWS / 2 + 1 - (7 - m1.getHeight()) / 2); + m1.draw(GRID_COLUMNS / 2 - 1 - (7 - m1.getWidth()) / 2 - m1.getWidth(), + GRID_ROWS / 2 + 1 - (7 - m1.getHeight()) / 2); } { TextHandler m2 = TextHandler(std::to_string(minute % 10), font); @@ -118,9 +118,11 @@ void LargeClockMode::handle() } if (ticking && second != local.tm_sec) { - Display.setPixel(GRID_COLUMNS / 2 - 8 + (second + 2) / 4, second % 2 ? GRID_ROWS / 2 : GRID_ROWS / 2 - 1, 0); + Display.setPixel( + GRID_COLUMNS / 2 - 8 + (second + 2) / 4, second % 2 ? GRID_ROWS / 2 : GRID_ROWS / 2 - 1, 0); second = local.tm_sec; - Display.setPixel(GRID_COLUMNS / 2 - 8 + (second + 2) / 4, second % 2 ? GRID_ROWS / 2 : GRID_ROWS / 2 - 1, INT8_MAX); + Display.setPixel( + GRID_COLUMNS / 2 - 8 + (second + 2) / 4, second % 2 ? GRID_ROWS / 2 : GRID_ROWS / 2 - 1, INT8_MAX); } } } diff --git a/firmware/src/modes/MetaballsMode.cpp b/firmware/src/modes/MetaballsMode.cpp index 0c5e4b74..1d2a0b9a 100644 --- a/firmware/src/modes/MetaballsMode.cpp +++ b/firmware/src/modes/MetaballsMode.cpp @@ -27,16 +27,16 @@ void MetaballsMode::handle() #endif // EXTENSION_MICROPHONE { const bool rotated = Display.getOrientation() % 2; - const float - xRatio = 2 * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / (float)(PITCH_VERTICAL + PITCH_HORIZONTAL), - yRatio = 2 * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / (float)(PITCH_VERTICAL + PITCH_HORIZONTAL); + const float xRatio = + 2 * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / (float)(PITCH_VERTICAL + PITCH_HORIZONTAL); + const float yRatio = + 2 * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / (float)(PITCH_VERTICAL + PITCH_HORIZONTAL); for (const Ball &ball : balls) { - const uint8_t - xMin = max(ball.x - radius - max(ball.xVelocity, 0), 0), - yMin = max(ball.y - radius - max(ball.yVelocity, 0), 0), - xMax = min(ceil(ball.x + radius - min(ball.xVelocity, 0)), GRID_COLUMNS - 1), - yMax = min(ceil(ball.y + radius - min(ball.yVelocity, 0)), GRID_ROWS - 1); + const uint8_t xMin = max(ball.x - radius - max(ball.xVelocity, 0), 0); + const uint8_t yMin = max(ball.y - radius - max(ball.yVelocity, 0), 0); + const uint8_t xMax = min(ceil(ball.x + radius - min(ball.xVelocity, 0)), GRID_COLUMNS - 1); + const uint8_t yMax = min(ceil(ball.y + radius - min(ball.yVelocity, 0)), GRID_ROWS - 1); for (uint8_t x = xMin; x <= xMax; ++x) { for (uint8_t y = yMin; y <= yMax; ++y) @@ -44,13 +44,13 @@ void MetaballsMode::handle() uint8_t brightness = 0; for (const Ball &ball : balls) { - const float - xDistance = (ball.x - x) * xRatio, - yDistance = (ball.y - y) * yRatio, - distanceSq = xDistance * xDistance + yDistance * yDistance; + const float xDistance = (ball.x - x) * xRatio; + const float yDistance = (ball.y - y) * yRatio; + const float distanceSq = xDistance * xDistance + yDistance * yDistance; if (distanceSq < radiusSq) { - brightness = min(brightness + contributions[(uint8_t)(distanceSq * UINT8_MAX / radiusSq)], UINT8_MAX); + brightness = min( + brightness + contributions[(uint8_t)(distanceSq * UINT8_MAX / radiusSq)], UINT8_MAX); if (brightness >= UINT8_MAX) { break; diff --git a/firmware/src/modes/OpenMeteoMode.cpp b/firmware/src/modes/OpenMeteoMode.cpp index 1f7dac71..40e7c772 100644 --- a/firmware/src/modes/OpenMeteoMode.cpp +++ b/firmware/src/modes/OpenMeteoMode.cpp @@ -31,7 +31,8 @@ void OpenMeteoMode::update() { lastMillis = millis(); NetworkClientSecure client; - client.setCACertBundle(Certificates::x509_crt_bundle_start, Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); + client.setCACertBundle(Certificates::x509_crt_bundle_start, + Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); HTTPClient http; http.begin(client, urls.back()); http.addHeader("Accept", "application/json"); @@ -50,7 +51,8 @@ void OpenMeteoMode::update() filter["current"]["temperature_2m"] = true; filter["current"]["weather_code"] = true; JsonDocument doc; - if (deserializeJson(doc, stream, DeserializationOption::Filter(filter)) || !doc["current"]["temperature_2m"].is() || !doc["current"]["weather_code"].is()) + if (deserializeJson(doc, stream, DeserializationOption::Filter(filter)) || + !doc["current"]["temperature_2m"].is() || !doc["current"]["weather_code"].is()) { urls.pop_back(); lastMillis = millis() - interval + (1 << 14); diff --git a/firmware/src/modes/OpenWeatherMode.cpp b/firmware/src/modes/OpenWeatherMode.cpp index 637785f6..2078c132 100644 --- a/firmware/src/modes/OpenWeatherMode.cpp +++ b/firmware/src/modes/OpenWeatherMode.cpp @@ -31,7 +31,8 @@ void OpenWeatherMode::update() { lastMillis = millis(); NetworkClientSecure client; - client.setCACertBundle(Certificates::x509_crt_bundle_start, Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); + client.setCACertBundle(Certificates::x509_crt_bundle_start, + Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); HTTPClient http; http.begin(client, urls.back()); http.addHeader("Accept", "application/json"); diff --git a/firmware/src/modes/PingPongMode.cpp b/firmware/src/modes/PingPongMode.cpp index 92aede20..04c53bcc 100644 --- a/firmware/src/modes/PingPongMode.cpp +++ b/firmware/src/modes/PingPongMode.cpp @@ -114,9 +114,9 @@ void PingPongMode::handle() x = xDec + .5f; y = yDec + .5f; Display.setPixel(x, y, clock ? INT8_MAX : UINT8_MAX); - const float - aRad = atanf(clock ? (xDec - 1) / abs(paddleA[1] - yDec) : (yDec - 1) / abs(paddleB[1] - xDec)), - bRad = atanf(clock ? (GRID_COLUMNS - 2 - xDec) / abs(paddleB[1] - yDec) : (GRID_ROWS - 2 - yDec) / abs(paddleA[1] - xDec)); + const float aRad = atanf(clock ? (xDec - 1) / abs(paddleA[1] - yDec) : (yDec - 1) / abs(paddleB[1] - xDec)); + const float bRad = atanf(clock ? (GRID_COLUMNS - 2 - xDec) / abs(paddleB[1] - yDec) + : (GRID_ROWS - 2 - yDec) / abs(paddleA[1] - xDec)); if (!clock && xDec < paddleA.front() && bRad < 1 && paddleA.front() > 0) { // Bottom left diff --git a/firmware/src/modes/SmallClockMode.cpp b/firmware/src/modes/SmallClockMode.cpp index a9c43188..4be2dbb3 100644 --- a/firmware/src/modes/SmallClockMode.cpp +++ b/firmware/src/modes/SmallClockMode.cpp @@ -46,10 +46,7 @@ void SmallClockMode::configure() transmit(); } -void SmallClockMode::begin() -{ - pending = true; -} +void SmallClockMode::begin() { pending = true; } void SmallClockMode::handle() { diff --git a/firmware/src/modes/SnakeMode.cpp b/firmware/src/modes/SnakeMode.cpp index 5f97126f..05928199 100644 --- a/firmware/src/modes/SnakeMode.cpp +++ b/firmware/src/modes/SnakeMode.cpp @@ -85,19 +85,19 @@ void SnakeMode::handle() void SnakeMode::idle() { - const uint8_t - x = random(GRID_COLUMNS), - y = random(clock ? 5 : 0, GRID_ROWS); + const uint8_t x = random(GRID_COLUMNS); + const uint8_t y = random(clock ? 5 : 0, GRID_ROWS); snake = {{x, y}}; Display.setPixel(x, y); setDot(); stage = 1; } -bool SnakeMode::findPath(Pixel start, Pixel goal, Pixel &next) +std::optional SnakeMode::next() { - std::queue frontier; + Pixel start = snake.back(); std::map from; + std::queue frontier; frontier.push(start); from[start] = start; bool pathFound = false; @@ -105,8 +105,7 @@ bool SnakeMode::findPath(Pixel start, Pixel goal, Pixel &next) { Pixel current = frontier.front(); frontier.pop(); - - if (current == goal) + if (current == dot) { pathFound = true; break; @@ -139,13 +138,12 @@ bool SnakeMode::findPath(Pixel start, Pixel goal, Pixel &next) } if (pathFound) { - Pixel step = goal; - while (!(from[step] == start)) + Pixel step = dot; + while (from[step] != start) { step = from[step]; } - next = step; - return true; + return step; } std::vector fallback; if (start.y > (clock ? 5 : 0)) @@ -168,29 +166,27 @@ bool SnakeMode::findPath(Pixel start, Pixel goal, Pixel &next) { if (std::find(snake.begin(), snake.end(), option) == snake.end()) { - next = option; - return true; + return option; } } - return false; + return std::nullopt; } void SnakeMode::move() { if (millis() - lastMillis > INT8_MAX + snake.size()) { - Pixel nextStep; - if (findPath(snake.back(), dot, nextStep)) + std::optional step = next(); + if (step.has_value()) { - if (nextStep == dot) + snake.push_back(step.value()); + if (snake.back() == dot) { - snake.push_back(nextStep); - Display.setPixel(nextStep.x, nextStep.y, 1); + Display.setPixel(dot.x, dot.y); setDot(); } else { - snake.push_back(nextStep); uint8_t i = 0; for (const Pixel &part : snake) { @@ -198,7 +194,7 @@ void SnakeMode::move() ++i; } Display.setPixel(snake.front().x, snake.front().y, 0); - snake.erase(snake.begin()); + snake.pop_front(); } } else @@ -246,7 +242,8 @@ void SnakeMode::setDot() { do { - dot = {(uint8_t)random(GRID_COLUMNS), (uint8_t)random(clock ? 5 : 0, GRID_ROWS)}; + dot.x = random(GRID_COLUMNS); + dot.y = random(clock ? 5 : 0, GRID_ROWS); } while (Display.getPixel(dot.x, dot.y)); Display.setPixel(dot.x, dot.y, random(1, 1 << 8)); } diff --git a/firmware/src/modes/StarsMode.cpp b/firmware/src/modes/StarsMode.cpp index 86ef3153..7b9d3e6d 100644 --- a/firmware/src/modes/StarsMode.cpp +++ b/firmware/src/modes/StarsMode.cpp @@ -4,10 +4,7 @@ #include "services/DisplayService.h" -void StarsMode::begin() -{ - Display.clearFrame(); -} +void StarsMode::begin() { Display.clearFrame(); } void StarsMode::handle() { diff --git a/firmware/src/modes/StreamMode.cpp b/firmware/src/modes/StreamMode.cpp index eaf21646..ea9864da 100644 --- a/firmware/src/modes/StreamMode.cpp +++ b/firmware/src/modes/StreamMode.cpp @@ -18,7 +18,8 @@ void StreamMode::configure() { const std::string id = std::string(name).append("_protocol"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"port\":{{{\"Art-Net\":6454,\"Distributed Display Protocol\":4048,\"E1.31\":5568}.get(value)}}}"; + component[HomeAssistantAbbreviations::command_template] = + "{\"port\":{{{\"Art-Net\":6454,\"Distributed Display Protocol\":4048,\"E1.31\":5568}.get(value)}}}"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::enabled_by_default] = false; component[HomeAssistantAbbreviations::entity_category] = "config"; @@ -32,7 +33,8 @@ void StreamMode::configure() component[HomeAssistantAbbreviations::platform] = "select"; component[HomeAssistantAbbreviations::state_topic] = topic; component[HomeAssistantAbbreviations::unique_id] = HomeAssistant->uniquePrefix + id; - component[HomeAssistantAbbreviations::value_template] = "{{{4048:\"Distributed Display Protocol\",5568:\"E1.31\",6454:\"Art-Net\"}.get(value_json.port)}}"; + component[HomeAssistantAbbreviations::value_template] = + "{{{4048:\"Distributed Display Protocol\",5568:\"E1.31\",6454:\"Art-Net\"}.get(value_json.port)}}"; } #endif // EXTENSION_HOMEASSISTANT Preferences Storage; @@ -101,9 +103,6 @@ void StreamMode::onPacket(AsyncUDPPacket packet) } } -void StreamMode::end() -{ - udp.reset(); -} +void StreamMode::end() { udp.reset(); } #endif // MODE_STREAM diff --git a/firmware/src/modes/TickerMode.cpp b/firmware/src/modes/TickerMode.cpp index c2c7ede4..802debc6 100644 --- a/firmware/src/modes/TickerMode.cpp +++ b/firmware/src/modes/TickerMode.cpp @@ -70,10 +70,7 @@ void TickerMode::configure() transmit(); } -void TickerMode::begin() -{ - pending = true; -} +void TickerMode::begin() { pending = true; } void TickerMode::handle() { @@ -156,9 +153,6 @@ void TickerMode::onReceive(const JsonDocument doc, const char *const source) } } -void TickerMode::end() -{ - text.reset(); -} +void TickerMode::end() { text.reset(); } #endif // MODE_TICKER diff --git a/firmware/src/modes/WorldWeatherOnlineMode.cpp b/firmware/src/modes/WorldWeatherOnlineMode.cpp index 526c1e21..1417547f 100644 --- a/firmware/src/modes/WorldWeatherOnlineMode.cpp +++ b/firmware/src/modes/WorldWeatherOnlineMode.cpp @@ -31,7 +31,8 @@ void WorldWeatherOnlineMode::update() { lastMillis = millis(); NetworkClientSecure client; - client.setCACertBundle(Certificates::x509_crt_bundle_start, Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); + client.setCACertBundle(Certificates::x509_crt_bundle_start, + Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); HTTPClient http; http.begin(client, urls.back()); http.addHeader("Accept", "application/json"); @@ -56,11 +57,14 @@ void WorldWeatherOnlineMode::update() JsonDocument doc; if (deserializeJson(doc, stream, DeserializationOption::Filter(filter)) || #if TEMPERATURE_FAHRENHEIT - !(doc["data"]["current_condition"][0]["temp_F"].is() || doc["data"]["current_condition"][0]["temp_F"].is()) || + !(doc["data"]["current_condition"][0]["temp_F"].is() || + doc["data"]["current_condition"][0]["temp_F"].is()) || #else - !(doc["data"]["current_condition"][0]["temp_C"].is() || doc["data"]["current_condition"][0]["temp_C"].is()) || + !(doc["data"]["current_condition"][0]["temp_C"].is() || + doc["data"]["current_condition"][0]["temp_C"].is()) || #endif // TEMPERATURE_FAHRENHEIT - !(doc["data"]["current_condition"][0]["weatherCode"].is() || doc["data"]["current_condition"][0]["weatherCode"].is())) + !(doc["data"]["current_condition"][0]["weatherCode"].is() || + doc["data"]["current_condition"][0]["weatherCode"].is())) { urls.pop_back(); lastMillis = millis() - interval + (1 << 14); diff --git a/firmware/src/modes/WttrInMode.cpp b/firmware/src/modes/WttrInMode.cpp index 68fdaac3..26d81661 100644 --- a/firmware/src/modes/WttrInMode.cpp +++ b/firmware/src/modes/WttrInMode.cpp @@ -31,7 +31,8 @@ void WttrInMode::update() { lastMillis = millis(); NetworkClientSecure client; - client.setCACertBundle(Certificates::x509_crt_bundle_start, Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); + client.setCACertBundle(Certificates::x509_crt_bundle_start, + Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); HTTPClient http; http.begin(client, urls.back()); http.addHeader("Accept", "application/json"); @@ -56,11 +57,14 @@ void WttrInMode::update() JsonDocument doc; if (deserializeJson(doc, stream, DeserializationOption::Filter(filter)) || #if TEMPERATURE_FAHRENHEIT - !(doc["current_condition"][0]["temp_F"].is() || doc["current_condition"][0]["temp_F"].is()) || + !(doc["current_condition"][0]["temp_F"].is() || + doc["current_condition"][0]["temp_F"].is()) || #else - !(doc["current_condition"][0]["temp_C"].is() || doc["current_condition"][0]["temp_C"].is()) || + !(doc["current_condition"][0]["temp_C"].is() || + doc["current_condition"][0]["temp_C"].is()) || #endif // TEMPERATURE_FAHRENHEIT - !(doc["current_condition"][0]["weatherCode"].is() || doc["current_condition"][0]["weatherCode"].is())) + !(doc["current_condition"][0]["weatherCode"].is() || + doc["current_condition"][0]["weatherCode"].is())) { urls.pop_back(); lastMillis = millis() - interval + (1 << 14); diff --git a/firmware/src/modes/YrMode.cpp b/firmware/src/modes/YrMode.cpp index 6166c787..9cd764d4 100644 --- a/firmware/src/modes/YrMode.cpp +++ b/firmware/src/modes/YrMode.cpp @@ -31,7 +31,8 @@ void YrMode::update() { lastMillis = millis(); NetworkClientSecure client; - client.setCACertBundle(Certificates::x509_crt_bundle_start, Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); + client.setCACertBundle(Certificates::x509_crt_bundle_start, + Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); HTTPClient http; http.begin(client, urls.back()); http.addHeader("Accept", "application/json"); @@ -50,7 +51,9 @@ void YrMode::update() filter["properties"]["timeseries"][0]["data"]["instant"]["details"]["air_temperature"] = true; filter["properties"]["timeseries"][0]["data"]["next_1_hours"]["summary"]["symbol_code"] = true; JsonDocument doc; - if (deserializeJson(doc, stream, DeserializationOption::Filter(filter)) || !doc["properties"]["timeseries"][0]["data"]["instant"]["details"]["air_temperature"].is() || !doc["properties"]["timeseries"][0]["data"]["next_1_hours"]["summary"]["symbol_code"].is()) + if (deserializeJson(doc, stream, DeserializationOption::Filter(filter)) || + !doc["properties"]["timeseries"][0]["data"]["instant"]["details"]["air_temperature"].is() || + !doc["properties"]["timeseries"][0]["data"]["next_1_hours"]["summary"]["symbol_code"].is()) { urls.pop_back(); lastMillis = millis() - interval + (1 << 14); @@ -58,8 +61,11 @@ void YrMode::update() return; } WeatherHandler weather = WeatherHandler(); - weather.temperature = round(doc["properties"]["timeseries"][0]["data"]["instant"]["details"]["air_temperature"].as()); - weather.parse(doc["properties"]["timeseries"][0]["data"]["next_1_hours"]["summary"]["symbol_code"].as(), codesets); + weather.temperature = + round(doc["properties"]["timeseries"][0]["data"]["instant"]["details"]["air_temperature"].as()); + weather.parse( + doc["properties"]["timeseries"][0]["data"]["next_1_hours"]["summary"]["symbol_code"].as(), + codesets); weather.draw(); } else if (code >= 400 && code < 500) diff --git a/firmware/src/services/ConnectivityService.cpp b/firmware/src/services/ConnectivityService.cpp index 19ee7ec3..294d71b6 100644 --- a/firmware/src/services/ConnectivityService.cpp +++ b/firmware/src/services/ConnectivityService.cpp @@ -20,7 +20,8 @@ void ConnectivityService::configure() #ifdef PIN_SW2 pinMode(PIN_SW2, INPUT_PULLUP); #endif // PIN_SW2 - esp_crt_bundle_set(Certificates::x509_crt_bundle_start, Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); + esp_crt_bundle_set(Certificates::x509_crt_bundle_start, + Certificates::x509_crt_bundle_end - Certificates::x509_crt_bundle_start); WiFi.enableIPv6(); WiFi.setHostname(HOSTNAME); WiFi.mode(wifi_mode_t::WIFI_MODE_STA); @@ -48,7 +49,8 @@ void ConnectivityService::configure() #endif // WIFI_COUNTRY #if defined(PIN_SW1) || defined(PIN_SW2) #if defined(PIN_SW1) && defined(PIN_SW2) - if (esp_sleep_get_wakeup_cause() == esp_sleep_source_t::ESP_SLEEP_WAKEUP_UNDEFINED && (digitalRead(PIN_SW1) == LOW || digitalRead(PIN_SW2) == LOW)) + if (esp_sleep_get_wakeup_cause() == esp_sleep_source_t::ESP_SLEEP_WAKEUP_UNDEFINED && + (digitalRead(PIN_SW1) == LOW || digitalRead(PIN_SW2) == LOW)) #elif defined(PIN_SW1) if (esp_sleep_get_wakeup_cause() == esp_sleep_source_t::ESP_SLEEP_WAKEUP_UNDEFINED && digitalRead(PIN_SW1) == LOW) #elif defined(PIN_SW2) @@ -210,7 +212,9 @@ void ConnectivityService::onDisconnected(WiFiEvent_t event, WiFiEventInfo_t info Connectivity.mDNS = false; } ESP_LOGI(Connectivity.name, "disconnected"); - ESP_LOGD(Connectivity.name, "%s", WiFi.disconnectReasonName(static_cast(info.wifi_sta_disconnected.reason))); + ESP_LOGD(Connectivity.name, + "%s", + WiFi.disconnectReasonName(static_cast(info.wifi_sta_disconnected.reason))); } void ConnectivityService::onIPv4(WiFiEvent_t event, WiFiEventInfo_t info) @@ -318,7 +322,8 @@ void ConnectivityService::onReceive(const JsonDocument doc, const char *const so // Connect if (doc["ssid"].is()) { - connect(doc["ssid"].as(), doc["key"].is() ? doc["key"].as() : nullptr); + connect(doc["ssid"].as(), + doc["key"].is() ? doc["key"].as() : nullptr); } // Scan if (doc["action"].is() && !strcmp(doc["action"].as(), "scan")) diff --git a/firmware/src/services/DeviceService.cpp b/firmware/src/services/DeviceService.cpp index b050f684..692cb4e4 100644 --- a/firmware/src/services/DeviceService.cpp +++ b/firmware/src/services/DeviceService.cpp @@ -74,7 +74,8 @@ void DeviceService::begin() #elif SOC_PM_SUPPORT_EXT_WAKEUP && defined(PIN_SW2) esp_sleep_enable_ext0_wakeup((gpio_num_t)PIN_SW2, LOW); #elif SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && defined(PIN_INT) && defined(PIN_SW1) && defined(PIN_SW2) - esp_deep_sleep_enable_gpio_wakeup((1ULL << PIN_INT) | (1ULL << PIN_SW1) | (1ULL << PIN_SW2), ESP_GPIO_WAKEUP_GPIO_LOW); + esp_deep_sleep_enable_gpio_wakeup((1ULL << PIN_INT) | (1ULL << PIN_SW1) | (1ULL << PIN_SW2), + ESP_GPIO_WAKEUP_GPIO_LOW); #elif SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && defined(PIN_INT) && defined(PIN_SW1) esp_deep_sleep_enable_gpio_wakeup((1ULL << PIN_INT) | (1ULL << PIN_SW1), ESP_GPIO_WAKEUP_GPIO_LOW); #elif SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && defined(PIN_INT) && defined(PIN_SW2) @@ -228,10 +229,7 @@ void DeviceService::restore() esp_deep_sleep_start(); } -const JsonDocument DeviceService::getTransmits() const -{ - return transmits; -} +const JsonDocument DeviceService::getTransmits() const { return transmits; } void DeviceService::transmit() { diff --git a/firmware/src/services/DisplayService.cpp b/firmware/src/services/DisplayService.cpp index 534e8148..91c49c9c 100644 --- a/firmware/src/services/DisplayService.cpp +++ b/firmware/src/services/DisplayService.cpp @@ -40,7 +40,8 @@ void DisplayService::configure() Preferences Storage; Storage.begin(name, true); const uint8_t _brightness = Storage.isKey("brightness") ? Storage.getUShort("brightness") : UINT8_MAX; - const Orientation _orientation = Storage.isKey("orientation") ? (Orientation)Storage.getUShort("orientation") : orientation; + const Orientation _orientation = + Storage.isKey("orientation") ? (Orientation)Storage.getUShort("orientation") : orientation; Storage.end(); setOrientation(_orientation); setBrightness(_brightness); @@ -91,14 +92,12 @@ void DisplayService::handle() IRAM_ATTR void DisplayService::onTimer() { - static uint8_t - filter = 0, - bytes[(GRID_COLUMNS * GRID_ROWS + 7) / 8]; - uint8_t - *frame = Display.frame, - *out = bytes, - bitMask = 0x80, - outByte = 0; + static uint8_t filter = 0; + static uint8_t bytes[(GRID_COLUMNS * GRID_ROWS + 7) / 8]; + uint8_t *frame = Display.frame; + uint8_t *out = bytes; + uint8_t bitMask = 0x80; + uint8_t outByte = 0; for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; i++) { if (*frame++ > filter) @@ -129,15 +128,9 @@ void DisplayService::flush() } } -float DisplayService::getRatio() const -{ - return ratio; -} +float DisplayService::getRatio() const { return ratio; } -DisplayService::Orientation DisplayService::getOrientation() const -{ - return orientation; -} +DisplayService::Orientation DisplayService::getOrientation() const { return orientation; } void DisplayService::setOrientation(Orientation orientation) { @@ -147,20 +140,23 @@ void DisplayService::setOrientation(Orientation orientation) case Orientation::deg180: for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; ++i) { - _pixel[i] = pixel[((GRID_ROWS - 1 - (i >> __builtin_ctz(GRID_COLUMNS))) << __builtin_ctz(GRID_COLUMNS)) | (GRID_COLUMNS - 1 - (i & (GRID_COLUMNS - 1)))]; + _pixel[i] = pixel[((GRID_ROWS - 1 - (i >> __builtin_ctz(GRID_COLUMNS))) << __builtin_ctz(GRID_COLUMNS)) | + (GRID_COLUMNS - 1 - (i & (GRID_COLUMNS - 1)))]; } break; #if GRID_COLUMNS == GRID_ROWS case Orientation::deg90: for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; ++i) { - _pixel[i] = pixel[((GRID_COLUMNS - 1 - (i & (GRID_COLUMNS - 1))) << __builtin_ctz(GRID_COLUMNS)) | (i >> __builtin_ctz(GRID_COLUMNS))]; + _pixel[i] = pixel[((GRID_COLUMNS - 1 - (i & (GRID_COLUMNS - 1))) << __builtin_ctz(GRID_COLUMNS)) | + (i >> __builtin_ctz(GRID_COLUMNS))]; } break; case Orientation::deg270: for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; ++i) { - _pixel[i] = pixel[((i & (GRID_COLUMNS - 1)) << __builtin_ctz(GRID_COLUMNS)) | (GRID_ROWS - 1 - (i >> __builtin_ctz(GRID_COLUMNS)))]; + _pixel[i] = pixel[((i & (GRID_COLUMNS - 1)) << __builtin_ctz(GRID_COLUMNS)) | + (GRID_ROWS - 1 - (i >> __builtin_ctz(GRID_COLUMNS)))]; } break; #endif // GRID_COLUMNS == GRID_ROWS @@ -171,9 +167,7 @@ void DisplayService::setOrientation(Orientation orientation) memcpy(pixel, _pixel.data(), _pixel.size()); this->orientation = orientation; #if GRID_COLUMNS == GRID_ROWS - ratio = this->orientation % 2 - ? PITCH_VERTICAL / (float)PITCH_HORIZONTAL - : PITCH_HORIZONTAL / (float)PITCH_VERTICAL; + ratio = this->orientation % 2 ? PITCH_VERTICAL / (float)PITCH_HORIZONTAL : PITCH_HORIZONTAL / (float)PITCH_VERTICAL; #endif Preferences Storage; Storage.begin(name); @@ -182,10 +176,7 @@ void DisplayService::setOrientation(Orientation orientation) pending = true; } -bool DisplayService::getPower() const -{ - return power; -} +bool DisplayService::getPower() const { return power; } void DisplayService::setPower(bool power) { @@ -197,9 +188,16 @@ void DisplayService::setPower(bool power) if (power) { #ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED - ledcFadeGamma(PIN_OE, 0, max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), (1 << 5) * brightness); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGamma`. + ledcFadeGamma(PIN_OE, + 0, + max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + (1 << 5) * + brightness); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGamma`. #else - ledcFade(PIN_OE, 0, max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), (1 << 5) * brightness); // -2 offset due to `ledcFade` stability issues. + ledcFade(PIN_OE, + 0, + max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + (1 << 5) * brightness); // -2 offset due to `ledcFade` stability issues. #endif // SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED this->power = true; pending = true; @@ -208,9 +206,18 @@ void DisplayService::setPower(bool power) else { #ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED - ledcFadeGammaWithInterrupt(PIN_OE, max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), 0, (1 << 3) * brightness, &onPowerOff); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGammaWithInterrupt`. + ledcFadeGammaWithInterrupt( + PIN_OE, + max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + 0, + (1 << 3) * brightness, + &onPowerOff); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGammaWithInterrupt`. #else - ledcFadeWithInterrupt(PIN_OE, max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), 0, (1 << 3) * brightness, &onPowerOff); // -2 offset due to `ledcFade` stability issues. + ledcFadeWithInterrupt(PIN_OE, + max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + 0, + (1 << 3) * brightness, + &onPowerOff); // -2 offset due to `ledcFade` stability issues. #endif // SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED } } @@ -223,10 +230,7 @@ void DisplayService::onPowerOff() memset(Display.frame, 0, sizeof(Display.frame)); } -uint8_t DisplayService::getBrightness() const -{ - return brightness; -} +uint8_t DisplayService::getBrightness() const { return brightness; } void DisplayService::setBrightness(uint8_t brightness) { @@ -241,9 +245,20 @@ void DisplayService::setBrightness(uint8_t brightness) } ESP_LOGI(name, "brightness"); #ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED - ledcFadeGamma(PIN_OE, power ? max(this->brightness, pow(this->brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) : 0, max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), (1 << 4) * abs(this->brightness - brightness)); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGamma`. + ledcFadeGamma( + PIN_OE, + power ? max(this->brightness, pow(this->brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) + : 0, + max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + (1 << 4) * abs(this->brightness - + brightness)); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGamma`. #else - ledcFade(PIN_OE, power ? max(this->brightness, pow(this->brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) : 0, max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), (1 << 4) * abs(this->brightness - brightness)); // -2 offset due to `ledcFade` stability issues. + ledcFade(PIN_OE, + power + ? max(this->brightness, pow(this->brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) + : 0, + max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + (1 << 4) * abs(this->brightness - brightness)); // -2 offset due to `ledcFade` stability issues. #endif // SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED if (!power) { @@ -274,10 +289,7 @@ void DisplayService::setFrame(uint8_t frame[GRID_COLUMNS * GRID_ROWS]) } } -void DisplayService::clearFrame(uint8_t brightness) -{ - memset(_frame, brightness, sizeof(_frame)); -} +void DisplayService::clearFrame(uint8_t brightness) { memset(_frame, brightness, sizeof(_frame)); } void DisplayService::invertFrame() { @@ -308,22 +320,21 @@ void DisplayService::setPixel(uint8_t x, uint8_t y, uint8_t brightness) void DisplayService::drawEllipse(float x, float y, float radius, float ratio, bool fill, uint8_t brightness) { const bool rotated = orientation % 2; - const float - xRatio = 2 * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)), - yRatio = 2 * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); - const uint8_t - xMax = min(GRID_COLUMNS - 1, ceil(x + radius / xRatio)), - xMin = max(0, floor(x - radius / xRatio)), - yMax = min(GRID_COLUMNS - 1, ceil(y + radius / yRatio)), - yMin = max(0, floor(y - radius / yRatio)); + const float xRatio = + 2 * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); + const float yRatio = + 2 * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); + const uint8_t xMax = min(GRID_COLUMNS - 1, ceil(x + radius / xRatio)); + const uint8_t xMin = max(0, floor(x - radius / xRatio)); + const uint8_t yMax = min(GRID_COLUMNS - 1, ceil(y + radius / yRatio)); + const uint8_t yMin = max(0, floor(y - radius / yRatio)); for (uint8_t _x = xMin; _x <= xMax; ++_x) { for (uint8_t _y = yMin; _y <= yMax; ++_y) { - const float - xDistance = (_x - x) * xRatio, - yDistance = (_y - y) * yRatio, - distance = sqrt(xDistance * xDistance + yDistance * yDistance); + const float xDistance = (_x - x) * xRatio; + const float yDistance = (_y - y) * yRatio; + const float distance = sqrt(xDistance * xDistance + yDistance * yDistance); if (fill ? (distance <= radius) : (fabs(distance - radius) < .5f)) { setPixel(_x, _y, brightness); @@ -332,7 +343,8 @@ void DisplayService::drawEllipse(float x, float y, float radius, float ratio, bo } } -void DisplayService::drawRectangle(uint8_t minX, uint8_t minY, uint8_t maxX, uint8_t maxY, bool fill, uint8_t brightness) +void DisplayService::drawRectangle(uint8_t minX, uint8_t minY, uint8_t maxX, uint8_t maxY, bool fill, + uint8_t brightness) { for (uint8_t x = minX; x <= maxX; ++x) { diff --git a/firmware/src/services/ExtensionsService.cpp b/firmware/src/services/ExtensionsService.cpp index 577d49ae..af60af81 100644 --- a/firmware/src/services/ExtensionsService.cpp +++ b/firmware/src/services/ExtensionsService.cpp @@ -22,10 +22,7 @@ void ExtensionsService::begin() transmit(); } -const std::vector &ExtensionsService::getAll() const -{ - return modules; -} +const std::vector &ExtensionsService::getAll() const { return modules; } void ExtensionsService::transmit() { diff --git a/firmware/src/services/FontsService.cpp b/firmware/src/services/FontsService.cpp index 2d4f0963..2e7c4b5a 100644 --- a/firmware/src/services/FontsService.cpp +++ b/firmware/src/services/FontsService.cpp @@ -4,15 +4,9 @@ #include "services/DisplayService.h" #include "services/ModesService.h" -void FontsService::begin() -{ - transmit(); -} +void FontsService::begin() { transmit(); } -const std::vector &FontsService::getAll() const -{ - return modules; -} +const std::vector &FontsService::getAll() const { return modules; } void FontsService::transmit() { diff --git a/firmware/src/services/ModesService.cpp b/firmware/src/services/ModesService.cpp index c8c06abe..813f657a 100644 --- a/firmware/src/services/ModesService.cpp +++ b/firmware/src/services/ModesService.cpp @@ -179,16 +179,13 @@ void ModesService::setMode(ModeModule *mode, bool power) Display.setPower(power); } -const std::vector &ModesService::getAll() const -{ - return modes; -} +const std::vector &ModesService::getAll() const { return modes; } void ModesService::setModeNext() { const char *const _name = mode ? mode->name : scheduled->name; - std::vector::const_iterator _mode = std::find_if(modes.begin(), modes.end(), [_name](const ModeModule *_mode) - { return !strcmp(_mode->name, _name); }); + std::vector::const_iterator _mode = std::find_if( + modes.begin(), modes.end(), [_name](const ModeModule *_mode) { return !strcmp(_mode->name, _name); }); if (!Display.getPower()) { Display.setPower(true); @@ -207,8 +204,8 @@ void ModesService::setModeNext() void ModesService::setModePrevious() { const char *const _name = mode ? mode->name : scheduled->name; - std::vector::const_iterator _mode = std::find_if(modes.begin(), modes.end(), [_name](const ModeModule *_mode) - { return !strcmp(_mode->name, _name); }); + std::vector::const_iterator _mode = std::find_if( + modes.begin(), modes.end(), [_name](const ModeModule *_mode) { return !strcmp(_mode->name, _name); }); if (!Display.getPower()) { Display.setPower(true); diff --git a/firmware/src/services/WebServerService.cpp b/firmware/src/services/WebServerService.cpp index 38a0317b..28c647d8 100644 --- a/firmware/src/services/WebServerService.cpp +++ b/firmware/src/services/WebServerService.cpp @@ -6,15 +6,9 @@ #include #include -void WebServerService::configure() -{ - http->begin(); -} +void WebServerService::configure() { http->begin(); } -void WebServerService::begin() -{ - http->onNotFound(&onNotFound); -} +void WebServerService::begin() { http->onNotFound(&onNotFound); } void WebServerService::onNotFound(AsyncWebServerRequest *request) { From b46d5efc1a179a1a50d7ddb2a6e2f5bcdbd7cf6b Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Sun, 1 Feb 2026 19:55:52 +0100 Subject: [PATCH 10/26] WIP --- .clang-tidy | 63 ------------------- .github/workflows/clang.yml | 5 -- .github/workflows/generate.yml | 3 - extra/Python/ModeGenerator.py | 4 +- .../src/extensions/HomeAssistantExtension.cpp | 2 +- firmware/src/extensions/MessageExtension.cpp | 6 +- firmware/src/modes/CountdownMode.cpp | 2 +- firmware/src/modes/LargeClockMode.cpp | 2 +- firmware/src/modes/StreamMode.cpp | 4 +- firmware/src/modes/TickerMode.cpp | 4 +- firmware/src/services/DeviceService.cpp | 4 +- firmware/src/services/ModesService.cpp | 2 +- 12 files changed, 15 insertions(+), 86 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 225a3b08..44f88c2d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,70 +1,7 @@ Checks: > - boost-*, bugprone-*, clang-analyzer-*, cppcoreguidelines-*, modernize-*, performance-*, - portability-*, readability-*, - -bugprone-assignment-in-if-condition, - -bugprone-branch-clone, - -bugprone-easily-swappable-parameters, - -bugprone-incorrect-roundings, - -bugprone-infinite-loop, - -bugprone-integer-division, - -bugprone-narrowing-conversions, - -bugprone-suspicious-string-compare, - -bugprone-too-small-loop-variable, - -clang-diagnostic-error, - -cppcoreguidelines-avoid-c-arrays, - -cppcoreguidelines-avoid-const-or-ref-data-members, - -cppcoreguidelines-avoid-do-while, - -cppcoreguidelines-avoid-magic-numbers, - -cppcoreguidelines-avoid-non-const-global-variables, - -cppcoreguidelines-explicit-virtual-functions, - -cppcoreguidelines-init-variables, - -cppcoreguidelines-macro-to-enum, - -cppcoreguidelines-macro-usage, - -cppcoreguidelines-narrowing-conversions, - -cppcoreguidelines-non-private-member-variables-in-classes, - -cppcoreguidelines-pro-bounds-array-to-pointer-decay, - -cppcoreguidelines-pro-bounds-constant-array-index, - -cppcoreguidelines-pro-bounds-pointer-arithmetic, - -cppcoreguidelines-pro-type-cstyle-cast, - -cppcoreguidelines-pro-type-member-init, - -cppcoreguidelines-pro-type-reinterpret-cast, - -cppcoreguidelines-pro-type-vararg, - -cppcoreguidelines-special-member-functions, - -cppcoreguidelines-use-enum-class, - -cppcoreguidelines-virtual-class-destructor, - -modernize-avoid-c-arrays, - -modernize-deprecated-headers, - -modernize-macro-to-enum, - -modernize-use-auto, - -modernize-use-designated-initializers, - -modernize-use-integer-sign-comparison, - -modernize-use-nodiscard, - -modernize-use-override, - -modernize-use-std-numbers, - -modernize-use-trailing-return-type, - -performance-enum-size, - -performance-type-promotion-in-math-fn, - -performance-unnecessary-value-param, - -portability-avoid-pragma-once, - -readability-avoid-const-params-in-decls, - -readability-avoid-nested-conditional-operator, - -readability-const-return-type, - -readability-convert-member-functions-to-static, - -readability-else-after-return, - -readability-function-cognitive-complexity, - -readability-identifier-length, - -readability-implicit-bool-conversion, - -readability-isolate-declaration, - -readability-make-member-function-const, - -readability-magic-numbers, - -readability-math-missing-parentheses, - -readability-misplaced-array-index, - -readability-non-const-parameter, - -readability-static-accessed-through-instance, - -readability-uppercase-literal-suffix diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 34729401..a2dd0b0d 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -220,8 +220,3 @@ jobs: step-summary: true style: "" tidy-checks: "" - tidy-review: true - - - name: Clang tidy checks failed? - if: steps.tidy.outputs.clang-tidy-checks-failed != 0 - run: exit 1 diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 0668936c..1a15144d 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -137,7 +137,6 @@ jobs: step-summary: true style: file tidy-checks: "" - tidy-review: true mode-dynamic: name: Dynamic mode @@ -271,7 +270,6 @@ jobs: step-summary: true style: file tidy-checks: "" - tidy-review: true mode-static: name: Static mode @@ -389,4 +387,3 @@ jobs: step-summary: true style: file tidy-checks: "" - tidy-review: true diff --git a/extra/Python/ModeGenerator.py b/extra/Python/ModeGenerator.py index 20524b82..d07b4743 100644 --- a/extra/Python/ModeGenerator.py +++ b/extra/Python/ModeGenerator.py @@ -117,10 +117,10 @@ def _drawing_h(self) -> str: frame = [ "#pragma once", "", - "#include ", - "", '#include "modules/ModeModule.h"', "", + "#include ", + "", "//", "// @warning Automatically generated file", "//", diff --git a/firmware/src/extensions/HomeAssistantExtension.cpp b/firmware/src/extensions/HomeAssistantExtension.cpp index 00f108ec..dbd73b29 100644 --- a/firmware/src/extensions/HomeAssistantExtension.cpp +++ b/firmware/src/extensions/HomeAssistantExtension.cpp @@ -29,7 +29,7 @@ void HomeAssistantExtension::configure() component[HomeAssistantAbbreviations::brightness_state_topic] = topicDisplay; component[HomeAssistantAbbreviations::brightness_value_template] = "{{value_json.brightness}}"; component[HomeAssistantAbbreviations::command_topic] = topicDisplay + "/set"; - component[HomeAssistantAbbreviations::effect_command_template] = "{\"mode\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::effect_command_template] = R"({"mode":"{{value}}"})"; component[HomeAssistantAbbreviations::effect_command_topic] = std::string("frekvens/" HOSTNAME "/").append(Modes.name).append("/set"); JsonArray effectList = component[HomeAssistantAbbreviations::effect_list].to(); diff --git a/firmware/src/extensions/MessageExtension.cpp b/firmware/src/extensions/MessageExtension.cpp index 63d8e549..376dd9c5 100644 --- a/firmware/src/extensions/MessageExtension.cpp +++ b/firmware/src/extensions/MessageExtension.cpp @@ -21,7 +21,7 @@ void MessageExtension::configure() { const std::string id = std::string(name).append("_font"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"font\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::command_template] = R"({"font":"{{value}}"})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::enabled_by_default] = false; component[HomeAssistantAbbreviations::entity_category] = "config"; @@ -41,7 +41,7 @@ void MessageExtension::configure() { const std::string id = std::string(name).append("_notify"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"message\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::command_template] = R"({"message":"{{value}}"})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::name] = ""; component[HomeAssistantAbbreviations::object_id] = HOSTNAME "_" + id; @@ -51,7 +51,7 @@ void MessageExtension::configure() { const std::string id = std::string(name).append("_repeat"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"repeat\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::command_template] = R"({"repeat":"{{value}}"})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::enabled_by_default] = false; component[HomeAssistantAbbreviations::entity_category] = "config"; diff --git a/firmware/src/modes/CountdownMode.cpp b/firmware/src/modes/CountdownMode.cpp index 43cb44b3..de825a22 100644 --- a/firmware/src/modes/CountdownMode.cpp +++ b/firmware/src/modes/CountdownMode.cpp @@ -21,7 +21,7 @@ void CountdownMode::configure() { const std::string id = std::string(name).append("_timestamp"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"timestamp\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::command_template] = R"({"timestamp":"{{value}}"})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::entity_category] = "config"; component[HomeAssistantAbbreviations::icon] = "mdi:timer-sand-full"; diff --git a/firmware/src/modes/LargeClockMode.cpp b/firmware/src/modes/LargeClockMode.cpp index daf0b866..ab9094db 100644 --- a/firmware/src/modes/LargeClockMode.cpp +++ b/firmware/src/modes/LargeClockMode.cpp @@ -44,7 +44,7 @@ void LargeClockMode::configure() { const std::string id = std::string(name).append("_font"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"font\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::command_template] = R"({"font":"{{value}}"})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::enabled_by_default] = false; component[HomeAssistantAbbreviations::entity_category] = "config"; diff --git a/firmware/src/modes/StreamMode.cpp b/firmware/src/modes/StreamMode.cpp index ea9864da..96929c24 100644 --- a/firmware/src/modes/StreamMode.cpp +++ b/firmware/src/modes/StreamMode.cpp @@ -19,7 +19,7 @@ void StreamMode::configure() const std::string id = std::string(name).append("_protocol"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); component[HomeAssistantAbbreviations::command_template] = - "{\"port\":{{{\"Art-Net\":6454,\"Distributed Display Protocol\":4048,\"E1.31\":5568}.get(value)}}}"; + R"({"port":{{{"Art-Net":6454,"Distributed Display Protocol":4048,"E1.31":5568}.get(value)}}})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::enabled_by_default] = false; component[HomeAssistantAbbreviations::entity_category] = "config"; @@ -34,7 +34,7 @@ void StreamMode::configure() component[HomeAssistantAbbreviations::state_topic] = topic; component[HomeAssistantAbbreviations::unique_id] = HomeAssistant->uniquePrefix + id; component[HomeAssistantAbbreviations::value_template] = - "{{{4048:\"Distributed Display Protocol\",5568:\"E1.31\",6454:\"Art-Net\"}.get(value_json.port)}}"; + R"({{{4048:"Distributed Display Protocol",5568:"E1.31",6454:"Art-Net"}.get(value_json.port)}})"; } #endif // EXTENSION_HOMEASSISTANT Preferences Storage; diff --git a/firmware/src/modes/TickerMode.cpp b/firmware/src/modes/TickerMode.cpp index 802debc6..2236931c 100644 --- a/firmware/src/modes/TickerMode.cpp +++ b/firmware/src/modes/TickerMode.cpp @@ -16,7 +16,7 @@ void TickerMode::configure() { const std::string id = std::string(name).append("_font"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"font\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::command_template] = R"({"font":"{{value}}"})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::enabled_by_default] = false; component[HomeAssistantAbbreviations::entity_category] = "config"; @@ -36,7 +36,7 @@ void TickerMode::configure() { const std::string id = std::string(name).append("_message"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"message\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::command_template] = R"({"message":"{{value}}"})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::icon] = "mdi:message"; component[HomeAssistantAbbreviations::name] = name; diff --git a/firmware/src/services/DeviceService.cpp b/firmware/src/services/DeviceService.cpp index 692cb4e4..165bdba8 100644 --- a/firmware/src/services/DeviceService.cpp +++ b/firmware/src/services/DeviceService.cpp @@ -106,7 +106,7 @@ void DeviceService::begin() { const std::string id = std::string(name).append("_reboot"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"action\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::command_template] = R"({"action":"{{value}}"})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::device_class] = "restart"; component[HomeAssistantAbbreviations::enabled_by_default] = false; @@ -120,7 +120,7 @@ void DeviceService::begin() { const std::string id = std::string(name).append("_power"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"action\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::command_template] = R"({"action":"{{value}}"})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::entity_category] = "config"; component[HomeAssistantAbbreviations::icon] = "mdi:power"; diff --git a/firmware/src/services/ModesService.cpp b/firmware/src/services/ModesService.cpp index 813f657a..67b7342c 100644 --- a/firmware/src/services/ModesService.cpp +++ b/firmware/src/services/ModesService.cpp @@ -16,7 +16,7 @@ void ModesService::configure() { const std::string id = std::string(name).append("_mode"); JsonObject component = (*HomeAssistant->discovery)[HomeAssistantAbbreviations::components][id].to(); - component[HomeAssistantAbbreviations::command_template] = "{\"mode\":\"{{value}}\"}"; + component[HomeAssistantAbbreviations::command_template] = R"({"mode":"{{value}}"})"; component[HomeAssistantAbbreviations::command_topic] = topic + "/set"; component[HomeAssistantAbbreviations::icon] = "mdi:format-list-bulleted"; component[HomeAssistantAbbreviations::name] = "Mode"; From 546ec51f8a1d4c5b191816ba3f1c4bfd0d6df3f5 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Mon, 2 Feb 2026 02:46:53 +0100 Subject: [PATCH 11/26] WIP --- .clang-tidy | 7 ++++++ .github/workflows/clang.yml | 19 +++++++++++++-- .github/workflows/generate.yml | 24 ++++++++++++++----- .../workflows/ikea-frekvens-led-spotlight.yml | 1 + extra/Python/FontGenerator.py | 2 +- firmware/include/extensions/AlexaExtension.h | 2 +- .../extensions/HomeAssistantExtension.h | 2 +- .../include/extensions/InfraredExtension.h | 2 +- .../include/extensions/MessageExtension.h | 6 ++--- .../include/extensions/MicrophoneExtension.h | 6 ++--- firmware/include/extensions/MqttExtension.h | 2 +- .../include/extensions/PhotocellExtension.h | 4 ++-- .../include/extensions/PlaylistExtension.h | 4 ++-- .../extensions/ServerSentEventsExtension.h | 2 +- firmware/include/extensions/SignalExtension.h | 2 +- .../include/extensions/WebSocketExtension.h | 2 +- firmware/include/fonts/BrailleFont.h | 2 +- firmware/include/fonts/LargeFont.h | 2 +- firmware/include/fonts/MediumBoldFont.h | 2 +- firmware/include/fonts/MediumFont.h | 2 +- firmware/include/fonts/MicroFont.h | 2 +- firmware/include/fonts/MiniFont.h | 2 +- firmware/include/fonts/SmallFont.h | 2 +- firmware/include/modes/AnimationMode.h | 2 +- firmware/include/modes/BinaryClockMode.h | 6 ++--- firmware/include/modes/BreakoutClockMode.h | 4 ++-- firmware/include/modes/CountdownMode.h | 2 +- firmware/include/modes/DrawMode.h | 2 +- firmware/include/modes/FliesMode.h | 2 +- firmware/include/modes/GameOfLifeMode.h | 8 +++---- firmware/include/modes/GoogleWeatherMode.h | 4 ++-- firmware/include/modes/HomeThermometerMode.h | 2 +- firmware/include/modes/LargeClockMode.h | 10 ++++---- firmware/include/modes/PingPongMode.h | 8 +++---- firmware/include/modes/RainMode.h | 8 +++---- firmware/include/modes/SmallClockMode.h | 10 ++++---- firmware/include/modes/SnakeMode.h | 8 +++---- firmware/include/modes/StreamMode.h | 2 +- firmware/include/modes/TickerMode.h | 4 ++-- firmware/include/modules/ExtensionModule.h | 4 ++-- firmware/include/modules/FontModule.h | 8 +++---- firmware/include/modules/ModeModule.h | 2 +- firmware/include/modules/ServiceModule.h | 2 +- .../include/services/ConnectivityService.h | 2 +- firmware/include/services/DeviceService.h | 8 +++---- firmware/include/services/DisplayService.h | 2 +- firmware/include/services/ModesService.h | 6 ++--- firmware/src/extensions/InfraredExtension.cpp | 2 +- firmware/src/extensions/MessageExtension.cpp | 4 ++-- .../src/extensions/MicrophoneExtension.cpp | 4 ++-- firmware/src/extensions/OtaExtension.cpp | 2 +- .../src/extensions/PhotocellExtension.cpp | 2 +- firmware/src/extensions/PlaylistExtension.cpp | 2 +- firmware/src/extensions/SignalExtension.cpp | 2 +- firmware/src/modes/AnimationMode.cpp | 2 +- firmware/src/modes/BinaryClockMode.cpp | 2 +- firmware/src/modes/CountdownMode.cpp | 2 +- firmware/src/modes/DrawMode.cpp | 2 +- firmware/src/modes/FliesMode.cpp | 2 +- firmware/src/modes/GameOfLifeMode.cpp | 6 ++--- firmware/src/modes/HomeThermometerMode.cpp | 2 +- firmware/src/modes/LargeClockMode.cpp | 6 ++--- firmware/src/modes/PingPongMode.cpp | 4 ++-- firmware/src/modes/SmallClockMode.cpp | 4 ++-- firmware/src/modes/SnakeMode.cpp | 4 ++-- firmware/src/modes/StreamMode.cpp | 2 +- firmware/src/modes/TickerMode.cpp | 4 ++-- firmware/src/modules/ExtensionModule.cpp | 4 ++-- firmware/src/modules/ModeModule.cpp | 2 +- firmware/src/modules/ServiceModule.cpp | 2 +- firmware/src/services/ConnectivityService.cpp | 6 ++--- firmware/src/services/DeviceService.cpp | 4 ++-- firmware/src/services/DisplayService.cpp | 2 +- firmware/src/services/ModesService.cpp | 4 ++-- 74 files changed, 168 insertions(+), 133 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 44f88c2d..b0f49f8e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,3 +5,10 @@ Checks: > modernize-*, performance-*, readability-*, + -bugprone-easily-swappable-parameters, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-init-variables, + -modernize-use-trailing-return-type, + -readability-convert-member-functions-to-static, + -readability-identifier-length, + -readability-static-accessed-through-instance diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index a2dd0b0d..2e36031f 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -66,7 +66,7 @@ jobs: style: file tidy-checks: -* - - name: Clang format checks failed? + - name: Clang format checks failed if: steps.format.outputs.clang-format-checks-failed != 0 run: exit 1 @@ -76,7 +76,6 @@ jobs: runs-on: ubuntu-latest strategy: - max-parallel: 1 matrix: environment: ${{ fromJson(needs.platformio.outputs.environments) }} include: @@ -220,3 +219,19 @@ jobs: step-summary: true style: "" tidy-checks: "" + + - name: GitHub Script file count + id: changed + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: | + const { data } = await github.rest.pulls.listFiles({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); + core.setOutput('count', data.length); + + - name: Clang tidy checks failed + if: steps.tidy.outputs.clang-tidy-checks-failed > steps.changed.outputs.count + run: exit 1 diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 1a15144d..4d299869 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -43,8 +43,7 @@ jobs: strategy: matrix: toolchain: - - clang-version: false - python-version: 3.11 + - python-version: 3.11 - clang-version: 21 python-version: 3.13 @@ -137,6 +136,11 @@ jobs: step-summary: true style: file tidy-checks: "" + tidy-review: true + + - name: Clang checks failed + if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed != 0 + run: exit 1 mode-dynamic: name: Dynamic mode @@ -146,8 +150,7 @@ jobs: strategy: matrix: toolchain: - - clang-version: false - python-version: 3.11 + - python-version: 3.11 - clang-version: 21 python-version: 3.13 @@ -270,6 +273,11 @@ jobs: step-summary: true style: file tidy-checks: "" + tidy-review: true + + - name: Clang checks failed + if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed != 0 + run: exit 1 mode-static: name: Static mode @@ -279,8 +287,7 @@ jobs: strategy: matrix: toolchain: - - clang-version: false - python-version: 3.11 + - python-version: 3.11 - clang-version: 21 python-version: 3.13 @@ -387,3 +394,8 @@ jobs: step-summary: true style: file tidy-checks: "" + tidy-review: true + + - name: Clang checks failed + if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed != 0 + run: exit 1 diff --git a/.github/workflows/ikea-frekvens-led-spotlight.yml b/.github/workflows/ikea-frekvens-led-spotlight.yml index 8fb4495c..c55770e1 100644 --- a/.github/workflows/ikea-frekvens-led-spotlight.yml +++ b/.github/workflows/ikea-frekvens-led-spotlight.yml @@ -30,6 +30,7 @@ jobs: name: ESPHome build needs: esphome runs-on: ubuntu-latest + continue-on-error: true strategy: matrix: diff --git a/extra/Python/FontGenerator.py b/extra/Python/FontGenerator.py index b0be88c4..cbc060e4 100644 --- a/extra/Python/FontGenerator.py +++ b/extra/Python/FontGenerator.py @@ -205,7 +205,7 @@ def _source_h(self, unique: str) -> str: "public:", f" {unique}Font();", "", - " Symbol getChar(uint32_t character) const override;", + " [[nodiscard]] Symbol getChar(uint32_t character) const override;", "};", "", f"extern {unique}Font *Font{unique};", diff --git a/firmware/include/extensions/AlexaExtension.h b/firmware/include/extensions/AlexaExtension.h index d8fe9df4..4f656c3e 100644 --- a/firmware/include/extensions/AlexaExtension.h +++ b/firmware/include/extensions/AlexaExtension.h @@ -22,7 +22,7 @@ class AlexaExtension : public ExtensionModule void begin() override; void handle() override; - void onTransmit(const JsonDocument &doc, const char *const source) override; + void onTransmit(const JsonDocument &doc, const char *source) override; }; extern AlexaExtension *Alexa; diff --git a/firmware/include/extensions/HomeAssistantExtension.h b/firmware/include/extensions/HomeAssistantExtension.h index 682dfac2..a4d212c4 100644 --- a/firmware/include/extensions/HomeAssistantExtension.h +++ b/firmware/include/extensions/HomeAssistantExtension.h @@ -31,7 +31,7 @@ class HomeAssistantExtension : public ExtensionModule void undiscover(); - void onTransmit(const JsonDocument &doc, const char *const source) override; + void onTransmit(const JsonDocument &doc, const char *source) override; }; extern HomeAssistantExtension *HomeAssistant; diff --git a/firmware/include/extensions/InfraredExtension.h b/firmware/include/extensions/InfraredExtension.h index 9f8b3ff2..4254f136 100644 --- a/firmware/include/extensions/InfraredExtension.h +++ b/firmware/include/extensions/InfraredExtension.h @@ -139,7 +139,7 @@ class InfraredExtension : public ExtensionModule void setActive(bool active); void parse(); - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; extern InfraredExtension *Infrared; diff --git a/firmware/include/extensions/MessageExtension.h b/firmware/include/extensions/MessageExtension.h index da904f2a..26433554 100644 --- a/firmware/include/extensions/MessageExtension.h +++ b/firmware/include/extensions/MessageExtension.h @@ -29,11 +29,11 @@ class MessageExtension : public ExtensionModule std::vector messages; - std::unique_ptr text; + std::unique_ptr text = {}; void addMessage(std::string message); - void setFont(const char *const fontName); + void setFont(const char *fontName); void setRepeat(uint8_t count); void transmit(); @@ -47,7 +47,7 @@ class MessageExtension : public ExtensionModule void begin() override; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; extern MessageExtension *Message; diff --git a/firmware/include/extensions/MicrophoneExtension.h b/firmware/include/extensions/MicrophoneExtension.h index 3a1a56a2..5a63f5f5 100644 --- a/firmware/include/extensions/MicrophoneExtension.h +++ b/firmware/include/extensions/MicrophoneExtension.h @@ -27,12 +27,12 @@ class MicrophoneExtension : public ExtensionModule void begin() override; void handle() override; - bool getActive(); + bool getActive() const; void setActive(bool active); void setThreshold(uint16_t _threshold); - bool isTriggered() const; + [[nodiscard]] bool isTriggered() const; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; extern MicrophoneExtension *Microphone; diff --git a/firmware/include/extensions/MqttExtension.h b/firmware/include/extensions/MqttExtension.h index db1fba72..699c4829 100644 --- a/firmware/include/extensions/MqttExtension.h +++ b/firmware/include/extensions/MqttExtension.h @@ -31,7 +31,7 @@ class MqttExtension : public ExtensionModule void disconnect(); - void onTransmit(const JsonDocument &doc, const char *const source) override; + void onTransmit(const JsonDocument &doc, const char *source) override; }; extern MqttExtension *Mqtt; diff --git a/firmware/include/extensions/PhotocellExtension.h b/firmware/include/extensions/PhotocellExtension.h index 740cc0a1..7053dc03 100644 --- a/firmware/include/extensions/PhotocellExtension.h +++ b/firmware/include/extensions/PhotocellExtension.h @@ -36,8 +36,8 @@ class PhotocellExtension : public ExtensionModule bool getActive() const; void setActive(bool active); - void onReceive(const JsonDocument doc, const char *const source) override; - void onTransmit(const JsonDocument &doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; + void onTransmit(const JsonDocument &doc, const char *source) override; }; extern PhotocellExtension *Photocell; diff --git a/firmware/include/extensions/PlaylistExtension.h b/firmware/include/extensions/PlaylistExtension.h index d9742c87..bbd7058c 100644 --- a/firmware/include/extensions/PlaylistExtension.h +++ b/firmware/include/extensions/PlaylistExtension.h @@ -23,8 +23,8 @@ class PlaylistExtension : public ExtensionModule bool getActive() const; void setActive(bool active); - void onReceive(const JsonDocument doc, const char *const source) override; - void onTransmit(const JsonDocument &doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; + void onTransmit(const JsonDocument &doc, const char *source) override; private: bool active = false; diff --git a/firmware/include/extensions/ServerSentEventsExtension.h b/firmware/include/extensions/ServerSentEventsExtension.h index 41bab824..c3dad821 100644 --- a/firmware/include/extensions/ServerSentEventsExtension.h +++ b/firmware/include/extensions/ServerSentEventsExtension.h @@ -15,7 +15,7 @@ class ServerSentEventsExtension : public ExtensionModule void begin() override; - void onTransmit(const JsonDocument &doc, const char *const source) override; + void onTransmit(const JsonDocument &doc, const char *source) override; static void onConnect(AsyncEventSourceClient *client); }; diff --git a/firmware/include/extensions/SignalExtension.h b/firmware/include/extensions/SignalExtension.h index 22841d58..20e5cfa9 100644 --- a/firmware/include/extensions/SignalExtension.h +++ b/firmware/include/extensions/SignalExtension.h @@ -27,7 +27,7 @@ class SignalExtension : public ExtensionModule void begin() override; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; extern SignalExtension *Signal; diff --git a/firmware/include/extensions/WebSocketExtension.h b/firmware/include/extensions/WebSocketExtension.h index 93df1cb9..5fa3233b 100644 --- a/firmware/include/extensions/WebSocketExtension.h +++ b/firmware/include/extensions/WebSocketExtension.h @@ -20,7 +20,7 @@ class WebSocketExtension : public ExtensionModule void begin() override; void handle() override; - void onTransmit(const JsonDocument &doc, const char *const source) override; + void onTransmit(const JsonDocument &doc, const char *source) override; }; extern WebSocketExtension *WebSocket; diff --git a/firmware/include/fonts/BrailleFont.h b/firmware/include/fonts/BrailleFont.h index 260a9d36..afdd5e50 100644 --- a/firmware/include/fonts/BrailleFont.h +++ b/firmware/include/fonts/BrailleFont.h @@ -344,7 +344,7 @@ class BrailleFont : public FontModule public: BrailleFont(); - Symbol getChar(uint32_t character) const override; + [[nodiscard]] Symbol getChar(uint32_t character) const override; }; extern BrailleFont *FontBraille; diff --git a/firmware/include/fonts/LargeFont.h b/firmware/include/fonts/LargeFont.h index 4ffcc00d..a5f3f188 100644 --- a/firmware/include/fonts/LargeFont.h +++ b/firmware/include/fonts/LargeFont.h @@ -146,7 +146,7 @@ class LargeFont : public FontModule public: LargeFont(); - Symbol getChar(uint32_t character) const override; + [[nodiscard]] Symbol getChar(uint32_t character) const override; }; extern LargeFont *FontLarge; diff --git a/firmware/include/fonts/MediumBoldFont.h b/firmware/include/fonts/MediumBoldFont.h index e337484f..b67bb576 100644 --- a/firmware/include/fonts/MediumBoldFont.h +++ b/firmware/include/fonts/MediumBoldFont.h @@ -263,7 +263,7 @@ class MediumBoldFont : public FontModule public: MediumBoldFont(); - Symbol getChar(uint32_t character) const override; + [[nodiscard]] Symbol getChar(uint32_t character) const override; }; extern MediumBoldFont *FontMediumBold; diff --git a/firmware/include/fonts/MediumFont.h b/firmware/include/fonts/MediumFont.h index 97e13980..f052f314 100644 --- a/firmware/include/fonts/MediumFont.h +++ b/firmware/include/fonts/MediumFont.h @@ -263,7 +263,7 @@ class MediumFont : public FontModule public: MediumFont(); - Symbol getChar(uint32_t character) const override; + [[nodiscard]] Symbol getChar(uint32_t character) const override; }; extern MediumFont *FontMedium; diff --git a/firmware/include/fonts/MicroFont.h b/firmware/include/fonts/MicroFont.h index ffdb680b..07c526ed 100644 --- a/firmware/include/fonts/MicroFont.h +++ b/firmware/include/fonts/MicroFont.h @@ -646,7 +646,7 @@ class MicroFont : public FontModule public: MicroFont(); - Symbol getChar(uint32_t character) const override; + [[nodiscard]] Symbol getChar(uint32_t character) const override; }; extern MicroFont *FontMicro; diff --git a/firmware/include/fonts/MiniFont.h b/firmware/include/fonts/MiniFont.h index 76ccae4c..12daa81f 100644 --- a/firmware/include/fonts/MiniFont.h +++ b/firmware/include/fonts/MiniFont.h @@ -872,7 +872,7 @@ class MiniFont : public FontModule public: MiniFont(); - Symbol getChar(uint32_t character) const override; + [[nodiscard]] Symbol getChar(uint32_t character) const override; }; extern MiniFont *FontMini; diff --git a/firmware/include/fonts/SmallFont.h b/firmware/include/fonts/SmallFont.h index 91bc2aa9..572aeebe 100644 --- a/firmware/include/fonts/SmallFont.h +++ b/firmware/include/fonts/SmallFont.h @@ -1458,7 +1458,7 @@ class SmallFont : public FontModule public: SmallFont(); - Symbol getChar(uint32_t character) const override; + [[nodiscard]] Symbol getChar(uint32_t character) const override; }; extern SmallFont *FontSmall; diff --git a/firmware/include/modes/AnimationMode.h b/firmware/include/modes/AnimationMode.h index 929b5b1b..e1231691 100644 --- a/firmware/include/modes/AnimationMode.h +++ b/firmware/include/modes/AnimationMode.h @@ -30,7 +30,7 @@ class AnimationMode : public ModeModule void begin() override; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_ANIMATION diff --git a/firmware/include/modes/BinaryClockMode.h b/firmware/include/modes/BinaryClockMode.h index 58068f97..a47d3fdb 100644 --- a/firmware/include/modes/BinaryClockMode.h +++ b/firmware/include/modes/BinaryClockMode.h @@ -11,9 +11,9 @@ class BinaryClockMode : public ModeModule bool pending = false; - uint8_t hour; - uint8_t minute; - uint8_t second; + uint8_t hour = 24; + uint8_t minute = 60; + uint8_t second = 60; void draw(uint8_t col, uint8_t value); diff --git a/firmware/include/modes/BreakoutClockMode.h b/firmware/include/modes/BreakoutClockMode.h index 400328bf..404f74cc 100644 --- a/firmware/include/modes/BreakoutClockMode.h +++ b/firmware/include/modes/BreakoutClockMode.h @@ -19,8 +19,8 @@ class BreakoutClockMode : public ModeModule tm local; - uint8_t hour; - uint8_t minute; + uint8_t hour = 24; + uint8_t minute = 60; uint8_t x = GRID_COLUMNS / 2; uint8_t y = GRID_ROWS - 2; diff --git a/firmware/include/modes/CountdownMode.h b/firmware/include/modes/CountdownMode.h index 21d890cc..2210abe4 100644 --- a/firmware/include/modes/CountdownMode.h +++ b/firmware/include/modes/CountdownMode.h @@ -25,7 +25,7 @@ class CountdownMode : public ModeModule void configure() override; void begin() override; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_COUNTDOWN diff --git a/firmware/include/modes/DrawMode.h b/firmware/include/modes/DrawMode.h index 0ea012cb..56ee8acd 100644 --- a/firmware/include/modes/DrawMode.h +++ b/firmware/include/modes/DrawMode.h @@ -23,7 +23,7 @@ class DrawMode : public ModeModule void begin() override; void handle() override; void end() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_DRAW diff --git a/firmware/include/modes/FliesMode.h b/firmware/include/modes/FliesMode.h index 4ff5c661..d032649c 100644 --- a/firmware/include/modes/FliesMode.h +++ b/firmware/include/modes/FliesMode.h @@ -26,7 +26,7 @@ class FliesMode : public ModeModule FliesMode() : ModeModule("Flies") {}; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_FLIES diff --git a/firmware/include/modes/GameOfLifeMode.h b/firmware/include/modes/GameOfLifeMode.h index e0a7864e..04b5b376 100644 --- a/firmware/include/modes/GameOfLifeMode.h +++ b/firmware/include/modes/GameOfLifeMode.h @@ -13,12 +13,12 @@ class GameOfLifeMode : public ModeModule bool pending = false; uint8_t active = 0; - uint8_t hour; - uint8_t minute; + uint8_t hour = 24; + uint8_t minute = 60; unsigned long lastMillis = 0; - void setClock(const bool _clock); + void setClock(bool _clock); void transmit(); public: @@ -27,7 +27,7 @@ class GameOfLifeMode : public ModeModule void configure() override; void begin() override; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_GAMEOFLIFE diff --git a/firmware/include/modes/GoogleWeatherMode.h b/firmware/include/modes/GoogleWeatherMode.h index 4b7cc37c..51c622fe 100644 --- a/firmware/include/modes/GoogleWeatherMode.h +++ b/firmware/include/modes/GoogleWeatherMode.h @@ -112,8 +112,8 @@ class GoogleWeatherMode : public ModeModule public: GoogleWeatherMode() : ModeModule("Google Weather") {}; - void begin(); - void handle(); + void begin() override; + void handle() override; }; #endif // MODE_GOOGLEWEATHER diff --git a/firmware/include/modes/HomeThermometerMode.h b/firmware/include/modes/HomeThermometerMode.h index 9f528e82..a8d8c1a2 100644 --- a/firmware/include/modes/HomeThermometerMode.h +++ b/firmware/include/modes/HomeThermometerMode.h @@ -19,7 +19,7 @@ class HomeThermometerMode : public ModeModule void configure() override; void begin() override; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_HOMETHERMOMETER diff --git a/firmware/include/modes/LargeClockMode.h b/firmware/include/modes/LargeClockMode.h index b3801514..468c4d26 100644 --- a/firmware/include/modes/LargeClockMode.h +++ b/firmware/include/modes/LargeClockMode.h @@ -15,16 +15,16 @@ class LargeClockMode : public ModeModule bool pending = false; bool ticking = false; - uint8_t hour; - uint8_t minute; + uint8_t hour = 24; + uint8_t minute = 60; uint8_t second = 0; FontModule *font = nullptr; std::vector fonts = {}; - void setFont(const char *const fontName); - void setTicking(const bool _ticking); + void setFont(const char * fontName); + void setTicking(bool _ticking); void transmit(); public: @@ -33,7 +33,7 @@ class LargeClockMode : public ModeModule void configure() override; void begin() override; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_LARGECLOCK diff --git a/firmware/include/modes/PingPongMode.h b/firmware/include/modes/PingPongMode.h index 481b892b..eec89398 100644 --- a/firmware/include/modes/PingPongMode.h +++ b/firmware/include/modes/PingPongMode.h @@ -23,8 +23,8 @@ class PingPongMode : public ModeModule tm local; - uint8_t hour; - uint8_t minute; + uint8_t hour = 24; + uint8_t minute = 60; uint8_t x = GRID_COLUMNS - 2; uint8_t y = GRID_ROWS / 2; @@ -32,7 +32,7 @@ class PingPongMode : public ModeModule unsigned long lastMillis = 0; - void setClock(const bool _clock); + void setClock(bool _clock); void transmit(); public: @@ -41,7 +41,7 @@ class PingPongMode : public ModeModule void configure() override; void begin() override; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_PINGPONG diff --git a/firmware/include/modes/RainMode.h b/firmware/include/modes/RainMode.h index e3f687ab..6fab22eb 100644 --- a/firmware/include/modes/RainMode.h +++ b/firmware/include/modes/RainMode.h @@ -10,10 +10,10 @@ class RainMode : public ModeModule private: struct Drop { - uint8_t delay; - uint8_t length; - uint8_t x; - uint8_t y; + uint8_t delay = INT8_MAX; + uint8_t length = 3; + uint8_t x = 0; + uint8_t y = 0; unsigned long lastMillis = 0; }; diff --git a/firmware/include/modes/SmallClockMode.h b/firmware/include/modes/SmallClockMode.h index 2ccf396e..da74d5cb 100644 --- a/firmware/include/modes/SmallClockMode.h +++ b/firmware/include/modes/SmallClockMode.h @@ -12,11 +12,11 @@ class SmallClockMode : public ModeModule bool pending = false; bool ticking = true; - uint8_t hour; - uint8_t minute; - uint8_t second; + uint8_t hour = 24; + uint8_t minute = 60; + uint8_t second = 60; - void setTicking(const bool _ticking); + void setTicking(bool _ticking); void transmit(); public: @@ -25,7 +25,7 @@ class SmallClockMode : public ModeModule void configure() override; void begin() override; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_SMALLCLOCK diff --git a/firmware/include/modes/SnakeMode.h b/firmware/include/modes/SnakeMode.h index bd0d6f58..e85241f0 100644 --- a/firmware/include/modes/SnakeMode.h +++ b/firmware/include/modes/SnakeMode.h @@ -28,8 +28,8 @@ class SnakeMode : public ModeModule unsigned long lastMillis = 0; uint8_t blink = 0; - uint8_t hour; - uint8_t minute; + uint8_t hour = 24; + uint8_t minute = 60; uint8_t stage = 0; Pixel dot; @@ -43,7 +43,7 @@ class SnakeMode : public ModeModule void end(); void clean(); - void setClock(const bool _clock); + void setClock(bool _clock); void setDot(); void transmit(); @@ -53,7 +53,7 @@ class SnakeMode : public ModeModule void configure() override; void begin() override; void handle() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_SNAKE diff --git a/firmware/include/modes/StreamMode.h b/firmware/include/modes/StreamMode.h index a2f661fa..9df70fd4 100644 --- a/firmware/include/modes/StreamMode.h +++ b/firmware/include/modes/StreamMode.h @@ -28,7 +28,7 @@ class StreamMode : public ModeModule void begin() override; void end() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_STREAM diff --git a/firmware/include/modes/TickerMode.h b/firmware/include/modes/TickerMode.h index 76d554cc..d321a011 100644 --- a/firmware/include/modes/TickerMode.h +++ b/firmware/include/modes/TickerMode.h @@ -28,7 +28,7 @@ class TickerMode : public ModeModule std::unique_ptr text; - void setFont(const char *const fontName); + void setFont(const char *fontName); void setMessage(std::string _message); void transmit(); @@ -41,7 +41,7 @@ class TickerMode : public ModeModule void handle() override; void end() override; - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; }; #endif // MODE_TICKER diff --git a/firmware/include/modules/ExtensionModule.h b/firmware/include/modules/ExtensionModule.h index 576a5e42..d5069c66 100644 --- a/firmware/include/modules/ExtensionModule.h +++ b/firmware/include/modules/ExtensionModule.h @@ -17,6 +17,6 @@ class ExtensionModule virtual void begin(); virtual void handle(); - virtual void onTransmit(const JsonDocument &doc, const char *const source); - virtual void onReceive(const JsonDocument doc, const char *source); + virtual void onReceive(const JsonDocument &doc, const char *source); + virtual void onTransmit(const JsonDocument &doc, const char *source); }; diff --git a/firmware/include/modules/FontModule.h b/firmware/include/modules/FontModule.h index 8e299d8e..c4ff4849 100644 --- a/firmware/include/modules/FontModule.h +++ b/firmware/include/modules/FontModule.h @@ -14,9 +14,9 @@ class FontModule struct Symbol { - const std::vector bitmap; - const int8_t offsetX; - const int8_t offsetY; + const std::vector bitmap = {}; + const int8_t offsetX = 0; + const int8_t offsetY = 0; }; struct SymbolExtended @@ -27,5 +27,5 @@ class FontModule const char *const name; - virtual Symbol getChar(uint32_t character) const = 0; + [[nodiscard]] virtual Symbol getChar(uint32_t character) const = 0; }; diff --git a/firmware/include/modules/ModeModule.h b/firmware/include/modules/ModeModule.h index 7c0afc5f..b341bd25 100644 --- a/firmware/include/modules/ModeModule.h +++ b/firmware/include/modules/ModeModule.h @@ -18,5 +18,5 @@ class ModeModule virtual void handle(); virtual void end(); - virtual void onReceive(const JsonDocument doc, const char *source); + virtual void onReceive(const JsonDocument &doc, const char *source); }; diff --git a/firmware/include/modules/ServiceModule.h b/firmware/include/modules/ServiceModule.h index f39d9003..91b22e25 100644 --- a/firmware/include/modules/ServiceModule.h +++ b/firmware/include/modules/ServiceModule.h @@ -13,5 +13,5 @@ class ServiceModule const char *const name; - virtual void onReceive(const JsonDocument doc, const char *const source); + virtual void onReceive(const JsonDocument &doc, const char *source); }; diff --git a/firmware/include/services/ConnectivityService.h b/firmware/include/services/ConnectivityService.h index 83b0ca7e..32754937 100644 --- a/firmware/include/services/ConnectivityService.h +++ b/firmware/include/services/ConnectivityService.h @@ -42,7 +42,7 @@ class ConnectivityService : public ServiceModule void begin(); void handle(); - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; static ConnectivityService &getInstance(); }; diff --git a/firmware/include/services/DeviceService.h b/firmware/include/services/DeviceService.h index b4a950c2..50c576b9 100644 --- a/firmware/include/services/DeviceService.h +++ b/firmware/include/services/DeviceService.h @@ -18,7 +18,7 @@ class DeviceService : public ServiceModule void transmit(); - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; public: TaskHandle_t taskHandle = nullptr; @@ -29,10 +29,10 @@ class DeviceService : public ServiceModule void setPower(bool power); void restore(); - void transmit(JsonDocument doc, const char *const source, bool retain = true); - void receive(const JsonDocument doc, const char *const source, const char *const destination); + void transmit(JsonDocument doc, const char *source, bool retain = true); + void receive(const JsonDocument &doc, const char *source, const char *destination); - const JsonDocument getTransmits() const; + [[nodiscard]] const JsonDocument getTransmits() const; static DeviceService &getInstance(); }; diff --git a/firmware/include/services/DisplayService.h b/firmware/include/services/DisplayService.h index 1033885b..3bc43bf6 100644 --- a/firmware/include/services/DisplayService.h +++ b/firmware/include/services/DisplayService.h @@ -94,7 +94,7 @@ class DisplayService : public ServiceModule void flush(); - void onReceive(const JsonDocument doc, const char *const source) override; + void onReceive(const JsonDocument &doc, const char *source) override; static DisplayService &getInstance(); }; diff --git a/firmware/include/services/ModesService.h b/firmware/include/services/ModesService.h index 1b1b8337..f9eac126 100644 --- a/firmware/include/services/ModesService.h +++ b/firmware/include/services/ModesService.h @@ -201,11 +201,11 @@ class ModesService : public ServiceModule void begin(); void handle(); void setActive(bool active); - void setMode(const char *const name); + void setMode(const char *name); void setModeNext(); void setModePrevious(); - const std::vector &getAll() const; - void onReceive(const JsonDocument doc, const char *const source) override; + [[nodiscard]] const std::vector &getAll() const; + void onReceive(const JsonDocument &doc, const char *source) override; static ModesService &getInstance(); }; diff --git a/firmware/src/extensions/InfraredExtension.cpp b/firmware/src/extensions/InfraredExtension.cpp index 88329618..cbf8bf51 100644 --- a/firmware/src/extensions/InfraredExtension.cpp +++ b/firmware/src/extensions/InfraredExtension.cpp @@ -195,7 +195,7 @@ void InfraredExtension::transmit() Device.transmit(doc, name); } -void InfraredExtension::onReceive(const JsonDocument doc, const char *const source) +void InfraredExtension::onReceive(const JsonDocument &doc, const char *source) { // Active if (doc["active"].is()) diff --git a/firmware/src/extensions/MessageExtension.cpp b/firmware/src/extensions/MessageExtension.cpp index 376dd9c5..193bf634 100644 --- a/firmware/src/extensions/MessageExtension.cpp +++ b/firmware/src/extensions/MessageExtension.cpp @@ -150,7 +150,7 @@ void MessageExtension::addMessage(std::string message) ESP_LOGD(name, "received"); } -void MessageExtension::setFont(const char *const fontName) +void MessageExtension::setFont(const char *fontName) { if (!font || strcmp(fontName, font->name)) { @@ -192,7 +192,7 @@ void MessageExtension::transmit() Device.transmit(doc, name); } -void MessageExtension::onReceive(const JsonDocument doc, const char *const source) +void MessageExtension::onReceive(const JsonDocument &doc, const char *source) { // Font if (doc["font"].is()) diff --git a/firmware/src/extensions/MicrophoneExtension.cpp b/firmware/src/extensions/MicrophoneExtension.cpp index 29d919ba..0abfd491 100644 --- a/firmware/src/extensions/MicrophoneExtension.cpp +++ b/firmware/src/extensions/MicrophoneExtension.cpp @@ -134,7 +134,7 @@ void MicrophoneExtension::handle() } } -bool MicrophoneExtension::getActive() { return active; } +bool MicrophoneExtension::getActive() const { return active; } void MicrophoneExtension::setActive(bool active) { @@ -185,7 +185,7 @@ void MicrophoneExtension::transmit() Device.transmit(doc, name); } -void MicrophoneExtension::onReceive(const JsonDocument doc, const char *const source) +void MicrophoneExtension::onReceive(const JsonDocument &doc, const char *source) { // Active if (doc["active"].is()) diff --git a/firmware/src/extensions/OtaExtension.cpp b/firmware/src/extensions/OtaExtension.cpp index 374ae1e0..d49e48de 100644 --- a/firmware/src/extensions/OtaExtension.cpp +++ b/firmware/src/extensions/OtaExtension.cpp @@ -57,7 +57,7 @@ void OtaExtension::onEnd() { ESP_LOGI(Ota->name, "complete"); } void OtaExtension::onPost(AsyncWebServerRequest *request, const String &filename, size_t index, uint8_t *data, size_t len, bool final) { - if (!index) + if (index == 0) { onStart(); } diff --git a/firmware/src/extensions/PhotocellExtension.cpp b/firmware/src/extensions/PhotocellExtension.cpp index 5e83a7b7..fc1a98d2 100644 --- a/firmware/src/extensions/PhotocellExtension.cpp +++ b/firmware/src/extensions/PhotocellExtension.cpp @@ -145,7 +145,7 @@ void PhotocellExtension::transmit() lastMillis = millis(); } -void PhotocellExtension::onReceive(const JsonDocument doc, const char *const source) +void PhotocellExtension::onReceive(const JsonDocument &doc, const char *source) { // Active if (doc["active"].is()) diff --git a/firmware/src/extensions/PlaylistExtension.cpp b/firmware/src/extensions/PlaylistExtension.cpp index 67fee552..ed876f09 100644 --- a/firmware/src/extensions/PlaylistExtension.cpp +++ b/firmware/src/extensions/PlaylistExtension.cpp @@ -177,7 +177,7 @@ void PlaylistExtension::onTransmit(const JsonDocument &doc, const char *const so } } -void PlaylistExtension::onReceive(const JsonDocument doc, const char *const source) +void PlaylistExtension::onReceive(const JsonDocument &doc, const char *source) { // Playlist if (doc["playlist"].is()) diff --git a/firmware/src/extensions/SignalExtension.cpp b/firmware/src/extensions/SignalExtension.cpp index d0bd262c..8a372c75 100644 --- a/firmware/src/extensions/SignalExtension.cpp +++ b/firmware/src/extensions/SignalExtension.cpp @@ -72,7 +72,7 @@ void SignalExtension::transmit() Device.transmit(doc, name); } -void SignalExtension::onReceive(const JsonDocument doc, const char *const source) +void SignalExtension::onReceive(const JsonDocument &doc, const char *source) { // Duration if (doc["duration"].is()) diff --git a/firmware/src/modes/AnimationMode.cpp b/firmware/src/modes/AnimationMode.cpp index f8466c73..692debd9 100644 --- a/firmware/src/modes/AnimationMode.cpp +++ b/firmware/src/modes/AnimationMode.cpp @@ -97,7 +97,7 @@ void AnimationMode::transmit(const uint8_t index, const uint8_t frame[GRID_COLUM Device.transmit(doc, name, false); } -void AnimationMode::onReceive(const JsonDocument doc, const char *const source) +void AnimationMode::onReceive(const JsonDocument &doc, const char *source) { // Action: pull if (doc["action"].is() && !strcmp(doc["action"].as(), "pull")) diff --git a/firmware/src/modes/BinaryClockMode.cpp b/firmware/src/modes/BinaryClockMode.cpp index b8d58678..bb64b9e1 100644 --- a/firmware/src/modes/BinaryClockMode.cpp +++ b/firmware/src/modes/BinaryClockMode.cpp @@ -38,7 +38,7 @@ void BinaryClockMode::draw(uint8_t y, uint8_t value) { for (uint8_t i = 0; i < 6; ++i) { - const uint8_t x = GRID_COLUMNS / 2 + 4 - i * 2; + const uint8_t x = (GRID_COLUMNS / 2) + 4 - (i * 2); Display.drawRectangle(x, y, x + 1, y + 3, true, value & (1 << i) ? UINT8_MAX : 0); } } diff --git a/firmware/src/modes/CountdownMode.cpp b/firmware/src/modes/CountdownMode.cpp index de825a22..8005a86a 100644 --- a/firmware/src/modes/CountdownMode.cpp +++ b/firmware/src/modes/CountdownMode.cpp @@ -124,7 +124,7 @@ void CountdownMode::transmit() Device.transmit(doc, name); } -void CountdownMode::onReceive(const JsonDocument doc, const char *const source) +void CountdownMode::onReceive(const JsonDocument &doc, const char *source) { if (doc["time"].is()) { diff --git a/firmware/src/modes/DrawMode.cpp b/firmware/src/modes/DrawMode.cpp index ca334bdd..a3b59c02 100644 --- a/firmware/src/modes/DrawMode.cpp +++ b/firmware/src/modes/DrawMode.cpp @@ -93,7 +93,7 @@ void DrawMode::transmit() Device.transmit(doc, name, false); } -void DrawMode::onReceive(const JsonDocument doc, const char *const source) +void DrawMode::onReceive(const JsonDocument &doc, const char *source) { if (doc["action"].is()) { diff --git a/firmware/src/modes/FliesMode.cpp b/firmware/src/modes/FliesMode.cpp index 88bc54fd..b14bb716 100644 --- a/firmware/src/modes/FliesMode.cpp +++ b/firmware/src/modes/FliesMode.cpp @@ -17,7 +17,7 @@ void FliesMode::handle() } } -void FliesMode::onReceive(const JsonDocument doc, const char *const source) +void FliesMode::onReceive(const JsonDocument &doc, const char *source) { if (doc["id"].is() && doc["x"].is() && doc["y"].is()) { diff --git a/firmware/src/modes/GameOfLifeMode.cpp b/firmware/src/modes/GameOfLifeMode.cpp index 6848a1c0..f6e618e3 100644 --- a/firmware/src/modes/GameOfLifeMode.cpp +++ b/firmware/src/modes/GameOfLifeMode.cpp @@ -67,7 +67,7 @@ void GameOfLifeMode::handle() for (uint8_t i = active; i < GRID_COLUMNS * (GRID_ROWS - (clock ? 5 : 0)) / (1 << 4); ++i) { seeds[random(1, GRID_COLUMNS - 1) + - random(clock ? 6 : 1, GRID_ROWS - 1) * (GRID_COLUMNS - (clock ? 5 : 0))] = true; + (random(clock ? 6 : 1, GRID_ROWS - 1) * (GRID_COLUMNS - (clock ? 5 : 0)))] = true; } lastMillis = millis(); active = 0; @@ -103,7 +103,7 @@ void GameOfLifeMode::handle() } } -void GameOfLifeMode::setClock(const bool _clock) +void GameOfLifeMode::setClock(bool _clock) { if (_clock != clock) { @@ -124,7 +124,7 @@ void GameOfLifeMode::transmit() Device.transmit(doc, name); } -void GameOfLifeMode::onReceive(const JsonDocument doc, const char *const source) +void GameOfLifeMode::onReceive(const JsonDocument &doc, const char *source) { // Clock if (doc["clock"].is()) diff --git a/firmware/src/modes/HomeThermometerMode.cpp b/firmware/src/modes/HomeThermometerMode.cpp index e8123ab7..00da41b0 100644 --- a/firmware/src/modes/HomeThermometerMode.cpp +++ b/firmware/src/modes/HomeThermometerMode.cpp @@ -120,7 +120,7 @@ void HomeThermometerMode::transmit() } } -void HomeThermometerMode::onReceive(const JsonDocument doc, const char *const source) +void HomeThermometerMode::onReceive(const JsonDocument &doc, const char *source) { if (doc["indoor"].is()) { diff --git a/firmware/src/modes/LargeClockMode.cpp b/firmware/src/modes/LargeClockMode.cpp index ab9094db..819d63f0 100644 --- a/firmware/src/modes/LargeClockMode.cpp +++ b/firmware/src/modes/LargeClockMode.cpp @@ -127,7 +127,7 @@ void LargeClockMode::handle() } } -void LargeClockMode::setFont(const char *const fontName) +void LargeClockMode::setFont(const char *fontName) { if (!font || strcmp(font->name, fontName)) { @@ -149,7 +149,7 @@ void LargeClockMode::setFont(const char *const fontName) } } -void LargeClockMode::setTicking(const bool _ticking) +void LargeClockMode::setTicking(bool _ticking) { if (_ticking != ticking) { @@ -176,7 +176,7 @@ void LargeClockMode::transmit() Device.transmit(doc, name); } -void LargeClockMode::onReceive(const JsonDocument doc, const char *const source) +void LargeClockMode::onReceive(const JsonDocument &doc, const char *source) { // Font if (doc["font"].is()) diff --git a/firmware/src/modes/PingPongMode.cpp b/firmware/src/modes/PingPongMode.cpp index 04c53bcc..490c920b 100644 --- a/firmware/src/modes/PingPongMode.cpp +++ b/firmware/src/modes/PingPongMode.cpp @@ -183,7 +183,7 @@ void PingPongMode::handle() } } -void PingPongMode::setClock(const bool _clock) +void PingPongMode::setClock(bool _clock) { if (_clock != clock) { @@ -209,7 +209,7 @@ void PingPongMode::transmit() Device.transmit(doc, name); } -void PingPongMode::onReceive(const JsonDocument doc, const char *const source) +void PingPongMode::onReceive(const JsonDocument &doc, const char *source) { // Clock if (doc["clock"].is()) diff --git a/firmware/src/modes/SmallClockMode.cpp b/firmware/src/modes/SmallClockMode.cpp index 4be2dbb3..b4fa6cbd 100644 --- a/firmware/src/modes/SmallClockMode.cpp +++ b/firmware/src/modes/SmallClockMode.cpp @@ -95,7 +95,7 @@ void SmallClockMode::handle() } } -void SmallClockMode::setTicking(const bool _ticking) +void SmallClockMode::setTicking(bool _ticking) { if (_ticking != ticking) { @@ -116,7 +116,7 @@ void SmallClockMode::transmit() Device.transmit(doc, name); } -void SmallClockMode::onReceive(const JsonDocument doc, const char *const source) +void SmallClockMode::onReceive(const JsonDocument &doc, const char *source) { // Toggle ticking if (doc["ticking"].is()) diff --git a/firmware/src/modes/SnakeMode.cpp b/firmware/src/modes/SnakeMode.cpp index 05928199..7c85b671 100644 --- a/firmware/src/modes/SnakeMode.cpp +++ b/firmware/src/modes/SnakeMode.cpp @@ -248,7 +248,7 @@ void SnakeMode::setDot() Display.setPixel(dot.x, dot.y, random(1, 1 << 8)); } -void SnakeMode::setClock(const bool _clock) +void SnakeMode::setClock(bool _clock) { if (_clock != clock) { @@ -277,7 +277,7 @@ void SnakeMode::transmit() Device.transmit(doc, name); } -void SnakeMode::onReceive(const JsonDocument doc, const char *const source) +void SnakeMode::onReceive(const JsonDocument &doc, const char *source) { // Clock if (doc["clock"].is()) diff --git a/firmware/src/modes/StreamMode.cpp b/firmware/src/modes/StreamMode.cpp index 96929c24..2513461e 100644 --- a/firmware/src/modes/StreamMode.cpp +++ b/firmware/src/modes/StreamMode.cpp @@ -82,7 +82,7 @@ void StreamMode::transmit() Device.transmit(doc, name); } -void StreamMode::onReceive(const JsonDocument doc, const char *const source) +void StreamMode::onReceive(const JsonDocument &doc, const char *source) { // Port if (doc["port"].is()) diff --git a/firmware/src/modes/TickerMode.cpp b/firmware/src/modes/TickerMode.cpp index 2236931c..b6111009 100644 --- a/firmware/src/modes/TickerMode.cpp +++ b/firmware/src/modes/TickerMode.cpp @@ -96,7 +96,7 @@ void TickerMode::handle() } } -void TickerMode::setFont(const char *const fontName) +void TickerMode::setFont(const char *fontName) { if (!font || strcmp(font->name, fontName)) { @@ -139,7 +139,7 @@ void TickerMode::transmit() Device.transmit(doc, name); } -void TickerMode::onReceive(const JsonDocument doc, const char *const source) +void TickerMode::onReceive(const JsonDocument &doc, const char *source) { // Font if (doc["font"].is()) diff --git a/firmware/src/modules/ExtensionModule.cpp b/firmware/src/modules/ExtensionModule.cpp index 892b6f11..006ed7fe 100644 --- a/firmware/src/modules/ExtensionModule.cpp +++ b/firmware/src/modules/ExtensionModule.cpp @@ -4,5 +4,5 @@ void ExtensionModule::configure() {} void ExtensionModule::begin() {} void ExtensionModule::handle() {} -void ExtensionModule::onReceive(const JsonDocument doc, const char *const source) {} -void ExtensionModule::onTransmit(const JsonDocument &doc, const char *const source) {} +void ExtensionModule::onReceive(const JsonDocument &doc, const char *source) {} +void ExtensionModule::onTransmit(const JsonDocument &doc, const char *source) {} diff --git a/firmware/src/modules/ModeModule.cpp b/firmware/src/modules/ModeModule.cpp index e0b611da..1326c2f0 100644 --- a/firmware/src/modules/ModeModule.cpp +++ b/firmware/src/modules/ModeModule.cpp @@ -5,4 +5,4 @@ void ModeModule::begin() {} void ModeModule::handle() {} void ModeModule::end() {} -void ModeModule::onReceive(const JsonDocument doc, const char *const source) {} +void ModeModule::onReceive(const JsonDocument &doc, const char *source) {} diff --git a/firmware/src/modules/ServiceModule.cpp b/firmware/src/modules/ServiceModule.cpp index d7fa0a6b..4a56b876 100644 --- a/firmware/src/modules/ServiceModule.cpp +++ b/firmware/src/modules/ServiceModule.cpp @@ -1,3 +1,3 @@ #include "modules/ServiceModule.h" -void ServiceModule::onReceive(const JsonDocument doc, const char *const source) {} +void ServiceModule::onReceive(const JsonDocument &doc, const char *source) {} diff --git a/firmware/src/services/ConnectivityService.cpp b/firmware/src/services/ConnectivityService.cpp index 294d71b6..909535b7 100644 --- a/firmware/src/services/ConnectivityService.cpp +++ b/firmware/src/services/ConnectivityService.cpp @@ -123,7 +123,7 @@ void ConnectivityService::initStation() deserializeJson(doc, _buffer.data(), _length); } wifi_config_t config; - if (!esp_wifi_get_config(wifi_interface_t::WIFI_IF_STA, &config)) + if (esp_wifi_get_config(wifi_interface_t::WIFI_IF_STA, &config) == ESP_OK) { const char *_ssid = reinterpret_cast(config.sta.ssid); const std::string_view ssid(_ssid, strnlen(_ssid, sizeof(config.sta.ssid))); @@ -186,7 +186,7 @@ void ConnectivityService::onConnected(WiFiEvent_t event, WiFiEventInfo_t info) ESP_LOGI(Connectivity.name, HOSTNAME ".local"); #ifndef WIFI_COUNTRY char country[3]; - if (!esp_wifi_get_country_code(country)) + if (esp_wifi_get_country_code(country) == ESP_OK) { Preferences Storage; Storage.begin(_name.data()); @@ -317,7 +317,7 @@ void ConnectivityService::transmit() Device.transmit(doc, name); } -void ConnectivityService::onReceive(const JsonDocument doc, const char *const source) +void ConnectivityService::onReceive(const JsonDocument &doc, const char *source) { // Connect if (doc["ssid"].is()) diff --git a/firmware/src/services/DeviceService.cpp b/firmware/src/services/DeviceService.cpp index 165bdba8..fc16bb1e 100644 --- a/firmware/src/services/DeviceService.cpp +++ b/firmware/src/services/DeviceService.cpp @@ -260,7 +260,7 @@ void DeviceService::transmit(JsonDocument doc, const char *const source, bool re } } -void DeviceService::receive(const JsonDocument doc, const char *const source, const char *const destination) +void DeviceService::receive(const JsonDocument &doc, const char *source, const char *destination) { if (operational) { @@ -298,7 +298,7 @@ void DeviceService::receive(const JsonDocument doc, const char *const source, co } } -void DeviceService::onReceive(const JsonDocument doc, const char *const source) +void DeviceService::onReceive(const JsonDocument &doc, const char *source) { if (doc["action"].is()) { diff --git a/firmware/src/services/DisplayService.cpp b/firmware/src/services/DisplayService.cpp index 91c49c9c..fc943c4d 100644 --- a/firmware/src/services/DisplayService.cpp +++ b/firmware/src/services/DisplayService.cpp @@ -378,7 +378,7 @@ void DisplayService::transmit() Device.transmit(doc, name); } -void DisplayService::onReceive(const JsonDocument doc, const char *const source) +void DisplayService::onReceive(const JsonDocument &doc, const char *source) { // Brightness if (doc["brightness"].is()) diff --git a/firmware/src/services/ModesService.cpp b/firmware/src/services/ModesService.cpp index 67b7342c..a5ba7f51 100644 --- a/firmware/src/services/ModesService.cpp +++ b/firmware/src/services/ModesService.cpp @@ -113,7 +113,7 @@ void ModesService::setActive(bool active) } } -void ModesService::setMode(const char *const name) +void ModesService::setMode(const char *name) { if (!mode || strcmp(mode->name, name)) { @@ -236,7 +236,7 @@ void ModesService::transmit() Device.transmit(doc, name); } -void ModesService::onReceive(const JsonDocument doc, const char *const source) +void ModesService::onReceive(const JsonDocument &doc, const char *source) { // Mode if (doc["mode"].is()) From 0fb453fb2e6648dc828a89a98a79f895e2223dc5 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Mon, 2 Feb 2026 03:57:12 +0100 Subject: [PATCH 12/26] WIP --- .clang-tidy | 6 +++++- .github/workflows/clang.yml | 4 ++-- .github/workflows/generate.yml | 4 ++-- .../ikea-frekvens-led-multi-use-light.yml | 4 ++-- .../ikea-obegransad-led-wall-lamp.yml | 4 ++-- .github/workflows/miscellaneous.yml | 4 ++-- .../include/extensions/InfraredExtension.h | 2 +- .../include/extensions/MicrophoneExtension.h | 2 +- .../include/extensions/PhotocellExtension.h | 2 +- .../include/extensions/PlaylistExtension.h | 6 +++--- firmware/include/handlers/BitmapHandler.h | 6 +++--- firmware/include/handlers/TextHandler.h | 6 +++--- firmware/include/handlers/WeatherHandler.h | 8 ++++---- firmware/include/modes/BinaryEpochMode.h | 2 +- firmware/include/modes/BreakoutClockMode.h | 2 +- firmware/include/modes/EqualizerMode.h | 2 +- firmware/include/modes/FliesMode.h | 6 +++--- firmware/include/modes/HomeThermometerMode.h | 2 +- firmware/include/modes/LargeClockMode.h | 2 +- firmware/include/modes/LeafFallMode.h | 4 ++-- firmware/include/modes/SnakeMode.h | 13 ++++++------ firmware/include/modes/TickerMode.h | 2 +- firmware/include/modules/FontModule.h | 4 ++-- .../include/services/ConnectivityService.h | 2 +- firmware/include/services/DisplayService.h | 10 +++++----- firmware/include/services/FontsService.h | 2 +- firmware/src/extensions/HeapExtension.cpp | 2 +- firmware/src/extensions/InfraredExtension.cpp | 2 +- firmware/src/extensions/MessageExtension.cpp | 4 ++-- firmware/src/extensions/OtaExtension.cpp | 2 +- firmware/src/modes/AnimationMode.cpp | 2 +- firmware/src/modes/BinaryEpochMode.cpp | 4 ++-- firmware/src/modes/CountdownMode.cpp | 12 +++++------ firmware/src/modes/HomeThermometerMode.cpp | 4 ++-- firmware/src/modes/LargeClockMode.cpp | 16 +++++++-------- firmware/src/modes/MetaballsMode.cpp | 2 +- firmware/src/modes/SnakeMode.cpp | 10 +++++----- firmware/src/modes/StreamMode.cpp | 8 ++++---- firmware/src/modes/TickerMode.cpp | 4 ++-- firmware/src/services/ConnectivityService.cpp | 2 +- firmware/src/services/DisplayService.cpp | 9 +++++---- firmware/src/services/ModesService.cpp | 20 +++++++++---------- 42 files changed, 109 insertions(+), 105 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index b0f49f8e..3ab6a5ca 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -8,7 +8,11 @@ Checks: > -bugprone-easily-swappable-parameters, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-init-variables, + -cppcoreguidelines-macro-to-enum, + -modernize-use-auto, -modernize-use-trailing-return-type, -readability-convert-member-functions-to-static, -readability-identifier-length, - -readability-static-accessed-through-instance + -readability-magic-numbers, + -readability-static-accessed-through-instance, + -readability-uppercase-literal-suffix diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 2e36031f..af8beea6 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -13,7 +13,7 @@ permissions: jobs: platformio: - name: PlatformIO variable extract + name: PlatformIO environments runs-on: ubuntu-latest outputs: environments: ${{ steps.print.outputs.environments }} @@ -33,7 +33,7 @@ jobs: - name: Set up PlatformIO run: pip install -r .github/platformio/requirements.txt - - name: PlatformIO extract + - name: PlatformIO environments id: print run: | echo "environments=$(pio project config --json-output | jq -c '[.[] | .[0] | select(startswith("env:")) | sub("^env:"; "")]')" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 4d299869..35be75da 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -12,7 +12,7 @@ permissions: jobs: platformio: - name: PlatformIO version extract + name: PlatformIO version runs-on: ubuntu-latest outputs: version: ${{ steps.print.outputs.version }} @@ -31,7 +31,7 @@ jobs: - name: Set up PlatformIO run: pip install -r .github/platformio/requirements.txt - - name: PlatformIO extract + - name: PlatformIO version id: print run: echo "version=$(pio --version | awk '{print $NF}')" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/ikea-frekvens-led-multi-use-light.yml b/.github/workflows/ikea-frekvens-led-multi-use-light.yml index 68f062a8..b7b81f55 100644 --- a/.github/workflows/ikea-frekvens-led-multi-use-light.yml +++ b/.github/workflows/ikea-frekvens-led-multi-use-light.yml @@ -20,7 +20,7 @@ permissions: jobs: platformio: - name: PlatformIO variable extract + name: PlatformIO environments runs-on: ubuntu-latest outputs: environments: ${{ steps.print.outputs.environments }} @@ -40,7 +40,7 @@ jobs: - name: Set up PlatformIO run: pip install -r .github/platformio/requirements.txt - - name: PlatformIO extract + - name: PlatformIO environments id: print run: | echo "environments=$(pio project config --json-output | jq -c '[.[] | .[0] | select(startswith("env:")) | sub("^env:"; "")]')" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/ikea-obegransad-led-wall-lamp.yml b/.github/workflows/ikea-obegransad-led-wall-lamp.yml index 54de3b5e..03d7013b 100644 --- a/.github/workflows/ikea-obegransad-led-wall-lamp.yml +++ b/.github/workflows/ikea-obegransad-led-wall-lamp.yml @@ -20,7 +20,7 @@ permissions: jobs: platformio: - name: PlatformIO variable extract + name: PlatformIO environments runs-on: ubuntu-latest outputs: environments: ${{ steps.print.outputs.environments }} @@ -40,7 +40,7 @@ jobs: - name: Set up PlatformIO run: pip install -r .github/platformio/requirements.txt - - name: PlatformIO extract + - name: PlatformIO environments id: print run: | echo "environments=$(pio project config --json-output | jq -c '[.[] | .[0] | select(startswith("env:")) | sub("^env:"; "")]')" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/miscellaneous.yml b/.github/workflows/miscellaneous.yml index 1af1e0df..b98aa091 100644 --- a/.github/workflows/miscellaneous.yml +++ b/.github/workflows/miscellaneous.yml @@ -12,7 +12,7 @@ permissions: jobs: platformio: - name: PlatformIO version extract + name: PlatformIO version runs-on: ubuntu-latest outputs: version: ${{ steps.print.outputs.version }} @@ -31,7 +31,7 @@ jobs: - name: Set up PlatformIO run: pip install -r .github/platformio/requirements.txt - - name: PlatformIO extract + - name: PlatformIO version id: print run: echo "version=$(pio --version | awk '{print $NF}')" >> "$GITHUB_OUTPUT" diff --git a/firmware/include/extensions/InfraredExtension.h b/firmware/include/extensions/InfraredExtension.h index 4254f136..e44244ef 100644 --- a/firmware/include/extensions/InfraredExtension.h +++ b/firmware/include/extensions/InfraredExtension.h @@ -135,7 +135,7 @@ class InfraredExtension : public ExtensionModule void begin() override; void handle() override; - bool getActive(); + bool getActive() const; void setActive(bool active); void parse(); diff --git a/firmware/include/extensions/MicrophoneExtension.h b/firmware/include/extensions/MicrophoneExtension.h index 5a63f5f5..dede478f 100644 --- a/firmware/include/extensions/MicrophoneExtension.h +++ b/firmware/include/extensions/MicrophoneExtension.h @@ -27,7 +27,7 @@ class MicrophoneExtension : public ExtensionModule void begin() override; void handle() override; - bool getActive() const; + [[nodiscard]] bool getActive() const; void setActive(bool active); void setThreshold(uint16_t _threshold); [[nodiscard]] bool isTriggered() const; diff --git a/firmware/include/extensions/PhotocellExtension.h b/firmware/include/extensions/PhotocellExtension.h index 7053dc03..e82a59ec 100644 --- a/firmware/include/extensions/PhotocellExtension.h +++ b/firmware/include/extensions/PhotocellExtension.h @@ -33,7 +33,7 @@ class PhotocellExtension : public ExtensionModule void begin() override; void handle() override; - bool getActive() const; + [[nodiscard]] bool getActive() const; void setActive(bool active); void onReceive(const JsonDocument &doc, const char *source) override; diff --git a/firmware/include/extensions/PlaylistExtension.h b/firmware/include/extensions/PlaylistExtension.h index bbd7058c..217a3c4b 100644 --- a/firmware/include/extensions/PlaylistExtension.h +++ b/firmware/include/extensions/PlaylistExtension.h @@ -13,14 +13,14 @@ class PlaylistExtension : public ExtensionModule struct Mode { - std::string mode; - uint16_t duration; + std::string mode = ""; + uint16_t duration = 60; }; void configure() override; void begin() override; void handle() override; - bool getActive() const; + [[nodiscard]] bool getActive() const; void setActive(bool active); void onReceive(const JsonDocument &doc, const char *source) override; diff --git a/firmware/include/handlers/BitmapHandler.h b/firmware/include/handlers/BitmapHandler.h index 42af1efc..e8ca5783 100644 --- a/firmware/include/handlers/BitmapHandler.h +++ b/firmware/include/handlers/BitmapHandler.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -19,6 +19,6 @@ class BitmapHandler void draw(uint8_t brightness = UINT8_MAX); void draw(uint8_t x, uint8_t y, uint8_t brightness = UINT8_MAX); - uint8_t getHeight() const; - uint8_t getWidth() const; + [[nodiscard]] uint8_t getHeight() const; + [[nodiscard]] uint8_t getWidth() const; }; diff --git a/firmware/include/handlers/TextHandler.h b/firmware/include/handlers/TextHandler.h index 600d14e7..af25bccd 100644 --- a/firmware/include/handlers/TextHandler.h +++ b/firmware/include/handlers/TextHandler.h @@ -19,7 +19,7 @@ class TextHandler uint8_t tracking = 1; uint8_t width = 0; - uint8_t calcMsbMax(const FontModule::Symbol &character) const; + [[nodiscard]] uint8_t calcMsbMax(const FontModule::Symbol &character) const; bool nextCodepoint(uint32_t &out); @@ -31,6 +31,6 @@ class TextHandler void draw(uint8_t brightness = UINT8_MAX); void draw(int16_t x, int8_t y, uint8_t brightness = UINT8_MAX); - uint8_t getHeight() const; - uint8_t getWidth() const; + [[nodiscard]] uint8_t getHeight() const; + [[nodiscard]] uint8_t getWidth() const; }; diff --git a/firmware/include/handlers/WeatherHandler.h b/firmware/include/handlers/WeatherHandler.h index e5c148fe..935a8925 100644 --- a/firmware/include/handlers/WeatherHandler.h +++ b/firmware/include/handlers/WeatherHandler.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -23,19 +23,19 @@ class WeatherHandler struct Codeset { const Conditions condition; - const std::vector codes; + const std::vector codes = {}; }; struct Codeset8 { const Conditions condition; - const std::vector codes; + const std::vector codes = {}; }; struct Codeset16 { const Conditions condition; - const std::vector codes; + const std::vector codes = {}; }; std::vector sign = {}; diff --git a/firmware/include/modes/BinaryEpochMode.h b/firmware/include/modes/BinaryEpochMode.h index f5d19b53..cd6fe516 100644 --- a/firmware/include/modes/BinaryEpochMode.h +++ b/firmware/include/modes/BinaryEpochMode.h @@ -7,7 +7,7 @@ class BinaryEpochMode : public ModeModule { private: - time_t epoch; + time_t epoch = 0; public: BinaryEpochMode() : ModeModule("Binary epoch") {}; diff --git a/firmware/include/modes/BreakoutClockMode.h b/firmware/include/modes/BreakoutClockMode.h index 404f74cc..0a541e28 100644 --- a/firmware/include/modes/BreakoutClockMode.h +++ b/firmware/include/modes/BreakoutClockMode.h @@ -15,7 +15,7 @@ class BreakoutClockMode : public ModeModule float xDec = GRID_COLUMNS / 2; float yDec = GRID_ROWS - 2; - std::deque paddle; + std::deque paddle = {}; tm local; diff --git a/firmware/include/modes/EqualizerMode.h b/firmware/include/modes/EqualizerMode.h index 9738b645..7fafec3e 100644 --- a/firmware/include/modes/EqualizerMode.h +++ b/firmware/include/modes/EqualizerMode.h @@ -16,7 +16,7 @@ class EqualizerMode : public ModeModule uint8_t target = GRID_ROWS - 1; }; - Bar bars[GRID_COLUMNS / (width + 1)]; + Bar bars[GRID_COLUMNS / (width + 1)] = {0}; unsigned long lastMillis = 0; diff --git a/firmware/include/modes/FliesMode.h b/firmware/include/modes/FliesMode.h index d032649c..058e7542 100644 --- a/firmware/include/modes/FliesMode.h +++ b/firmware/include/modes/FliesMode.h @@ -12,13 +12,13 @@ class FliesMode : public ModeModule private: struct Dot { - uint8_t x; - uint8_t y; + uint8_t x = 0; + uint8_t y = 0; }; bool pending = false; - std::unordered_map flies; + std::unordered_map flies = {}; uint8_t drawing[GRID_COLUMNS * GRID_ROWS] = {0}; diff --git a/firmware/include/modes/HomeThermometerMode.h b/firmware/include/modes/HomeThermometerMode.h index a8d8c1a2..528c1d27 100644 --- a/firmware/include/modes/HomeThermometerMode.h +++ b/firmware/include/modes/HomeThermometerMode.h @@ -10,7 +10,7 @@ class HomeThermometerMode : public ModeModule bool pending = false; void update(); - void setTemperature(const char *const where, const int16_t temperature); + void setTemperature(const char *where, const int16_t temperature); void transmit(); public: diff --git a/firmware/include/modes/LargeClockMode.h b/firmware/include/modes/LargeClockMode.h index 468c4d26..61b72904 100644 --- a/firmware/include/modes/LargeClockMode.h +++ b/firmware/include/modes/LargeClockMode.h @@ -23,7 +23,7 @@ class LargeClockMode : public ModeModule std::vector fonts = {}; - void setFont(const char * fontName); + void setFont(const char *fontName); void setTicking(bool _ticking); void transmit(); diff --git a/firmware/include/modes/LeafFallMode.h b/firmware/include/modes/LeafFallMode.h index a3e4d74f..1a9fa156 100644 --- a/firmware/include/modes/LeafFallMode.h +++ b/firmware/include/modes/LeafFallMode.h @@ -10,8 +10,8 @@ class LeafFallMode : public ModeModule private: struct Leaf { - uint8_t x; - uint8_t y; + uint8_t x = 0; + uint8_t y = 0; uint8_t brightness; uint16_t delay; unsigned long lastMillis = 0; diff --git a/firmware/include/modes/SnakeMode.h b/firmware/include/modes/SnakeMode.h index e85241f0..d275b021 100644 --- a/firmware/include/modes/SnakeMode.h +++ b/firmware/include/modes/SnakeMode.h @@ -12,12 +12,11 @@ class SnakeMode : public ModeModule private: struct Pixel { - uint8_t x; - uint8_t y; - + uint8_t x = 0; + uint8_t y = 0; bool operator==(const Pixel &pixel) const { return x == pixel.x && y == pixel.y; } bool operator!=(const Pixel &pixel) const { return x != pixel.x || y != pixel.y; } - bool operator<(const Pixel &pixel) const { return (y < pixel.y) || (y == pixel.y && x < pixel.x); } + bool operator<(const Pixel &pixel) const { return y < pixel.y || (y == pixel.y && x < pixel.x); } }; tm local; @@ -27,20 +26,20 @@ class SnakeMode : public ModeModule unsigned long lastMillis = 0; - uint8_t blink = 0; + uint8_t n = 0; uint8_t hour = 24; uint8_t minute = 60; uint8_t stage = 0; Pixel dot; - std::deque snake; + std::deque snake = {}; std::optional next(); void idle(); void move(); - void end(); + void blink(); void clean(); void setClock(bool _clock); diff --git a/firmware/include/modes/TickerMode.h b/firmware/include/modes/TickerMode.h index d321a011..57b94356 100644 --- a/firmware/include/modes/TickerMode.h +++ b/firmware/include/modes/TickerMode.h @@ -26,7 +26,7 @@ class TickerMode : public ModeModule std::string message = NAME; - std::unique_ptr text; + std::unique_ptr text = nullptr; void setFont(const char *fontName); void setMessage(std::string _message); diff --git a/firmware/include/modules/FontModule.h b/firmware/include/modules/FontModule.h index c4ff4849..270694f5 100644 --- a/firmware/include/modules/FontModule.h +++ b/firmware/include/modules/FontModule.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include class FontModule @@ -21,7 +21,7 @@ class FontModule struct SymbolExtended { - const wchar_t hex; + const wchar_t hex = 0; const Symbol symbol; }; diff --git a/firmware/include/services/ConnectivityService.h b/firmware/include/services/ConnectivityService.h index 32754937..310dffaa 100644 --- a/firmware/include/services/ConnectivityService.h +++ b/firmware/include/services/ConnectivityService.h @@ -25,7 +25,7 @@ class ConnectivityService : public ServiceModule void initStation(); void initHotspot(); - void connect(const char *const ssid, const char *const key); + void connect(const char *ssid, const char *key); void transmit(); static void onConnected(WiFiEvent_t event, WiFiEventInfo_t info); diff --git a/firmware/include/services/DisplayService.h b/firmware/include/services/DisplayService.h index 3bc43bf6..a7ee14a9 100644 --- a/firmware/include/services/DisplayService.h +++ b/firmware/include/services/DisplayService.h @@ -67,15 +67,15 @@ class DisplayService : public ServiceModule void handle(); - float getRatio() const; + [[nodiscard]] float getRatio() const; - Orientation getOrientation() const; + [[nodiscard]] Orientation getOrientation() const; void setOrientation(Orientation _orientation); - bool getPower() const; + [[nodiscard]] bool getPower() const; void setPower(bool power); - uint8_t getBrightness() const; + [[nodiscard]] uint8_t getBrightness() const; void setBrightness(uint8_t brightness); void getFrame(uint8_t frame[GRID_COLUMNS * GRID_ROWS]); @@ -84,7 +84,7 @@ class DisplayService : public ServiceModule void clearFrame(uint8_t brightness = 0); void invertFrame(); - uint8_t getPixel(uint8_t x, uint8_t y) const; + [[nodiscard]] uint8_t getPixel(uint8_t x, uint8_t y) const; void setPixel(uint8_t x, uint8_t y, uint8_t brightness = UINT8_MAX); void drawEllipse(float x, float y, float radius, float ratio = 1, bool fill = false, diff --git a/firmware/include/services/FontsService.h b/firmware/include/services/FontsService.h index dae5c9a3..18221648 100644 --- a/firmware/include/services/FontsService.h +++ b/firmware/include/services/FontsService.h @@ -30,7 +30,7 @@ class FontsService : public ServiceModule public: void begin(); - const std::vector &getAll() const; + [[nodiscard]] const std::vector &getAll() const; static FontsService &getInstance(); }; diff --git a/firmware/src/extensions/HeapExtension.cpp b/firmware/src/extensions/HeapExtension.cpp index ee59a5d4..c12a12e6 100644 --- a/firmware/src/extensions/HeapExtension.cpp +++ b/firmware/src/extensions/HeapExtension.cpp @@ -101,7 +101,7 @@ void HeapExtension::transmit() doc["extensions"] = Extensions.stackSize - uxTaskGetStackHighWaterMark(Extensions.taskHandle); doc["heap"] = ESP.getHeapSize() - ESP.getFreeHeap(); doc["main"] = CONFIG_ARDUINO_LOOP_STACK_SIZE - uxTaskGetStackHighWaterMark(Device.taskHandle); - if (Modes.taskHandle) + if (Modes.taskHandle != nullptr) { doc["modes"] = Modes.stackSize - uxTaskGetStackHighWaterMark(Modes.taskHandle); } diff --git a/firmware/src/extensions/InfraredExtension.cpp b/firmware/src/extensions/InfraredExtension.cpp index cbf8bf51..325c1400 100644 --- a/firmware/src/extensions/InfraredExtension.cpp +++ b/firmware/src/extensions/InfraredExtension.cpp @@ -161,7 +161,7 @@ void InfraredExtension::parse() } } -bool InfraredExtension::getActive() { return active; } +bool InfraredExtension::getActive() const { return active; } void InfraredExtension::setActive(bool active) { diff --git a/firmware/src/extensions/MessageExtension.cpp b/firmware/src/extensions/MessageExtension.cpp index 193bf634..705d385f 100644 --- a/firmware/src/extensions/MessageExtension.cpp +++ b/firmware/src/extensions/MessageExtension.cpp @@ -86,7 +86,7 @@ void MessageExtension::begin() { Storage.end(); } - if (!font) + if (font == nullptr) { font = FontSmall; } @@ -152,7 +152,7 @@ void MessageExtension::addMessage(std::string message) void MessageExtension::setFont(const char *fontName) { - if (!font || strcmp(fontName, font->name)) + if (font == nullptr || strcmp(fontName, font->name)) { for (FontModule *_font : Fonts.getAll()) { diff --git a/firmware/src/extensions/OtaExtension.cpp b/firmware/src/extensions/OtaExtension.cpp index d49e48de..a16e9e8d 100644 --- a/firmware/src/extensions/OtaExtension.cpp +++ b/firmware/src/extensions/OtaExtension.cpp @@ -61,7 +61,7 @@ void OtaExtension::onPost(AsyncWebServerRequest *request, const String &filename { onStart(); } - if ((!index && !Update.begin(UPDATE_SIZE_UNKNOWN, filename.indexOf("littlefs") >= 0 ? U_LITTLEFS : U_FLASH)) || + if ((index == 0 && !Update.begin(UPDATE_SIZE_UNKNOWN, filename.indexOf("littlefs") >= 0 ? U_LITTLEFS : U_FLASH)) || Update.write(data, len) != len || (final && !Update.end(true))) { ESP_LOGE(Ota->name, "%s", Update.errorString()); diff --git a/firmware/src/modes/AnimationMode.cpp b/firmware/src/modes/AnimationMode.cpp index 692debd9..c2909d20 100644 --- a/firmware/src/modes/AnimationMode.cpp +++ b/firmware/src/modes/AnimationMode.cpp @@ -102,7 +102,7 @@ void AnimationMode::onReceive(const JsonDocument &doc, const char *source) // Action: pull if (doc["action"].is() && !strcmp(doc["action"].as(), "pull")) { - lastMillis = millis() + GRID_COLUMNS * GRID_ROWS; + lastMillis = millis() + (GRID_COLUMNS * GRID_ROWS); index = 0; pending = true; } diff --git a/firmware/src/modes/BinaryEpochMode.cpp b/firmware/src/modes/BinaryEpochMode.cpp index 69a7fa60..fce635fb 100644 --- a/firmware/src/modes/BinaryEpochMode.cpp +++ b/firmware/src/modes/BinaryEpochMode.cpp @@ -13,8 +13,8 @@ void BinaryEpochMode::handle() epoch = _epoch; for (uint8_t i = 0; i < GRID_COLUMNS * GRID_ROWS / 8; ++i) { - const uint8_t x = GRID_COLUMNS - 2 - i % (GRID_COLUMNS / 2) * 2; - const uint8_t y = GRID_ROWS - 4 - i / (GRID_COLUMNS / 2) * 4; + const uint8_t x = GRID_COLUMNS - 2 - (i % (GRID_COLUMNS / 2) * 2); + const uint8_t y = GRID_ROWS - 4 - (i / (GRID_COLUMNS / 2) * 4); Display.drawRectangle(x, y, x + 1, y + 3, true, epoch & (1 << i) ? UINT8_MAX : 0); } } diff --git a/firmware/src/modes/CountdownMode.cpp b/firmware/src/modes/CountdownMode.cpp index 8005a86a..ab7e4526 100644 --- a/firmware/src/modes/CountdownMode.cpp +++ b/firmware/src/modes/CountdownMode.cpp @@ -72,18 +72,18 @@ void CountdownMode::handle() Display.clearFrame(); { TextHandler tl = TextHandler(std::to_string(upper / 10), FontMedium); - tl.draw(GRID_COLUMNS / 2 - 1 - (7 - tl.getWidth()) / 2 - tl.getWidth(), - GRID_ROWS / 2 - 1 - (7 - tl.getHeight()) / 2 - tl.getHeight()); + tl.draw((GRID_COLUMNS / 2) - 1 - ((7 - tl.getWidth()) / 2) - tl.getWidth(), + (GRID_ROWS / 2) - 1 - ((7 - tl.getHeight()) / 2) - tl.getHeight()); } { TextHandler tr = TextHandler(std::to_string(upper % 10), FontMedium); - tr.draw(GRID_COLUMNS / 2 + 1 + (7 - tr.getWidth()) / 2, - GRID_ROWS / 2 - 1 + (7 - tr.getHeight()) / 2 - tr.getHeight()); + tr.draw((GRID_COLUMNS / 2) + 1 + ((7 - tr.getWidth()) / 2), + (GRID_ROWS / 2) - 1 + ((7 - tr.getHeight()) / 2) - tr.getHeight()); } { TextHandler bl = TextHandler(std::to_string(lower / 10), FontMedium); - bl.draw(GRID_COLUMNS / 2 - 1 - (7 - bl.getWidth()) / 2 - bl.getWidth(), - GRID_ROWS / 2 + 1 - (7 - bl.getHeight()) / 2); + bl.draw((GRID_COLUMNS / 2) - 1 - ((7 - bl.getWidth()) / 2) - bl.getWidth(), + (GRID_ROWS / 2) + 1 - ((7 - bl.getHeight()) / 2)); } { TextHandler br = TextHandler(std::to_string(lower % 10), FontMedium); diff --git a/firmware/src/modes/HomeThermometerMode.cpp b/firmware/src/modes/HomeThermometerMode.cpp index 00da41b0..f1af798c 100644 --- a/firmware/src/modes/HomeThermometerMode.cpp +++ b/firmware/src/modes/HomeThermometerMode.cpp @@ -114,7 +114,7 @@ void HomeThermometerMode::transmit() doc["outdoor"] = Storage.getShort("outdoor"); } Storage.end(); - if (doc.size()) + if (doc.size() != 0) { Device.transmit(doc, name); } @@ -132,7 +132,7 @@ void HomeThermometerMode::onReceive(const JsonDocument &doc, const char *source) } } -void HomeThermometerMode::setTemperature(const char *const where, const int16_t temperature) +void HomeThermometerMode::setTemperature(const char *where, const int16_t temperature) { Preferences Storage; Storage.begin(std::string(name).substr(0, NVS_KEY_NAME_MAX_SIZE - 1).c_str()); diff --git a/firmware/src/modes/LargeClockMode.cpp b/firmware/src/modes/LargeClockMode.cpp index 819d63f0..7139a2f9 100644 --- a/firmware/src/modes/LargeClockMode.cpp +++ b/firmware/src/modes/LargeClockMode.cpp @@ -35,7 +35,7 @@ void LargeClockMode::configure() { Storage.end(); } - if (!font) + if (font == nullptr) { font = FontMediumBold; } @@ -97,18 +97,18 @@ void LargeClockMode::handle() Display.clearFrame(); { TextHandler h1 = TextHandler(std::to_string(hour / 10), font); - h1.draw(GRID_COLUMNS / 2 - 1 - (7 - h1.getWidth()) / 2 - h1.getWidth(), - GRID_ROWS / 2 - 1 - (7 - h1.getHeight()) / 2 - h1.getHeight()); + h1.draw((GRID_COLUMNS / 2) - 1 - ((7 - h1.getWidth()) / 2) - h1.getWidth(), + (GRID_ROWS / 2) - 1 - ((7 - h1.getHeight()) / 2) - h1.getHeight()); } { TextHandler h2 = TextHandler(std::to_string(hour % 10), font); - h2.draw(GRID_COLUMNS / 2 + 1 + (7 - h2.getWidth()) / 2, - GRID_ROWS / 2 - 1 + (7 - h2.getHeight()) / 2 - h2.getHeight()); + h2.draw((GRID_COLUMNS / 2) + 1 + ((7 - h2.getWidth()) / 2), + (GRID_ROWS / 2) - 1 + ((7 - h2.getHeight()) / 2) - h2.getHeight()); } { TextHandler m1 = TextHandler(std::to_string(minute / 10), font); - m1.draw(GRID_COLUMNS / 2 - 1 - (7 - m1.getWidth()) / 2 - m1.getWidth(), - GRID_ROWS / 2 + 1 - (7 - m1.getHeight()) / 2); + m1.draw((GRID_COLUMNS / 2) - 1 - ((7 - m1.getWidth()) / 2) - m1.getWidth(), + (GRID_ROWS / 2) + 1 - ((7 - m1.getHeight()) / 2)); } { TextHandler m2 = TextHandler(std::to_string(minute % 10), font); @@ -129,7 +129,7 @@ void LargeClockMode::handle() void LargeClockMode::setFont(const char *fontName) { - if (!font || strcmp(font->name, fontName)) + if (font == nullptr || strcmp(font->name, fontName)) { for (FontModule *_font : fonts) { diff --git a/firmware/src/modes/MetaballsMode.cpp b/firmware/src/modes/MetaballsMode.cpp index 1d2a0b9a..d6f50064 100644 --- a/firmware/src/modes/MetaballsMode.cpp +++ b/firmware/src/modes/MetaballsMode.cpp @@ -46,7 +46,7 @@ void MetaballsMode::handle() { const float xDistance = (ball.x - x) * xRatio; const float yDistance = (ball.y - y) * yRatio; - const float distanceSq = xDistance * xDistance + yDistance * yDistance; + const float distanceSq = (xDistance * xDistance) + (yDistance * yDistance); if (distanceSq < radiusSq) { brightness = min( diff --git a/firmware/src/modes/SnakeMode.cpp b/firmware/src/modes/SnakeMode.cpp index 7c85b671..10c8a4b9 100644 --- a/firmware/src/modes/SnakeMode.cpp +++ b/firmware/src/modes/SnakeMode.cpp @@ -73,7 +73,7 @@ void SnakeMode::handle() move(); break; case 2: - end(); + blink(); break; case 3: clean(); @@ -200,22 +200,22 @@ void SnakeMode::move() else { lastMillis = millis(); - blink = 0; + n = 0; stage = 2; } lastMillis = millis(); } } -void SnakeMode::end() +void SnakeMode::blink() { if (millis() - lastMillis > UINT8_MAX) { for (const Pixel &piece : snake) { - Display.setPixel(piece.x, piece.y, blink % 2 == 0 ? 0 : UINT8_MAX); + Display.setPixel(piece.x, piece.y, n % 2 == 0 ? 0 : UINT8_MAX); } - if (++blink >= 6) + if (++n >= 6) { stage = 3; } diff --git a/firmware/src/modes/StreamMode.cpp b/firmware/src/modes/StreamMode.cpp index 2513461e..1f548ad1 100644 --- a/firmware/src/modes/StreamMode.cpp +++ b/firmware/src/modes/StreamMode.cpp @@ -95,11 +95,11 @@ void StreamMode::onPacket(AsyncUDPPacket packet) { const uint16_t port = packet.localPort(); const size_t len = packet.length(); - if ((port == 4048 && (len == 10 + GRID_COLUMNS * GRID_ROWS || len == 14 + GRID_COLUMNS * GRID_ROWS)) || - (port == 6454 && len == 18 + GRID_COLUMNS * GRID_ROWS) || - (port == 5568 && len == 126 + GRID_COLUMNS * GRID_ROWS)) + if ((port == 4048 && (len == 10 + (GRID_COLUMNS * GRID_ROWS) || len == 14 + (GRID_COLUMNS * GRID_ROWS))) || + (port == 6454 && len == 18 + (GRID_COLUMNS * GRID_ROWS)) || + (port == 5568 && len == 126 + (GRID_COLUMNS * GRID_ROWS))) { - Display.setFrame(packet.data() + len - GRID_COLUMNS * GRID_ROWS); + Display.setFrame(packet.data() + len - (GRID_COLUMNS * GRID_ROWS)); } } diff --git a/firmware/src/modes/TickerMode.cpp b/firmware/src/modes/TickerMode.cpp index b6111009..c4d2a368 100644 --- a/firmware/src/modes/TickerMode.cpp +++ b/firmware/src/modes/TickerMode.cpp @@ -63,7 +63,7 @@ void TickerMode::configure() { Storage.end(); } - if (!font) + if (font == nullptr) { font = FontSmall; } @@ -98,7 +98,7 @@ void TickerMode::handle() void TickerMode::setFont(const char *fontName) { - if (!font || strcmp(font->name, fontName)) + if (font == nullptr || strcmp(font->name, fontName)) { for (FontModule *_font : Fonts.getAll()) { diff --git a/firmware/src/services/ConnectivityService.cpp b/firmware/src/services/ConnectivityService.cpp index 909535b7..87931061 100644 --- a/firmware/src/services/ConnectivityService.cpp +++ b/firmware/src/services/ConnectivityService.cpp @@ -167,7 +167,7 @@ void ConnectivityService::initHotspot() #endif // EXTENSION_WEBAPP } -void ConnectivityService::connect(const char *const ssid, const char *const key) +void ConnectivityService::connect(const char *ssid, const char *key) { if (WiFi.getMode() == wifi_mode_t::WIFI_MODE_AP) { diff --git a/firmware/src/services/DisplayService.cpp b/firmware/src/services/DisplayService.cpp index fc943c4d..8870f3cd 100644 --- a/firmware/src/services/DisplayService.cpp +++ b/firmware/src/services/DisplayService.cpp @@ -167,7 +167,8 @@ void DisplayService::setOrientation(Orientation orientation) memcpy(pixel, _pixel.data(), _pixel.size()); this->orientation = orientation; #if GRID_COLUMNS == GRID_ROWS - ratio = this->orientation % 2 ? PITCH_VERTICAL / (float)PITCH_HORIZONTAL : PITCH_HORIZONTAL / (float)PITCH_VERTICAL; + ratio = (this->orientation % 2) == 0 ? PITCH_HORIZONTAL / (float)PITCH_VERTICAL + : PITCH_VERTICAL / (float)PITCH_HORIZONTAL; #endif Preferences Storage; Storage.begin(name); @@ -319,7 +320,7 @@ void DisplayService::setPixel(uint8_t x, uint8_t y, uint8_t brightness) void DisplayService::drawEllipse(float x, float y, float radius, float ratio, bool fill, uint8_t brightness) { - const bool rotated = orientation % 2; + const bool rotated = (orientation % 2) != 0; const float xRatio = 2 * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); const float yRatio = @@ -334,7 +335,7 @@ void DisplayService::drawEllipse(float x, float y, float radius, float ratio, bo { const float xDistance = (_x - x) * xRatio; const float yDistance = (_y - y) * yRatio; - const float distance = sqrt(xDistance * xDistance + yDistance * yDistance); + const float distance = sqrt((xDistance * xDistance) + (yDistance * yDistance)); if (fill ? (distance <= radius) : (fabs(distance - radius) < .5f)) { setPixel(_x, _y, brightness); @@ -360,7 +361,7 @@ void DisplayService::drawRectangle(uint8_t minX, uint8_t minY, uint8_t maxX, uin void DisplayService::transmit() { - const bool rotated = orientation % 2; + const bool rotated = (orientation % 2) != 0; JsonDocument doc; doc["brightness"] = brightness; #if GRID_COLUMNS == GRID_ROWS diff --git a/firmware/src/services/ModesService.cpp b/firmware/src/services/ModesService.cpp index a5ba7f51..b6f92c0a 100644 --- a/firmware/src/services/ModesService.cpp +++ b/firmware/src/services/ModesService.cpp @@ -64,7 +64,7 @@ void ModesService::begin() Storage.end(); } } - if (!mode) + if (mode == nullptr) { setMode(modes[random(modes.size())]); } @@ -72,7 +72,7 @@ void ModesService::begin() void ModesService::handle() { - if (scheduled && millis() - lastMillis > (1 << 11)) + if (scheduled != nullptr && millis() - lastMillis > (1 << 11)) { mode = scheduled; scheduled = nullptr; @@ -99,15 +99,15 @@ void ModesService::onTask(void *parameter) void ModesService::setActive(bool active) { - if (taskHandle && active && eTaskGetState(taskHandle) == eTaskState::eSuspended) + if (taskHandle != nullptr && active && eTaskGetState(taskHandle) == eTaskState::eSuspended) { vTaskResume(taskHandle); } - else if (taskHandle && !active && eTaskGetState(taskHandle) != eTaskState::eSuspended) + else if (taskHandle != nullptr && !active && eTaskGetState(taskHandle) != eTaskState::eSuspended) { vTaskSuspend(taskHandle); } - else if (!taskHandle && active && mode) + else if (taskHandle == nullptr && active && mode != nullptr) { xTaskCreate(&onTask, name, stackSize, nullptr, 2, &taskHandle); } @@ -115,7 +115,7 @@ void ModesService::setActive(bool active) void ModesService::setMode(const char *name) { - if (!mode || strcmp(mode->name, name)) + if (mode == nullptr || strcmp(mode->name, name)) { for (ModeModule *_mode : modes) { @@ -130,7 +130,7 @@ void ModesService::setMode(const char *name) void ModesService::setMode(ModeModule *mode, bool power) { - if (taskHandle && this->mode) + if (taskHandle != nullptr && this->mode) { vTaskDelete(taskHandle); taskHandle = nullptr; @@ -183,7 +183,7 @@ const std::vector &ModesService::getAll() const { return modes; } void ModesService::setModeNext() { - const char *const _name = mode ? mode->name : scheduled->name; + const char *const _name = mode == nullptr ? scheduled->name : mode->name; std::vector::const_iterator _mode = std::find_if( modes.begin(), modes.end(), [_name](const ModeModule *_mode) { return !strcmp(_mode->name, _name); }); if (!Display.getPower()) @@ -203,7 +203,7 @@ void ModesService::setModeNext() void ModesService::setModePrevious() { - const char *const _name = mode ? mode->name : scheduled->name; + const char *const _name = mode == nullptr ? scheduled->name : mode->name; std::vector::const_iterator _mode = std::find_if( modes.begin(), modes.end(), [_name](const ModeModule *_mode) { return !strcmp(_mode->name, _name); }); if (!Display.getPower()) @@ -229,7 +229,7 @@ void ModesService::transmit() { list.add(_mode->name); } - if (mode) + if (mode != nullptr) { doc["mode"] = mode->name; } From 6454df6c37851f54f328d04bc746d1373f3d1a3b Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Mon, 2 Feb 2026 15:36:45 +0100 Subject: [PATCH 13/26] WIP --- .clang-tidy | 2 ++ extra/Python/FontGenerator.py | 5 +--- .../include/extensions/InfraredExtension.h | 20 ++++++------- firmware/include/handlers/BitmapHandler.h | 2 +- firmware/include/handlers/TextHandler.h | 2 +- firmware/include/handlers/WeatherHandler.h | 6 ++-- firmware/include/modes/AnimationMode.h | 2 +- firmware/include/modes/BreakoutClockMode.h | 4 +-- firmware/include/modes/CountdownMode.h | 2 +- firmware/include/modes/DrawMode.h | 4 +-- firmware/include/modes/HomeThermometerMode.h | 2 +- firmware/include/modes/LeafFallMode.h | 4 +-- firmware/include/modes/MetaballsMode.h | 6 ++-- firmware/include/modes/SnakeMode.h | 3 +- firmware/include/modes/StreamMode.h | 2 +- firmware/include/modes/YrMode.h | 4 +-- .../include/services/ConnectivityService.h | 2 +- firmware/include/services/DeviceService.h | 4 +-- firmware/include/services/DisplayService.h | 2 +- firmware/include/services/ExtensionsService.h | 2 +- firmware/src/handlers/WeatherHandler.cpp | 6 ++-- firmware/src/modes/AnimationMode.cpp | 4 +-- firmware/src/modes/BreakoutClockMode.cpp | 4 +-- firmware/src/modes/CountdownMode.cpp | 3 +- firmware/src/modes/DrawMode.cpp | 4 +-- firmware/src/modes/HomeThermometerMode.cpp | 2 +- firmware/src/modes/LargeClockMode.cpp | 10 ++++--- firmware/src/modes/MetaballsMode.cpp | 14 +++++----- firmware/src/modes/SmallClockMode.cpp | 28 +++++++++---------- firmware/src/modes/SnakeMode.cpp | 2 +- firmware/src/modes/StreamMode.cpp | 2 +- firmware/src/services/DeviceService.cpp | 4 +-- firmware/src/services/DisplayService.cpp | 10 +++---- firmware/src/services/ModesService.cpp | 2 +- 34 files changed, 88 insertions(+), 87 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 3ab6a5ca..eceee023 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -9,6 +9,8 @@ Checks: > -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-init-variables, -cppcoreguidelines-macro-to-enum, + -cppcoreguidelines-macro-usage, + -modernize-macro-to-enum, -modernize-use-auto, -modernize-use-trailing-return-type, -readability-convert-member-functions-to-static, diff --git a/extra/Python/FontGenerator.py b/extra/Python/FontGenerator.py index cbc060e4..33a5726f 100644 --- a/extra/Python/FontGenerator.py +++ b/extra/Python/FontGenerator.py @@ -228,10 +228,7 @@ def _source_cpp(self, unique: str, name: str) -> str: "", f"{unique}Font *Font{unique} = nullptr;", "", - f'{unique}Font::{unique}Font() : FontModule("{name}")', - "{", - f" Font{unique} = this;", - "}", + f'{unique}Font::{unique}Font() : FontModule("{name}") {{ Font{unique} = this; }}', "", f"FontModule::Symbol {unique}Font::getChar(uint32_t character) const", "{", diff --git a/firmware/include/extensions/InfraredExtension.h b/firmware/include/extensions/InfraredExtension.h index e44244ef..0f0ec55e 100644 --- a/firmware/include/extensions/InfraredExtension.h +++ b/firmware/include/extensions/InfraredExtension.h @@ -18,21 +18,21 @@ class InfraredExtension : public ExtensionModule struct Code { const decode_type_t protocol; - const std::vector displayBrightnessDecrease; - const std::vector displayBrightnessIncrease; - const std::vector displayPowerToggle; + const std::vector displayBrightnessDecrease = {}; + const std::vector displayBrightnessIncrease = {}; + const std::vector displayPowerToggle = {}; #if EXTENSION_MICROPHONE - const std::vector extensionMicrophoneToggle; + const std::vector extensionMicrophoneToggle = {}; #endif // EXTENSION_MICROPHONE #if EXTENSION_PHOTOCELL - const std::vector extensionPhotocellToggle; + const std::vector extensionPhotocellToggle = {}; #endif // EXTENSION_PHOTOCELL #if EXTENSION_PLAYLIST - const std::vector extensionPlaylistStart; - const std::vector extensionPlaylistStop; + const std::vector extensionPlaylistStart = {}; + const std::vector extensionPlaylistStop = {}; #endif // EXTENSION_PLAYLIST - const std::vector modeNext; - const std::vector modePrevious; + const std::vector modeNext = {}; + const std::vector modePrevious = {}; }; const std::vector codes = { @@ -135,7 +135,7 @@ class InfraredExtension : public ExtensionModule void begin() override; void handle() override; - bool getActive() const; + [[nodiscard]] bool getActive() const; void setActive(bool active); void parse(); diff --git a/firmware/include/handlers/BitmapHandler.h b/firmware/include/handlers/BitmapHandler.h index e8ca5783..b9e8cd69 100644 --- a/firmware/include/handlers/BitmapHandler.h +++ b/firmware/include/handlers/BitmapHandler.h @@ -9,7 +9,7 @@ class BitmapHandler private: static constexpr std::string_view _name = "BitmapHandler"; - const std::vector bitmap; + const std::vector bitmap = {}; uint8_t height = 0; uint8_t width = 0; diff --git a/firmware/include/handlers/TextHandler.h b/firmware/include/handlers/TextHandler.h index af25bccd..4afd4717 100644 --- a/firmware/include/handlers/TextHandler.h +++ b/firmware/include/handlers/TextHandler.h @@ -10,7 +10,7 @@ class TextHandler private: static constexpr std::string_view _name = "TextHandler"; - const std::string text; + const std::string text = ""; FontModule *font = nullptr; diff --git a/firmware/include/handlers/WeatherHandler.h b/firmware/include/handlers/WeatherHandler.h index 935a8925..2d867747 100644 --- a/firmware/include/handlers/WeatherHandler.h +++ b/firmware/include/handlers/WeatherHandler.h @@ -41,9 +41,9 @@ class WeatherHandler std::vector sign = {}; int16_t temperature; - void parse(const std::string code, const std::vector codesets); - void parse(const uint8_t code, const std::vector codesets); - void parse(const uint16_t code, const std::vector codesets); + void parse(std::string code, const std::vector codesets); + void parse(uint8_t code, const std::vector codesets); + void parse(uint16_t code, const std::vector codesets); void draw(); private: diff --git a/firmware/include/modes/AnimationMode.h b/firmware/include/modes/AnimationMode.h index e1231691..a82a503d 100644 --- a/firmware/include/modes/AnimationMode.h +++ b/firmware/include/modes/AnimationMode.h @@ -22,7 +22,7 @@ class AnimationMode : public ModeModule void setFrames(uint8_t count); void setInterval(uint16_t interval); - void transmit(const uint8_t index, const uint8_t frame[GRID_COLUMNS * GRID_ROWS]); + void transmit(uint8_t index, const uint8_t frame[GRID_COLUMNS * GRID_ROWS]); public: AnimationMode() : ModeModule("Animation") {}; diff --git a/firmware/include/modes/BreakoutClockMode.h b/firmware/include/modes/BreakoutClockMode.h index 0a541e28..e63b913f 100644 --- a/firmware/include/modes/BreakoutClockMode.h +++ b/firmware/include/modes/BreakoutClockMode.h @@ -12,8 +12,8 @@ class BreakoutClockMode : public ModeModule private: static constexpr float speed = 7e-4 * GRID_ROWS; - float xDec = GRID_COLUMNS / 2; - float yDec = GRID_ROWS - 2; + float xDec = GRID_COLUMNS / 2.0f; + float yDec = GRID_ROWS - 2.0f; std::deque paddle = {}; diff --git a/firmware/include/modes/CountdownMode.h b/firmware/include/modes/CountdownMode.h index 2210abe4..0fee1268 100644 --- a/firmware/include/modes/CountdownMode.h +++ b/firmware/include/modes/CountdownMode.h @@ -14,7 +14,7 @@ class CountdownMode : public ModeModule uint8_t lower = 0; uint8_t upper = 0; - std::chrono::time_point epoch; + std::chrono::time_point epoch = {}; void save(); void transmit(); diff --git a/firmware/include/modes/DrawMode.h b/firmware/include/modes/DrawMode.h index 56ee8acd..b9377d61 100644 --- a/firmware/include/modes/DrawMode.h +++ b/firmware/include/modes/DrawMode.h @@ -13,8 +13,8 @@ class DrawMode : public ModeModule uint8_t drawing[GRID_COLUMNS * GRID_ROWS] = {0}; - void load(const bool cache = false); - void save(const bool cache = false); + void load(bool cache = false); + void save(bool cache = false); void transmit(); public: diff --git a/firmware/include/modes/HomeThermometerMode.h b/firmware/include/modes/HomeThermometerMode.h index 528c1d27..c92e6edc 100644 --- a/firmware/include/modes/HomeThermometerMode.h +++ b/firmware/include/modes/HomeThermometerMode.h @@ -10,7 +10,7 @@ class HomeThermometerMode : public ModeModule bool pending = false; void update(); - void setTemperature(const char *where, const int16_t temperature); + void setTemperature(const char *where, int16_t temperature); void transmit(); public: diff --git a/firmware/include/modes/LeafFallMode.h b/firmware/include/modes/LeafFallMode.h index 1a9fa156..d86018f1 100644 --- a/firmware/include/modes/LeafFallMode.h +++ b/firmware/include/modes/LeafFallMode.h @@ -12,8 +12,8 @@ class LeafFallMode : public ModeModule { uint8_t x = 0; uint8_t y = 0; - uint8_t brightness; - uint16_t delay; + uint8_t brightness = INT8_MAX; + uint16_t delay = UINT8_MAX; unsigned long lastMillis = 0; }; diff --git a/firmware/include/modes/MetaballsMode.h b/firmware/include/modes/MetaballsMode.h index 996ca352..16d13950 100644 --- a/firmware/include/modes/MetaballsMode.h +++ b/firmware/include/modes/MetaballsMode.h @@ -10,7 +10,7 @@ class MetaballsMode : public ModeModule private: static constexpr float radius = min(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, GRID_ROWS *PITCH_VERTICAL / (float)PITCH_HORIZONTAL) / - PI; + std::numbers::pi; static constexpr float radiusSq = radius * radius; static constexpr float speed = 5e-6 * GRID_COLUMNS * GRID_ROWS; @@ -24,9 +24,9 @@ class MetaballsMode : public ModeModule float yVelocity; }; - uint8_t contributions[1 << 8]; + uint8_t contributions[1 << 8] = {0}; - Ball balls[GRID_COLUMNS * GRID_ROWS / (1 << 6)]; + Ball balls[GRID_COLUMNS * GRID_ROWS / (1 << 6)] = {}; public: MetaballsMode() : ModeModule("Metaballs") {}; diff --git a/firmware/include/modes/SnakeMode.h b/firmware/include/modes/SnakeMode.h index d275b021..b80633f2 100644 --- a/firmware/include/modes/SnakeMode.h +++ b/firmware/include/modes/SnakeMode.h @@ -35,9 +35,8 @@ class SnakeMode : public ModeModule std::deque snake = {}; - std::optional next(); - void idle(); + std::optional next() const; void move(); void blink(); void clean(); diff --git a/firmware/include/modes/StreamMode.h b/firmware/include/modes/StreamMode.h index 9df70fd4..9889e720 100644 --- a/firmware/include/modes/StreamMode.h +++ b/firmware/include/modes/StreamMode.h @@ -16,7 +16,7 @@ class StreamMode : public ModeModule std::unique_ptr udp; - void set(const uint16_t _port); + void set(uint16_t _port); void transmit(); static void onPacket(AsyncUDPPacket packet); diff --git a/firmware/include/modes/YrMode.h b/firmware/include/modes/YrMode.h index 5a4ca709..0a4930ca 100644 --- a/firmware/include/modes/YrMode.h +++ b/firmware/include/modes/YrMode.h @@ -155,8 +155,8 @@ class YrMode : public ModeModule public: YrMode() : ModeModule("Yr") {}; - void begin(); - void handle(); + void begin() override; + void handle() override; }; #endif // MODE_YR diff --git a/firmware/include/services/ConnectivityService.h b/firmware/include/services/ConnectivityService.h index 310dffaa..569f8e52 100644 --- a/firmware/include/services/ConnectivityService.h +++ b/firmware/include/services/ConnectivityService.h @@ -19,7 +19,7 @@ class ConnectivityService : public ServiceModule unsigned long lastMillis = 0; - std::unique_ptr dns; + std::unique_ptr dns = nullptr; WiFiMulti multi; diff --git a/firmware/include/services/DeviceService.h b/firmware/include/services/DeviceService.h index 50c576b9..aa0cae2a 100644 --- a/firmware/include/services/DeviceService.h +++ b/firmware/include/services/DeviceService.h @@ -29,8 +29,8 @@ class DeviceService : public ServiceModule void setPower(bool power); void restore(); - void transmit(JsonDocument doc, const char *source, bool retain = true); - void receive(const JsonDocument &doc, const char *source, const char *destination); + void transmit(const JsonDocument &doc, const char *source, bool retain = true) const; + void receive(const JsonDocument &doc, const char *source, const char *destination) const; [[nodiscard]] const JsonDocument getTransmits() const; diff --git a/firmware/include/services/DisplayService.h b/firmware/include/services/DisplayService.h index a7ee14a9..0687250d 100644 --- a/firmware/include/services/DisplayService.h +++ b/firmware/include/services/DisplayService.h @@ -60,7 +60,7 @@ class DisplayService : public ServiceModule static IRAM_ATTR void onTimer(); public: - hw_timer_t *timer; + hw_timer_t *timer = nullptr; void configure(); void begin(); diff --git a/firmware/include/services/ExtensionsService.h b/firmware/include/services/ExtensionsService.h index d8312991..ca07bbb0 100644 --- a/firmware/include/services/ExtensionsService.h +++ b/firmware/include/services/ExtensionsService.h @@ -95,7 +95,7 @@ class ExtensionsService : public ServiceModule void configure(); void begin(); - const std::vector &getAll() const; + [[nodiscard]] const std::vector &getAll() const; static ExtensionsService &getInstance(); }; diff --git a/firmware/src/handlers/WeatherHandler.cpp b/firmware/src/handlers/WeatherHandler.cpp index 12629da2..3cf40782 100644 --- a/firmware/src/handlers/WeatherHandler.cpp +++ b/firmware/src/handlers/WeatherHandler.cpp @@ -7,7 +7,7 @@ #include "services/DisplayService.h" #include "services/FontsService.h" -void WeatherHandler::parse(const std::string code, const std::vector codesets) +void WeatherHandler::parse(std::string code, const std::vector codesets) { for (const WeatherHandler::Codeset codeset : codesets) { @@ -20,7 +20,7 @@ void WeatherHandler::parse(const std::string code, const std::vector co ESP_LOGD(_name.data(), "unknown condition code %s", code.c_str()); } -void WeatherHandler::parse(const uint8_t code, const std::vector codesets) +void WeatherHandler::parse(uint8_t code, const std::vector codesets) { for (const WeatherHandler::Codeset8 codeset : codesets) { @@ -33,7 +33,7 @@ void WeatherHandler::parse(const uint8_t code, const std::vector codes ESP_LOGD(_name.data(), "unknown condition code %d", code); } -void WeatherHandler::parse(const uint16_t code, const std::vector codesets) +void WeatherHandler::parse(uint16_t code, const std::vector codesets) { for (const WeatherHandler::Codeset16 codeset : codesets) { diff --git a/firmware/src/modes/AnimationMode.cpp b/firmware/src/modes/AnimationMode.cpp index c2909d20..b19d628b 100644 --- a/firmware/src/modes/AnimationMode.cpp +++ b/firmware/src/modes/AnimationMode.cpp @@ -49,7 +49,7 @@ void AnimationMode::handle() void AnimationMode::setFrame(uint8_t index, uint8_t frame[GRID_COLUMNS * GRID_ROWS]) { - lastMillis = millis() + GRID_COLUMNS * GRID_ROWS * 2; + lastMillis = millis() + (GRID_COLUMNS * GRID_ROWS * 2); Preferences Storage; Storage.begin(name); Storage.putBytes(std::to_string(index).c_str(), frame, GRID_COLUMNS * GRID_ROWS); @@ -84,7 +84,7 @@ void AnimationMode::setInterval(uint16_t interval) } } -void AnimationMode::transmit(const uint8_t index, const uint8_t frame[GRID_COLUMNS * GRID_ROWS]) +void AnimationMode::transmit(uint8_t index, const uint8_t frame[GRID_COLUMNS * GRID_ROWS]) { JsonDocument doc; doc["interval"] = interval; diff --git a/firmware/src/modes/BreakoutClockMode.cpp b/firmware/src/modes/BreakoutClockMode.cpp index 895b690c..a5307822 100644 --- a/firmware/src/modes/BreakoutClockMode.cpp +++ b/firmware/src/modes/BreakoutClockMode.cpp @@ -25,8 +25,8 @@ void BreakoutClockMode::begin() void BreakoutClockMode::handle() { - const uint8_t nextX = xDec + cos(deg * DEG_TO_RAD) * speed + .5f; - const uint8_t nextY = yDec - sin(deg * DEG_TO_RAD) * speed + .5f; + const uint8_t nextX = xDec + (cos(deg * DEG_TO_RAD) * speed) + .5f; + const uint8_t nextY = yDec - (sin(deg * DEG_TO_RAD) * speed) + .5f; if (y <= 0 && deg < 180) { // Top diff --git a/firmware/src/modes/CountdownMode.cpp b/firmware/src/modes/CountdownMode.cpp index ab7e4526..d8ef315b 100644 --- a/firmware/src/modes/CountdownMode.cpp +++ b/firmware/src/modes/CountdownMode.cpp @@ -87,7 +87,8 @@ void CountdownMode::handle() } { TextHandler br = TextHandler(std::to_string(lower % 10), FontMedium); - br.draw(GRID_COLUMNS / 2 + 1 + (7 - br.getWidth()) / 2, GRID_ROWS / 2 + 1 + (7 - br.getHeight()) / 2); + br.draw((GRID_COLUMNS / 2) + 1 + ((7 - br.getWidth()) / 2), + (GRID_ROWS / 2) + 1 + ((7 - br.getHeight()) / 2)); } if (seconds == 0 && minutes == 0 && hours == 0) { diff --git a/firmware/src/modes/DrawMode.cpp b/firmware/src/modes/DrawMode.cpp index a3b59c02..efa70696 100644 --- a/firmware/src/modes/DrawMode.cpp +++ b/firmware/src/modes/DrawMode.cpp @@ -42,7 +42,7 @@ void DrawMode::handle() void DrawMode::end() { save(true); } -void DrawMode::load(const bool cache) +void DrawMode::load(bool cache) { Preferences Storage; Storage.begin(name, true); @@ -62,7 +62,7 @@ void DrawMode::load(const bool cache) Storage.end(); } -void DrawMode::save(const bool cache) +void DrawMode::save(bool cache) { for (const uint8_t pixel : drawing) { diff --git a/firmware/src/modes/HomeThermometerMode.cpp b/firmware/src/modes/HomeThermometerMode.cpp index f1af798c..0ce064b3 100644 --- a/firmware/src/modes/HomeThermometerMode.cpp +++ b/firmware/src/modes/HomeThermometerMode.cpp @@ -132,7 +132,7 @@ void HomeThermometerMode::onReceive(const JsonDocument &doc, const char *source) } } -void HomeThermometerMode::setTemperature(const char *where, const int16_t temperature) +void HomeThermometerMode::setTemperature(const char *where, int16_t temperature) { Preferences Storage; Storage.begin(std::string(name).substr(0, NVS_KEY_NAME_MAX_SIZE - 1).c_str()); diff --git a/firmware/src/modes/LargeClockMode.cpp b/firmware/src/modes/LargeClockMode.cpp index 7139a2f9..1bc7c6d6 100644 --- a/firmware/src/modes/LargeClockMode.cpp +++ b/firmware/src/modes/LargeClockMode.cpp @@ -112,17 +112,19 @@ void LargeClockMode::handle() } { TextHandler m2 = TextHandler(std::to_string(minute % 10), font); - m2.draw(GRID_COLUMNS / 2 + 1 + (7 - m2.getWidth()) / 2, GRID_ROWS / 2 + 1 + (7 - m2.getHeight()) / 2); + m2.draw(GRID_COLUMNS / 2 + 1 + (7 - m2.getWidth()) / 2, + (GRID_ROWS / 2) + 1 + ((7 - m2.getHeight()) / 2)); } pending = false; } if (ticking && second != local.tm_sec) { Display.setPixel( - GRID_COLUMNS / 2 - 8 + (second + 2) / 4, second % 2 ? GRID_ROWS / 2 : GRID_ROWS / 2 - 1, 0); + (GRID_COLUMNS / 2) - 8 + ((second + 2) / 4), second % 2 ? GRID_ROWS / 2 : (GRID_ROWS / 2) - 1, 0); second = local.tm_sec; - Display.setPixel( - GRID_COLUMNS / 2 - 8 + (second + 2) / 4, second % 2 ? GRID_ROWS / 2 : GRID_ROWS / 2 - 1, INT8_MAX); + Display.setPixel((GRID_COLUMNS / 2) - 8 + ((second + 2) / 4), + second % 2 ? GRID_ROWS / 2 : (GRID_ROWS / 2) - 1, + INT8_MAX); } } } diff --git a/firmware/src/modes/MetaballsMode.cpp b/firmware/src/modes/MetaballsMode.cpp index d6f50064..a7784cdf 100644 --- a/firmware/src/modes/MetaballsMode.cpp +++ b/firmware/src/modes/MetaballsMode.cpp @@ -13,8 +13,8 @@ void MetaballsMode::configure() } for (Ball &ball : balls) { - ball.x = random(GRID_COLUMNS); - ball.y = random(GRID_ROWS); + ball.x = static_cast(random(GRID_COLUMNS)); + ball.y = static_cast(random(GRID_ROWS)); ball.xVelocity = random(1, multiplier) * speed * (random(2) * 2 - 1); ball.yVelocity = random(1, multiplier) * speed * (random(2) * 2 - 1); } @@ -26,11 +26,11 @@ void MetaballsMode::handle() if (Microphone->isTriggered()) #endif // EXTENSION_MICROPHONE { - const bool rotated = Display.getOrientation() % 2; - const float xRatio = - 2 * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / (float)(PITCH_VERTICAL + PITCH_HORIZONTAL); - const float yRatio = - 2 * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / (float)(PITCH_VERTICAL + PITCH_HORIZONTAL); + const bool rotated = (Display.getOrientation() % 2) != 0; + const float xRatio = 2.0f * static_cast(rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / + static_cast(PITCH_VERTICAL + PITCH_HORIZONTAL); + const float yRatio = 2.0f * static_cast(rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / + static_cast(PITCH_VERTICAL + PITCH_HORIZONTAL); for (const Ball &ball : balls) { const uint8_t xMin = max(ball.x - radius - max(ball.xVelocity, 0), 0); diff --git a/firmware/src/modes/SmallClockMode.cpp b/firmware/src/modes/SmallClockMode.cpp index b4fa6cbd..fd8ae2ca 100644 --- a/firmware/src/modes/SmallClockMode.cpp +++ b/firmware/src/modes/SmallClockMode.cpp @@ -57,10 +57,10 @@ void SmallClockMode::handle() hour = local.tm_hour; minute = local.tm_min; Display.clearFrame(); - TextHandler(std::to_string(hour / 10), FontMini).draw(GRID_COLUMNS / 2 - 4, GRID_ROWS / 2 - 6); - TextHandler(std::to_string(hour % 10), FontMini).draw(GRID_COLUMNS / 2 + 1, GRID_ROWS / 2 - 6); - TextHandler(std::to_string(minute / 10), FontMini).draw(GRID_COLUMNS / 2 - 4, GRID_ROWS / 2); - TextHandler(std::to_string(minute % 10), FontMini).draw(GRID_COLUMNS / 2 + 1, GRID_ROWS / 2); + TextHandler(std::to_string(hour / 10), FontMini).draw((GRID_COLUMNS / 2) - 4, (GRID_ROWS / 2) - 6); + TextHandler(std::to_string(hour % 10), FontMini).draw((GRID_COLUMNS / 2) + 1, (GRID_ROWS / 2) - 6); + TextHandler(std::to_string(minute / 10), FontMini).draw((GRID_COLUMNS / 2) - 4, GRID_ROWS / 2); + TextHandler(std::to_string(minute % 10), FontMini).draw((GRID_COLUMNS / 2) + 1, GRID_ROWS / 2); pending = false; } if (second != local.tm_sec && ticking) @@ -68,28 +68,28 @@ void SmallClockMode::handle() second = local.tm_sec; if (second < 8) { - Display.setPixel(GRID_COLUMNS / 2 - 1 + second, GRID_ROWS / 2 - 8, 0); - Display.setPixel(GRID_COLUMNS / 2 + second, GRID_ROWS / 2 - 8, INT8_MAX); + Display.setPixel((GRID_COLUMNS / 2) - 1 + second, (GRID_ROWS / 2) - 8, 0); + Display.setPixel((GRID_COLUMNS / 2) + second, (GRID_ROWS / 2) - 8, INT8_MAX); } else if (second < 8 + 15) { - Display.setPixel(GRID_COLUMNS / 2 + 7, GRID_ROWS / 2 - 16 + second, 0); - Display.setPixel(GRID_COLUMNS / 2 + 7, GRID_ROWS / 2 - 15 + second, INT8_MAX); + Display.setPixel((GRID_COLUMNS / 2) + 7, (GRID_ROWS / 2) - 16 + second, 0); + Display.setPixel((GRID_COLUMNS / 2) + 7, (GRID_ROWS / 2) - 15 + second, INT8_MAX); } else if (second < 8 + 15 * 2) { - Display.setPixel(GRID_COLUMNS / 2 + 30 - second, GRID_ROWS / 2 + 7, 0); - Display.setPixel(GRID_COLUMNS / 2 + 29 - second, GRID_ROWS / 2 + 7, INT8_MAX); + Display.setPixel((GRID_COLUMNS / 2) + 30 - second, (GRID_ROWS / 2) + 7, 0); + Display.setPixel((GRID_COLUMNS / 2) + 29 - second, (GRID_ROWS / 2) + 7, INT8_MAX); } else if (second < 8 + 15 * 3) { - Display.setPixel(GRID_COLUMNS / 2 - 8, GRID_ROWS / 2 + 45 - second, 0); - Display.setPixel(GRID_COLUMNS / 2 - 8, GRID_ROWS / 2 + 44 - second, INT8_MAX); + Display.setPixel((GRID_COLUMNS / 2) - 8, (GRID_ROWS / 2) + 45 - second, 0); + Display.setPixel((GRID_COLUMNS / 2) - 8, (GRID_ROWS / 2) + 44 - second, INT8_MAX); } else { - Display.setPixel(GRID_COLUMNS / 2 - 61 + second, GRID_ROWS / 2 - 8, 0); - Display.setPixel(GRID_COLUMNS / 2 - 60 + second, GRID_ROWS / 2 - 8, INT8_MAX); + Display.setPixel((GRID_COLUMNS / 2) - 61 + second, (GRID_ROWS / 2) - 8, 0); + Display.setPixel((GRID_COLUMNS / 2) - 60 + second, (GRID_ROWS / 2) - 8, INT8_MAX); } } } diff --git a/firmware/src/modes/SnakeMode.cpp b/firmware/src/modes/SnakeMode.cpp index 10c8a4b9..c0e6f20b 100644 --- a/firmware/src/modes/SnakeMode.cpp +++ b/firmware/src/modes/SnakeMode.cpp @@ -93,7 +93,7 @@ void SnakeMode::idle() stage = 1; } -std::optional SnakeMode::next() +std::optional SnakeMode::next() const { Pixel start = snake.back(); std::map from; diff --git a/firmware/src/modes/StreamMode.cpp b/firmware/src/modes/StreamMode.cpp index 1f548ad1..28170f8e 100644 --- a/firmware/src/modes/StreamMode.cpp +++ b/firmware/src/modes/StreamMode.cpp @@ -57,7 +57,7 @@ void StreamMode::begin() } } -void StreamMode::set(const uint16_t _port) +void StreamMode::set(uint16_t _port) { if (_port != port && (_port == 4048 || _port == 5568 || _port == 6454)) { diff --git a/firmware/src/services/DeviceService.cpp b/firmware/src/services/DeviceService.cpp index fc16bb1e..00b61a01 100644 --- a/firmware/src/services/DeviceService.cpp +++ b/firmware/src/services/DeviceService.cpp @@ -244,7 +244,7 @@ void DeviceService::transmit() Device.transmit(doc, name); } -void DeviceService::transmit(JsonDocument doc, const char *const source, bool retain) +void DeviceService::transmit(const JsonDocument &doc, const char *const source, bool retain) const { if (retain) { @@ -260,7 +260,7 @@ void DeviceService::transmit(JsonDocument doc, const char *const source, bool re } } -void DeviceService::receive(const JsonDocument &doc, const char *source, const char *destination) +void DeviceService::receive(const JsonDocument &doc, const char *source, const char *destination) const { if (operational) { diff --git a/firmware/src/services/DisplayService.cpp b/firmware/src/services/DisplayService.cpp index 8870f3cd..5aa98c64 100644 --- a/firmware/src/services/DisplayService.cpp +++ b/firmware/src/services/DisplayService.cpp @@ -239,7 +239,7 @@ void DisplayService::setBrightness(uint8_t brightness) { return; } - else if (!brightness) + if (!brightness) { setPower(false); return; @@ -321,10 +321,10 @@ void DisplayService::setPixel(uint8_t x, uint8_t y, uint8_t brightness) void DisplayService::drawEllipse(float x, float y, float radius, float ratio, bool fill, uint8_t brightness) { const bool rotated = (orientation % 2) != 0; - const float xRatio = - 2 * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); - const float yRatio = - 2 * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); + const float xRatio = 2.0f * static_cast(rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / + (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); + const float yRatio = 2.0f * static_cast(rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / + (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); const uint8_t xMax = min(GRID_COLUMNS - 1, ceil(x + radius / xRatio)); const uint8_t xMin = max(0, floor(x - radius / xRatio)); const uint8_t yMax = min(GRID_COLUMNS - 1, ceil(y + radius / yRatio)); diff --git a/firmware/src/services/ModesService.cpp b/firmware/src/services/ModesService.cpp index b6f92c0a..7b810342 100644 --- a/firmware/src/services/ModesService.cpp +++ b/firmware/src/services/ModesService.cpp @@ -130,7 +130,7 @@ void ModesService::setMode(const char *name) void ModesService::setMode(ModeModule *mode, bool power) { - if (taskHandle != nullptr && this->mode) + if (taskHandle != nullptr && this->mode != nullptr) { vTaskDelete(taskHandle); taskHandle = nullptr; From 3ccc6321e0eb0f3203f0bbc00225e5a15e25ad5c Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Mon, 2 Feb 2026 18:15:20 +0100 Subject: [PATCH 14/26] WIP --- .clang-tidy | 1 + .../workflows/ikea-frekvens-led-spotlight.yml | 11 +-- .../include/extensions/RestfulExtension.h | 2 +- .../include/extensions/WebSocketExtension.h | 2 +- firmware/include/handlers/BitmapHandler.h | 1 - firmware/include/handlers/TextHandler.h | 2 +- firmware/include/handlers/WeatherHandler.h | 7 +- firmware/include/modes/AnimationMode.h | 2 +- firmware/include/modes/BinaryClockMode.h | 8 +-- firmware/include/modes/BreakoutClockMode.h | 7 +- firmware/include/modes/CircleMode.h | 2 +- firmware/include/modes/GameOfLifeMode.h | 6 +- firmware/include/modes/LargeClockMode.h | 8 +-- firmware/include/modes/PingPongMode.h | 7 +- firmware/include/modes/SmallClockMode.h | 8 +-- firmware/include/modes/SnakeMode.h | 9 +-- firmware/include/modes/StreamMode.h | 2 +- firmware/include/modules/FontModule.h | 2 +- firmware/include/services/DisplayService.h | 4 +- firmware/include/services/WebServerService.h | 4 +- firmware/src/extensions/AlexaExtension.cpp | 2 +- firmware/src/extensions/InfraredExtension.cpp | 2 +- firmware/src/extensions/MessageExtension.cpp | 2 +- .../src/extensions/PhotocellExtension.cpp | 4 +- firmware/src/extensions/RestfulExtension.cpp | 3 +- firmware/src/extensions/RtcExtension.cpp | 4 +- .../src/extensions/WebSocketExtension.cpp | 2 +- firmware/src/handlers/TextHandler.cpp | 4 +- firmware/src/handlers/WeatherHandler.cpp | 8 +-- firmware/src/modes/AnimationMode.cpp | 2 +- firmware/src/modes/BinaryClockMode.cpp | 8 +-- firmware/src/modes/BinaryEpochMode.cpp | 2 +- firmware/src/modes/BlinkMode.cpp | 2 +- firmware/src/modes/BreakoutClockMode.cpp | 14 ++-- firmware/src/modes/CountdownMode.cpp | 2 +- firmware/src/modes/DrawMode.cpp | 8 +-- firmware/src/modes/GameOfLifeMode.cpp | 4 +- firmware/src/modes/LargeClockMode.cpp | 11 +-- firmware/src/modes/LeafFallMode.cpp | 2 +- firmware/src/modes/MetaballsMode.cpp | 24 +++---- firmware/src/modes/PingPongMode.cpp | 8 +-- firmware/src/modes/SmallClockMode.cpp | 4 +- firmware/src/modes/SnakeMode.cpp | 2 +- firmware/src/modes/TickerMode.cpp | 2 +- firmware/src/services/ConnectivityService.cpp | 16 ++--- firmware/src/services/DeviceService.cpp | 6 +- firmware/src/services/DisplayService.cpp | 71 ++++++++++--------- firmware/src/services/ModesService.cpp | 2 +- firmware/src/services/WebServerService.cpp | 4 +- 49 files changed, 164 insertions(+), 156 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index eceee023..c86ee17b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -16,5 +16,6 @@ Checks: > -readability-convert-member-functions-to-static, -readability-identifier-length, -readability-magic-numbers, + -readability-misplaced-array-index, -readability-static-accessed-through-instance, -readability-uppercase-literal-suffix diff --git a/.github/workflows/ikea-frekvens-led-spotlight.yml b/.github/workflows/ikea-frekvens-led-spotlight.yml index c55770e1..888c222f 100644 --- a/.github/workflows/ikea-frekvens-led-spotlight.yml +++ b/.github/workflows/ikea-frekvens-led-spotlight.yml @@ -30,13 +30,16 @@ jobs: name: ESPHome build needs: esphome runs-on: ubuntu-latest - continue-on-error: true + continue-on-error: ${{ matrix.experimental }} strategy: matrix: - esphome-version: - - ${{ needs.esphome.outputs.min_version }} - - latest + experimental: [false] + include: + - esphome-version: ${{ needs.esphome.outputs.min_version }} + + - esphome-version: latest + experimental: true steps: - name: Checkout diff --git a/firmware/include/extensions/RestfulExtension.h b/firmware/include/extensions/RestfulExtension.h index 75b2ea16..a4255a30 100644 --- a/firmware/include/extensions/RestfulExtension.h +++ b/firmware/include/extensions/RestfulExtension.h @@ -12,7 +12,7 @@ class RestfulExtension : public ExtensionModule static constexpr size_t prefixLength = sizeof("/restful/") - 1; static void onGet(AsyncWebServerRequest *request); - static void onPatch(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total); + static void onPatch(AsyncWebServerRequest *request, const uint8_t *data, size_t len, size_t index, size_t total); public: RestfulExtension(); diff --git a/firmware/include/extensions/WebSocketExtension.h b/firmware/include/extensions/WebSocketExtension.h index 5fa3233b..e4f98bf6 100644 --- a/firmware/include/extensions/WebSocketExtension.h +++ b/firmware/include/extensions/WebSocketExtension.h @@ -10,7 +10,7 @@ class WebSocketExtension : public ExtensionModule { private: static void onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, - uint8_t *data, size_t len); + const uint8_t *data, size_t len); public: WebSocketExtension(); diff --git a/firmware/include/handlers/BitmapHandler.h b/firmware/include/handlers/BitmapHandler.h index b9e8cd69..0d0c1434 100644 --- a/firmware/include/handlers/BitmapHandler.h +++ b/firmware/include/handlers/BitmapHandler.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include diff --git a/firmware/include/handlers/TextHandler.h b/firmware/include/handlers/TextHandler.h index 4afd4717..7bec55a7 100644 --- a/firmware/include/handlers/TextHandler.h +++ b/firmware/include/handlers/TextHandler.h @@ -10,7 +10,7 @@ class TextHandler private: static constexpr std::string_view _name = "TextHandler"; - const std::string text = ""; + std::string text = ""; FontModule *font = nullptr; diff --git a/firmware/include/handlers/WeatherHandler.h b/firmware/include/handlers/WeatherHandler.h index 2d867747..092c8ae5 100644 --- a/firmware/include/handlers/WeatherHandler.h +++ b/firmware/include/handlers/WeatherHandler.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include @@ -41,9 +40,9 @@ class WeatherHandler std::vector sign = {}; int16_t temperature; - void parse(std::string code, const std::vector codesets); - void parse(uint8_t code, const std::vector codesets); - void parse(uint16_t code, const std::vector codesets); + void parse(std::string code, std::vector codesets); + void parse(uint8_t code, std::vector codesets); + void parse(uint16_t code, std::vector codesets); void draw(); private: diff --git a/firmware/include/modes/AnimationMode.h b/firmware/include/modes/AnimationMode.h index a82a503d..f9c9539b 100644 --- a/firmware/include/modes/AnimationMode.h +++ b/firmware/include/modes/AnimationMode.h @@ -18,7 +18,7 @@ class AnimationMode : public ModeModule unsigned long lastMillis = 0; - void setFrame(uint8_t index, uint8_t frame[GRID_COLUMNS * GRID_ROWS]); + void setFrame(uint8_t index, const uint8_t frame[GRID_COLUMNS * GRID_ROWS]); void setFrames(uint8_t count); void setInterval(uint16_t interval); diff --git a/firmware/include/modes/BinaryClockMode.h b/firmware/include/modes/BinaryClockMode.h index a47d3fdb..a3aa2441 100644 --- a/firmware/include/modes/BinaryClockMode.h +++ b/firmware/include/modes/BinaryClockMode.h @@ -7,13 +7,13 @@ class BinaryClockMode : public ModeModule { private: - tm local; + tm local = {}; bool pending = false; - uint8_t hour = 24; - uint8_t minute = 60; - uint8_t second = 60; + int hour = 24; + int minute = 60; + int second = 60; void draw(uint8_t col, uint8_t value); diff --git a/firmware/include/modes/BreakoutClockMode.h b/firmware/include/modes/BreakoutClockMode.h index e63b913f..1cb9ffe0 100644 --- a/firmware/include/modes/BreakoutClockMode.h +++ b/firmware/include/modes/BreakoutClockMode.h @@ -17,10 +17,11 @@ class BreakoutClockMode : public ModeModule std::deque paddle = {}; - tm local; + tm local = {}; + + int hour = 24; + int minute = 60; - uint8_t hour = 24; - uint8_t minute = 60; uint8_t x = GRID_COLUMNS / 2; uint8_t y = GRID_ROWS - 2; diff --git a/firmware/include/modes/CircleMode.h b/firmware/include/modes/CircleMode.h index 501dc2ee..fd5b054b 100644 --- a/firmware/include/modes/CircleMode.h +++ b/firmware/include/modes/CircleMode.h @@ -11,7 +11,7 @@ class CircleMode : public ModeModule static constexpr float x = (GRID_COLUMNS - 1) / 2.0f; static constexpr float y = (GRID_ROWS - 1) / 2.0f; - const uint8_t maxRadius = 3 + ceil((max(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, + const uint8_t maxRadius = 3 + ceilf((max(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, GRID_ROWS *PITCH_VERTICAL / (float)PITCH_HORIZONTAL) / M_SQRT2 + M_SQRT1_2) / diff --git a/firmware/include/modes/GameOfLifeMode.h b/firmware/include/modes/GameOfLifeMode.h index 04b5b376..1764b845 100644 --- a/firmware/include/modes/GameOfLifeMode.h +++ b/firmware/include/modes/GameOfLifeMode.h @@ -7,14 +7,14 @@ class GameOfLifeMode : public ModeModule { private: - tm local; + tm local = {}; bool clock = true; bool pending = false; uint8_t active = 0; - uint8_t hour = 24; - uint8_t minute = 60; + int hour = 24; + int minute = 60; unsigned long lastMillis = 0; diff --git a/firmware/include/modes/LargeClockMode.h b/firmware/include/modes/LargeClockMode.h index 61b72904..902be9f3 100644 --- a/firmware/include/modes/LargeClockMode.h +++ b/firmware/include/modes/LargeClockMode.h @@ -10,14 +10,14 @@ class LargeClockMode : public ModeModule { private: - tm local; + tm local = {}; bool pending = false; bool ticking = false; - uint8_t hour = 24; - uint8_t minute = 60; - uint8_t second = 0; + int hour = 24; + int minute = 60; + int second = 0; FontModule *font = nullptr; diff --git a/firmware/include/modes/PingPongMode.h b/firmware/include/modes/PingPongMode.h index eec89398..8305a62e 100644 --- a/firmware/include/modes/PingPongMode.h +++ b/firmware/include/modes/PingPongMode.h @@ -21,10 +21,11 @@ class PingPongMode : public ModeModule std::deque paddleA; std::deque paddleB; - tm local; + tm local = {}; + + int hour = 24; + int minute = 60; - uint8_t hour = 24; - uint8_t minute = 60; uint8_t x = GRID_COLUMNS - 2; uint8_t y = GRID_ROWS / 2; diff --git a/firmware/include/modes/SmallClockMode.h b/firmware/include/modes/SmallClockMode.h index da74d5cb..10f991ad 100644 --- a/firmware/include/modes/SmallClockMode.h +++ b/firmware/include/modes/SmallClockMode.h @@ -7,14 +7,14 @@ class SmallClockMode : public ModeModule { private: - tm local; + tm local = {}; bool pending = false; bool ticking = true; - uint8_t hour = 24; - uint8_t minute = 60; - uint8_t second = 60; + int hour = 24; + int minute = 60; + int second = 60; void setTicking(bool _ticking); void transmit(); diff --git a/firmware/include/modes/SnakeMode.h b/firmware/include/modes/SnakeMode.h index b80633f2..2f10cb1a 100644 --- a/firmware/include/modes/SnakeMode.h +++ b/firmware/include/modes/SnakeMode.h @@ -19,16 +19,17 @@ class SnakeMode : public ModeModule bool operator<(const Pixel &pixel) const { return y < pixel.y || (y == pixel.y && x < pixel.x); } }; - tm local; + tm local = {}; bool clock = true; bool pending = false; unsigned long lastMillis = 0; + int hour = 24; + int minute = 60; + uint8_t n = 0; - uint8_t hour = 24; - uint8_t minute = 60; uint8_t stage = 0; Pixel dot; @@ -36,7 +37,7 @@ class SnakeMode : public ModeModule std::deque snake = {}; void idle(); - std::optional next() const; + [[nodiscard]] std::optional next() const; void move(); void blink(); void clean(); diff --git a/firmware/include/modes/StreamMode.h b/firmware/include/modes/StreamMode.h index 9889e720..3e430539 100644 --- a/firmware/include/modes/StreamMode.h +++ b/firmware/include/modes/StreamMode.h @@ -14,7 +14,7 @@ class StreamMode : public ModeModule uint16_t port = 4048; - std::unique_ptr udp; + std::unique_ptr udp = nullptr; void set(uint16_t _port); void transmit(); diff --git a/firmware/include/modules/FontModule.h b/firmware/include/modules/FontModule.h index 270694f5..bee2fd6d 100644 --- a/firmware/include/modules/FontModule.h +++ b/firmware/include/modules/FontModule.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include class FontModule diff --git a/firmware/include/services/DisplayService.h b/firmware/include/services/DisplayService.h index 0687250d..23d56806 100644 --- a/firmware/include/services/DisplayService.h +++ b/firmware/include/services/DisplayService.h @@ -24,7 +24,7 @@ class DisplayService : public ServiceModule deg270, }; - const uint8_t depth = min(log2(1 / PWM_WIDTH / (float)(frameRate * 2)), SOC_LEDC_TIMER_BIT_WIDTH); + const uint8_t depth = min(log2f(1 / PWM_WIDTH / (float)(frameRate * 2)), SOC_LEDC_TIMER_BIT_WIDTH); const std::vector hi = { 0b1000001001, @@ -79,7 +79,7 @@ class DisplayService : public ServiceModule void setBrightness(uint8_t brightness); void getFrame(uint8_t frame[GRID_COLUMNS * GRID_ROWS]); - void setFrame(uint8_t frame[GRID_COLUMNS * GRID_ROWS]); + void setFrame(const uint8_t frame[GRID_COLUMNS * GRID_ROWS]); void clearFrame(uint8_t brightness = 0); void invertFrame(); diff --git a/firmware/include/services/WebServerService.h b/firmware/include/services/WebServerService.h index 0c48a00d..d6b7ac07 100644 --- a/firmware/include/services/WebServerService.h +++ b/firmware/include/services/WebServerService.h @@ -14,8 +14,8 @@ class WebServerService : public ServiceModule AsyncWebServer *http = new AsyncWebServer(80); - void configure(); - void begin(); + void configure() const; + void begin() const; static void onEmpty(AsyncWebServerRequest *request); diff --git a/firmware/src/extensions/AlexaExtension.cpp b/firmware/src/extensions/AlexaExtension.cpp index 1a4d631c..140e21df 100644 --- a/firmware/src/extensions/AlexaExtension.cpp +++ b/firmware/src/extensions/AlexaExtension.cpp @@ -42,7 +42,7 @@ void AlexaExtension::handle() { fauxmo.handle(); } void AlexaExtension::onSetState(unsigned char deviceId, const char *deviceName, bool state, unsigned char value) { - if (!strcmp(deviceName, NAME)) + if (strcmp(deviceName, NAME) == 0) { Display.setBrightness(static_cast(value)); Display.setPower(state); diff --git a/firmware/src/extensions/InfraredExtension.cpp b/firmware/src/extensions/InfraredExtension.cpp index 325c1400..a31895c7 100644 --- a/firmware/src/extensions/InfraredExtension.cpp +++ b/firmware/src/extensions/InfraredExtension.cpp @@ -155,7 +155,7 @@ void InfraredExtension::parse() break; } } - if (!IrReceiver.decodedIRData.flags) + if (IrReceiver.decodedIRData.flags == 0) { ESP_LOGV(name, "%s 0x%X", ProtocolNames[IrReceiver.decodedIRData.protocol], IrReceiver.decodedIRData.command); } diff --git a/firmware/src/extensions/MessageExtension.cpp b/firmware/src/extensions/MessageExtension.cpp index 705d385f..f1d56f34 100644 --- a/firmware/src/extensions/MessageExtension.cpp +++ b/firmware/src/extensions/MessageExtension.cpp @@ -152,7 +152,7 @@ void MessageExtension::addMessage(std::string message) void MessageExtension::setFont(const char *fontName) { - if (font == nullptr || strcmp(fontName, font->name)) + if (font == nullptr || strcmp(fontName, font->name) != 0) { for (FontModule *_font : Fonts.getAll()) { diff --git a/firmware/src/extensions/PhotocellExtension.cpp b/firmware/src/extensions/PhotocellExtension.cpp index fc1a98d2..e446976f 100644 --- a/firmware/src/extensions/PhotocellExtension.cpp +++ b/firmware/src/extensions/PhotocellExtension.cpp @@ -80,7 +80,7 @@ void PhotocellExtension::handle() { _lastMillis = millis(); raw = analogRead(PIN_LDR); - const uint8_t _brightness = pow((raw) / (float)((1 << 12) - 1), gamma) * UINT8_MAX; + const uint8_t _brightness = powf(raw / (float)((1 << 12) - 1), gamma) * UINT8_MAX; if ((direction && _brightness < brightness) || (!direction && _brightness > brightness)) { direction = !direction; @@ -162,7 +162,7 @@ void PhotocellExtension::onTransmit(const JsonDocument &doc, const char *const s const uint8_t _brightness = doc["brightness"].as(); if (_brightness != brightness) { - setGamma(log(_brightness / (float)(1 << 8)) / log((raw + 1) / (float)((1 << 12) + 1))); + setGamma(logf(_brightness / (float)(1 << 8)) / logf((raw + 1) / (float)((1 << 12) + 1))); } } } diff --git a/firmware/src/extensions/RestfulExtension.cpp b/firmware/src/extensions/RestfulExtension.cpp index 11cecae3..9998ee5c 100644 --- a/firmware/src/extensions/RestfulExtension.cpp +++ b/firmware/src/extensions/RestfulExtension.cpp @@ -43,7 +43,8 @@ void RestfulExtension::onGet(AsyncWebServerRequest *request) } } -void RestfulExtension::onPatch(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) +void RestfulExtension::onPatch(AsyncWebServerRequest *request, const uint8_t *data, size_t len, size_t index, + size_t total) { JsonDocument doc; if (request->contentType() == "application/json" && !deserializeJson(doc, data, len)) diff --git a/firmware/src/extensions/RtcExtension.cpp b/firmware/src/extensions/RtcExtension.cpp index 3a2b22e4..22b3a75d 100644 --- a/firmware/src/extensions/RtcExtension.cpp +++ b/firmware/src/extensions/RtcExtension.cpp @@ -22,10 +22,10 @@ void RtcExtension::configure() #endif if (rtc.IsDateTimeValid()) { - tm local; + tm local = {}; if (!getLocalTime(&local)) { - struct timeval tv; + struct timeval tv = {}; tv.tv_sec = rtc.GetDateTime().Unix64Time(); settimeofday(&tv, nullptr); ESP_LOGD(name, "sync"); diff --git a/firmware/src/extensions/WebSocketExtension.cpp b/firmware/src/extensions/WebSocketExtension.cpp index d81375af..caee2cc9 100644 --- a/firmware/src/extensions/WebSocketExtension.cpp +++ b/firmware/src/extensions/WebSocketExtension.cpp @@ -28,7 +28,7 @@ void WebSocketExtension::onTransmit(const JsonDocument &doc, const char *const s } void WebSocketExtension::onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, - uint8_t *data, size_t len) + const uint8_t *data, size_t len) { switch (type) { diff --git a/firmware/src/handlers/TextHandler.cpp b/firmware/src/handlers/TextHandler.cpp index 2d070878..7276e299 100644 --- a/firmware/src/handlers/TextHandler.cpp +++ b/firmware/src/handlers/TextHandler.cpp @@ -21,7 +21,7 @@ TextHandler::TextHandler(std::string text, FontModule *font) : text(text), font( } height = yMax - yMin; } - tracking = ceil(height / Display.getRatio() / 10.0f); + tracking = ceilf(height / Display.getRatio() / 10.0f); { i = 0; uint8_t _width = 0; @@ -62,7 +62,7 @@ void TextHandler::draw(int16_t x, int8_t y, uint8_t brightness) { FontModule::Symbol character = font->getChar(codepoint); const uint8_t _height = character.bitmap.size(); - if (_height) + if (_height != 0) { const uint8_t msbMax = calcMsbMax(character); for (uint8_t _x = 0; _x <= msbMax; ++_x) diff --git a/firmware/src/handlers/WeatherHandler.cpp b/firmware/src/handlers/WeatherHandler.cpp index 3cf40782..34088859 100644 --- a/firmware/src/handlers/WeatherHandler.cpp +++ b/firmware/src/handlers/WeatherHandler.cpp @@ -7,7 +7,7 @@ #include "services/DisplayService.h" #include "services/FontsService.h" -void WeatherHandler::parse(std::string code, const std::vector codesets) +void WeatherHandler::parse(std::string code, std::vector codesets) { for (const WeatherHandler::Codeset codeset : codesets) { @@ -20,7 +20,7 @@ void WeatherHandler::parse(std::string code, const std::vector codesets ESP_LOGD(_name.data(), "unknown condition code %s", code.c_str()); } -void WeatherHandler::parse(uint8_t code, const std::vector codesets) +void WeatherHandler::parse(uint8_t code, std::vector codesets) { for (const WeatherHandler::Codeset8 codeset : codesets) { @@ -33,7 +33,7 @@ void WeatherHandler::parse(uint8_t code, const std::vector codesets) ESP_LOGD(_name.data(), "unknown condition code %d", code); } -void WeatherHandler::parse(uint16_t code, const std::vector codesets) +void WeatherHandler::parse(uint16_t code, std::vector codesets) { for (const WeatherHandler::Codeset16 codeset : codesets) { @@ -54,7 +54,7 @@ void WeatherHandler::setSign(Conditions condition) #if PITCH_HORIZONTAL == PITCH_VERTICAL sign = conditionClear; #else - sign = Display.getRatio() > 1 ? conditionClearTall : conditionClearWide; + sign = Display.getRatio() > 1.0f ? conditionClearTall : conditionClearWide; #endif // PITCH_HORIZONTAL == PITCH_VERTICAL return; case Conditions::CLOUDY: diff --git a/firmware/src/modes/AnimationMode.cpp b/firmware/src/modes/AnimationMode.cpp index b19d628b..535268f1 100644 --- a/firmware/src/modes/AnimationMode.cpp +++ b/firmware/src/modes/AnimationMode.cpp @@ -47,7 +47,7 @@ void AnimationMode::handle() } } -void AnimationMode::setFrame(uint8_t index, uint8_t frame[GRID_COLUMNS * GRID_ROWS]) +void AnimationMode::setFrame(uint8_t index, const uint8_t frame[GRID_COLUMNS * GRID_ROWS]) { lastMillis = millis() + (GRID_COLUMNS * GRID_ROWS * 2); Preferences Storage; diff --git a/firmware/src/modes/BinaryClockMode.cpp b/firmware/src/modes/BinaryClockMode.cpp index bb64b9e1..7bd4423b 100644 --- a/firmware/src/modes/BinaryClockMode.cpp +++ b/firmware/src/modes/BinaryClockMode.cpp @@ -18,17 +18,17 @@ void BinaryClockMode::handle() if (second != local.tm_sec || pending) { second = local.tm_sec; - draw(GRID_ROWS / 2 + 3, second); + draw((GRID_ROWS / 2) + 3, second); } if (minute != local.tm_min || pending) { minute = local.tm_min; - draw(GRID_ROWS / 2 - 2, minute); + draw((GRID_ROWS / 2) - 2, minute); } if (hour != local.tm_hour || pending) { hour = local.tm_hour; - draw(GRID_ROWS / 2 - 7, hour); + draw((GRID_ROWS / 2) - 7, hour); pending = false; } } @@ -39,7 +39,7 @@ void BinaryClockMode::draw(uint8_t y, uint8_t value) for (uint8_t i = 0; i < 6; ++i) { const uint8_t x = (GRID_COLUMNS / 2) + 4 - (i * 2); - Display.drawRectangle(x, y, x + 1, y + 3, true, value & (1 << i) ? UINT8_MAX : 0); + Display.drawRectangle(x, y, x + 1, y + 3, true, (value & (1 << i)) != 0 ? UINT8_MAX : 0); } } diff --git a/firmware/src/modes/BinaryEpochMode.cpp b/firmware/src/modes/BinaryEpochMode.cpp index fce635fb..343b0e7f 100644 --- a/firmware/src/modes/BinaryEpochMode.cpp +++ b/firmware/src/modes/BinaryEpochMode.cpp @@ -15,7 +15,7 @@ void BinaryEpochMode::handle() { const uint8_t x = GRID_COLUMNS - 2 - (i % (GRID_COLUMNS / 2) * 2); const uint8_t y = GRID_ROWS - 4 - (i / (GRID_COLUMNS / 2) * 4); - Display.drawRectangle(x, y, x + 1, y + 3, true, epoch & (1 << i) ? UINT8_MAX : 0); + Display.drawRectangle(x, y, x + 1, y + 3, true, (epoch & (1 << i)) == 0 ? 0 : UINT8_MAX); } } } diff --git a/firmware/src/modes/BlinkMode.cpp b/firmware/src/modes/BlinkMode.cpp index 6513c1b7..cbb76e36 100644 --- a/firmware/src/modes/BlinkMode.cpp +++ b/firmware/src/modes/BlinkMode.cpp @@ -14,7 +14,7 @@ void BlinkMode::handle() #endif // EXTENSION_MICROPHONE { lastMillis = millis(); - Display.clearFrame(Display.getPixel(0, 0) ? 0 : UINT8_MAX); + Display.clearFrame(Display.getPixel(0, 0) == 0 ? UINT8_MAX : 0); } } diff --git a/firmware/src/modes/BreakoutClockMode.cpp b/firmware/src/modes/BreakoutClockMode.cpp index a5307822..49819faa 100644 --- a/firmware/src/modes/BreakoutClockMode.cpp +++ b/firmware/src/modes/BreakoutClockMode.cpp @@ -25,8 +25,8 @@ void BreakoutClockMode::begin() void BreakoutClockMode::handle() { - const uint8_t nextX = xDec + (cos(deg * DEG_TO_RAD) * speed) + .5f; - const uint8_t nextY = yDec - (sin(deg * DEG_TO_RAD) * speed) + .5f; + const uint8_t nextX = static_cast(lroundf(xDec + cosf(deg * DEG_TO_RAD) * speed)); + const uint8_t nextY = static_cast(std::lroundf(yDec - sinf(deg * DEG_TO_RAD) * speed)); if (y <= 0 && deg < 180) { // Top @@ -51,7 +51,7 @@ void BreakoutClockMode::handle() TextHandler(std::to_string(minute % 10), FontMini).draw(GRID_COLUMNS / 2 + 5, 0); } } - else if ((nextX != x || nextY != y) && Display.getPixel(nextX, nextY)) + else if ((nextX != x || nextY != y) && Display.getPixel(nextX, nextY) != 0) { // Brick Display.setPixel(nextX, nextY, 0); @@ -65,10 +65,10 @@ void BreakoutClockMode::handle() } } Display.setPixel(x, y, 0); - xDec += cos(deg * DEG_TO_RAD) * speed; - yDec -= sin(deg * DEG_TO_RAD) * speed; - x = xDec + .5f; - y = yDec + .5f; + xDec += cosf(deg * DEG_TO_RAD) * speed; + yDec -= sinf(deg * DEG_TO_RAD) * speed; + x = lroundf(xDec); + y = lroundf(yDec); Display.setPixel(x, y); const float rad = atanf((GRID_ROWS - 2 - yDec) / abs(paddle[1] - xDec)); if (xDec < paddle.front() && rad < 1 && paddle.front() > 0) diff --git a/firmware/src/modes/CountdownMode.cpp b/firmware/src/modes/CountdownMode.cpp index d8ef315b..9f130275 100644 --- a/firmware/src/modes/CountdownMode.cpp +++ b/firmware/src/modes/CountdownMode.cpp @@ -134,7 +134,7 @@ void CountdownMode::onReceive(const JsonDocument &doc, const char *source) } else if (doc["timestamp"].is()) { - tm local; + tm local = {}; strptime(doc["timestamp"].as(), "%FT%T", &local); local.tm_isdst = -1; epoch = std::chrono::system_clock::from_time_t(mktime(&local)); diff --git a/firmware/src/modes/DrawMode.cpp b/firmware/src/modes/DrawMode.cpp index efa70696..76cdbde9 100644 --- a/firmware/src/modes/DrawMode.cpp +++ b/firmware/src/modes/DrawMode.cpp @@ -99,23 +99,23 @@ void DrawMode::onReceive(const JsonDocument &doc, const char *source) { const char *const action = doc["action"].as(); // Clear - if (!strcmp(action, "clear")) + if (strcmp(action, "clear") == 0) { memset(drawing, 0, sizeof(drawing)); render = true; } // Load - else if (!strcmp(action, "load")) + else if (strcmp(action, "load") == 0) { load(); } // Pull - else if (!strcmp(action, "pull")) + else if (strcmp(action, "pull") == 0) { save(true); } // Save - else if (!strcmp(action, "save")) + else if (strcmp(action, "save") == 0) { save(); } diff --git a/firmware/src/modes/GameOfLifeMode.cpp b/firmware/src/modes/GameOfLifeMode.cpp index f6e618e3..459b8133 100644 --- a/firmware/src/modes/GameOfLifeMode.cpp +++ b/firmware/src/modes/GameOfLifeMode.cpp @@ -82,13 +82,13 @@ void GameOfLifeMode::handle() ++_y) { if ((_x != x || _y != y) && - (seeds[_x + _y * (GRID_COLUMNS - (clock ? 5 : 0))] || Display.getPixel(_x, _y))) + (seeds[_x + (_y * (GRID_COLUMNS - (clock ? 5 : 0)))] || Display.getPixel(_x, _y) != 0)) { ++n; } } } - const bool lit = seeds[x + y * (GRID_COLUMNS - (clock ? 5 : 0))] || Display.getPixel(x, y); + const bool lit = seeds[x + (y * (GRID_COLUMNS - (clock ? 5 : 0)))] || Display.getPixel(x, y) != 0; if (lit && (n < 2 || n > 3)) { Display.setPixel(x, y, 0); diff --git a/firmware/src/modes/LargeClockMode.cpp b/firmware/src/modes/LargeClockMode.cpp index 1bc7c6d6..6fd14c44 100644 --- a/firmware/src/modes/LargeClockMode.cpp +++ b/firmware/src/modes/LargeClockMode.cpp @@ -112,18 +112,19 @@ void LargeClockMode::handle() } { TextHandler m2 = TextHandler(std::to_string(minute % 10), font); - m2.draw(GRID_COLUMNS / 2 + 1 + (7 - m2.getWidth()) / 2, + m2.draw(GRID_COLUMNS / 2 + 1 + ((7 - m2.getWidth()) / 2), (GRID_ROWS / 2) + 1 + ((7 - m2.getHeight()) / 2)); } pending = false; } if (ticking && second != local.tm_sec) { - Display.setPixel( - (GRID_COLUMNS / 2) - 8 + ((second + 2) / 4), second % 2 ? GRID_ROWS / 2 : (GRID_ROWS / 2) - 1, 0); + Display.setPixel((GRID_COLUMNS / 2) - 8 + ((second + 2) / 4), + (second % 2) == 0 ? (GRID_ROWS / 2) - 1 : GRID_ROWS / 2, + 0); second = local.tm_sec; Display.setPixel((GRID_COLUMNS / 2) - 8 + ((second + 2) / 4), - second % 2 ? GRID_ROWS / 2 : (GRID_ROWS / 2) - 1, + (second % 2) == 0 ? (GRID_ROWS / 2) - 1 : GRID_ROWS / 2, INT8_MAX); } } @@ -131,7 +132,7 @@ void LargeClockMode::handle() void LargeClockMode::setFont(const char *fontName) { - if (font == nullptr || strcmp(font->name, fontName)) + if (font == nullptr || strcmp(font->name, fontName) != 0) { for (FontModule *_font : fonts) { diff --git a/firmware/src/modes/LeafFallMode.cpp b/firmware/src/modes/LeafFallMode.cpp index 39f8df43..f4172687 100644 --- a/firmware/src/modes/LeafFallMode.cpp +++ b/firmware/src/modes/LeafFallMode.cpp @@ -31,7 +31,7 @@ void LeafFallMode::handle() do { leaf.x = random(GRID_COLUMNS); - } while (Display.getPixel(leaf.x, leaf.y)); + } while (Display.getPixel(leaf.x, leaf.y) != 0); } else if (leaf.x > 0 && random(4) == 0) { diff --git a/firmware/src/modes/MetaballsMode.cpp b/firmware/src/modes/MetaballsMode.cpp index a7784cdf..aef1b721 100644 --- a/firmware/src/modes/MetaballsMode.cpp +++ b/firmware/src/modes/MetaballsMode.cpp @@ -15,8 +15,8 @@ void MetaballsMode::configure() { ball.x = static_cast(random(GRID_COLUMNS)); ball.y = static_cast(random(GRID_ROWS)); - ball.xVelocity = random(1, multiplier) * speed * (random(2) * 2 - 1); - ball.yVelocity = random(1, multiplier) * speed * (random(2) * 2 - 1); + ball.xVelocity = speed * random(1, multiplier) * ((random(2) * 2) - 1); + ball.yVelocity = speed * random(1, multiplier) * ((random(2) * 2) - 1); } } @@ -27,16 +27,16 @@ void MetaballsMode::handle() #endif // EXTENSION_MICROPHONE { const bool rotated = (Display.getOrientation() % 2) != 0; - const float xRatio = 2.0f * static_cast(rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / + const float xRatio = 2.0f * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / static_cast(PITCH_VERTICAL + PITCH_HORIZONTAL); - const float yRatio = 2.0f * static_cast(rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / + const float yRatio = 2.0f * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / static_cast(PITCH_VERTICAL + PITCH_HORIZONTAL); for (const Ball &ball : balls) { const uint8_t xMin = max(ball.x - radius - max(ball.xVelocity, 0), 0); const uint8_t yMin = max(ball.y - radius - max(ball.yVelocity, 0), 0); - const uint8_t xMax = min(ceil(ball.x + radius - min(ball.xVelocity, 0)), GRID_COLUMNS - 1); - const uint8_t yMax = min(ceil(ball.y + radius - min(ball.yVelocity, 0)), GRID_ROWS - 1); + const uint8_t xMax = min(ceilf(ball.x + radius - min(ball.xVelocity, 0)), GRID_COLUMNS - 1); + const uint8_t yMax = min(ceilf(ball.y + radius - min(ball.yVelocity, 0)), GRID_ROWS - 1); for (uint8_t x = xMin; x <= xMax; ++x) { for (uint8_t y = yMin; y <= yMax; ++y) @@ -44,8 +44,8 @@ void MetaballsMode::handle() uint8_t brightness = 0; for (const Ball &ball : balls) { - const float xDistance = (ball.x - x) * xRatio; - const float yDistance = (ball.y - y) * yRatio; + const float xDistance = (ball.x - static_cast(x)) * xRatio; + const float yDistance = (ball.y - static_cast(y)) * yRatio; const float distanceSq = (xDistance * xDistance) + (yDistance * yDistance); if (distanceSq < radiusSq) { @@ -68,22 +68,22 @@ void MetaballsMode::handle() if (ball.x < 0) { ball.x = 0; - ball.xVelocity = random(1, multiplier) * speed; + ball.xVelocity = speed * random(1, multiplier); } else if (ball.x > GRID_COLUMNS - 1) { ball.x = GRID_COLUMNS - 1; - ball.xVelocity = random(1, multiplier) * -speed; + ball.xVelocity = -speed * random(1, multiplier); } if (ball.y < 0) { ball.y = 0; - ball.yVelocity = random(1, multiplier) * speed; + ball.yVelocity = speed * random(1, multiplier); } else if (ball.y > GRID_ROWS - 1) { ball.y = GRID_ROWS - 1; - ball.yVelocity = random(1, multiplier) * -speed; + ball.yVelocity = -speed * random(1, multiplier); } } } diff --git a/firmware/src/modes/PingPongMode.cpp b/firmware/src/modes/PingPongMode.cpp index 490c920b..8774cf65 100644 --- a/firmware/src/modes/PingPongMode.cpp +++ b/firmware/src/modes/PingPongMode.cpp @@ -109,10 +109,10 @@ void PingPongMode::handle() deg = 360 - deg; // Invert Y } Display.setPixel(x, y, 0); - xDec += cos(deg * DEG_TO_RAD) * speed; - yDec -= sin(deg * DEG_TO_RAD) * speed; - x = xDec + .5f; - y = yDec + .5f; + xDec += cosf(deg * DEG_TO_RAD) * speed; + yDec -= sinf(deg * DEG_TO_RAD) * speed; + x = lroundf(xDec); + y = lroundf(yDec); Display.setPixel(x, y, clock ? INT8_MAX : UINT8_MAX); const float aRad = atanf(clock ? (xDec - 1) / abs(paddleA[1] - yDec) : (yDec - 1) / abs(paddleB[1] - xDec)); const float bRad = atanf(clock ? (GRID_COLUMNS - 2 - xDec) / abs(paddleB[1] - yDec) diff --git a/firmware/src/modes/SmallClockMode.cpp b/firmware/src/modes/SmallClockMode.cpp index fd8ae2ca..7c037d60 100644 --- a/firmware/src/modes/SmallClockMode.cpp +++ b/firmware/src/modes/SmallClockMode.cpp @@ -76,12 +76,12 @@ void SmallClockMode::handle() Display.setPixel((GRID_COLUMNS / 2) + 7, (GRID_ROWS / 2) - 16 + second, 0); Display.setPixel((GRID_COLUMNS / 2) + 7, (GRID_ROWS / 2) - 15 + second, INT8_MAX); } - else if (second < 8 + 15 * 2) + else if (second < 8 + 30) { Display.setPixel((GRID_COLUMNS / 2) + 30 - second, (GRID_ROWS / 2) + 7, 0); Display.setPixel((GRID_COLUMNS / 2) + 29 - second, (GRID_ROWS / 2) + 7, INT8_MAX); } - else if (second < 8 + 15 * 3) + else if (second < 8 + 45) { Display.setPixel((GRID_COLUMNS / 2) - 8, (GRID_ROWS / 2) + 45 - second, 0); Display.setPixel((GRID_COLUMNS / 2) - 8, (GRID_ROWS / 2) + 44 - second, INT8_MAX); diff --git a/firmware/src/modes/SnakeMode.cpp b/firmware/src/modes/SnakeMode.cpp index c0e6f20b..2fdffa02 100644 --- a/firmware/src/modes/SnakeMode.cpp +++ b/firmware/src/modes/SnakeMode.cpp @@ -244,7 +244,7 @@ void SnakeMode::setDot() { dot.x = random(GRID_COLUMNS); dot.y = random(clock ? 5 : 0, GRID_ROWS); - } while (Display.getPixel(dot.x, dot.y)); + } while (Display.getPixel(dot.x, dot.y) != 0); Display.setPixel(dot.x, dot.y, random(1, 1 << 8)); } diff --git a/firmware/src/modes/TickerMode.cpp b/firmware/src/modes/TickerMode.cpp index c4d2a368..e5e1cddf 100644 --- a/firmware/src/modes/TickerMode.cpp +++ b/firmware/src/modes/TickerMode.cpp @@ -98,7 +98,7 @@ void TickerMode::handle() void TickerMode::setFont(const char *fontName) { - if (font == nullptr || strcmp(font->name, fontName)) + if (font == nullptr || strcmp(font->name, fontName) != 0) { for (FontModule *_font : Fonts.getAll()) { diff --git a/firmware/src/services/ConnectivityService.cpp b/firmware/src/services/ConnectivityService.cpp index 87931061..78e0e5fc 100644 --- a/firmware/src/services/ConnectivityService.cpp +++ b/firmware/src/services/ConnectivityService.cpp @@ -125,12 +125,12 @@ void ConnectivityService::initStation() wifi_config_t config; if (esp_wifi_get_config(wifi_interface_t::WIFI_IF_STA, &config) == ESP_OK) { - const char *_ssid = reinterpret_cast(config.sta.ssid); - const std::string_view ssid(_ssid, strnlen(_ssid, sizeof(config.sta.ssid))); - if (ssid.length()) + const char *ssid_ptr = static_cast(static_cast(config.sta.ssid)); + const std::string_view ssid(ssid_ptr, strnlen(ssid_ptr, sizeof(config.sta.ssid))); + if (!ssid.empty()) { - const char *_key = reinterpret_cast(config.sta.password); - const std::string_view key(_key, strnlen(_key, sizeof(config.sta.password))); + const char *key_ptr = static_cast(static_cast(config.sta.password)); + const std::string_view key(key_ptr, strnlen(key_ptr, sizeof(config.sta.password))); doc[ssid] = key.length() ? key : nullptr; } } @@ -229,7 +229,7 @@ void ConnectivityService::onIPv4(WiFiEvent_t event, WiFiEventInfo_t info) void ConnectivityService::onIPv6(WiFiEvent_t event, WiFiEventInfo_t info) { const char *const ipv6 = WiFi.globalIPv6().toString().c_str(); - if (strcmp(ipv6, "")) + if (strcmp(ipv6, "") != 0) { ESP_LOGI(Connectivity.name, "IPv6 %s", ipv6); if (!Connectivity.routable) @@ -262,7 +262,7 @@ void ConnectivityService::onRoutable() MDNS.addService("ws", "tcp", 80); #endif // EXTENSION_WEBSOCKET } - timeval tv; + timeval tv = {}; sntp_sync_time(&tv); } @@ -273,7 +273,7 @@ void ConnectivityService::onScan(WiFiEvent_t event, WiFiEventInfo_t info) { JsonDocument doc; JsonArray scan = doc["scan"].to(); - for (uint8_t i = 0; i < n; ++i) + for (int16_t i = 0; i < n; ++i) { JsonObject _scan = scan.add(); _scan["encrypted"] = (bool)WiFi.encryptionType(i); diff --git a/firmware/src/services/DeviceService.cpp b/firmware/src/services/DeviceService.cpp index 00b61a01..a3e0877a 100644 --- a/firmware/src/services/DeviceService.cpp +++ b/firmware/src/services/DeviceService.cpp @@ -304,17 +304,17 @@ void DeviceService::onReceive(const JsonDocument &doc, const char *source) { const char *const action = doc["action"].as(); // Power off - if (!strcmp(action, "power")) + if (strcmp(action, "power") == 0) { setPower(false); } // Reboot - else if (!strcmp(action, "reboot")) + else if (strcmp(action, "reboot") == 0) { setPower(true); } // Restore - else if (!strcmp(action, "restore")) + else if (strcmp(action, "restore") == 0) { restore(); } diff --git a/firmware/src/services/DisplayService.cpp b/firmware/src/services/DisplayService.cpp index 5aa98c64..80d35471 100644 --- a/firmware/src/services/DisplayService.cpp +++ b/firmware/src/services/DisplayService.cpp @@ -30,7 +30,7 @@ void DisplayService::configure() timerAlarm(timer, 1'000'000 / (1 << 8) / frameRate, true, 0); timerStart(timer); - ledcAttach(PIN_OE, 1 / PWM_WIDTH / (float)(1 << depth), depth); + ledcAttach(PIN_OE, 1.0f / PWM_WIDTH / (float)(1 << depth), depth); ledcOutputInvert(PIN_OE, true); ledcWrite(PIN_OE, 0); #ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED @@ -104,7 +104,7 @@ IRAM_ATTR void DisplayService::onTimer() { outByte |= bitMask; } - if (!(bitMask >>= 1)) + if ((bitMask >>= 1) == 0) { *out++ = outByte; outByte = 0; @@ -122,7 +122,7 @@ IRAM_ATTR void DisplayService::onTimer() void DisplayService::flush() { - if (memcmp(frame, _frame, sizeof(_frame))) + if (memcmp(frame, _frame, sizeof(_frame)) != 0) { memcpy(frame, _frame, sizeof(_frame)); } @@ -191,13 +191,13 @@ void DisplayService::setPower(bool power) #ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED ledcFadeGamma(PIN_OE, 0, - max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), (1 << 5) * brightness); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGamma`. #else ledcFade(PIN_OE, 0, - max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), (1 << 5) * brightness); // -2 offset due to `ledcFade` stability issues. #endif // SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED this->power = true; @@ -209,16 +209,17 @@ void DisplayService::setPower(bool power) #ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED ledcFadeGammaWithInterrupt( PIN_OE, - max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), 0, (1 << 3) * brightness, &onPowerOff); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGammaWithInterrupt`. #else - ledcFadeWithInterrupt(PIN_OE, - max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), - 0, - (1 << 3) * brightness, - &onPowerOff); // -2 offset due to `ledcFade` stability issues. + ledcFadeWithInterrupt( + PIN_OE, + max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + 0, + (1 << 3) * brightness, + &onPowerOff); // -2 offset due to `ledcFade` stability issues. #endif // SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED } } @@ -239,7 +240,7 @@ void DisplayService::setBrightness(uint8_t brightness) { return; } - if (!brightness) + if (brightness == 0) { setPower(false); return; @@ -248,18 +249,18 @@ void DisplayService::setBrightness(uint8_t brightness) #ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED ledcFadeGamma( PIN_OE, - power ? max(this->brightness, pow(this->brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) + power ? max(this->brightness, powf(this->brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) : 0, - max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), (1 << 4) * abs(this->brightness - brightness)); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGamma`. #else - ledcFade(PIN_OE, - power - ? max(this->brightness, pow(this->brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) - : 0, - max(brightness, pow(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), - (1 << 4) * abs(this->brightness - brightness)); // -2 offset due to `ledcFade` stability issues. + ledcFade( + PIN_OE, + power ? max(this->brightness, powf(this->brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) + : 0, + max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + (1 << 4) * abs(this->brightness - brightness)); // -2 offset due to `ledcFade` stability issues. #endif // SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED if (!power) { @@ -282,7 +283,7 @@ void DisplayService::getFrame(uint8_t frame[GRID_COLUMNS * GRID_ROWS]) } } -void DisplayService::setFrame(uint8_t frame[GRID_COLUMNS * GRID_ROWS]) +void DisplayService::setFrame(const uint8_t frame[GRID_COLUMNS * GRID_ROWS]) { for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; ++i) { @@ -306,7 +307,7 @@ uint8_t DisplayService::getPixel(uint8_t x, uint8_t y) const { ESP_LOGV(name, "invalid pixel %d:%d", x, y); } - return frame[pixel[x + y * GRID_COLUMNS]]; + return frame[pixel[x + (y * GRID_COLUMNS)]]; } void DisplayService::setPixel(uint8_t x, uint8_t y, uint8_t brightness) @@ -315,28 +316,28 @@ void DisplayService::setPixel(uint8_t x, uint8_t y, uint8_t brightness) { ESP_LOGV(name, "invalid pixel %d:%d", x, y); } - _frame[pixel[x + y * GRID_COLUMNS]] = brightness; + _frame[pixel[x + (y * GRID_COLUMNS)]] = brightness; } void DisplayService::drawEllipse(float x, float y, float radius, float ratio, bool fill, uint8_t brightness) { const bool rotated = (orientation % 2) != 0; - const float xRatio = 2.0f * static_cast(rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / - (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); - const float yRatio = 2.0f * static_cast(rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / - (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); - const uint8_t xMax = min(GRID_COLUMNS - 1, ceil(x + radius / xRatio)); - const uint8_t xMin = max(0, floor(x - radius / xRatio)); - const uint8_t yMax = min(GRID_COLUMNS - 1, ceil(y + radius / yRatio)); - const uint8_t yMin = max(0, floor(y - radius / yRatio)); + const float xRatio = + 2.0f * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); + const float yRatio = + 2.0f * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); + const uint8_t xMax = min(GRID_COLUMNS - 1, ceilf(x + (radius / xRatio))); + const uint8_t xMin = max(0, floorf(x - (radius / xRatio))); + const uint8_t yMax = min(GRID_COLUMNS - 1, ceilf(y + (radius / yRatio))); + const uint8_t yMin = max(0, floorf(y - (radius / yRatio))); for (uint8_t _x = xMin; _x <= xMax; ++_x) { for (uint8_t _y = yMin; _y <= yMax; ++_y) { - const float xDistance = (_x - x) * xRatio; - const float yDistance = (_y - y) * yRatio; - const float distance = sqrt((xDistance * xDistance) + (yDistance * yDistance)); - if (fill ? (distance <= radius) : (fabs(distance - radius) < .5f)) + const float xDistance = xRatio * (_x - x); + const float yDistance = yRatio * (_y - y); + const float distance = sqrtf((xDistance * xDistance) + (yDistance * yDistance)); + if (fill ? (distance <= radius) : (fabsf(distance - radius) < .5f)) { setPixel(_x, _y, brightness); } diff --git a/firmware/src/services/ModesService.cpp b/firmware/src/services/ModesService.cpp index 7b810342..3c46134b 100644 --- a/firmware/src/services/ModesService.cpp +++ b/firmware/src/services/ModesService.cpp @@ -115,7 +115,7 @@ void ModesService::setActive(bool active) void ModesService::setMode(const char *name) { - if (mode == nullptr || strcmp(mode->name, name)) + if (mode == nullptr || strcmp(mode->name, name) != 0) { for (ModeModule *_mode : modes) { diff --git a/firmware/src/services/WebServerService.cpp b/firmware/src/services/WebServerService.cpp index 28c647d8..8d1c4aa8 100644 --- a/firmware/src/services/WebServerService.cpp +++ b/firmware/src/services/WebServerService.cpp @@ -6,9 +6,9 @@ #include #include -void WebServerService::configure() { http->begin(); } +void WebServerService::configure() const { http->begin(); } -void WebServerService::begin() { http->onNotFound(&onNotFound); } +void WebServerService::begin() const { http->onNotFound(&onNotFound); } void WebServerService::onNotFound(AsyncWebServerRequest *request) { From b4a032a2dd800cf91f8e959305de1d802222a839 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Mon, 2 Feb 2026 18:48:41 +0100 Subject: [PATCH 15/26] WIP --- .clang-tidy | 1 + .github/workflows/ikea-frekvens-led-spotlight.yml | 15 ++++++--------- firmware/include/extensions/InfraredExtension.h | 2 +- firmware/include/modes/CircleMode.h | 8 ++++---- firmware/include/modules/ExtensionModule.h | 1 + firmware/include/modules/FontModule.h | 1 + firmware/include/modules/ModeModule.h | 2 ++ firmware/include/modules/ServiceModule.h | 1 + firmware/src/modes/MetaballsMode.cpp | 12 ++++++------ 9 files changed, 23 insertions(+), 20 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index c86ee17b..43bef074 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,6 +7,7 @@ Checks: > readability-*, -bugprone-easily-swappable-parameters, -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-init-variables, -cppcoreguidelines-macro-to-enum, -cppcoreguidelines-macro-usage, diff --git a/.github/workflows/ikea-frekvens-led-spotlight.yml b/.github/workflows/ikea-frekvens-led-spotlight.yml index 888c222f..d0d81f08 100644 --- a/.github/workflows/ikea-frekvens-led-spotlight.yml +++ b/.github/workflows/ikea-frekvens-led-spotlight.yml @@ -12,7 +12,7 @@ permissions: jobs: esphome: - name: ESPHome minimum version extract + name: ESPHome minimum version runs-on: ubuntu-latest outputs: min_version: ${{ steps.print.outputs.min_version }} @@ -21,7 +21,7 @@ jobs: - name: Checkout uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 - - name: Extract ESPHome minimum version + - name: ESPHome minimum version id: print run: | echo "min_version=$(grep " min_version:" "extra/IKEA-Frekvens-LED-spotlight/esphome.yaml" | cut -d '"' -f 2)" >> "$GITHUB_OUTPUT" @@ -30,16 +30,13 @@ jobs: name: ESPHome build needs: esphome runs-on: ubuntu-latest - continue-on-error: ${{ matrix.experimental }} + continue-on-error: true strategy: matrix: - experimental: [false] - include: - - esphome-version: ${{ needs.esphome.outputs.min_version }} - - - esphome-version: latest - experimental: true + esphome-version: + - ${{ needs.esphome.outputs.min_version }} + - latest steps: - name: Checkout diff --git a/firmware/include/extensions/InfraredExtension.h b/firmware/include/extensions/InfraredExtension.h index 0f0ec55e..963e57e6 100644 --- a/firmware/include/extensions/InfraredExtension.h +++ b/firmware/include/extensions/InfraredExtension.h @@ -17,7 +17,7 @@ class InfraredExtension : public ExtensionModule private: struct Code { - const decode_type_t protocol; + const decode_type_t protocol = {}; const std::vector displayBrightnessDecrease = {}; const std::vector displayBrightnessIncrease = {}; const std::vector displayPowerToggle = {}; diff --git a/firmware/include/modes/CircleMode.h b/firmware/include/modes/CircleMode.h index fd5b054b..41cbca68 100644 --- a/firmware/include/modes/CircleMode.h +++ b/firmware/include/modes/CircleMode.h @@ -12,10 +12,10 @@ class CircleMode : public ModeModule static constexpr float y = (GRID_ROWS - 1) / 2.0f; const uint8_t maxRadius = 3 + ceilf((max(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, - GRID_ROWS *PITCH_VERTICAL / (float)PITCH_HORIZONTAL) / - M_SQRT2 + - M_SQRT1_2) / - 2.0f); + GRID_ROWS *PITCH_VERTICAL / (float)PITCH_HORIZONTAL) / + M_SQRT2 + + M_SQRT1_2) / + 2.0f); bool lit = true; diff --git a/firmware/include/modules/ExtensionModule.h b/firmware/include/modules/ExtensionModule.h index d5069c66..358a52a9 100644 --- a/firmware/include/modules/ExtensionModule.h +++ b/firmware/include/modules/ExtensionModule.h @@ -6,6 +6,7 @@ class ExtensionModule { protected: ExtensionModule(const char *const name) : name(name) {}; + ~ExtensionModule() = default; public: ExtensionModule(const ExtensionModule &) = delete; diff --git a/firmware/include/modules/FontModule.h b/firmware/include/modules/FontModule.h index bee2fd6d..8a33de5a 100644 --- a/firmware/include/modules/FontModule.h +++ b/firmware/include/modules/FontModule.h @@ -7,6 +7,7 @@ class FontModule { protected: FontModule(const char *const name) : name(name) {}; + ~FontModule() = default; public: FontModule(const FontModule &) = delete; diff --git a/firmware/include/modules/ModeModule.h b/firmware/include/modules/ModeModule.h index b341bd25..7ffcc272 100644 --- a/firmware/include/modules/ModeModule.h +++ b/firmware/include/modules/ModeModule.h @@ -8,6 +8,8 @@ class ModeModule ModeModule(const char *const name) : name(name) {}; public: + ~ModeModule() = default; + ModeModule(const ModeModule &) = delete; ModeModule &operator=(const ModeModule &) = delete; diff --git a/firmware/include/modules/ServiceModule.h b/firmware/include/modules/ServiceModule.h index 91b22e25..bcbc4470 100644 --- a/firmware/include/modules/ServiceModule.h +++ b/firmware/include/modules/ServiceModule.h @@ -6,6 +6,7 @@ class ServiceModule { protected: ServiceModule(const char *const name) : name(name) {}; + ~ServiceModule() = default; public: ServiceModule(const ServiceModule &) = delete; diff --git a/firmware/src/modes/MetaballsMode.cpp b/firmware/src/modes/MetaballsMode.cpp index aef1b721..b14a9ec5 100644 --- a/firmware/src/modes/MetaballsMode.cpp +++ b/firmware/src/modes/MetaballsMode.cpp @@ -15,8 +15,8 @@ void MetaballsMode::configure() { ball.x = static_cast(random(GRID_COLUMNS)); ball.y = static_cast(random(GRID_ROWS)); - ball.xVelocity = speed * random(1, multiplier) * ((random(2) * 2) - 1); - ball.yVelocity = speed * random(1, multiplier) * ((random(2) * 2) - 1); + ball.xVelocity = speed * static_cast(random(1, multiplier) * ((random(2) * 2) - 1)); + ball.yVelocity = speed * static_cast(random(1, multiplier) * ((random(2) * 2) - 1)); } } @@ -68,22 +68,22 @@ void MetaballsMode::handle() if (ball.x < 0) { ball.x = 0; - ball.xVelocity = speed * random(1, multiplier); + ball.xVelocity = speed * static_cast(random(1, multiplier)); } else if (ball.x > GRID_COLUMNS - 1) { ball.x = GRID_COLUMNS - 1; - ball.xVelocity = -speed * random(1, multiplier); + ball.xVelocity = -speed * static_cast(random(1, multiplier)); } if (ball.y < 0) { ball.y = 0; - ball.yVelocity = speed * random(1, multiplier); + ball.yVelocity = speed * static_cast(random(1, multiplier)); } else if (ball.y > GRID_ROWS - 1) { ball.y = GRID_ROWS - 1; - ball.yVelocity = -speed * random(1, multiplier); + ball.yVelocity = -speed * static_cast(random(1, multiplier)); } } } From 5bfc70080b23df8a1bfb54c15e9e9ae364a9936c Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Mon, 2 Feb 2026 19:54:25 +0100 Subject: [PATCH 16/26] WIP --- extra/Python/FontGenerator.py | 5 ++++- extra/Python/ModeGenerator.py | 10 ++++++++-- firmware/include/extensions/AlexaExtension.h | 5 ++++- firmware/include/extensions/ButtonExtension.h | 5 ++++- firmware/include/extensions/HeapExtension.h | 5 ++++- firmware/include/extensions/HomeAssistantExtension.h | 5 ++++- firmware/include/extensions/InfraredExtension.h | 5 ++++- firmware/include/extensions/MessageExtension.h | 5 ++++- firmware/include/extensions/MicrophoneExtension.h | 5 ++++- firmware/include/extensions/MqttExtension.h | 5 ++++- firmware/include/extensions/OtaExtension.h | 5 ++++- firmware/include/extensions/PhotocellExtension.h | 5 ++++- firmware/include/extensions/PlaylistExtension.h | 5 ++++- firmware/include/extensions/RestfulExtension.h | 5 ++++- firmware/include/extensions/RtcExtension.h | 5 ++++- .../include/extensions/ServerSentEventsExtension.h | 5 ++++- firmware/include/extensions/SignalExtension.h | 5 ++++- firmware/include/extensions/WebAppExtension.h | 5 ++++- firmware/include/extensions/WebSocketExtension.h | 5 ++++- firmware/include/fonts/BrailleFont.h | 5 ++++- firmware/include/fonts/LargeFont.h | 5 ++++- firmware/include/fonts/MediumBoldFont.h | 5 ++++- firmware/include/fonts/MediumFont.h | 5 ++++- firmware/include/fonts/MicroFont.h | 5 ++++- firmware/include/fonts/MiniFont.h | 5 ++++- firmware/include/fonts/SmallFont.h | 5 ++++- firmware/include/handlers/BitmapHandler.h | 1 + firmware/include/handlers/TextHandler.h | 1 + firmware/include/handlers/WeatherHandler.h | 3 +++ firmware/include/modes/AnimationMode.h | 5 ++++- firmware/include/modes/ArrowMode.h | 5 ++++- firmware/include/modes/BinaryClockMode.h | 5 ++++- firmware/include/modes/BinaryEpochMode.h | 5 ++++- firmware/include/modes/BlindsMode.h | 5 ++++- firmware/include/modes/BlinkMode.h | 5 ++++- firmware/include/modes/BreakoutClockMode.h | 5 ++++- firmware/include/modes/BrightMode.h | 5 ++++- firmware/include/modes/CircleMode.h | 5 ++++- firmware/include/modes/CountdownMode.h | 5 ++++- firmware/include/modes/DrawMode.h | 5 ++++- firmware/include/modes/EqualizerMode.h | 5 ++++- firmware/include/modes/FireworkMode.h | 5 ++++- firmware/include/modes/FliesMode.h | 5 ++++- firmware/include/modes/GameOfLifeMode.h | 5 ++++- firmware/include/modes/GlitterMode.h | 5 ++++- firmware/include/modes/GoogleWeatherMode.h | 5 ++++- firmware/include/modes/HomeAssistantWeatherMode.h | 5 ++++- firmware/include/modes/HomeThermometerMode.h | 5 ++++- firmware/include/modes/JaggedWaveformMode.h | 5 ++++- firmware/include/modes/LargeClockMode.h | 5 ++++- firmware/include/modes/LeafFallMode.h | 5 ++++- firmware/include/modes/LinesMode.h | 5 ++++- firmware/include/modes/MetaballsMode.h | 5 ++++- firmware/include/modes/NoiseMode.h | 5 ++++- firmware/include/modes/OpenMeteoMode.h | 5 ++++- firmware/include/modes/OpenWeatherMode.h | 5 ++++- firmware/include/modes/PingPongMode.h | 5 ++++- firmware/include/modes/PixelSequenceMode.h | 5 ++++- firmware/include/modes/RainMode.h | 5 ++++- firmware/include/modes/RingMode.h | 5 ++++- firmware/include/modes/ScanMode.h | 5 ++++- firmware/include/modes/SmallClockMode.h | 5 ++++- firmware/include/modes/SmoothWaveformMode.h | 5 ++++- firmware/include/modes/SnakeMode.h | 5 ++++- firmware/include/modes/StarsMode.h | 5 ++++- firmware/include/modes/StreamMode.h | 5 ++++- firmware/include/modes/TickerMode.h | 5 ++++- firmware/include/modes/WaveformMode.h | 5 ++++- firmware/include/modes/WorldWeatherOnlineMode.h | 5 ++++- firmware/include/modes/WttrInMode.h | 5 ++++- firmware/include/modes/YrMode.h | 5 ++++- firmware/include/modules/ModeModule.h | 3 +-- firmware/include/services/ConnectivityService.h | 5 ++++- firmware/include/services/DeviceService.h | 5 ++++- firmware/include/services/DisplayService.h | 5 ++++- firmware/include/services/ExtensionsService.h | 5 ++++- firmware/include/services/FontsService.h | 5 ++++- firmware/include/services/ModesService.h | 5 ++++- firmware/include/services/WebServerService.h | 5 ++++- 79 files changed, 310 insertions(+), 78 deletions(-) diff --git a/extra/Python/FontGenerator.py b/extra/Python/FontGenerator.py index 33a5726f..ef671d2c 100644 --- a/extra/Python/FontGenerator.py +++ b/extra/Python/FontGenerator.py @@ -113,7 +113,7 @@ def _source_h(self, unique: str) -> str: "// @warning Automatically generated file", "//", "", - f"class {unique}Font : public FontModule", + f"class {unique}Font final : public FontModule", "{", "private:", " const std::vector ascii = {", @@ -201,6 +201,9 @@ def _source_h(self, unique: str) -> str: with open(f"{unique}Font.h", "w", encoding="utf-8") as h: font.extend( [ + "", + "protected:", + f" ~{unique}Font() = default;", "", "public:", f" {unique}Font();", diff --git a/extra/Python/ModeGenerator.py b/extra/Python/ModeGenerator.py index d07b4743..57c616be 100644 --- a/extra/Python/ModeGenerator.py +++ b/extra/Python/ModeGenerator.py @@ -45,7 +45,7 @@ def _animation_h(self) -> str: "// @warning Automatically generated file", "//", "", - f"class {self.id}Mode : public ModeModule", + f"class {self.id}Mode final : public ModeModule", "{", "private:", " unsigned long lastMillis = 0;", @@ -65,6 +65,9 @@ def _animation_h(self) -> str: [ " };", "", + "protected:", + f" ~{self.id}Mode() = default;", + "", "public:", f' {self.id}Mode() : ModeModule("{self.name}") {{}};', "", @@ -125,7 +128,7 @@ def _drawing_h(self) -> str: "// @warning Automatically generated file", "//", "", - f"class {self.id}Mode : public ModeModule", + f"class {self.id}Mode final : public ModeModule", "{", "private:", " std::vector frame = {", @@ -144,6 +147,9 @@ def _drawing_h(self) -> str: [ " };", "", + "protected:", + f" ~{self.id}Mode() = default;", + "", "public:", f' {self.id}Mode() : ModeModule("{self.name}") {{}};', "", diff --git a/firmware/include/extensions/AlexaExtension.h b/firmware/include/extensions/AlexaExtension.h index 4f656c3e..48939680 100644 --- a/firmware/include/extensions/AlexaExtension.h +++ b/firmware/include/extensions/AlexaExtension.h @@ -7,7 +7,7 @@ #include #include -class AlexaExtension : public ExtensionModule +class AlexaExtension final : public ExtensionModule { private: fauxmoESP fauxmo = fauxmoESP(); @@ -16,6 +16,9 @@ class AlexaExtension : public ExtensionModule static void onSet(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total); static void onSetState(unsigned char deviceId, const char *deviceName, bool state, unsigned char value); +protected: + ~AlexaExtension() = default; + public: AlexaExtension(); diff --git a/firmware/include/extensions/ButtonExtension.h b/firmware/include/extensions/ButtonExtension.h index 35388ade..76722169 100644 --- a/firmware/include/extensions/ButtonExtension.h +++ b/firmware/include/extensions/ButtonExtension.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ExtensionModule.h" -class ButtonExtension : public ExtensionModule +class ButtonExtension final : public ExtensionModule { private: #ifdef PIN_SW1 @@ -36,6 +36,9 @@ class ButtonExtension : public ExtensionModule static void event(const char *key, const char *value); +protected: + ~ButtonExtension() = default; + public: ButtonExtension(); diff --git a/firmware/include/extensions/HeapExtension.h b/firmware/include/extensions/HeapExtension.h index 9256df99..f7f5b654 100644 --- a/firmware/include/extensions/HeapExtension.h +++ b/firmware/include/extensions/HeapExtension.h @@ -4,11 +4,14 @@ #include "modules/ExtensionModule.h" -class HeapExtension : public ExtensionModule +class HeapExtension final : public ExtensionModule { private: unsigned long lastMillis = 0; +protected: + ~HeapExtension() = default; + public: HeapExtension(); diff --git a/firmware/include/extensions/HomeAssistantExtension.h b/firmware/include/extensions/HomeAssistantExtension.h index a4d212c4..b08fa105 100644 --- a/firmware/include/extensions/HomeAssistantExtension.h +++ b/firmware/include/extensions/HomeAssistantExtension.h @@ -6,7 +6,7 @@ #include -class HomeAssistantExtension : public ExtensionModule +class HomeAssistantExtension final : public ExtensionModule { private: bool pending = false; @@ -18,6 +18,9 @@ class HomeAssistantExtension : public ExtensionModule void transmit(); +protected: + ~HomeAssistantExtension() = default; + public: HomeAssistantExtension(); diff --git a/firmware/include/extensions/InfraredExtension.h b/firmware/include/extensions/InfraredExtension.h index 963e57e6..68a576ac 100644 --- a/firmware/include/extensions/InfraredExtension.h +++ b/firmware/include/extensions/InfraredExtension.h @@ -12,7 +12,7 @@ #include -class InfraredExtension : public ExtensionModule +class InfraredExtension final : public ExtensionModule { private: struct Code @@ -128,6 +128,9 @@ class InfraredExtension : public ExtensionModule void transmit(); +protected: + ~InfraredExtension() = default; + public: InfraredExtension(); diff --git a/firmware/include/extensions/MessageExtension.h b/firmware/include/extensions/MessageExtension.h index 26433554..aedea144 100644 --- a/firmware/include/extensions/MessageExtension.h +++ b/firmware/include/extensions/MessageExtension.h @@ -9,7 +9,7 @@ #include -class MessageExtension : public ExtensionModule +class MessageExtension final : public ExtensionModule { private: bool active = false; @@ -38,6 +38,9 @@ class MessageExtension : public ExtensionModule void transmit(); +protected: + ~MessageExtension() = default; + public: MessageExtension(); diff --git a/firmware/include/extensions/MicrophoneExtension.h b/firmware/include/extensions/MicrophoneExtension.h index dede478f..33fb1538 100644 --- a/firmware/include/extensions/MicrophoneExtension.h +++ b/firmware/include/extensions/MicrophoneExtension.h @@ -4,7 +4,7 @@ #include "modules/ExtensionModule.h" -class MicrophoneExtension : public ExtensionModule +class MicrophoneExtension final : public ExtensionModule { private: bool active = false; @@ -20,6 +20,9 @@ class MicrophoneExtension : public ExtensionModule void transmit(); +protected: + ~MicrophoneExtension() = default; + public: MicrophoneExtension(); diff --git a/firmware/include/extensions/MqttExtension.h b/firmware/include/extensions/MqttExtension.h index 699c4829..b35bcbdf 100644 --- a/firmware/include/extensions/MqttExtension.h +++ b/firmware/include/extensions/MqttExtension.h @@ -6,7 +6,7 @@ #include -class MqttExtension : public ExtensionModule +class MqttExtension final : public ExtensionModule { private: unsigned long lastMillis = 0; @@ -21,6 +21,9 @@ class MqttExtension : public ExtensionModule static void onMessage(const espMqttClientTypes::MessageProperties &properties, const char *topic, const uint8_t *payload, size_t len, size_t index, size_t total); +protected: + ~MqttExtension() = default; + public: MqttExtension(); diff --git a/firmware/include/extensions/OtaExtension.h b/firmware/include/extensions/OtaExtension.h index 1b365284..bc7f5e0c 100644 --- a/firmware/include/extensions/OtaExtension.h +++ b/firmware/include/extensions/OtaExtension.h @@ -7,7 +7,7 @@ #include -class OtaExtension : public ExtensionModule +class OtaExtension final : public ExtensionModule { private: ArduinoOTAClass ArduinoOTA; @@ -20,6 +20,9 @@ class OtaExtension : public ExtensionModule bool final); #endif +protected: + ~OtaExtension() = default; + public: OtaExtension(); diff --git a/firmware/include/extensions/PhotocellExtension.h b/firmware/include/extensions/PhotocellExtension.h index e82a59ec..b5d03ebf 100644 --- a/firmware/include/extensions/PhotocellExtension.h +++ b/firmware/include/extensions/PhotocellExtension.h @@ -4,7 +4,7 @@ #include "modules/ExtensionModule.h" -class PhotocellExtension : public ExtensionModule +class PhotocellExtension final : public ExtensionModule { private: bool active = false; @@ -26,6 +26,9 @@ class PhotocellExtension : public ExtensionModule void transmit(); +protected: + ~PhotocellExtension() = default; + public: PhotocellExtension(); diff --git a/firmware/include/extensions/PlaylistExtension.h b/firmware/include/extensions/PlaylistExtension.h index 217a3c4b..c527f66c 100644 --- a/firmware/include/extensions/PlaylistExtension.h +++ b/firmware/include/extensions/PlaylistExtension.h @@ -6,7 +6,7 @@ #include -class PlaylistExtension : public ExtensionModule +class PlaylistExtension final : public ExtensionModule { public: PlaylistExtension(); @@ -26,6 +26,9 @@ class PlaylistExtension : public ExtensionModule void onReceive(const JsonDocument &doc, const char *source) override; void onTransmit(const JsonDocument &doc, const char *source) override; +protected: + ~PlaylistExtension() = default; + private: bool active = false; diff --git a/firmware/include/extensions/RestfulExtension.h b/firmware/include/extensions/RestfulExtension.h index a4255a30..4d1a74f1 100644 --- a/firmware/include/extensions/RestfulExtension.h +++ b/firmware/include/extensions/RestfulExtension.h @@ -6,7 +6,7 @@ #include -class RestfulExtension : public ExtensionModule +class RestfulExtension final : public ExtensionModule { private: static constexpr size_t prefixLength = sizeof("/restful/") - 1; @@ -14,6 +14,9 @@ class RestfulExtension : public ExtensionModule static void onGet(AsyncWebServerRequest *request); static void onPatch(AsyncWebServerRequest *request, const uint8_t *data, size_t len, size_t index, size_t total); +protected: + ~RestfulExtension() = default; + public: RestfulExtension(); diff --git a/firmware/include/extensions/RtcExtension.h b/firmware/include/extensions/RtcExtension.h index 65f5db5d..2867c19e 100644 --- a/firmware/include/extensions/RtcExtension.h +++ b/firmware/include/extensions/RtcExtension.h @@ -11,7 +11,7 @@ #include #include -class RtcExtension : public ExtensionModule +class RtcExtension final : public ExtensionModule { private: #ifdef PIN_INT @@ -32,6 +32,9 @@ class RtcExtension : public ExtensionModule static void onInterrupt(); #endif +protected: + ~RtcExtension() = default; + public: RtcExtension(); diff --git a/firmware/include/extensions/ServerSentEventsExtension.h b/firmware/include/extensions/ServerSentEventsExtension.h index c3dad821..ccbfd1af 100644 --- a/firmware/include/extensions/ServerSentEventsExtension.h +++ b/firmware/include/extensions/ServerSentEventsExtension.h @@ -6,8 +6,11 @@ #include -class ServerSentEventsExtension : public ExtensionModule +class ServerSentEventsExtension final : public ExtensionModule { +protected: + ~ServerSentEventsExtension() = default; + public: ServerSentEventsExtension(); diff --git a/firmware/include/extensions/SignalExtension.h b/firmware/include/extensions/SignalExtension.h index 20e5cfa9..96b065c4 100644 --- a/firmware/include/extensions/SignalExtension.h +++ b/firmware/include/extensions/SignalExtension.h @@ -6,7 +6,7 @@ #include "handlers/BitmapHandler.h" #include "modules/ExtensionModule.h" -class SignalExtension : public ExtensionModule +class SignalExtension final : public ExtensionModule { private: bool active = false; @@ -21,6 +21,9 @@ class SignalExtension : public ExtensionModule void setDuration(uint8_t seconds); void transmit(); +protected: + ~SignalExtension() = default; + public: SignalExtension(); diff --git a/firmware/include/extensions/WebAppExtension.h b/firmware/include/extensions/WebAppExtension.h index 50f7df94..598bab67 100644 --- a/firmware/include/extensions/WebAppExtension.h +++ b/firmware/include/extensions/WebAppExtension.h @@ -5,11 +5,14 @@ #include "modules/ExtensionModule.h" #include "services/WebServerService.h" -class WebAppExtension : public ExtensionModule +class WebAppExtension final : public ExtensionModule { private: static void onHeadRoot(AsyncWebServerRequest *request); +protected: + ~WebAppExtension() = default; + public: WebAppExtension(); diff --git a/firmware/include/extensions/WebSocketExtension.h b/firmware/include/extensions/WebSocketExtension.h index e4f98bf6..20d86207 100644 --- a/firmware/include/extensions/WebSocketExtension.h +++ b/firmware/include/extensions/WebSocketExtension.h @@ -6,12 +6,15 @@ #include -class WebSocketExtension : public ExtensionModule +class WebSocketExtension final : public ExtensionModule { private: static void onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, const uint8_t *data, size_t len); +protected: + ~WebSocketExtension() = default; + public: WebSocketExtension(); diff --git a/firmware/include/fonts/BrailleFont.h b/firmware/include/fonts/BrailleFont.h index afdd5e50..5fb7fd4b 100644 --- a/firmware/include/fonts/BrailleFont.h +++ b/firmware/include/fonts/BrailleFont.h @@ -4,7 +4,7 @@ #include "modules/FontModule.h" -class BrailleFont : public FontModule +class BrailleFont final : public FontModule { private: const std::vector ascii = { @@ -341,6 +341,9 @@ class BrailleFont : public FontModule }, }; +protected: + ~BrailleFont() = default; + public: BrailleFont(); diff --git a/firmware/include/fonts/LargeFont.h b/firmware/include/fonts/LargeFont.h index a5f3f188..50fe30f5 100644 --- a/firmware/include/fonts/LargeFont.h +++ b/firmware/include/fonts/LargeFont.h @@ -2,7 +2,7 @@ #include "modules/FontModule.h" -class LargeFont : public FontModule +class LargeFont final : public FontModule { private: const std::vector ascii = { @@ -143,6 +143,9 @@ class LargeFont : public FontModule }, }; +protected: + ~LargeFont() = default; + public: LargeFont(); diff --git a/firmware/include/fonts/MediumBoldFont.h b/firmware/include/fonts/MediumBoldFont.h index b67bb576..4bfa5bae 100644 --- a/firmware/include/fonts/MediumBoldFont.h +++ b/firmware/include/fonts/MediumBoldFont.h @@ -2,7 +2,7 @@ #include "modules/FontModule.h" -class MediumBoldFont : public FontModule +class MediumBoldFont final : public FontModule { private: const std::vector ascii = { @@ -260,6 +260,9 @@ class MediumBoldFont : public FontModule }, }; +protected: + ~MediumBoldFont() = default; + public: MediumBoldFont(); diff --git a/firmware/include/fonts/MediumFont.h b/firmware/include/fonts/MediumFont.h index f052f314..f1fd337f 100644 --- a/firmware/include/fonts/MediumFont.h +++ b/firmware/include/fonts/MediumFont.h @@ -2,7 +2,7 @@ #include "modules/FontModule.h" -class MediumFont : public FontModule +class MediumFont final : public FontModule { private: const std::vector ascii = { @@ -260,6 +260,9 @@ class MediumFont : public FontModule }, }; +protected: + ~MediumFont() = default; + public: MediumFont(); diff --git a/firmware/include/fonts/MicroFont.h b/firmware/include/fonts/MicroFont.h index 07c526ed..20ce362c 100644 --- a/firmware/include/fonts/MicroFont.h +++ b/firmware/include/fonts/MicroFont.h @@ -2,7 +2,7 @@ #include "modules/FontModule.h" -class MicroFont : public FontModule +class MicroFont final : public FontModule { private: const std::vector ascii = { @@ -643,6 +643,9 @@ class MicroFont : public FontModule }, }; +protected: + ~MicroFont() = default; + public: MicroFont(); diff --git a/firmware/include/fonts/MiniFont.h b/firmware/include/fonts/MiniFont.h index 12daa81f..4dffa547 100644 --- a/firmware/include/fonts/MiniFont.h +++ b/firmware/include/fonts/MiniFont.h @@ -2,7 +2,7 @@ #include "modules/FontModule.h" -class MiniFont : public FontModule +class MiniFont final : public FontModule { private: const std::vector ascii = { @@ -869,6 +869,9 @@ class MiniFont : public FontModule }, }; +protected: + ~MiniFont() = default; + public: MiniFont(); diff --git a/firmware/include/fonts/SmallFont.h b/firmware/include/fonts/SmallFont.h index 572aeebe..32f0569b 100644 --- a/firmware/include/fonts/SmallFont.h +++ b/firmware/include/fonts/SmallFont.h @@ -6,7 +6,7 @@ // Font inspired by https://github.com/MakeMagazinDE/Obegraensad // -class SmallFont : public FontModule +class SmallFont final : public FontModule { private: const std::vector ascii = { @@ -1455,6 +1455,9 @@ class SmallFont : public FontModule }, }; +protected: + ~SmallFont() = default; + public: SmallFont(); diff --git a/firmware/include/handlers/BitmapHandler.h b/firmware/include/handlers/BitmapHandler.h index 0d0c1434..a4eedced 100644 --- a/firmware/include/handlers/BitmapHandler.h +++ b/firmware/include/handlers/BitmapHandler.h @@ -15,6 +15,7 @@ class BitmapHandler public: BitmapHandler(std::vector bitmap); + ~BitmapHandler() = default; void draw(uint8_t brightness = UINT8_MAX); void draw(uint8_t x, uint8_t y, uint8_t brightness = UINT8_MAX); diff --git a/firmware/include/handlers/TextHandler.h b/firmware/include/handlers/TextHandler.h index 7bec55a7..59eb4fbb 100644 --- a/firmware/include/handlers/TextHandler.h +++ b/firmware/include/handlers/TextHandler.h @@ -27,6 +27,7 @@ class TextHandler public: TextHandler(std::string text, FontModule *font); + ~TextHandler() = default; void draw(uint8_t brightness = UINT8_MAX); void draw(int16_t x, int8_t y, uint8_t brightness = UINT8_MAX); diff --git a/firmware/include/handlers/WeatherHandler.h b/firmware/include/handlers/WeatherHandler.h index 092c8ae5..c9d568c5 100644 --- a/firmware/include/handlers/WeatherHandler.h +++ b/firmware/include/handlers/WeatherHandler.h @@ -6,6 +6,9 @@ class WeatherHandler { public: + WeatherHandler() {}; + ~WeatherHandler() = default; + enum Conditions { CLEAR, diff --git a/firmware/include/modes/AnimationMode.h b/firmware/include/modes/AnimationMode.h index f9c9539b..c66f32b1 100644 --- a/firmware/include/modes/AnimationMode.h +++ b/firmware/include/modes/AnimationMode.h @@ -7,7 +7,7 @@ #include -class AnimationMode : public ModeModule +class AnimationMode final : public ModeModule { private: bool pending = false; @@ -24,6 +24,9 @@ class AnimationMode : public ModeModule void transmit(uint8_t index, const uint8_t frame[GRID_COLUMNS * GRID_ROWS]); +protected: + ~AnimationMode() = default; + public: AnimationMode() : ModeModule("Animation") {}; diff --git a/firmware/include/modes/ArrowMode.h b/firmware/include/modes/ArrowMode.h index 856b5be2..da082eb9 100644 --- a/firmware/include/modes/ArrowMode.h +++ b/firmware/include/modes/ArrowMode.h @@ -4,7 +4,7 @@ #include "modules/ModeModule.h" -class ArrowMode : public ModeModule +class ArrowMode final : public ModeModule { private: const std::vector> arrow = { @@ -83,6 +83,9 @@ class ArrowMode : public ModeModule unsigned long lastMillis = 0; +protected: + ~ArrowMode() = default; + public: ArrowMode() : ModeModule("Arrow") {}; diff --git a/firmware/include/modes/BinaryClockMode.h b/firmware/include/modes/BinaryClockMode.h index a3aa2441..4648d86a 100644 --- a/firmware/include/modes/BinaryClockMode.h +++ b/firmware/include/modes/BinaryClockMode.h @@ -4,7 +4,7 @@ #include "modules/ModeModule.h" -class BinaryClockMode : public ModeModule +class BinaryClockMode final : public ModeModule { private: tm local = {}; @@ -17,6 +17,9 @@ class BinaryClockMode : public ModeModule void draw(uint8_t col, uint8_t value); +protected: + ~BinaryClockMode() = default; + public: BinaryClockMode() : ModeModule("Binary clock") {}; diff --git a/firmware/include/modes/BinaryEpochMode.h b/firmware/include/modes/BinaryEpochMode.h index cd6fe516..c2336fd0 100644 --- a/firmware/include/modes/BinaryEpochMode.h +++ b/firmware/include/modes/BinaryEpochMode.h @@ -4,11 +4,14 @@ #include "modules/ModeModule.h" -class BinaryEpochMode : public ModeModule +class BinaryEpochMode final : public ModeModule { private: time_t epoch = 0; +protected: + ~BinaryEpochMode() = default; + public: BinaryEpochMode() : ModeModule("Binary epoch") {}; diff --git a/firmware/include/modes/BlindsMode.h b/firmware/include/modes/BlindsMode.h index 74b16dba..fc7511a7 100644 --- a/firmware/include/modes/BlindsMode.h +++ b/firmware/include/modes/BlindsMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class BlindsMode : public ModeModule +class BlindsMode final : public ModeModule { private: static constexpr uint8_t moduloMax = GRID_ROWS / 3; @@ -16,6 +16,9 @@ class BlindsMode : public ModeModule unsigned long lastMillis = 0; +protected: + ~BlindsMode() = default; + public: BlindsMode() : ModeModule("Blinds") {}; diff --git a/firmware/include/modes/BlinkMode.h b/firmware/include/modes/BlinkMode.h index 3ccfd3e7..93e884b4 100644 --- a/firmware/include/modes/BlinkMode.h +++ b/firmware/include/modes/BlinkMode.h @@ -4,11 +4,14 @@ #include "modules/ModeModule.h" -class BlinkMode : public ModeModule +class BlinkMode final : public ModeModule { private: unsigned long lastMillis = 0; +protected: + ~BlinkMode() = default; + public: BlinkMode() : ModeModule("Blink") {}; diff --git a/firmware/include/modes/BreakoutClockMode.h b/firmware/include/modes/BreakoutClockMode.h index 1cb9ffe0..a173a0ad 100644 --- a/firmware/include/modes/BreakoutClockMode.h +++ b/firmware/include/modes/BreakoutClockMode.h @@ -7,7 +7,7 @@ #include -class BreakoutClockMode : public ModeModule +class BreakoutClockMode final : public ModeModule { private: static constexpr float speed = 7e-4 * GRID_ROWS; @@ -27,6 +27,9 @@ class BreakoutClockMode : public ModeModule uint16_t deg = 90; +protected: + ~BreakoutClockMode() = default; + public: BreakoutClockMode() : ModeModule("Breakout clock") {}; diff --git a/firmware/include/modes/BrightMode.h b/firmware/include/modes/BrightMode.h index faa99cfa..15fec25e 100644 --- a/firmware/include/modes/BrightMode.h +++ b/firmware/include/modes/BrightMode.h @@ -4,8 +4,11 @@ #include "modules/ModeModule.h" -class BrightMode : public ModeModule +class BrightMode final : public ModeModule { +protected: + ~BrightMode() = default; + public: BrightMode() : ModeModule("Bright") {}; diff --git a/firmware/include/modes/CircleMode.h b/firmware/include/modes/CircleMode.h index 41cbca68..e4d110eb 100644 --- a/firmware/include/modes/CircleMode.h +++ b/firmware/include/modes/CircleMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class CircleMode : public ModeModule +class CircleMode final : public ModeModule { private: static constexpr float x = (GRID_COLUMNS - 1) / 2.0f; @@ -23,6 +23,9 @@ class CircleMode : public ModeModule unsigned long lastMillis = 0; +protected: + ~CircleMode() = default; + public: CircleMode() : ModeModule("Circle") {}; diff --git a/firmware/include/modes/CountdownMode.h b/firmware/include/modes/CountdownMode.h index 0fee1268..035eff6d 100644 --- a/firmware/include/modes/CountdownMode.h +++ b/firmware/include/modes/CountdownMode.h @@ -6,7 +6,7 @@ #include -class CountdownMode : public ModeModule +class CountdownMode final : public ModeModule { private: bool done = false; @@ -19,6 +19,9 @@ class CountdownMode : public ModeModule void save(); void transmit(); +protected: + ~CountdownMode() = default; + public: CountdownMode() : ModeModule("Countdown") {}; diff --git a/firmware/include/modes/DrawMode.h b/firmware/include/modes/DrawMode.h index b9377d61..c822c6e3 100644 --- a/firmware/include/modes/DrawMode.h +++ b/firmware/include/modes/DrawMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class DrawMode : public ModeModule +class DrawMode final : public ModeModule { private: bool pending = false; @@ -17,6 +17,9 @@ class DrawMode : public ModeModule void save(bool cache = false); void transmit(); +protected: + ~DrawMode() = default; + public: DrawMode() : ModeModule("Draw") {}; diff --git a/firmware/include/modes/EqualizerMode.h b/firmware/include/modes/EqualizerMode.h index 7fafec3e..d674de4e 100644 --- a/firmware/include/modes/EqualizerMode.h +++ b/firmware/include/modes/EqualizerMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class EqualizerMode : public ModeModule +class EqualizerMode final : public ModeModule { private: static constexpr uint8_t width = 3; @@ -20,6 +20,9 @@ class EqualizerMode : public ModeModule unsigned long lastMillis = 0; +protected: + ~EqualizerMode() = default; + public: EqualizerMode() : ModeModule("Equalizer") {}; diff --git a/firmware/include/modes/FireworkMode.h b/firmware/include/modes/FireworkMode.h index 668f9340..6288ce49 100644 --- a/firmware/include/modes/FireworkMode.h +++ b/firmware/include/modes/FireworkMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class FireworkMode : public ModeModule +class FireworkMode final : public ModeModule { private: unsigned long lastMillis = 0; @@ -22,6 +22,9 @@ class FireworkMode : public ModeModule void exploding(); void fading(); +protected: + ~FireworkMode() = default; + public: FireworkMode() : ModeModule("Firework") {}; diff --git a/firmware/include/modes/FliesMode.h b/firmware/include/modes/FliesMode.h index 058e7542..7e93948b 100644 --- a/firmware/include/modes/FliesMode.h +++ b/firmware/include/modes/FliesMode.h @@ -7,7 +7,7 @@ #include -class FliesMode : public ModeModule +class FliesMode final : public ModeModule { private: struct Dot @@ -22,6 +22,9 @@ class FliesMode : public ModeModule uint8_t drawing[GRID_COLUMNS * GRID_ROWS] = {0}; +protected: + ~FliesMode() = default; + public: FliesMode() : ModeModule("Flies") {}; diff --git a/firmware/include/modes/GameOfLifeMode.h b/firmware/include/modes/GameOfLifeMode.h index 1764b845..593a56c2 100644 --- a/firmware/include/modes/GameOfLifeMode.h +++ b/firmware/include/modes/GameOfLifeMode.h @@ -4,7 +4,7 @@ #include "modules/ModeModule.h" -class GameOfLifeMode : public ModeModule +class GameOfLifeMode final : public ModeModule { private: tm local = {}; @@ -21,6 +21,9 @@ class GameOfLifeMode : public ModeModule void setClock(bool _clock); void transmit(); +protected: + ~GameOfLifeMode() = default; + public: GameOfLifeMode() : ModeModule("Game of Life") {}; diff --git a/firmware/include/modes/GlitterMode.h b/firmware/include/modes/GlitterMode.h index c00f40be..597d9d3e 100644 --- a/firmware/include/modes/GlitterMode.h +++ b/firmware/include/modes/GlitterMode.h @@ -4,8 +4,11 @@ #include "modules/ModeModule.h" -class GlitterMode : public ModeModule +class GlitterMode final : public ModeModule { +protected: + ~GlitterMode() = default; + public: GlitterMode() : ModeModule("Glitter") {}; diff --git a/firmware/include/modes/GoogleWeatherMode.h b/firmware/include/modes/GoogleWeatherMode.h index 51c622fe..46aa5a9a 100644 --- a/firmware/include/modes/GoogleWeatherMode.h +++ b/firmware/include/modes/GoogleWeatherMode.h @@ -8,7 +8,7 @@ #include -class GoogleWeatherMode : public ModeModule +class GoogleWeatherMode final : public ModeModule { private: static constexpr uint32_t interval = 900'000; // Update interval: 15 minutes @@ -109,6 +109,9 @@ class GoogleWeatherMode : public ModeModule void update(); +protected: + ~GoogleWeatherMode() = default; + public: GoogleWeatherMode() : ModeModule("Google Weather") {}; diff --git a/firmware/include/modes/HomeAssistantWeatherMode.h b/firmware/include/modes/HomeAssistantWeatherMode.h index 18ebc2f8..bcf9d9e8 100644 --- a/firmware/include/modes/HomeAssistantWeatherMode.h +++ b/firmware/include/modes/HomeAssistantWeatherMode.h @@ -8,7 +8,7 @@ #include -class HomeAssistantWeatherMode : public ModeModule +class HomeAssistantWeatherMode final : public ModeModule { private: static constexpr uint16_t interval = UINT16_MAX; @@ -116,6 +116,9 @@ class HomeAssistantWeatherMode : public ModeModule void update(); +protected: + ~HomeAssistantWeatherMode() = default; + public: HomeAssistantWeatherMode() : ModeModule("Home Assistant weather") {}; diff --git a/firmware/include/modes/HomeThermometerMode.h b/firmware/include/modes/HomeThermometerMode.h index c92e6edc..a743f99a 100644 --- a/firmware/include/modes/HomeThermometerMode.h +++ b/firmware/include/modes/HomeThermometerMode.h @@ -4,7 +4,7 @@ #include "modules/ModeModule.h" -class HomeThermometerMode : public ModeModule +class HomeThermometerMode final : public ModeModule { private: bool pending = false; @@ -13,6 +13,9 @@ class HomeThermometerMode : public ModeModule void setTemperature(const char *where, int16_t temperature); void transmit(); +protected: + ~HomeThermometerMode() = default; + public: HomeThermometerMode() : ModeModule("Home thermometer") {}; diff --git a/firmware/include/modes/JaggedWaveformMode.h b/firmware/include/modes/JaggedWaveformMode.h index 9684251c..13fe4638 100644 --- a/firmware/include/modes/JaggedWaveformMode.h +++ b/firmware/include/modes/JaggedWaveformMode.h @@ -4,7 +4,7 @@ #include "modules/ModeModule.h" -class JaggedWaveformMode : public ModeModule +class JaggedWaveformMode final : public ModeModule { private: unsigned long lastMillis = 0; @@ -69,6 +69,9 @@ class JaggedWaveformMode : public ModeModule }, }; +protected: + ~JaggedWaveformMode() = default; + public: JaggedWaveformMode() : ModeModule("Jagged waveform") {}; diff --git a/firmware/include/modes/LargeClockMode.h b/firmware/include/modes/LargeClockMode.h index 902be9f3..88dc85c7 100644 --- a/firmware/include/modes/LargeClockMode.h +++ b/firmware/include/modes/LargeClockMode.h @@ -7,7 +7,7 @@ #include -class LargeClockMode : public ModeModule +class LargeClockMode final : public ModeModule { private: tm local = {}; @@ -27,6 +27,9 @@ class LargeClockMode : public ModeModule void setTicking(bool _ticking); void transmit(); +protected: + ~LargeClockMode() = default; + public: LargeClockMode() : ModeModule("Large clock") {}; diff --git a/firmware/include/modes/LeafFallMode.h b/firmware/include/modes/LeafFallMode.h index d86018f1..19eb37ca 100644 --- a/firmware/include/modes/LeafFallMode.h +++ b/firmware/include/modes/LeafFallMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class LeafFallMode : public ModeModule +class LeafFallMode final : public ModeModule { private: struct Leaf @@ -19,6 +19,9 @@ class LeafFallMode : public ModeModule Leaf leaves[GRID_COLUMNS * GRID_ROWS / 20]; +protected: + ~LeafFallMode() = default; + public: LeafFallMode() : ModeModule("Leaf fall") {}; diff --git a/firmware/include/modes/LinesMode.h b/firmware/include/modes/LinesMode.h index f8889eb0..b39e7fcf 100644 --- a/firmware/include/modes/LinesMode.h +++ b/firmware/include/modes/LinesMode.h @@ -4,13 +4,16 @@ #include "modules/ModeModule.h" -class LinesMode : public ModeModule +class LinesMode final : public ModeModule { private: uint8_t x = 0; unsigned long lastMillis = 0; +protected: + ~LinesMode() = default; + public: LinesMode() : ModeModule("Lines") {}; diff --git a/firmware/include/modes/MetaballsMode.h b/firmware/include/modes/MetaballsMode.h index 16d13950..4057d95c 100644 --- a/firmware/include/modes/MetaballsMode.h +++ b/firmware/include/modes/MetaballsMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class MetaballsMode : public ModeModule +class MetaballsMode final : public ModeModule { private: static constexpr float radius = min(GRID_COLUMNS * PITCH_HORIZONTAL / (float)PITCH_VERTICAL, @@ -28,6 +28,9 @@ class MetaballsMode : public ModeModule Ball balls[GRID_COLUMNS * GRID_ROWS / (1 << 6)] = {}; +protected: + ~MetaballsMode() = default; + public: MetaballsMode() : ModeModule("Metaballs") {}; diff --git a/firmware/include/modes/NoiseMode.h b/firmware/include/modes/NoiseMode.h index 1b21ae3d..de172d62 100644 --- a/firmware/include/modes/NoiseMode.h +++ b/firmware/include/modes/NoiseMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class NoiseMode : public ModeModule +class NoiseMode final : public ModeModule { private: struct Dot @@ -18,6 +18,9 @@ class NoiseMode : public ModeModule Dot dots[GRID_COLUMNS * GRID_ROWS / 9]; +protected: + ~NoiseMode() = default; + public: NoiseMode() : ModeModule("Noise") {}; diff --git a/firmware/include/modes/OpenMeteoMode.h b/firmware/include/modes/OpenMeteoMode.h index 79568edf..93a22318 100644 --- a/firmware/include/modes/OpenMeteoMode.h +++ b/firmware/include/modes/OpenMeteoMode.h @@ -8,7 +8,7 @@ #include -class OpenMeteoMode : public ModeModule +class OpenMeteoMode final : public ModeModule { private: static constexpr uint32_t interval = 900'000; // Data resolution: down to 15 minutes (depending on location) @@ -74,6 +74,9 @@ class OpenMeteoMode : public ModeModule void update(); +protected: + ~OpenMeteoMode() = default; + public: OpenMeteoMode() : ModeModule("Open-Meteo") {}; diff --git a/firmware/include/modes/OpenWeatherMode.h b/firmware/include/modes/OpenWeatherMode.h index 0824d064..9cf0ba6f 100644 --- a/firmware/include/modes/OpenWeatherMode.h +++ b/firmware/include/modes/OpenWeatherMode.h @@ -8,7 +8,7 @@ #include -class OpenWeatherMode : public ModeModule +class OpenWeatherMode final : public ModeModule { private: static constexpr uint32_t interval = 600'000; // Recommended update interval: 10 minutes @@ -73,6 +73,9 @@ class OpenWeatherMode : public ModeModule void update(); +protected: + ~OpenWeatherMode() = default; + public: OpenWeatherMode() : ModeModule("OpenWeather") {}; diff --git a/firmware/include/modes/PingPongMode.h b/firmware/include/modes/PingPongMode.h index 8305a62e..4ee6ebc3 100644 --- a/firmware/include/modes/PingPongMode.h +++ b/firmware/include/modes/PingPongMode.h @@ -7,7 +7,7 @@ #include -class PingPongMode : public ModeModule +class PingPongMode final : public ModeModule { private: static constexpr float speed = 1e-3 * GRID_COLUMNS; @@ -36,6 +36,9 @@ class PingPongMode : public ModeModule void setClock(bool _clock); void transmit(); +protected: + ~PingPongMode() = default; + public: PingPongMode() : ModeModule("Ping-pong") {}; diff --git a/firmware/include/modes/PixelSequenceMode.h b/firmware/include/modes/PixelSequenceMode.h index f4e67a65..ec6a8f34 100644 --- a/firmware/include/modes/PixelSequenceMode.h +++ b/firmware/include/modes/PixelSequenceMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class PixelSequenceMode : public ModeModule +class PixelSequenceMode final : public ModeModule { private: static constexpr uint8_t pixelOrder[GRID_COLUMNS * GRID_ROWS] = LED_MAP; @@ -16,6 +16,9 @@ class PixelSequenceMode : public ModeModule unsigned long lastMillis = 0; +protected: + ~PixelSequenceMode() = default; + public: PixelSequenceMode() : ModeModule("Pixel sequence") {}; diff --git a/firmware/include/modes/RainMode.h b/firmware/include/modes/RainMode.h index 6fab22eb..cc01f33d 100644 --- a/firmware/include/modes/RainMode.h +++ b/firmware/include/modes/RainMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class RainMode : public ModeModule +class RainMode final : public ModeModule { private: struct Drop @@ -20,6 +20,9 @@ class RainMode : public ModeModule Drop drops[GRID_COLUMNS / 3]; +protected: + ~RainMode() = default; + public: RainMode() : ModeModule("Rain") {}; diff --git a/firmware/include/modes/RingMode.h b/firmware/include/modes/RingMode.h index 2a4c8a16..1f7b191b 100644 --- a/firmware/include/modes/RingMode.h +++ b/firmware/include/modes/RingMode.h @@ -4,7 +4,7 @@ #include "modules/ModeModule.h" -class RingMode : public ModeModule +class RingMode final : public ModeModule { private: bool direction = true; @@ -124,6 +124,9 @@ class RingMode : public ModeModule }, }; +protected: + ~RingMode() = default; + public: RingMode() : ModeModule("Ring") {}; diff --git a/firmware/include/modes/ScanMode.h b/firmware/include/modes/ScanMode.h index ece0a646..dba486a2 100644 --- a/firmware/include/modes/ScanMode.h +++ b/firmware/include/modes/ScanMode.h @@ -4,13 +4,16 @@ #include "modules/ModeModule.h" -class ScanMode : public ModeModule +class ScanMode final : public ModeModule { private: uint8_t column = 0; unsigned long lastMillis = 0; +protected: + ~ScanMode() = default; + public: ScanMode() : ModeModule("Scan") {}; diff --git a/firmware/include/modes/SmallClockMode.h b/firmware/include/modes/SmallClockMode.h index 10f991ad..2e53fd99 100644 --- a/firmware/include/modes/SmallClockMode.h +++ b/firmware/include/modes/SmallClockMode.h @@ -4,7 +4,7 @@ #include "modules/ModeModule.h" -class SmallClockMode : public ModeModule +class SmallClockMode final : public ModeModule { private: tm local = {}; @@ -19,6 +19,9 @@ class SmallClockMode : public ModeModule void setTicking(bool _ticking); void transmit(); +protected: + ~SmallClockMode() = default; + public: SmallClockMode() : ModeModule("Small clock") {}; diff --git a/firmware/include/modes/SmoothWaveformMode.h b/firmware/include/modes/SmoothWaveformMode.h index 70264846..d895f817 100644 --- a/firmware/include/modes/SmoothWaveformMode.h +++ b/firmware/include/modes/SmoothWaveformMode.h @@ -4,7 +4,7 @@ #include "modules/ModeModule.h" -class SmoothWaveformMode : public ModeModule +class SmoothWaveformMode final : public ModeModule { private: unsigned long lastMillis = 0; @@ -57,6 +57,9 @@ class SmoothWaveformMode : public ModeModule }, }; +protected: + ~SmoothWaveformMode() = default; + public: SmoothWaveformMode() : ModeModule("Smooth waveform") {}; diff --git a/firmware/include/modes/SnakeMode.h b/firmware/include/modes/SnakeMode.h index 2f10cb1a..5b82e4cd 100644 --- a/firmware/include/modes/SnakeMode.h +++ b/firmware/include/modes/SnakeMode.h @@ -7,7 +7,7 @@ #include #include -class SnakeMode : public ModeModule +class SnakeMode final : public ModeModule { private: struct Pixel @@ -46,6 +46,9 @@ class SnakeMode : public ModeModule void setDot(); void transmit(); +protected: + ~SnakeMode() = default; + public: SnakeMode() : ModeModule("Snake") {} diff --git a/firmware/include/modes/StarsMode.h b/firmware/include/modes/StarsMode.h index ff149532..0beb2f13 100644 --- a/firmware/include/modes/StarsMode.h +++ b/firmware/include/modes/StarsMode.h @@ -5,7 +5,7 @@ #include "config/constants.h" #include "modules/ModeModule.h" -class StarsMode : public ModeModule +class StarsMode final : public ModeModule { private: struct Star @@ -20,6 +20,9 @@ class StarsMode : public ModeModule Star stars[GRID_COLUMNS * GRID_ROWS / (1 << 4)]; +protected: + ~StarsMode() = default; + public: StarsMode() : ModeModule("Stars") {}; diff --git a/firmware/include/modes/StreamMode.h b/firmware/include/modes/StreamMode.h index 3e430539..d3969357 100644 --- a/firmware/include/modes/StreamMode.h +++ b/firmware/include/modes/StreamMode.h @@ -7,7 +7,7 @@ #include #include -class StreamMode : public ModeModule +class StreamMode final : public ModeModule { private: static constexpr std::string_view _name = "Stream"; @@ -21,6 +21,9 @@ class StreamMode : public ModeModule static void onPacket(AsyncUDPPacket packet); +protected: + ~StreamMode() = default; + public: StreamMode() : ModeModule(_name.data()) {}; diff --git a/firmware/include/modes/TickerMode.h b/firmware/include/modes/TickerMode.h index 57b94356..8bb7f389 100644 --- a/firmware/include/modes/TickerMode.h +++ b/firmware/include/modes/TickerMode.h @@ -10,7 +10,7 @@ #include -class TickerMode : public ModeModule +class TickerMode final : public ModeModule { private: bool pending = false; @@ -33,6 +33,9 @@ class TickerMode : public ModeModule void transmit(); +protected: + ~TickerMode() = default; + public: TickerMode() : ModeModule("Ticker") {}; diff --git a/firmware/include/modes/WaveformMode.h b/firmware/include/modes/WaveformMode.h index 02992f32..6de716cd 100644 --- a/firmware/include/modes/WaveformMode.h +++ b/firmware/include/modes/WaveformMode.h @@ -4,7 +4,7 @@ #include "modules/ModeModule.h" -class WaveformMode : public ModeModule +class WaveformMode final : public ModeModule { private: unsigned long lastMillis = 0; @@ -114,6 +114,9 @@ class WaveformMode : public ModeModule }, }; +protected: + ~WaveformMode() = default; + public: WaveformMode() : ModeModule("Waveform") {}; diff --git a/firmware/include/modes/WorldWeatherOnlineMode.h b/firmware/include/modes/WorldWeatherOnlineMode.h index 44d3b476..d7a5a4fc 100644 --- a/firmware/include/modes/WorldWeatherOnlineMode.h +++ b/firmware/include/modes/WorldWeatherOnlineMode.h @@ -8,7 +8,7 @@ #include -class WorldWeatherOnlineMode : public ModeModule +class WorldWeatherOnlineMode final : public ModeModule { private: static constexpr uint32_t interval = 600'000; // Recommended update interval: 10-15 minutes @@ -61,6 +61,9 @@ class WorldWeatherOnlineMode : public ModeModule void update(); +protected: + ~WorldWeatherOnlineMode() = default; + public: WorldWeatherOnlineMode() : ModeModule("World Weather Online") {}; diff --git a/firmware/include/modes/WttrInMode.h b/firmware/include/modes/WttrInMode.h index 0a925729..679c9519 100644 --- a/firmware/include/modes/WttrInMode.h +++ b/firmware/include/modes/WttrInMode.h @@ -8,7 +8,7 @@ #include -class WttrInMode : public ModeModule +class WttrInMode final : public ModeModule { private: static constexpr uint32_t interval = 3'600'000; // Recommended update interval: 1 hour (due to heavy caching) @@ -61,6 +61,9 @@ class WttrInMode : public ModeModule void update(); +protected: + ~WttrInMode() = default; + public: WttrInMode() : ModeModule("Wttr.in") {}; diff --git a/firmware/include/modes/YrMode.h b/firmware/include/modes/YrMode.h index 0a4930ca..d7d252bb 100644 --- a/firmware/include/modes/YrMode.h +++ b/firmware/include/modes/YrMode.h @@ -8,7 +8,7 @@ #include -class YrMode : public ModeModule +class YrMode final : public ModeModule { private: static constexpr uint32_t interval = 300'000; // Data resolution: down to 5 minutes (depending on location) @@ -152,6 +152,9 @@ class YrMode : public ModeModule void update(); +protected: + ~YrMode() = default; + public: YrMode() : ModeModule("Yr") {}; diff --git a/firmware/include/modules/ModeModule.h b/firmware/include/modules/ModeModule.h index 7ffcc272..35142ceb 100644 --- a/firmware/include/modules/ModeModule.h +++ b/firmware/include/modules/ModeModule.h @@ -6,10 +6,9 @@ class ModeModule { protected: ModeModule(const char *const name) : name(name) {}; - -public: ~ModeModule() = default; +public: ModeModule(const ModeModule &) = delete; ModeModule &operator=(const ModeModule &) = delete; diff --git a/firmware/include/services/ConnectivityService.h b/firmware/include/services/ConnectivityService.h index 569f8e52..639023df 100644 --- a/firmware/include/services/ConnectivityService.h +++ b/firmware/include/services/ConnectivityService.h @@ -6,7 +6,7 @@ #include #include -class ConnectivityService : public ServiceModule +class ConnectivityService final : public ServiceModule { private: static constexpr std::string_view _name = "Connectivity"; @@ -35,6 +35,9 @@ class ConnectivityService : public ServiceModule static void onRoutable(); static void onScan(WiFiEvent_t event, WiFiEventInfo_t info); +protected: + ~ConnectivityService() = default; + public: static constexpr std::string_view userAgent = "Frekvens/" VERSION " (ESP32; +https://github.com/VIPnytt/Frekvens)"; diff --git a/firmware/include/services/DeviceService.h b/firmware/include/services/DeviceService.h index aa0cae2a..6eb811b4 100644 --- a/firmware/include/services/DeviceService.h +++ b/firmware/include/services/DeviceService.h @@ -5,7 +5,7 @@ #include -class DeviceService : public ServiceModule +class DeviceService final : public ServiceModule { private: DeviceService() : ServiceModule("Device") {}; @@ -20,6 +20,9 @@ class DeviceService : public ServiceModule void onReceive(const JsonDocument &doc, const char *source) override; +protected: + ~DeviceService() = default; + public: TaskHandle_t taskHandle = nullptr; diff --git a/firmware/include/services/DisplayService.h b/firmware/include/services/DisplayService.h index 23d56806..9863f5bb 100644 --- a/firmware/include/services/DisplayService.h +++ b/firmware/include/services/DisplayService.h @@ -5,7 +5,7 @@ #include -class DisplayService : public ServiceModule +class DisplayService final : public ServiceModule { private: DisplayService() : ServiceModule("Display") {}; @@ -59,6 +59,9 @@ class DisplayService : public ServiceModule static IRAM_ATTR void onTimer(); +protected: + ~DisplayService() = default; + public: hw_timer_t *timer = nullptr; diff --git a/firmware/include/services/ExtensionsService.h b/firmware/include/services/ExtensionsService.h index ca07bbb0..c50695c4 100644 --- a/firmware/include/services/ExtensionsService.h +++ b/firmware/include/services/ExtensionsService.h @@ -22,7 +22,7 @@ #include -class ExtensionsService : public ServiceModule +class ExtensionsService final : public ServiceModule { private: ExtensionsService() : ServiceModule("Extensions") {}; @@ -87,6 +87,9 @@ class ExtensionsService : public ServiceModule static void onTask(void *parameter = nullptr); +protected: + ~ExtensionsService() = default; + public: TaskHandle_t taskHandle = nullptr; diff --git a/firmware/include/services/FontsService.h b/firmware/include/services/FontsService.h index 18221648..e7d78d35 100644 --- a/firmware/include/services/FontsService.h +++ b/firmware/include/services/FontsService.h @@ -9,7 +9,7 @@ #include "fonts/SmallFont.h" #include "modules/ServiceModule.h" -class FontsService : public ServiceModule +class FontsService final : public ServiceModule { private: FontsService() : ServiceModule("Fonts") {}; @@ -28,6 +28,9 @@ class FontsService : public ServiceModule void transmit(); +protected: + ~FontsService() = default; + public: void begin(); [[nodiscard]] const std::vector &getAll() const; diff --git a/firmware/include/services/ModesService.h b/firmware/include/services/ModesService.h index f9eac126..22b4c75e 100644 --- a/firmware/include/services/ModesService.h +++ b/firmware/include/services/ModesService.h @@ -47,7 +47,7 @@ #include -class ModesService : public ServiceModule +class ModesService final : public ServiceModule { private: ModesService() : ServiceModule("Modes") {}; @@ -190,6 +190,9 @@ class ModesService : public ServiceModule static void onTask(void *parameter = nullptr); +protected: + ~ModesService() = default; + public: static constexpr uint16_t stackSize = 1 << 13; // 8 kB diff --git a/firmware/include/services/WebServerService.h b/firmware/include/services/WebServerService.h index d6b7ac07..9af28e60 100644 --- a/firmware/include/services/WebServerService.h +++ b/firmware/include/services/WebServerService.h @@ -4,11 +4,14 @@ #include -class WebServerService : public ServiceModule +class WebServerService final : public ServiceModule { private: static void onNotFound(AsyncWebServerRequest *request); +protected: + ~WebServerService() = default; + public: WebServerService() : ServiceModule("WebServer") {}; From 994cc11f010521249e6073eb64fff5856cb824fa Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Mon, 2 Feb 2026 20:42:25 +0100 Subject: [PATCH 17/26] WIP --- firmware/include/extensions/AlexaExtension.h | 2 ++ firmware/include/extensions/ButtonExtension.h | 2 ++ firmware/include/extensions/HeapExtension.h | 2 ++ firmware/include/extensions/HomeAssistantExtension.h | 2 ++ firmware/include/extensions/InfraredExtension.h | 2 ++ firmware/include/extensions/MessageExtension.h | 2 ++ firmware/include/extensions/MicrophoneExtension.h | 2 ++ firmware/include/extensions/MqttExtension.h | 2 ++ firmware/include/extensions/OtaExtension.h | 2 ++ firmware/include/extensions/PhotocellExtension.h | 2 ++ firmware/include/extensions/PlaylistExtension.h | 2 ++ firmware/include/extensions/RestfulExtension.h | 2 ++ firmware/include/extensions/RtcExtension.h | 2 ++ firmware/include/extensions/ServerSentEventsExtension.h | 2 ++ firmware/include/extensions/SignalExtension.h | 2 ++ firmware/include/extensions/WebAppExtension.h | 2 ++ firmware/include/extensions/WebSocketExtension.h | 2 ++ firmware/include/fonts/BrailleFont.h | 2 ++ firmware/include/fonts/LargeFont.h | 2 ++ firmware/include/fonts/MediumBoldFont.h | 2 ++ firmware/include/fonts/MediumFont.h | 2 ++ firmware/include/fonts/MicroFont.h | 2 ++ firmware/include/fonts/MiniFont.h | 2 ++ firmware/include/fonts/SmallFont.h | 2 ++ firmware/include/handlers/WeatherHandler.h | 4 ++-- firmware/include/modes/AnimationMode.h | 2 ++ firmware/include/modes/ArrowMode.h | 2 ++ firmware/include/modes/BinaryClockMode.h | 2 ++ firmware/include/modes/BinaryEpochMode.h | 2 ++ firmware/include/modes/BlindsMode.h | 2 ++ firmware/include/modes/BlinkMode.h | 2 ++ firmware/include/modes/BreakoutClockMode.h | 2 ++ firmware/include/modes/BrightMode.h | 2 ++ firmware/include/modes/CircleMode.h | 2 ++ firmware/include/modes/CountdownMode.h | 2 ++ firmware/include/modes/DrawMode.h | 2 ++ firmware/include/modes/EqualizerMode.h | 2 ++ firmware/include/modes/FireworkMode.h | 2 ++ firmware/include/modes/FliesMode.h | 2 ++ firmware/include/modes/GameOfLifeMode.h | 2 ++ firmware/include/modes/GlitterMode.h | 2 ++ firmware/include/modes/GoogleWeatherMode.h | 2 ++ firmware/include/modes/HomeAssistantWeatherMode.h | 2 ++ firmware/include/modes/HomeThermometerMode.h | 2 ++ firmware/include/modes/JaggedWaveformMode.h | 2 ++ firmware/include/modes/LargeClockMode.h | 2 ++ firmware/include/modes/LeafFallMode.h | 2 ++ firmware/include/modes/LinesMode.h | 2 ++ firmware/include/modes/MetaballsMode.h | 2 ++ firmware/include/modes/NoiseMode.h | 2 ++ firmware/include/modes/OpenMeteoMode.h | 2 ++ firmware/include/modes/OpenWeatherMode.h | 2 ++ firmware/include/modes/PingPongMode.h | 2 ++ firmware/include/modes/PixelSequenceMode.h | 2 ++ firmware/include/modes/RainMode.h | 2 ++ firmware/include/modes/RingMode.h | 2 ++ firmware/include/modes/ScanMode.h | 2 ++ firmware/include/modes/SmallClockMode.h | 2 ++ firmware/include/modes/SmoothWaveformMode.h | 2 ++ firmware/include/modes/SnakeMode.h | 2 ++ firmware/include/modes/StarsMode.h | 2 ++ firmware/include/modes/StreamMode.h | 2 ++ firmware/include/modes/TickerMode.h | 2 ++ firmware/include/modes/WaveformMode.h | 2 ++ firmware/include/modes/WorldWeatherOnlineMode.h | 2 ++ firmware/include/modes/WttrInMode.h | 2 ++ firmware/include/modes/YrMode.h | 2 ++ firmware/include/services/ConnectivityService.h | 3 +++ firmware/include/services/DeviceService.h | 3 +++ firmware/include/services/DisplayService.h | 3 +++ firmware/include/services/ExtensionsService.h | 3 +++ firmware/include/services/FontsService.h | 3 +++ firmware/include/services/ModesService.h | 3 +++ firmware/include/services/WebServerService.h | 5 ++++- 74 files changed, 156 insertions(+), 3 deletions(-) diff --git a/firmware/include/extensions/AlexaExtension.h b/firmware/include/extensions/AlexaExtension.h index 48939680..f6e76af6 100644 --- a/firmware/include/extensions/AlexaExtension.h +++ b/firmware/include/extensions/AlexaExtension.h @@ -21,6 +21,8 @@ class AlexaExtension final : public ExtensionModule public: AlexaExtension(); + AlexaExtension(const AlexaExtension &) = delete; + AlexaExtension &operator=(const AlexaExtension &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/extensions/ButtonExtension.h b/firmware/include/extensions/ButtonExtension.h index 76722169..0ce98b7c 100644 --- a/firmware/include/extensions/ButtonExtension.h +++ b/firmware/include/extensions/ButtonExtension.h @@ -41,6 +41,8 @@ class ButtonExtension final : public ExtensionModule public: ButtonExtension(); + ButtonExtension(const ButtonExtension &) = delete; + ButtonExtension &operator=(const ButtonExtension &) = delete; void configure() override; void handle() override; diff --git a/firmware/include/extensions/HeapExtension.h b/firmware/include/extensions/HeapExtension.h index f7f5b654..3b7943ec 100644 --- a/firmware/include/extensions/HeapExtension.h +++ b/firmware/include/extensions/HeapExtension.h @@ -14,6 +14,8 @@ class HeapExtension final : public ExtensionModule public: HeapExtension(); + HeapExtension(const HeapExtension &) = delete; + HeapExtension &operator=(const HeapExtension &) = delete; #if EXTENSION_HOMEASSISTANT void configure() override; diff --git a/firmware/include/extensions/HomeAssistantExtension.h b/firmware/include/extensions/HomeAssistantExtension.h index b08fa105..11491042 100644 --- a/firmware/include/extensions/HomeAssistantExtension.h +++ b/firmware/include/extensions/HomeAssistantExtension.h @@ -23,6 +23,8 @@ class HomeAssistantExtension final : public ExtensionModule public: HomeAssistantExtension(); + HomeAssistantExtension(const HomeAssistantExtension &) = delete; + HomeAssistantExtension &operator=(const HomeAssistantExtension &) = delete; const std::string uniquePrefix = std::format("0x{:x}_", ESP.getEfuseMac()); diff --git a/firmware/include/extensions/InfraredExtension.h b/firmware/include/extensions/InfraredExtension.h index 68a576ac..c3da3656 100644 --- a/firmware/include/extensions/InfraredExtension.h +++ b/firmware/include/extensions/InfraredExtension.h @@ -133,6 +133,8 @@ class InfraredExtension final : public ExtensionModule public: InfraredExtension(); + InfraredExtension(const InfraredExtension &) = delete; + InfraredExtension &operator=(const InfraredExtension &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/extensions/MessageExtension.h b/firmware/include/extensions/MessageExtension.h index aedea144..9f540431 100644 --- a/firmware/include/extensions/MessageExtension.h +++ b/firmware/include/extensions/MessageExtension.h @@ -43,6 +43,8 @@ class MessageExtension final : public ExtensionModule public: MessageExtension(); + MessageExtension(const MessageExtension &) = delete; + MessageExtension &operator=(const MessageExtension &) = delete; #if EXTENSION_HOMEASSISTANT void configure() override; diff --git a/firmware/include/extensions/MicrophoneExtension.h b/firmware/include/extensions/MicrophoneExtension.h index 33fb1538..2cd45041 100644 --- a/firmware/include/extensions/MicrophoneExtension.h +++ b/firmware/include/extensions/MicrophoneExtension.h @@ -25,6 +25,8 @@ class MicrophoneExtension final : public ExtensionModule public: MicrophoneExtension(); + MicrophoneExtension(const MicrophoneExtension &) = delete; + MicrophoneExtension &operator=(const MicrophoneExtension &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/extensions/MqttExtension.h b/firmware/include/extensions/MqttExtension.h index b35bcbdf..23e0a0d4 100644 --- a/firmware/include/extensions/MqttExtension.h +++ b/firmware/include/extensions/MqttExtension.h @@ -26,6 +26,8 @@ class MqttExtension final : public ExtensionModule public: MqttExtension(); + MqttExtension(const MqttExtension &) = delete; + MqttExtension &operator=(const MqttExtension &) = delete; espMqttClient client; diff --git a/firmware/include/extensions/OtaExtension.h b/firmware/include/extensions/OtaExtension.h index bc7f5e0c..6d4877ec 100644 --- a/firmware/include/extensions/OtaExtension.h +++ b/firmware/include/extensions/OtaExtension.h @@ -25,6 +25,8 @@ class OtaExtension final : public ExtensionModule public: OtaExtension(); + OtaExtension(const OtaExtension &) = delete; + OtaExtension &operator=(const OtaExtension &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/extensions/PhotocellExtension.h b/firmware/include/extensions/PhotocellExtension.h index b5d03ebf..18ae636f 100644 --- a/firmware/include/extensions/PhotocellExtension.h +++ b/firmware/include/extensions/PhotocellExtension.h @@ -31,6 +31,8 @@ class PhotocellExtension final : public ExtensionModule public: PhotocellExtension(); + PhotocellExtension(const PhotocellExtension &) = delete; + PhotocellExtension &operator=(const PhotocellExtension &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/extensions/PlaylistExtension.h b/firmware/include/extensions/PlaylistExtension.h index c527f66c..e0df3f5e 100644 --- a/firmware/include/extensions/PlaylistExtension.h +++ b/firmware/include/extensions/PlaylistExtension.h @@ -10,6 +10,8 @@ class PlaylistExtension final : public ExtensionModule { public: PlaylistExtension(); + PlaylistExtension(const PlaylistExtension &) = delete; + PlaylistExtension &operator=(const PlaylistExtension &) = delete; struct Mode { diff --git a/firmware/include/extensions/RestfulExtension.h b/firmware/include/extensions/RestfulExtension.h index 4d1a74f1..e580674f 100644 --- a/firmware/include/extensions/RestfulExtension.h +++ b/firmware/include/extensions/RestfulExtension.h @@ -19,6 +19,8 @@ class RestfulExtension final : public ExtensionModule public: RestfulExtension(); + RestfulExtension(const RestfulExtension &) = delete; + RestfulExtension &operator=(const RestfulExtension &) = delete; void begin() override; }; diff --git a/firmware/include/extensions/RtcExtension.h b/firmware/include/extensions/RtcExtension.h index 2867c19e..94b7dc76 100644 --- a/firmware/include/extensions/RtcExtension.h +++ b/firmware/include/extensions/RtcExtension.h @@ -37,6 +37,8 @@ class RtcExtension final : public ExtensionModule public: RtcExtension(); + RtcExtension(const RtcExtension &) = delete; + RtcExtension &operator=(const RtcExtension &) = delete; #ifdef RTC_DS1307 RtcDS1307 rtc = RtcDS1307(Wire); diff --git a/firmware/include/extensions/ServerSentEventsExtension.h b/firmware/include/extensions/ServerSentEventsExtension.h index ccbfd1af..fbbfd413 100644 --- a/firmware/include/extensions/ServerSentEventsExtension.h +++ b/firmware/include/extensions/ServerSentEventsExtension.h @@ -13,6 +13,8 @@ class ServerSentEventsExtension final : public ExtensionModule public: ServerSentEventsExtension(); + ServerSentEventsExtension(const ServerSentEventsExtension &) = delete; + ServerSentEventsExtension &operator=(const ServerSentEventsExtension &) = delete; AsyncEventSource *client = new AsyncEventSource("/server-sent%20events"); diff --git a/firmware/include/extensions/SignalExtension.h b/firmware/include/extensions/SignalExtension.h index 96b065c4..bc0fe770 100644 --- a/firmware/include/extensions/SignalExtension.h +++ b/firmware/include/extensions/SignalExtension.h @@ -26,6 +26,8 @@ class SignalExtension final : public ExtensionModule public: SignalExtension(); + SignalExtension(const SignalExtension &) = delete; + SignalExtension &operator=(const SignalExtension &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/extensions/WebAppExtension.h b/firmware/include/extensions/WebAppExtension.h index 598bab67..c99eb805 100644 --- a/firmware/include/extensions/WebAppExtension.h +++ b/firmware/include/extensions/WebAppExtension.h @@ -15,6 +15,8 @@ class WebAppExtension final : public ExtensionModule public: WebAppExtension(); + WebAppExtension(const WebAppExtension &) = delete; + WebAppExtension &operator=(const WebAppExtension &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/extensions/WebSocketExtension.h b/firmware/include/extensions/WebSocketExtension.h index 20d86207..4b9b990a 100644 --- a/firmware/include/extensions/WebSocketExtension.h +++ b/firmware/include/extensions/WebSocketExtension.h @@ -17,6 +17,8 @@ class WebSocketExtension final : public ExtensionModule public: WebSocketExtension(); + WebSocketExtension(const WebSocketExtension &) = delete; + WebSocketExtension &operator=(const WebSocketExtension &) = delete; AsyncWebSocket *server = new AsyncWebSocket("/websocket"); diff --git a/firmware/include/fonts/BrailleFont.h b/firmware/include/fonts/BrailleFont.h index 5fb7fd4b..4f403a27 100644 --- a/firmware/include/fonts/BrailleFont.h +++ b/firmware/include/fonts/BrailleFont.h @@ -346,6 +346,8 @@ class BrailleFont final : public FontModule public: BrailleFont(); + BrailleFont(const BrailleFont &) = delete; + BrailleFont &operator=(const BrailleFont &) = delete; [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/LargeFont.h b/firmware/include/fonts/LargeFont.h index 50fe30f5..f20e4696 100644 --- a/firmware/include/fonts/LargeFont.h +++ b/firmware/include/fonts/LargeFont.h @@ -148,6 +148,8 @@ class LargeFont final : public FontModule public: LargeFont(); + LargeFont(const LargeFont &) = delete; + LargeFont &operator=(const LargeFont &) = delete; [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/MediumBoldFont.h b/firmware/include/fonts/MediumBoldFont.h index 4bfa5bae..1fee42a6 100644 --- a/firmware/include/fonts/MediumBoldFont.h +++ b/firmware/include/fonts/MediumBoldFont.h @@ -265,6 +265,8 @@ class MediumBoldFont final : public FontModule public: MediumBoldFont(); + MediumBoldFont(const MediumBoldFont &) = delete; + MediumBoldFont &operator=(const MediumBoldFont &) = delete; [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/MediumFont.h b/firmware/include/fonts/MediumFont.h index f1fd337f..7b2500b8 100644 --- a/firmware/include/fonts/MediumFont.h +++ b/firmware/include/fonts/MediumFont.h @@ -265,6 +265,8 @@ class MediumFont final : public FontModule public: MediumFont(); + MediumFont(const MediumFont &) = delete; + MediumFont &operator=(const MediumFont &) = delete; [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/MicroFont.h b/firmware/include/fonts/MicroFont.h index 20ce362c..ee463e2b 100644 --- a/firmware/include/fonts/MicroFont.h +++ b/firmware/include/fonts/MicroFont.h @@ -648,6 +648,8 @@ class MicroFont final : public FontModule public: MicroFont(); + MicroFont(const MicroFont &) = delete; + MicroFont &operator=(const MicroFont &) = delete; [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/MiniFont.h b/firmware/include/fonts/MiniFont.h index 4dffa547..4ed8cc8e 100644 --- a/firmware/include/fonts/MiniFont.h +++ b/firmware/include/fonts/MiniFont.h @@ -874,6 +874,8 @@ class MiniFont final : public FontModule public: MiniFont(); + MiniFont(const MiniFont &) = delete; + MiniFont &operator=(const MiniFont &) = delete; [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/SmallFont.h b/firmware/include/fonts/SmallFont.h index 32f0569b..5cd30c68 100644 --- a/firmware/include/fonts/SmallFont.h +++ b/firmware/include/fonts/SmallFont.h @@ -1460,6 +1460,8 @@ class SmallFont final : public FontModule public: SmallFont(); + SmallFont(const SmallFont &) = delete; + SmallFont &operator=(const SmallFont &) = delete; [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/handlers/WeatherHandler.h b/firmware/include/handlers/WeatherHandler.h index c9d568c5..aa53720d 100644 --- a/firmware/include/handlers/WeatherHandler.h +++ b/firmware/include/handlers/WeatherHandler.h @@ -6,7 +6,7 @@ class WeatherHandler { public: - WeatherHandler() {}; + WeatherHandler() = default; ~WeatherHandler() = default; enum Conditions @@ -41,7 +41,7 @@ class WeatherHandler }; std::vector sign = {}; - int16_t temperature; + int16_t temperature = 0; void parse(std::string code, std::vector codesets); void parse(uint8_t code, std::vector codesets); diff --git a/firmware/include/modes/AnimationMode.h b/firmware/include/modes/AnimationMode.h index c66f32b1..ba734eda 100644 --- a/firmware/include/modes/AnimationMode.h +++ b/firmware/include/modes/AnimationMode.h @@ -29,6 +29,8 @@ class AnimationMode final : public ModeModule public: AnimationMode() : ModeModule("Animation") {}; + AnimationMode(const AnimationMode &) = delete; + AnimationMode &operator=(const AnimationMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/ArrowMode.h b/firmware/include/modes/ArrowMode.h index da082eb9..5b71693d 100644 --- a/firmware/include/modes/ArrowMode.h +++ b/firmware/include/modes/ArrowMode.h @@ -88,6 +88,8 @@ class ArrowMode final : public ModeModule public: ArrowMode() : ModeModule("Arrow") {}; + ArrowMode(const ArrowMode &) = delete; + ArrowMode &operator=(const ArrowMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/BinaryClockMode.h b/firmware/include/modes/BinaryClockMode.h index 4648d86a..56eee021 100644 --- a/firmware/include/modes/BinaryClockMode.h +++ b/firmware/include/modes/BinaryClockMode.h @@ -22,6 +22,8 @@ class BinaryClockMode final : public ModeModule public: BinaryClockMode() : ModeModule("Binary clock") {}; + BinaryClockMode(const BinaryClockMode &) = delete; + BinaryClockMode &operator=(const BinaryClockMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/BinaryEpochMode.h b/firmware/include/modes/BinaryEpochMode.h index c2336fd0..e2a6df43 100644 --- a/firmware/include/modes/BinaryEpochMode.h +++ b/firmware/include/modes/BinaryEpochMode.h @@ -14,6 +14,8 @@ class BinaryEpochMode final : public ModeModule public: BinaryEpochMode() : ModeModule("Binary epoch") {}; + BinaryEpochMode(const BinaryEpochMode &) = delete; + BinaryEpochMode &operator=(const BinaryEpochMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/BlindsMode.h b/firmware/include/modes/BlindsMode.h index fc7511a7..2d9cabbe 100644 --- a/firmware/include/modes/BlindsMode.h +++ b/firmware/include/modes/BlindsMode.h @@ -21,6 +21,8 @@ class BlindsMode final : public ModeModule public: BlindsMode() : ModeModule("Blinds") {}; + BlindsMode(const BlindsMode &) = delete; + BlindsMode &operator=(const BlindsMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/BlinkMode.h b/firmware/include/modes/BlinkMode.h index 93e884b4..e34f0946 100644 --- a/firmware/include/modes/BlinkMode.h +++ b/firmware/include/modes/BlinkMode.h @@ -14,6 +14,8 @@ class BlinkMode final : public ModeModule public: BlinkMode() : ModeModule("Blink") {}; + BlinkMode(const BlinkMode &) = delete; + BlinkMode &operator=(const BlinkMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/BreakoutClockMode.h b/firmware/include/modes/BreakoutClockMode.h index a173a0ad..66087190 100644 --- a/firmware/include/modes/BreakoutClockMode.h +++ b/firmware/include/modes/BreakoutClockMode.h @@ -32,6 +32,8 @@ class BreakoutClockMode final : public ModeModule public: BreakoutClockMode() : ModeModule("Breakout clock") {}; + BreakoutClockMode(const BreakoutClockMode &) = delete; + BreakoutClockMode &operator=(const BreakoutClockMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/BrightMode.h b/firmware/include/modes/BrightMode.h index 15fec25e..5b72bd6a 100644 --- a/firmware/include/modes/BrightMode.h +++ b/firmware/include/modes/BrightMode.h @@ -11,6 +11,8 @@ class BrightMode final : public ModeModule public: BrightMode() : ModeModule("Bright") {}; + BrightMode(const BrightMode &) = delete; + BrightMode &operator=(const BrightMode &) = delete; void begin() override; }; diff --git a/firmware/include/modes/CircleMode.h b/firmware/include/modes/CircleMode.h index e4d110eb..cfa43757 100644 --- a/firmware/include/modes/CircleMode.h +++ b/firmware/include/modes/CircleMode.h @@ -28,6 +28,8 @@ class CircleMode final : public ModeModule public: CircleMode() : ModeModule("Circle") {}; + CircleMode(const CircleMode &) = delete; + CircleMode &operator=(const CircleMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/CountdownMode.h b/firmware/include/modes/CountdownMode.h index 035eff6d..99d6cf3f 100644 --- a/firmware/include/modes/CountdownMode.h +++ b/firmware/include/modes/CountdownMode.h @@ -24,6 +24,8 @@ class CountdownMode final : public ModeModule public: CountdownMode() : ModeModule("Countdown") {}; + CountdownMode(const CountdownMode &) = delete; + CountdownMode &operator=(const CountdownMode &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/modes/DrawMode.h b/firmware/include/modes/DrawMode.h index c822c6e3..c56b9f78 100644 --- a/firmware/include/modes/DrawMode.h +++ b/firmware/include/modes/DrawMode.h @@ -22,6 +22,8 @@ class DrawMode final : public ModeModule public: DrawMode() : ModeModule("Draw") {}; + DrawMode(const DrawMode &) = delete; + DrawMode &operator=(const DrawMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/EqualizerMode.h b/firmware/include/modes/EqualizerMode.h index d674de4e..c873a4fb 100644 --- a/firmware/include/modes/EqualizerMode.h +++ b/firmware/include/modes/EqualizerMode.h @@ -25,6 +25,8 @@ class EqualizerMode final : public ModeModule public: EqualizerMode() : ModeModule("Equalizer") {}; + EqualizerMode(const EqualizerMode &) = delete; + EqualizerMode &operator=(const EqualizerMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/FireworkMode.h b/firmware/include/modes/FireworkMode.h index 6288ce49..b1ade75b 100644 --- a/firmware/include/modes/FireworkMode.h +++ b/firmware/include/modes/FireworkMode.h @@ -27,6 +27,8 @@ class FireworkMode final : public ModeModule public: FireworkMode() : ModeModule("Firework") {}; + FireworkMode(const FireworkMode &) = delete; + FireworkMode &operator=(const FireworkMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/FliesMode.h b/firmware/include/modes/FliesMode.h index 7e93948b..850a4f0b 100644 --- a/firmware/include/modes/FliesMode.h +++ b/firmware/include/modes/FliesMode.h @@ -27,6 +27,8 @@ class FliesMode final : public ModeModule public: FliesMode() : ModeModule("Flies") {}; + FliesMode(const FliesMode &) = delete; + FliesMode &operator=(const FliesMode &) = delete; void handle() override; void onReceive(const JsonDocument &doc, const char *source) override; diff --git a/firmware/include/modes/GameOfLifeMode.h b/firmware/include/modes/GameOfLifeMode.h index 593a56c2..51adb4b9 100644 --- a/firmware/include/modes/GameOfLifeMode.h +++ b/firmware/include/modes/GameOfLifeMode.h @@ -26,6 +26,8 @@ class GameOfLifeMode final : public ModeModule public: GameOfLifeMode() : ModeModule("Game of Life") {}; + GameOfLifeMode(const GameOfLifeMode &) = delete; + GameOfLifeMode &operator=(const GameOfLifeMode &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/modes/GlitterMode.h b/firmware/include/modes/GlitterMode.h index 597d9d3e..d691d29a 100644 --- a/firmware/include/modes/GlitterMode.h +++ b/firmware/include/modes/GlitterMode.h @@ -11,6 +11,8 @@ class GlitterMode final : public ModeModule public: GlitterMode() : ModeModule("Glitter") {}; + GlitterMode(const GlitterMode &) = delete; + GlitterMode &operator=(const GlitterMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/GoogleWeatherMode.h b/firmware/include/modes/GoogleWeatherMode.h index 46aa5a9a..c1c9d0b3 100644 --- a/firmware/include/modes/GoogleWeatherMode.h +++ b/firmware/include/modes/GoogleWeatherMode.h @@ -114,6 +114,8 @@ class GoogleWeatherMode final : public ModeModule public: GoogleWeatherMode() : ModeModule("Google Weather") {}; + GoogleWeatherMode(const GoogleWeatherMode &) = delete; + GoogleWeatherMode &operator=(const GoogleWeatherMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/HomeAssistantWeatherMode.h b/firmware/include/modes/HomeAssistantWeatherMode.h index bcf9d9e8..a29544bb 100644 --- a/firmware/include/modes/HomeAssistantWeatherMode.h +++ b/firmware/include/modes/HomeAssistantWeatherMode.h @@ -121,6 +121,8 @@ class HomeAssistantWeatherMode final : public ModeModule public: HomeAssistantWeatherMode() : ModeModule("Home Assistant weather") {}; + HomeAssistantWeatherMode(const HomeAssistantWeatherMode &) = delete; + HomeAssistantWeatherMode &operator=(const HomeAssistantWeatherMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/HomeThermometerMode.h b/firmware/include/modes/HomeThermometerMode.h index a743f99a..86d0fccf 100644 --- a/firmware/include/modes/HomeThermometerMode.h +++ b/firmware/include/modes/HomeThermometerMode.h @@ -18,6 +18,8 @@ class HomeThermometerMode final : public ModeModule public: HomeThermometerMode() : ModeModule("Home thermometer") {}; + HomeThermometerMode(const HomeThermometerMode &) = delete; + HomeThermometerMode &operator=(const HomeThermometerMode &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/modes/JaggedWaveformMode.h b/firmware/include/modes/JaggedWaveformMode.h index 13fe4638..9c12ea72 100644 --- a/firmware/include/modes/JaggedWaveformMode.h +++ b/firmware/include/modes/JaggedWaveformMode.h @@ -74,6 +74,8 @@ class JaggedWaveformMode final : public ModeModule public: JaggedWaveformMode() : ModeModule("Jagged waveform") {}; + JaggedWaveformMode(const JaggedWaveformMode &) = delete; + JaggedWaveformMode &operator=(const JaggedWaveformMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/LargeClockMode.h b/firmware/include/modes/LargeClockMode.h index 88dc85c7..47224d63 100644 --- a/firmware/include/modes/LargeClockMode.h +++ b/firmware/include/modes/LargeClockMode.h @@ -32,6 +32,8 @@ class LargeClockMode final : public ModeModule public: LargeClockMode() : ModeModule("Large clock") {}; + LargeClockMode(const LargeClockMode &) = delete; + LargeClockMode &operator=(const LargeClockMode &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/modes/LeafFallMode.h b/firmware/include/modes/LeafFallMode.h index 19eb37ca..8a388654 100644 --- a/firmware/include/modes/LeafFallMode.h +++ b/firmware/include/modes/LeafFallMode.h @@ -24,6 +24,8 @@ class LeafFallMode final : public ModeModule public: LeafFallMode() : ModeModule("Leaf fall") {}; + LeafFallMode(const LeafFallMode &) = delete; + LeafFallMode &operator=(const LeafFallMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/LinesMode.h b/firmware/include/modes/LinesMode.h index b39e7fcf..e5dca603 100644 --- a/firmware/include/modes/LinesMode.h +++ b/firmware/include/modes/LinesMode.h @@ -16,6 +16,8 @@ class LinesMode final : public ModeModule public: LinesMode() : ModeModule("Lines") {}; + LinesMode(const LinesMode &) = delete; + LinesMode &operator=(const LinesMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/MetaballsMode.h b/firmware/include/modes/MetaballsMode.h index 4057d95c..9dde746b 100644 --- a/firmware/include/modes/MetaballsMode.h +++ b/firmware/include/modes/MetaballsMode.h @@ -33,6 +33,8 @@ class MetaballsMode final : public ModeModule public: MetaballsMode() : ModeModule("Metaballs") {}; + MetaballsMode(const MetaballsMode &) = delete; + MetaballsMode &operator=(const MetaballsMode &) = delete; void configure() override; void handle() override; diff --git a/firmware/include/modes/NoiseMode.h b/firmware/include/modes/NoiseMode.h index de172d62..d599818f 100644 --- a/firmware/include/modes/NoiseMode.h +++ b/firmware/include/modes/NoiseMode.h @@ -23,6 +23,8 @@ class NoiseMode final : public ModeModule public: NoiseMode() : ModeModule("Noise") {}; + NoiseMode(const NoiseMode &) = delete; + NoiseMode &operator=(const NoiseMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/OpenMeteoMode.h b/firmware/include/modes/OpenMeteoMode.h index 93a22318..19797ad3 100644 --- a/firmware/include/modes/OpenMeteoMode.h +++ b/firmware/include/modes/OpenMeteoMode.h @@ -79,6 +79,8 @@ class OpenMeteoMode final : public ModeModule public: OpenMeteoMode() : ModeModule("Open-Meteo") {}; + OpenMeteoMode(const OpenMeteoMode &) = delete; + OpenMeteoMode &operator=(const OpenMeteoMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/OpenWeatherMode.h b/firmware/include/modes/OpenWeatherMode.h index 9cf0ba6f..de180def 100644 --- a/firmware/include/modes/OpenWeatherMode.h +++ b/firmware/include/modes/OpenWeatherMode.h @@ -78,6 +78,8 @@ class OpenWeatherMode final : public ModeModule public: OpenWeatherMode() : ModeModule("OpenWeather") {}; + OpenWeatherMode(const OpenWeatherMode &) = delete; + OpenWeatherMode &operator=(const OpenWeatherMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/PingPongMode.h b/firmware/include/modes/PingPongMode.h index 4ee6ebc3..3055bfdf 100644 --- a/firmware/include/modes/PingPongMode.h +++ b/firmware/include/modes/PingPongMode.h @@ -41,6 +41,8 @@ class PingPongMode final : public ModeModule public: PingPongMode() : ModeModule("Ping-pong") {}; + PingPongMode(const PingPongMode &) = delete; + PingPongMode &operator=(const PingPongMode &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/modes/PixelSequenceMode.h b/firmware/include/modes/PixelSequenceMode.h index ec6a8f34..91fe8b8e 100644 --- a/firmware/include/modes/PixelSequenceMode.h +++ b/firmware/include/modes/PixelSequenceMode.h @@ -21,6 +21,8 @@ class PixelSequenceMode final : public ModeModule public: PixelSequenceMode() : ModeModule("Pixel sequence") {}; + PixelSequenceMode(const PixelSequenceMode &) = delete; + PixelSequenceMode &operator=(const PixelSequenceMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/RainMode.h b/firmware/include/modes/RainMode.h index cc01f33d..1ad6e41a 100644 --- a/firmware/include/modes/RainMode.h +++ b/firmware/include/modes/RainMode.h @@ -25,6 +25,8 @@ class RainMode final : public ModeModule public: RainMode() : ModeModule("Rain") {}; + RainMode(const RainMode &) = delete; + RainMode &operator=(const RainMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/RingMode.h b/firmware/include/modes/RingMode.h index 1f7b191b..fe3af05b 100644 --- a/firmware/include/modes/RingMode.h +++ b/firmware/include/modes/RingMode.h @@ -129,6 +129,8 @@ class RingMode final : public ModeModule public: RingMode() : ModeModule("Ring") {}; + RingMode(const RingMode &) = delete; + RingMode &operator=(const RingMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/ScanMode.h b/firmware/include/modes/ScanMode.h index dba486a2..2219f3e8 100644 --- a/firmware/include/modes/ScanMode.h +++ b/firmware/include/modes/ScanMode.h @@ -16,6 +16,8 @@ class ScanMode final : public ModeModule public: ScanMode() : ModeModule("Scan") {}; + ScanMode(const ScanMode &) = delete; + ScanMode &operator=(const ScanMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/SmallClockMode.h b/firmware/include/modes/SmallClockMode.h index 2e53fd99..9d5b9b6e 100644 --- a/firmware/include/modes/SmallClockMode.h +++ b/firmware/include/modes/SmallClockMode.h @@ -24,6 +24,8 @@ class SmallClockMode final : public ModeModule public: SmallClockMode() : ModeModule("Small clock") {}; + SmallClockMode(const SmallClockMode &) = delete; + SmallClockMode &operator=(const SmallClockMode &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/modes/SmoothWaveformMode.h b/firmware/include/modes/SmoothWaveformMode.h index d895f817..738b90b2 100644 --- a/firmware/include/modes/SmoothWaveformMode.h +++ b/firmware/include/modes/SmoothWaveformMode.h @@ -62,6 +62,8 @@ class SmoothWaveformMode final : public ModeModule public: SmoothWaveformMode() : ModeModule("Smooth waveform") {}; + SmoothWaveformMode(const SmoothWaveformMode &) = delete; + SmoothWaveformMode &operator=(const SmoothWaveformMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/SnakeMode.h b/firmware/include/modes/SnakeMode.h index 5b82e4cd..246d42a3 100644 --- a/firmware/include/modes/SnakeMode.h +++ b/firmware/include/modes/SnakeMode.h @@ -51,6 +51,8 @@ class SnakeMode final : public ModeModule public: SnakeMode() : ModeModule("Snake") {} + SnakeMode(const SnakeMode &) = delete; + SnakeMode &operator=(const SnakeMode &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/modes/StarsMode.h b/firmware/include/modes/StarsMode.h index 0beb2f13..62be37e0 100644 --- a/firmware/include/modes/StarsMode.h +++ b/firmware/include/modes/StarsMode.h @@ -25,6 +25,8 @@ class StarsMode final : public ModeModule public: StarsMode() : ModeModule("Stars") {}; + StarsMode(const StarsMode &) = delete; + StarsMode &operator=(const StarsMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/StreamMode.h b/firmware/include/modes/StreamMode.h index d3969357..2ede3e88 100644 --- a/firmware/include/modes/StreamMode.h +++ b/firmware/include/modes/StreamMode.h @@ -26,6 +26,8 @@ class StreamMode final : public ModeModule public: StreamMode() : ModeModule(_name.data()) {}; + StreamMode(const StreamMode &) = delete; + StreamMode &operator=(const StreamMode &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/modes/TickerMode.h b/firmware/include/modes/TickerMode.h index 8bb7f389..b9baff25 100644 --- a/firmware/include/modes/TickerMode.h +++ b/firmware/include/modes/TickerMode.h @@ -38,6 +38,8 @@ class TickerMode final : public ModeModule public: TickerMode() : ModeModule("Ticker") {}; + TickerMode(const TickerMode &) = delete; + TickerMode &operator=(const TickerMode &) = delete; void configure() override; void begin() override; diff --git a/firmware/include/modes/WaveformMode.h b/firmware/include/modes/WaveformMode.h index 6de716cd..1d8421bf 100644 --- a/firmware/include/modes/WaveformMode.h +++ b/firmware/include/modes/WaveformMode.h @@ -119,6 +119,8 @@ class WaveformMode final : public ModeModule public: WaveformMode() : ModeModule("Waveform") {}; + WaveformMode(const WaveformMode &) = delete; + WaveformMode &operator=(const WaveformMode &) = delete; void handle() override; }; diff --git a/firmware/include/modes/WorldWeatherOnlineMode.h b/firmware/include/modes/WorldWeatherOnlineMode.h index d7a5a4fc..9d06fb9c 100644 --- a/firmware/include/modes/WorldWeatherOnlineMode.h +++ b/firmware/include/modes/WorldWeatherOnlineMode.h @@ -66,6 +66,8 @@ class WorldWeatherOnlineMode final : public ModeModule public: WorldWeatherOnlineMode() : ModeModule("World Weather Online") {}; + WorldWeatherOnlineMode(const WorldWeatherOnlineMode &) = delete; + WorldWeatherOnlineMode &operator=(const WorldWeatherOnlineMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/WttrInMode.h b/firmware/include/modes/WttrInMode.h index 679c9519..5e1bd7bf 100644 --- a/firmware/include/modes/WttrInMode.h +++ b/firmware/include/modes/WttrInMode.h @@ -66,6 +66,8 @@ class WttrInMode final : public ModeModule public: WttrInMode() : ModeModule("Wttr.in") {}; + WttrInMode(const WttrInMode &) = delete; + WttrInMode &operator=(const WttrInMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/modes/YrMode.h b/firmware/include/modes/YrMode.h index d7d252bb..d5e6d1e9 100644 --- a/firmware/include/modes/YrMode.h +++ b/firmware/include/modes/YrMode.h @@ -157,6 +157,8 @@ class YrMode final : public ModeModule public: YrMode() : ModeModule("Yr") {}; + YrMode(const YrMode &) = delete; + YrMode &operator=(const YrMode &) = delete; void begin() override; void handle() override; diff --git a/firmware/include/services/ConnectivityService.h b/firmware/include/services/ConnectivityService.h index 639023df..c7ab10b3 100644 --- a/firmware/include/services/ConnectivityService.h +++ b/firmware/include/services/ConnectivityService.h @@ -39,6 +39,9 @@ class ConnectivityService final : public ServiceModule ~ConnectivityService() = default; public: + ConnectivityService(const ConnectivityService &) = delete; + ConnectivityService &operator=(const ConnectivityService &) = delete; + static constexpr std::string_view userAgent = "Frekvens/" VERSION " (ESP32; +https://github.com/VIPnytt/Frekvens)"; void configure(); diff --git a/firmware/include/services/DeviceService.h b/firmware/include/services/DeviceService.h index 6eb811b4..afcac84c 100644 --- a/firmware/include/services/DeviceService.h +++ b/firmware/include/services/DeviceService.h @@ -24,6 +24,9 @@ class DeviceService final : public ServiceModule ~DeviceService() = default; public: + DeviceService(const DeviceService &) = delete; + DeviceService &operator=(const DeviceService &) = delete; + TaskHandle_t taskHandle = nullptr; void begin(); diff --git a/firmware/include/services/DisplayService.h b/firmware/include/services/DisplayService.h index 9863f5bb..49ed62be 100644 --- a/firmware/include/services/DisplayService.h +++ b/firmware/include/services/DisplayService.h @@ -63,6 +63,9 @@ class DisplayService final : public ServiceModule ~DisplayService() = default; public: + DisplayService(const DisplayService &) = delete; + DisplayService &operator=(const DisplayService &) = delete; + hw_timer_t *timer = nullptr; void configure(); diff --git a/firmware/include/services/ExtensionsService.h b/firmware/include/services/ExtensionsService.h index c50695c4..93008ba0 100644 --- a/firmware/include/services/ExtensionsService.h +++ b/firmware/include/services/ExtensionsService.h @@ -91,6 +91,9 @@ class ExtensionsService final : public ServiceModule ~ExtensionsService() = default; public: + ExtensionsService(const ExtensionsService &) = delete; + ExtensionsService &operator=(const ExtensionsService &) = delete; + TaskHandle_t taskHandle = nullptr; static constexpr uint16_t stackSize = 1 << 12; // 4 kB diff --git a/firmware/include/services/FontsService.h b/firmware/include/services/FontsService.h index e7d78d35..a5b95149 100644 --- a/firmware/include/services/FontsService.h +++ b/firmware/include/services/FontsService.h @@ -32,6 +32,9 @@ class FontsService final : public ServiceModule ~FontsService() = default; public: + FontsService(const FontsService &) = delete; + FontsService &operator=(const FontsService &) = delete; + void begin(); [[nodiscard]] const std::vector &getAll() const; diff --git a/firmware/include/services/ModesService.h b/firmware/include/services/ModesService.h index 22b4c75e..2455f0ff 100644 --- a/firmware/include/services/ModesService.h +++ b/firmware/include/services/ModesService.h @@ -194,6 +194,9 @@ class ModesService final : public ServiceModule ~ModesService() = default; public: + ModesService(const ModesService &) = delete; + ModesService &operator=(const ModesService &) = delete; + static constexpr uint16_t stackSize = 1 << 13; // 8 kB ModeModule *mode = nullptr; diff --git a/firmware/include/services/WebServerService.h b/firmware/include/services/WebServerService.h index 9af28e60..aaa9793c 100644 --- a/firmware/include/services/WebServerService.h +++ b/firmware/include/services/WebServerService.h @@ -7,13 +7,16 @@ class WebServerService final : public ServiceModule { private: + WebServerService() : ServiceModule("WebServer") {}; + static void onNotFound(AsyncWebServerRequest *request); protected: ~WebServerService() = default; public: - WebServerService() : ServiceModule("WebServer") {}; + WebServerService(const WebServerService &) = delete; + WebServerService &operator=(const WebServerService &) = delete; AsyncWebServer *http = new AsyncWebServer(80); From c5749d440efbab8a21f250ffa30a6aab2eeade54 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Tue, 3 Feb 2026 01:33:15 +0100 Subject: [PATCH 18/26] WIP --- extra/Python/FontGenerator.py | 5 +---- extra/Python/ModeGenerator.py | 10 ++-------- firmware/include/extensions/AlexaExtension.h | 7 +------ firmware/include/extensions/ButtonExtension.h | 7 +------ firmware/include/extensions/HeapExtension.h | 7 +------ firmware/include/extensions/HomeAssistantExtension.h | 7 +------ firmware/include/extensions/InfraredExtension.h | 7 +------ firmware/include/extensions/MessageExtension.h | 7 +------ firmware/include/extensions/MicrophoneExtension.h | 7 +------ firmware/include/extensions/MqttExtension.h | 7 +------ firmware/include/extensions/OtaExtension.h | 7 +------ firmware/include/extensions/PhotocellExtension.h | 7 +------ firmware/include/extensions/PlaylistExtension.h | 7 +------ firmware/include/extensions/RestfulExtension.h | 7 +------ firmware/include/extensions/RtcExtension.h | 7 +------ .../include/extensions/ServerSentEventsExtension.h | 7 +------ firmware/include/extensions/SignalExtension.h | 7 +------ firmware/include/extensions/WebAppExtension.h | 7 +------ firmware/include/extensions/WebSocketExtension.h | 7 +------ firmware/include/fonts/BrailleFont.h | 7 +------ firmware/include/fonts/LargeFont.h | 7 +------ firmware/include/fonts/MediumBoldFont.h | 7 +------ firmware/include/fonts/MediumFont.h | 7 +------ firmware/include/fonts/MicroFont.h | 7 +------ firmware/include/fonts/MiniFont.h | 7 +------ firmware/include/fonts/SmallFont.h | 7 +------ firmware/include/handlers/BitmapHandler.h | 3 +-- firmware/include/handlers/TextHandler.h | 3 +-- firmware/include/handlers/WeatherHandler.h | 3 +-- firmware/include/modes/AnimationMode.h | 7 +------ firmware/include/modes/ArrowMode.h | 7 +------ firmware/include/modes/BinaryClockMode.h | 7 +------ firmware/include/modes/BinaryEpochMode.h | 7 +------ firmware/include/modes/BlindsMode.h | 7 +------ firmware/include/modes/BlinkMode.h | 7 +------ firmware/include/modes/BreakoutClockMode.h | 7 +------ firmware/include/modes/BrightMode.h | 7 +------ firmware/include/modes/CircleMode.h | 7 +------ firmware/include/modes/CountdownMode.h | 7 +------ firmware/include/modes/DrawMode.h | 7 +------ firmware/include/modes/EqualizerMode.h | 7 +------ firmware/include/modes/FireworkMode.h | 7 +------ firmware/include/modes/FliesMode.h | 7 +------ firmware/include/modes/GameOfLifeMode.h | 7 +------ firmware/include/modes/GlitterMode.h | 7 +------ firmware/include/modes/GoogleWeatherMode.h | 7 +------ firmware/include/modes/HomeAssistantWeatherMode.h | 7 +------ firmware/include/modes/HomeThermometerMode.h | 7 +------ firmware/include/modes/JaggedWaveformMode.h | 7 +------ firmware/include/modes/LargeClockMode.h | 7 +------ firmware/include/modes/LeafFallMode.h | 7 +------ firmware/include/modes/LinesMode.h | 7 +------ firmware/include/modes/MetaballsMode.h | 7 +------ firmware/include/modes/NoiseMode.h | 7 +------ firmware/include/modes/OpenMeteoMode.h | 7 +------ firmware/include/modes/OpenWeatherMode.h | 7 +------ firmware/include/modes/PingPongMode.h | 7 +------ firmware/include/modes/PixelSequenceMode.h | 7 +------ firmware/include/modes/RainMode.h | 7 +------ firmware/include/modes/RingMode.h | 7 +------ firmware/include/modes/ScanMode.h | 7 +------ firmware/include/modes/SmallClockMode.h | 7 +------ firmware/include/modes/SmoothWaveformMode.h | 7 +------ firmware/include/modes/SnakeMode.h | 7 +------ firmware/include/modes/StarsMode.h | 7 +------ firmware/include/modes/StreamMode.h | 7 +------ firmware/include/modes/TickerMode.h | 7 +------ firmware/include/modes/WaveformMode.h | 7 +------ firmware/include/modes/WorldWeatherOnlineMode.h | 7 +------ firmware/include/modes/WttrInMode.h | 7 +------ firmware/include/modes/YrMode.h | 7 +------ firmware/include/modules/ExtensionModule.h | 6 +----- firmware/include/modules/FontModule.h | 6 +----- firmware/include/modules/ModeModule.h | 6 +----- firmware/include/modules/ServiceModule.h | 6 +----- firmware/include/services/ConnectivityService.h | 11 +++-------- firmware/include/services/DeviceService.h | 7 +------ firmware/include/services/DisplayService.h | 7 +------ firmware/include/services/ExtensionsService.h | 7 +------ firmware/include/services/FontsService.h | 7 +------ firmware/include/services/ModesService.h | 7 +------ firmware/include/services/WebServerService.h | 7 +------ firmware/src/handlers/WeatherHandler.cpp | 2 ++ firmware/src/modes/LargeClockMode.cpp | 2 +- firmware/src/modes/MetaballsMode.cpp | 4 ++-- firmware/src/services/DisplayService.cpp | 8 ++++---- 86 files changed, 94 insertions(+), 485 deletions(-) diff --git a/extra/Python/FontGenerator.py b/extra/Python/FontGenerator.py index ef671d2c..38d7db02 100644 --- a/extra/Python/FontGenerator.py +++ b/extra/Python/FontGenerator.py @@ -201,12 +201,9 @@ def _source_h(self, unique: str) -> str: with open(f"{unique}Font.h", "w", encoding="utf-8") as h: font.extend( [ - "", - "protected:", - f" ~{unique}Font() = default;", "", "public:", - f" {unique}Font();", + f" explicit {unique}Font();", "", " [[nodiscard]] Symbol getChar(uint32_t character) const override;", "};", diff --git a/extra/Python/ModeGenerator.py b/extra/Python/ModeGenerator.py index 57c616be..877f201f 100644 --- a/extra/Python/ModeGenerator.py +++ b/extra/Python/ModeGenerator.py @@ -65,11 +65,8 @@ def _animation_h(self) -> str: [ " };", "", - "protected:", - f" ~{self.id}Mode() = default;", - "", "public:", - f' {self.id}Mode() : ModeModule("{self.name}") {{}};', + f' explicit {self.id}Mode() : ModeModule("{self.name}") {{}};', "", " void handle() override;", "};", @@ -147,11 +144,8 @@ def _drawing_h(self) -> str: [ " };", "", - "protected:", - f" ~{self.id}Mode() = default;", - "", "public:", - f' {self.id}Mode() : ModeModule("{self.name}") {{}};', + f' explicit {self.id}Mode() : ModeModule("{self.name}") {{}};', "", " void begin() override;", "};", diff --git a/firmware/include/extensions/AlexaExtension.h b/firmware/include/extensions/AlexaExtension.h index f6e76af6..dbc0c207 100644 --- a/firmware/include/extensions/AlexaExtension.h +++ b/firmware/include/extensions/AlexaExtension.h @@ -16,13 +16,8 @@ class AlexaExtension final : public ExtensionModule static void onSet(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total); static void onSetState(unsigned char deviceId, const char *deviceName, bool state, unsigned char value); -protected: - ~AlexaExtension() = default; - public: - AlexaExtension(); - AlexaExtension(const AlexaExtension &) = delete; - AlexaExtension &operator=(const AlexaExtension &) = delete; + explicit AlexaExtension(); void begin() override; void handle() override; diff --git a/firmware/include/extensions/ButtonExtension.h b/firmware/include/extensions/ButtonExtension.h index 0ce98b7c..ebb1c81e 100644 --- a/firmware/include/extensions/ButtonExtension.h +++ b/firmware/include/extensions/ButtonExtension.h @@ -36,13 +36,8 @@ class ButtonExtension final : public ExtensionModule static void event(const char *key, const char *value); -protected: - ~ButtonExtension() = default; - public: - ButtonExtension(); - ButtonExtension(const ButtonExtension &) = delete; - ButtonExtension &operator=(const ButtonExtension &) = delete; + explicit ButtonExtension(); void configure() override; void handle() override; diff --git a/firmware/include/extensions/HeapExtension.h b/firmware/include/extensions/HeapExtension.h index 3b7943ec..0e0be150 100644 --- a/firmware/include/extensions/HeapExtension.h +++ b/firmware/include/extensions/HeapExtension.h @@ -9,13 +9,8 @@ class HeapExtension final : public ExtensionModule private: unsigned long lastMillis = 0; -protected: - ~HeapExtension() = default; - public: - HeapExtension(); - HeapExtension(const HeapExtension &) = delete; - HeapExtension &operator=(const HeapExtension &) = delete; + explicit HeapExtension(); #if EXTENSION_HOMEASSISTANT void configure() override; diff --git a/firmware/include/extensions/HomeAssistantExtension.h b/firmware/include/extensions/HomeAssistantExtension.h index 11491042..315567d1 100644 --- a/firmware/include/extensions/HomeAssistantExtension.h +++ b/firmware/include/extensions/HomeAssistantExtension.h @@ -18,13 +18,8 @@ class HomeAssistantExtension final : public ExtensionModule void transmit(); -protected: - ~HomeAssistantExtension() = default; - public: - HomeAssistantExtension(); - HomeAssistantExtension(const HomeAssistantExtension &) = delete; - HomeAssistantExtension &operator=(const HomeAssistantExtension &) = delete; + explicit HomeAssistantExtension(); const std::string uniquePrefix = std::format("0x{:x}_", ESP.getEfuseMac()); diff --git a/firmware/include/extensions/InfraredExtension.h b/firmware/include/extensions/InfraredExtension.h index c3da3656..f3955619 100644 --- a/firmware/include/extensions/InfraredExtension.h +++ b/firmware/include/extensions/InfraredExtension.h @@ -128,13 +128,8 @@ class InfraredExtension final : public ExtensionModule void transmit(); -protected: - ~InfraredExtension() = default; - public: - InfraredExtension(); - InfraredExtension(const InfraredExtension &) = delete; - InfraredExtension &operator=(const InfraredExtension &) = delete; + explicit InfraredExtension(); void configure() override; void begin() override; diff --git a/firmware/include/extensions/MessageExtension.h b/firmware/include/extensions/MessageExtension.h index 9f540431..0599bcd0 100644 --- a/firmware/include/extensions/MessageExtension.h +++ b/firmware/include/extensions/MessageExtension.h @@ -38,13 +38,8 @@ class MessageExtension final : public ExtensionModule void transmit(); -protected: - ~MessageExtension() = default; - public: - MessageExtension(); - MessageExtension(const MessageExtension &) = delete; - MessageExtension &operator=(const MessageExtension &) = delete; + explicit MessageExtension(); #if EXTENSION_HOMEASSISTANT void configure() override; diff --git a/firmware/include/extensions/MicrophoneExtension.h b/firmware/include/extensions/MicrophoneExtension.h index 2cd45041..7a2492d6 100644 --- a/firmware/include/extensions/MicrophoneExtension.h +++ b/firmware/include/extensions/MicrophoneExtension.h @@ -20,13 +20,8 @@ class MicrophoneExtension final : public ExtensionModule void transmit(); -protected: - ~MicrophoneExtension() = default; - public: - MicrophoneExtension(); - MicrophoneExtension(const MicrophoneExtension &) = delete; - MicrophoneExtension &operator=(const MicrophoneExtension &) = delete; + explicit MicrophoneExtension(); void configure() override; void begin() override; diff --git a/firmware/include/extensions/MqttExtension.h b/firmware/include/extensions/MqttExtension.h index 23e0a0d4..172c6621 100644 --- a/firmware/include/extensions/MqttExtension.h +++ b/firmware/include/extensions/MqttExtension.h @@ -21,13 +21,8 @@ class MqttExtension final : public ExtensionModule static void onMessage(const espMqttClientTypes::MessageProperties &properties, const char *topic, const uint8_t *payload, size_t len, size_t index, size_t total); -protected: - ~MqttExtension() = default; - public: - MqttExtension(); - MqttExtension(const MqttExtension &) = delete; - MqttExtension &operator=(const MqttExtension &) = delete; + explicit MqttExtension(); espMqttClient client; diff --git a/firmware/include/extensions/OtaExtension.h b/firmware/include/extensions/OtaExtension.h index 6d4877ec..7120cc42 100644 --- a/firmware/include/extensions/OtaExtension.h +++ b/firmware/include/extensions/OtaExtension.h @@ -20,13 +20,8 @@ class OtaExtension final : public ExtensionModule bool final); #endif -protected: - ~OtaExtension() = default; - public: - OtaExtension(); - OtaExtension(const OtaExtension &) = delete; - OtaExtension &operator=(const OtaExtension &) = delete; + explicit OtaExtension(); void configure() override; void begin() override; diff --git a/firmware/include/extensions/PhotocellExtension.h b/firmware/include/extensions/PhotocellExtension.h index 18ae636f..c50c74cb 100644 --- a/firmware/include/extensions/PhotocellExtension.h +++ b/firmware/include/extensions/PhotocellExtension.h @@ -26,13 +26,8 @@ class PhotocellExtension final : public ExtensionModule void transmit(); -protected: - ~PhotocellExtension() = default; - public: - PhotocellExtension(); - PhotocellExtension(const PhotocellExtension &) = delete; - PhotocellExtension &operator=(const PhotocellExtension &) = delete; + explicit PhotocellExtension(); void configure() override; void begin() override; diff --git a/firmware/include/extensions/PlaylistExtension.h b/firmware/include/extensions/PlaylistExtension.h index e0df3f5e..9b932ece 100644 --- a/firmware/include/extensions/PlaylistExtension.h +++ b/firmware/include/extensions/PlaylistExtension.h @@ -9,9 +9,7 @@ class PlaylistExtension final : public ExtensionModule { public: - PlaylistExtension(); - PlaylistExtension(const PlaylistExtension &) = delete; - PlaylistExtension &operator=(const PlaylistExtension &) = delete; + explicit PlaylistExtension(); struct Mode { @@ -28,9 +26,6 @@ class PlaylistExtension final : public ExtensionModule void onReceive(const JsonDocument &doc, const char *source) override; void onTransmit(const JsonDocument &doc, const char *source) override; -protected: - ~PlaylistExtension() = default; - private: bool active = false; diff --git a/firmware/include/extensions/RestfulExtension.h b/firmware/include/extensions/RestfulExtension.h index e580674f..aceb83db 100644 --- a/firmware/include/extensions/RestfulExtension.h +++ b/firmware/include/extensions/RestfulExtension.h @@ -14,13 +14,8 @@ class RestfulExtension final : public ExtensionModule static void onGet(AsyncWebServerRequest *request); static void onPatch(AsyncWebServerRequest *request, const uint8_t *data, size_t len, size_t index, size_t total); -protected: - ~RestfulExtension() = default; - public: - RestfulExtension(); - RestfulExtension(const RestfulExtension &) = delete; - RestfulExtension &operator=(const RestfulExtension &) = delete; + explicit RestfulExtension(); void begin() override; }; diff --git a/firmware/include/extensions/RtcExtension.h b/firmware/include/extensions/RtcExtension.h index 94b7dc76..fc15a392 100644 --- a/firmware/include/extensions/RtcExtension.h +++ b/firmware/include/extensions/RtcExtension.h @@ -32,13 +32,8 @@ class RtcExtension final : public ExtensionModule static void onInterrupt(); #endif -protected: - ~RtcExtension() = default; - public: - RtcExtension(); - RtcExtension(const RtcExtension &) = delete; - RtcExtension &operator=(const RtcExtension &) = delete; + explicit RtcExtension(); #ifdef RTC_DS1307 RtcDS1307 rtc = RtcDS1307(Wire); diff --git a/firmware/include/extensions/ServerSentEventsExtension.h b/firmware/include/extensions/ServerSentEventsExtension.h index fbbfd413..2ec824fe 100644 --- a/firmware/include/extensions/ServerSentEventsExtension.h +++ b/firmware/include/extensions/ServerSentEventsExtension.h @@ -8,13 +8,8 @@ class ServerSentEventsExtension final : public ExtensionModule { -protected: - ~ServerSentEventsExtension() = default; - public: - ServerSentEventsExtension(); - ServerSentEventsExtension(const ServerSentEventsExtension &) = delete; - ServerSentEventsExtension &operator=(const ServerSentEventsExtension &) = delete; + explicit ServerSentEventsExtension(); AsyncEventSource *client = new AsyncEventSource("/server-sent%20events"); diff --git a/firmware/include/extensions/SignalExtension.h b/firmware/include/extensions/SignalExtension.h index bc0fe770..01d5fea9 100644 --- a/firmware/include/extensions/SignalExtension.h +++ b/firmware/include/extensions/SignalExtension.h @@ -21,13 +21,8 @@ class SignalExtension final : public ExtensionModule void setDuration(uint8_t seconds); void transmit(); -protected: - ~SignalExtension() = default; - public: - SignalExtension(); - SignalExtension(const SignalExtension &) = delete; - SignalExtension &operator=(const SignalExtension &) = delete; + explicit SignalExtension(); void begin() override; void handle() override; diff --git a/firmware/include/extensions/WebAppExtension.h b/firmware/include/extensions/WebAppExtension.h index c99eb805..59437c7a 100644 --- a/firmware/include/extensions/WebAppExtension.h +++ b/firmware/include/extensions/WebAppExtension.h @@ -10,13 +10,8 @@ class WebAppExtension final : public ExtensionModule private: static void onHeadRoot(AsyncWebServerRequest *request); -protected: - ~WebAppExtension() = default; - public: - WebAppExtension(); - WebAppExtension(const WebAppExtension &) = delete; - WebAppExtension &operator=(const WebAppExtension &) = delete; + explicit WebAppExtension(); void configure() override; void begin() override; diff --git a/firmware/include/extensions/WebSocketExtension.h b/firmware/include/extensions/WebSocketExtension.h index 4b9b990a..415e5018 100644 --- a/firmware/include/extensions/WebSocketExtension.h +++ b/firmware/include/extensions/WebSocketExtension.h @@ -12,13 +12,8 @@ class WebSocketExtension final : public ExtensionModule static void onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, const uint8_t *data, size_t len); -protected: - ~WebSocketExtension() = default; - public: - WebSocketExtension(); - WebSocketExtension(const WebSocketExtension &) = delete; - WebSocketExtension &operator=(const WebSocketExtension &) = delete; + explicit WebSocketExtension(); AsyncWebSocket *server = new AsyncWebSocket("/websocket"); diff --git a/firmware/include/fonts/BrailleFont.h b/firmware/include/fonts/BrailleFont.h index 4f403a27..ae4b8065 100644 --- a/firmware/include/fonts/BrailleFont.h +++ b/firmware/include/fonts/BrailleFont.h @@ -341,13 +341,8 @@ class BrailleFont final : public FontModule }, }; -protected: - ~BrailleFont() = default; - public: - BrailleFont(); - BrailleFont(const BrailleFont &) = delete; - BrailleFont &operator=(const BrailleFont &) = delete; + explicit BrailleFont(); [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/LargeFont.h b/firmware/include/fonts/LargeFont.h index f20e4696..5b99d111 100644 --- a/firmware/include/fonts/LargeFont.h +++ b/firmware/include/fonts/LargeFont.h @@ -143,13 +143,8 @@ class LargeFont final : public FontModule }, }; -protected: - ~LargeFont() = default; - public: - LargeFont(); - LargeFont(const LargeFont &) = delete; - LargeFont &operator=(const LargeFont &) = delete; + explicit LargeFont(); [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/MediumBoldFont.h b/firmware/include/fonts/MediumBoldFont.h index 1fee42a6..d19ec296 100644 --- a/firmware/include/fonts/MediumBoldFont.h +++ b/firmware/include/fonts/MediumBoldFont.h @@ -260,13 +260,8 @@ class MediumBoldFont final : public FontModule }, }; -protected: - ~MediumBoldFont() = default; - public: - MediumBoldFont(); - MediumBoldFont(const MediumBoldFont &) = delete; - MediumBoldFont &operator=(const MediumBoldFont &) = delete; + explicit MediumBoldFont(); [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/MediumFont.h b/firmware/include/fonts/MediumFont.h index 7b2500b8..63e3daf1 100644 --- a/firmware/include/fonts/MediumFont.h +++ b/firmware/include/fonts/MediumFont.h @@ -260,13 +260,8 @@ class MediumFont final : public FontModule }, }; -protected: - ~MediumFont() = default; - public: - MediumFont(); - MediumFont(const MediumFont &) = delete; - MediumFont &operator=(const MediumFont &) = delete; + explicit MediumFont(); [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/MicroFont.h b/firmware/include/fonts/MicroFont.h index ee463e2b..f83b20b4 100644 --- a/firmware/include/fonts/MicroFont.h +++ b/firmware/include/fonts/MicroFont.h @@ -643,13 +643,8 @@ class MicroFont final : public FontModule }, }; -protected: - ~MicroFont() = default; - public: - MicroFont(); - MicroFont(const MicroFont &) = delete; - MicroFont &operator=(const MicroFont &) = delete; + explicit MicroFont(); [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/MiniFont.h b/firmware/include/fonts/MiniFont.h index 4ed8cc8e..3a92794a 100644 --- a/firmware/include/fonts/MiniFont.h +++ b/firmware/include/fonts/MiniFont.h @@ -869,13 +869,8 @@ class MiniFont final : public FontModule }, }; -protected: - ~MiniFont() = default; - public: - MiniFont(); - MiniFont(const MiniFont &) = delete; - MiniFont &operator=(const MiniFont &) = delete; + explicit MiniFont(); [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/fonts/SmallFont.h b/firmware/include/fonts/SmallFont.h index 5cd30c68..1b264eaf 100644 --- a/firmware/include/fonts/SmallFont.h +++ b/firmware/include/fonts/SmallFont.h @@ -1455,13 +1455,8 @@ class SmallFont final : public FontModule }, }; -protected: - ~SmallFont() = default; - public: - SmallFont(); - SmallFont(const SmallFont &) = delete; - SmallFont &operator=(const SmallFont &) = delete; + explicit SmallFont(); [[nodiscard]] Symbol getChar(uint32_t character) const override; }; diff --git a/firmware/include/handlers/BitmapHandler.h b/firmware/include/handlers/BitmapHandler.h index a4eedced..40a2e4dd 100644 --- a/firmware/include/handlers/BitmapHandler.h +++ b/firmware/include/handlers/BitmapHandler.h @@ -14,8 +14,7 @@ class BitmapHandler uint8_t width = 0; public: - BitmapHandler(std::vector bitmap); - ~BitmapHandler() = default; + explicit BitmapHandler(std::vector bitmap); void draw(uint8_t brightness = UINT8_MAX); void draw(uint8_t x, uint8_t y, uint8_t brightness = UINT8_MAX); diff --git a/firmware/include/handlers/TextHandler.h b/firmware/include/handlers/TextHandler.h index 59eb4fbb..e0289670 100644 --- a/firmware/include/handlers/TextHandler.h +++ b/firmware/include/handlers/TextHandler.h @@ -26,8 +26,7 @@ class TextHandler static const char *encode(uint32_t codepoint, char *out); public: - TextHandler(std::string text, FontModule *font); - ~TextHandler() = default; + explicit TextHandler(std::string text, FontModule *font); void draw(uint8_t brightness = UINT8_MAX); void draw(int16_t x, int8_t y, uint8_t brightness = UINT8_MAX); diff --git a/firmware/include/handlers/WeatherHandler.h b/firmware/include/handlers/WeatherHandler.h index aa53720d..cfe40fb7 100644 --- a/firmware/include/handlers/WeatherHandler.h +++ b/firmware/include/handlers/WeatherHandler.h @@ -6,8 +6,7 @@ class WeatherHandler { public: - WeatherHandler() = default; - ~WeatherHandler() = default; + explicit WeatherHandler(); enum Conditions { diff --git a/firmware/include/modes/AnimationMode.h b/firmware/include/modes/AnimationMode.h index ba734eda..10e2614b 100644 --- a/firmware/include/modes/AnimationMode.h +++ b/firmware/include/modes/AnimationMode.h @@ -24,13 +24,8 @@ class AnimationMode final : public ModeModule void transmit(uint8_t index, const uint8_t frame[GRID_COLUMNS * GRID_ROWS]); -protected: - ~AnimationMode() = default; - public: - AnimationMode() : ModeModule("Animation") {}; - AnimationMode(const AnimationMode &) = delete; - AnimationMode &operator=(const AnimationMode &) = delete; + explicit AnimationMode() : ModeModule("Animation") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/ArrowMode.h b/firmware/include/modes/ArrowMode.h index 5b71693d..9cabe1d5 100644 --- a/firmware/include/modes/ArrowMode.h +++ b/firmware/include/modes/ArrowMode.h @@ -83,13 +83,8 @@ class ArrowMode final : public ModeModule unsigned long lastMillis = 0; -protected: - ~ArrowMode() = default; - public: - ArrowMode() : ModeModule("Arrow") {}; - ArrowMode(const ArrowMode &) = delete; - ArrowMode &operator=(const ArrowMode &) = delete; + explicit ArrowMode() : ModeModule("Arrow") {}; void handle() override; }; diff --git a/firmware/include/modes/BinaryClockMode.h b/firmware/include/modes/BinaryClockMode.h index 56eee021..d4803030 100644 --- a/firmware/include/modes/BinaryClockMode.h +++ b/firmware/include/modes/BinaryClockMode.h @@ -17,13 +17,8 @@ class BinaryClockMode final : public ModeModule void draw(uint8_t col, uint8_t value); -protected: - ~BinaryClockMode() = default; - public: - BinaryClockMode() : ModeModule("Binary clock") {}; - BinaryClockMode(const BinaryClockMode &) = delete; - BinaryClockMode &operator=(const BinaryClockMode &) = delete; + explicit BinaryClockMode() : ModeModule("Binary clock") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/BinaryEpochMode.h b/firmware/include/modes/BinaryEpochMode.h index e2a6df43..437d1ec3 100644 --- a/firmware/include/modes/BinaryEpochMode.h +++ b/firmware/include/modes/BinaryEpochMode.h @@ -9,13 +9,8 @@ class BinaryEpochMode final : public ModeModule private: time_t epoch = 0; -protected: - ~BinaryEpochMode() = default; - public: - BinaryEpochMode() : ModeModule("Binary epoch") {}; - BinaryEpochMode(const BinaryEpochMode &) = delete; - BinaryEpochMode &operator=(const BinaryEpochMode &) = delete; + explicit BinaryEpochMode() : ModeModule("Binary epoch") {}; void handle() override; }; diff --git a/firmware/include/modes/BlindsMode.h b/firmware/include/modes/BlindsMode.h index 2d9cabbe..92f894f8 100644 --- a/firmware/include/modes/BlindsMode.h +++ b/firmware/include/modes/BlindsMode.h @@ -16,13 +16,8 @@ class BlindsMode final : public ModeModule unsigned long lastMillis = 0; -protected: - ~BlindsMode() = default; - public: - BlindsMode() : ModeModule("Blinds") {}; - BlindsMode(const BlindsMode &) = delete; - BlindsMode &operator=(const BlindsMode &) = delete; + explicit BlindsMode() : ModeModule("Blinds") {}; void handle() override; }; diff --git a/firmware/include/modes/BlinkMode.h b/firmware/include/modes/BlinkMode.h index e34f0946..c404a4b7 100644 --- a/firmware/include/modes/BlinkMode.h +++ b/firmware/include/modes/BlinkMode.h @@ -9,13 +9,8 @@ class BlinkMode final : public ModeModule private: unsigned long lastMillis = 0; -protected: - ~BlinkMode() = default; - public: - BlinkMode() : ModeModule("Blink") {}; - BlinkMode(const BlinkMode &) = delete; - BlinkMode &operator=(const BlinkMode &) = delete; + explicit BlinkMode() : ModeModule("Blink") {}; void handle() override; }; diff --git a/firmware/include/modes/BreakoutClockMode.h b/firmware/include/modes/BreakoutClockMode.h index 66087190..91cf299c 100644 --- a/firmware/include/modes/BreakoutClockMode.h +++ b/firmware/include/modes/BreakoutClockMode.h @@ -27,13 +27,8 @@ class BreakoutClockMode final : public ModeModule uint16_t deg = 90; -protected: - ~BreakoutClockMode() = default; - public: - BreakoutClockMode() : ModeModule("Breakout clock") {}; - BreakoutClockMode(const BreakoutClockMode &) = delete; - BreakoutClockMode &operator=(const BreakoutClockMode &) = delete; + explicit BreakoutClockMode() : ModeModule("Breakout clock") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/BrightMode.h b/firmware/include/modes/BrightMode.h index 5b72bd6a..0653450c 100644 --- a/firmware/include/modes/BrightMode.h +++ b/firmware/include/modes/BrightMode.h @@ -6,13 +6,8 @@ class BrightMode final : public ModeModule { -protected: - ~BrightMode() = default; - public: - BrightMode() : ModeModule("Bright") {}; - BrightMode(const BrightMode &) = delete; - BrightMode &operator=(const BrightMode &) = delete; + explicit BrightMode() : ModeModule("Bright") {}; void begin() override; }; diff --git a/firmware/include/modes/CircleMode.h b/firmware/include/modes/CircleMode.h index cfa43757..be449082 100644 --- a/firmware/include/modes/CircleMode.h +++ b/firmware/include/modes/CircleMode.h @@ -23,13 +23,8 @@ class CircleMode final : public ModeModule unsigned long lastMillis = 0; -protected: - ~CircleMode() = default; - public: - CircleMode() : ModeModule("Circle") {}; - CircleMode(const CircleMode &) = delete; - CircleMode &operator=(const CircleMode &) = delete; + explicit CircleMode() : ModeModule("Circle") {}; void handle() override; }; diff --git a/firmware/include/modes/CountdownMode.h b/firmware/include/modes/CountdownMode.h index 99d6cf3f..a11e198d 100644 --- a/firmware/include/modes/CountdownMode.h +++ b/firmware/include/modes/CountdownMode.h @@ -19,13 +19,8 @@ class CountdownMode final : public ModeModule void save(); void transmit(); -protected: - ~CountdownMode() = default; - public: - CountdownMode() : ModeModule("Countdown") {}; - CountdownMode(const CountdownMode &) = delete; - CountdownMode &operator=(const CountdownMode &) = delete; + explicit CountdownMode() : ModeModule("Countdown") {}; void configure() override; void begin() override; diff --git a/firmware/include/modes/DrawMode.h b/firmware/include/modes/DrawMode.h index c56b9f78..2ed04d38 100644 --- a/firmware/include/modes/DrawMode.h +++ b/firmware/include/modes/DrawMode.h @@ -17,13 +17,8 @@ class DrawMode final : public ModeModule void save(bool cache = false); void transmit(); -protected: - ~DrawMode() = default; - public: - DrawMode() : ModeModule("Draw") {}; - DrawMode(const DrawMode &) = delete; - DrawMode &operator=(const DrawMode &) = delete; + explicit DrawMode() : ModeModule("Draw") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/EqualizerMode.h b/firmware/include/modes/EqualizerMode.h index c873a4fb..3d3cfef6 100644 --- a/firmware/include/modes/EqualizerMode.h +++ b/firmware/include/modes/EqualizerMode.h @@ -20,13 +20,8 @@ class EqualizerMode final : public ModeModule unsigned long lastMillis = 0; -protected: - ~EqualizerMode() = default; - public: - EqualizerMode() : ModeModule("Equalizer") {}; - EqualizerMode(const EqualizerMode &) = delete; - EqualizerMode &operator=(const EqualizerMode &) = delete; + explicit EqualizerMode() : ModeModule("Equalizer") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/FireworkMode.h b/firmware/include/modes/FireworkMode.h index b1ade75b..0056acde 100644 --- a/firmware/include/modes/FireworkMode.h +++ b/firmware/include/modes/FireworkMode.h @@ -22,13 +22,8 @@ class FireworkMode final : public ModeModule void exploding(); void fading(); -protected: - ~FireworkMode() = default; - public: - FireworkMode() : ModeModule("Firework") {}; - FireworkMode(const FireworkMode &) = delete; - FireworkMode &operator=(const FireworkMode &) = delete; + explicit FireworkMode() : ModeModule("Firework") {}; void handle() override; }; diff --git a/firmware/include/modes/FliesMode.h b/firmware/include/modes/FliesMode.h index 850a4f0b..7d662252 100644 --- a/firmware/include/modes/FliesMode.h +++ b/firmware/include/modes/FliesMode.h @@ -22,13 +22,8 @@ class FliesMode final : public ModeModule uint8_t drawing[GRID_COLUMNS * GRID_ROWS] = {0}; -protected: - ~FliesMode() = default; - public: - FliesMode() : ModeModule("Flies") {}; - FliesMode(const FliesMode &) = delete; - FliesMode &operator=(const FliesMode &) = delete; + explicit FliesMode() : ModeModule("Flies") {}; void handle() override; void onReceive(const JsonDocument &doc, const char *source) override; diff --git a/firmware/include/modes/GameOfLifeMode.h b/firmware/include/modes/GameOfLifeMode.h index 51adb4b9..8f59997b 100644 --- a/firmware/include/modes/GameOfLifeMode.h +++ b/firmware/include/modes/GameOfLifeMode.h @@ -21,13 +21,8 @@ class GameOfLifeMode final : public ModeModule void setClock(bool _clock); void transmit(); -protected: - ~GameOfLifeMode() = default; - public: - GameOfLifeMode() : ModeModule("Game of Life") {}; - GameOfLifeMode(const GameOfLifeMode &) = delete; - GameOfLifeMode &operator=(const GameOfLifeMode &) = delete; + explicit GameOfLifeMode() : ModeModule("Game of Life") {}; void configure() override; void begin() override; diff --git a/firmware/include/modes/GlitterMode.h b/firmware/include/modes/GlitterMode.h index d691d29a..442961d6 100644 --- a/firmware/include/modes/GlitterMode.h +++ b/firmware/include/modes/GlitterMode.h @@ -6,13 +6,8 @@ class GlitterMode final : public ModeModule { -protected: - ~GlitterMode() = default; - public: - GlitterMode() : ModeModule("Glitter") {}; - GlitterMode(const GlitterMode &) = delete; - GlitterMode &operator=(const GlitterMode &) = delete; + explicit GlitterMode() : ModeModule("Glitter") {}; void handle() override; }; diff --git a/firmware/include/modes/GoogleWeatherMode.h b/firmware/include/modes/GoogleWeatherMode.h index c1c9d0b3..24eb2d01 100644 --- a/firmware/include/modes/GoogleWeatherMode.h +++ b/firmware/include/modes/GoogleWeatherMode.h @@ -109,13 +109,8 @@ class GoogleWeatherMode final : public ModeModule void update(); -protected: - ~GoogleWeatherMode() = default; - public: - GoogleWeatherMode() : ModeModule("Google Weather") {}; - GoogleWeatherMode(const GoogleWeatherMode &) = delete; - GoogleWeatherMode &operator=(const GoogleWeatherMode &) = delete; + explicit GoogleWeatherMode() : ModeModule("Google Weather") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/HomeAssistantWeatherMode.h b/firmware/include/modes/HomeAssistantWeatherMode.h index a29544bb..11d302e5 100644 --- a/firmware/include/modes/HomeAssistantWeatherMode.h +++ b/firmware/include/modes/HomeAssistantWeatherMode.h @@ -116,13 +116,8 @@ class HomeAssistantWeatherMode final : public ModeModule void update(); -protected: - ~HomeAssistantWeatherMode() = default; - public: - HomeAssistantWeatherMode() : ModeModule("Home Assistant weather") {}; - HomeAssistantWeatherMode(const HomeAssistantWeatherMode &) = delete; - HomeAssistantWeatherMode &operator=(const HomeAssistantWeatherMode &) = delete; + explicit HomeAssistantWeatherMode() : ModeModule("Home Assistant weather") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/HomeThermometerMode.h b/firmware/include/modes/HomeThermometerMode.h index 86d0fccf..0dc2bd2e 100644 --- a/firmware/include/modes/HomeThermometerMode.h +++ b/firmware/include/modes/HomeThermometerMode.h @@ -13,13 +13,8 @@ class HomeThermometerMode final : public ModeModule void setTemperature(const char *where, int16_t temperature); void transmit(); -protected: - ~HomeThermometerMode() = default; - public: - HomeThermometerMode() : ModeModule("Home thermometer") {}; - HomeThermometerMode(const HomeThermometerMode &) = delete; - HomeThermometerMode &operator=(const HomeThermometerMode &) = delete; + explicit HomeThermometerMode() : ModeModule("Home thermometer") {}; void configure() override; void begin() override; diff --git a/firmware/include/modes/JaggedWaveformMode.h b/firmware/include/modes/JaggedWaveformMode.h index 9c12ea72..dc69a990 100644 --- a/firmware/include/modes/JaggedWaveformMode.h +++ b/firmware/include/modes/JaggedWaveformMode.h @@ -69,13 +69,8 @@ class JaggedWaveformMode final : public ModeModule }, }; -protected: - ~JaggedWaveformMode() = default; - public: - JaggedWaveformMode() : ModeModule("Jagged waveform") {}; - JaggedWaveformMode(const JaggedWaveformMode &) = delete; - JaggedWaveformMode &operator=(const JaggedWaveformMode &) = delete; + explicit JaggedWaveformMode() : ModeModule("Jagged waveform") {}; void handle() override; }; diff --git a/firmware/include/modes/LargeClockMode.h b/firmware/include/modes/LargeClockMode.h index 47224d63..69ec4457 100644 --- a/firmware/include/modes/LargeClockMode.h +++ b/firmware/include/modes/LargeClockMode.h @@ -27,13 +27,8 @@ class LargeClockMode final : public ModeModule void setTicking(bool _ticking); void transmit(); -protected: - ~LargeClockMode() = default; - public: - LargeClockMode() : ModeModule("Large clock") {}; - LargeClockMode(const LargeClockMode &) = delete; - LargeClockMode &operator=(const LargeClockMode &) = delete; + explicit LargeClockMode() : ModeModule("Large clock") {}; void configure() override; void begin() override; diff --git a/firmware/include/modes/LeafFallMode.h b/firmware/include/modes/LeafFallMode.h index 8a388654..711b703e 100644 --- a/firmware/include/modes/LeafFallMode.h +++ b/firmware/include/modes/LeafFallMode.h @@ -19,13 +19,8 @@ class LeafFallMode final : public ModeModule Leaf leaves[GRID_COLUMNS * GRID_ROWS / 20]; -protected: - ~LeafFallMode() = default; - public: - LeafFallMode() : ModeModule("Leaf fall") {}; - LeafFallMode(const LeafFallMode &) = delete; - LeafFallMode &operator=(const LeafFallMode &) = delete; + explicit LeafFallMode() : ModeModule("Leaf fall") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/LinesMode.h b/firmware/include/modes/LinesMode.h index e5dca603..0c55e3df 100644 --- a/firmware/include/modes/LinesMode.h +++ b/firmware/include/modes/LinesMode.h @@ -11,13 +11,8 @@ class LinesMode final : public ModeModule unsigned long lastMillis = 0; -protected: - ~LinesMode() = default; - public: - LinesMode() : ModeModule("Lines") {}; - LinesMode(const LinesMode &) = delete; - LinesMode &operator=(const LinesMode &) = delete; + explicit LinesMode() : ModeModule("Lines") {}; void handle() override; }; diff --git a/firmware/include/modes/MetaballsMode.h b/firmware/include/modes/MetaballsMode.h index 9dde746b..a13864d2 100644 --- a/firmware/include/modes/MetaballsMode.h +++ b/firmware/include/modes/MetaballsMode.h @@ -28,13 +28,8 @@ class MetaballsMode final : public ModeModule Ball balls[GRID_COLUMNS * GRID_ROWS / (1 << 6)] = {}; -protected: - ~MetaballsMode() = default; - public: - MetaballsMode() : ModeModule("Metaballs") {}; - MetaballsMode(const MetaballsMode &) = delete; - MetaballsMode &operator=(const MetaballsMode &) = delete; + explicit MetaballsMode() : ModeModule("Metaballs") {}; void configure() override; void handle() override; diff --git a/firmware/include/modes/NoiseMode.h b/firmware/include/modes/NoiseMode.h index d599818f..d2a9869e 100644 --- a/firmware/include/modes/NoiseMode.h +++ b/firmware/include/modes/NoiseMode.h @@ -18,13 +18,8 @@ class NoiseMode final : public ModeModule Dot dots[GRID_COLUMNS * GRID_ROWS / 9]; -protected: - ~NoiseMode() = default; - public: - NoiseMode() : ModeModule("Noise") {}; - NoiseMode(const NoiseMode &) = delete; - NoiseMode &operator=(const NoiseMode &) = delete; + explicit NoiseMode() : ModeModule("Noise") {}; void handle() override; }; diff --git a/firmware/include/modes/OpenMeteoMode.h b/firmware/include/modes/OpenMeteoMode.h index 19797ad3..2abb0cfd 100644 --- a/firmware/include/modes/OpenMeteoMode.h +++ b/firmware/include/modes/OpenMeteoMode.h @@ -74,13 +74,8 @@ class OpenMeteoMode final : public ModeModule void update(); -protected: - ~OpenMeteoMode() = default; - public: - OpenMeteoMode() : ModeModule("Open-Meteo") {}; - OpenMeteoMode(const OpenMeteoMode &) = delete; - OpenMeteoMode &operator=(const OpenMeteoMode &) = delete; + explicit OpenMeteoMode() : ModeModule("Open-Meteo") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/OpenWeatherMode.h b/firmware/include/modes/OpenWeatherMode.h index de180def..5f8252a7 100644 --- a/firmware/include/modes/OpenWeatherMode.h +++ b/firmware/include/modes/OpenWeatherMode.h @@ -73,13 +73,8 @@ class OpenWeatherMode final : public ModeModule void update(); -protected: - ~OpenWeatherMode() = default; - public: - OpenWeatherMode() : ModeModule("OpenWeather") {}; - OpenWeatherMode(const OpenWeatherMode &) = delete; - OpenWeatherMode &operator=(const OpenWeatherMode &) = delete; + explicit OpenWeatherMode() : ModeModule("OpenWeather") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/PingPongMode.h b/firmware/include/modes/PingPongMode.h index 3055bfdf..c18b838e 100644 --- a/firmware/include/modes/PingPongMode.h +++ b/firmware/include/modes/PingPongMode.h @@ -36,13 +36,8 @@ class PingPongMode final : public ModeModule void setClock(bool _clock); void transmit(); -protected: - ~PingPongMode() = default; - public: - PingPongMode() : ModeModule("Ping-pong") {}; - PingPongMode(const PingPongMode &) = delete; - PingPongMode &operator=(const PingPongMode &) = delete; + explicit PingPongMode() : ModeModule("Ping-pong") {}; void configure() override; void begin() override; diff --git a/firmware/include/modes/PixelSequenceMode.h b/firmware/include/modes/PixelSequenceMode.h index 91fe8b8e..15b27c05 100644 --- a/firmware/include/modes/PixelSequenceMode.h +++ b/firmware/include/modes/PixelSequenceMode.h @@ -16,13 +16,8 @@ class PixelSequenceMode final : public ModeModule unsigned long lastMillis = 0; -protected: - ~PixelSequenceMode() = default; - public: - PixelSequenceMode() : ModeModule("Pixel sequence") {}; - PixelSequenceMode(const PixelSequenceMode &) = delete; - PixelSequenceMode &operator=(const PixelSequenceMode &) = delete; + explicit PixelSequenceMode() : ModeModule("Pixel sequence") {}; void handle() override; }; diff --git a/firmware/include/modes/RainMode.h b/firmware/include/modes/RainMode.h index 1ad6e41a..8916f906 100644 --- a/firmware/include/modes/RainMode.h +++ b/firmware/include/modes/RainMode.h @@ -20,13 +20,8 @@ class RainMode final : public ModeModule Drop drops[GRID_COLUMNS / 3]; -protected: - ~RainMode() = default; - public: - RainMode() : ModeModule("Rain") {}; - RainMode(const RainMode &) = delete; - RainMode &operator=(const RainMode &) = delete; + explicit RainMode() : ModeModule("Rain") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/RingMode.h b/firmware/include/modes/RingMode.h index fe3af05b..6487c5c8 100644 --- a/firmware/include/modes/RingMode.h +++ b/firmware/include/modes/RingMode.h @@ -124,13 +124,8 @@ class RingMode final : public ModeModule }, }; -protected: - ~RingMode() = default; - public: - RingMode() : ModeModule("Ring") {}; - RingMode(const RingMode &) = delete; - RingMode &operator=(const RingMode &) = delete; + explicit RingMode() : ModeModule("Ring") {}; void handle() override; }; diff --git a/firmware/include/modes/ScanMode.h b/firmware/include/modes/ScanMode.h index 2219f3e8..4016056a 100644 --- a/firmware/include/modes/ScanMode.h +++ b/firmware/include/modes/ScanMode.h @@ -11,13 +11,8 @@ class ScanMode final : public ModeModule unsigned long lastMillis = 0; -protected: - ~ScanMode() = default; - public: - ScanMode() : ModeModule("Scan") {}; - ScanMode(const ScanMode &) = delete; - ScanMode &operator=(const ScanMode &) = delete; + explicit ScanMode() : ModeModule("Scan") {}; void handle() override; }; diff --git a/firmware/include/modes/SmallClockMode.h b/firmware/include/modes/SmallClockMode.h index 9d5b9b6e..e338d413 100644 --- a/firmware/include/modes/SmallClockMode.h +++ b/firmware/include/modes/SmallClockMode.h @@ -19,13 +19,8 @@ class SmallClockMode final : public ModeModule void setTicking(bool _ticking); void transmit(); -protected: - ~SmallClockMode() = default; - public: - SmallClockMode() : ModeModule("Small clock") {}; - SmallClockMode(const SmallClockMode &) = delete; - SmallClockMode &operator=(const SmallClockMode &) = delete; + explicit SmallClockMode() : ModeModule("Small clock") {}; void configure() override; void begin() override; diff --git a/firmware/include/modes/SmoothWaveformMode.h b/firmware/include/modes/SmoothWaveformMode.h index 738b90b2..408a55cd 100644 --- a/firmware/include/modes/SmoothWaveformMode.h +++ b/firmware/include/modes/SmoothWaveformMode.h @@ -57,13 +57,8 @@ class SmoothWaveformMode final : public ModeModule }, }; -protected: - ~SmoothWaveformMode() = default; - public: - SmoothWaveformMode() : ModeModule("Smooth waveform") {}; - SmoothWaveformMode(const SmoothWaveformMode &) = delete; - SmoothWaveformMode &operator=(const SmoothWaveformMode &) = delete; + explicit SmoothWaveformMode() : ModeModule("Smooth waveform") {}; void handle() override; }; diff --git a/firmware/include/modes/SnakeMode.h b/firmware/include/modes/SnakeMode.h index 246d42a3..0d371c62 100644 --- a/firmware/include/modes/SnakeMode.h +++ b/firmware/include/modes/SnakeMode.h @@ -46,13 +46,8 @@ class SnakeMode final : public ModeModule void setDot(); void transmit(); -protected: - ~SnakeMode() = default; - public: - SnakeMode() : ModeModule("Snake") {} - SnakeMode(const SnakeMode &) = delete; - SnakeMode &operator=(const SnakeMode &) = delete; + explicit SnakeMode() : ModeModule("Snake") {} void configure() override; void begin() override; diff --git a/firmware/include/modes/StarsMode.h b/firmware/include/modes/StarsMode.h index 62be37e0..18342fb4 100644 --- a/firmware/include/modes/StarsMode.h +++ b/firmware/include/modes/StarsMode.h @@ -20,13 +20,8 @@ class StarsMode final : public ModeModule Star stars[GRID_COLUMNS * GRID_ROWS / (1 << 4)]; -protected: - ~StarsMode() = default; - public: - StarsMode() : ModeModule("Stars") {}; - StarsMode(const StarsMode &) = delete; - StarsMode &operator=(const StarsMode &) = delete; + explicit StarsMode() : ModeModule("Stars") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/StreamMode.h b/firmware/include/modes/StreamMode.h index 2ede3e88..59a88549 100644 --- a/firmware/include/modes/StreamMode.h +++ b/firmware/include/modes/StreamMode.h @@ -21,13 +21,8 @@ class StreamMode final : public ModeModule static void onPacket(AsyncUDPPacket packet); -protected: - ~StreamMode() = default; - public: - StreamMode() : ModeModule(_name.data()) {}; - StreamMode(const StreamMode &) = delete; - StreamMode &operator=(const StreamMode &) = delete; + explicit StreamMode() : ModeModule(_name.data()) {}; void configure() override; void begin() override; diff --git a/firmware/include/modes/TickerMode.h b/firmware/include/modes/TickerMode.h index b9baff25..08596678 100644 --- a/firmware/include/modes/TickerMode.h +++ b/firmware/include/modes/TickerMode.h @@ -33,13 +33,8 @@ class TickerMode final : public ModeModule void transmit(); -protected: - ~TickerMode() = default; - public: - TickerMode() : ModeModule("Ticker") {}; - TickerMode(const TickerMode &) = delete; - TickerMode &operator=(const TickerMode &) = delete; + explicit TickerMode() : ModeModule("Ticker") {}; void configure() override; void begin() override; diff --git a/firmware/include/modes/WaveformMode.h b/firmware/include/modes/WaveformMode.h index 1d8421bf..3e2f1ac8 100644 --- a/firmware/include/modes/WaveformMode.h +++ b/firmware/include/modes/WaveformMode.h @@ -114,13 +114,8 @@ class WaveformMode final : public ModeModule }, }; -protected: - ~WaveformMode() = default; - public: - WaveformMode() : ModeModule("Waveform") {}; - WaveformMode(const WaveformMode &) = delete; - WaveformMode &operator=(const WaveformMode &) = delete; + explicit WaveformMode() : ModeModule("Waveform") {}; void handle() override; }; diff --git a/firmware/include/modes/WorldWeatherOnlineMode.h b/firmware/include/modes/WorldWeatherOnlineMode.h index 9d06fb9c..5926e62c 100644 --- a/firmware/include/modes/WorldWeatherOnlineMode.h +++ b/firmware/include/modes/WorldWeatherOnlineMode.h @@ -61,13 +61,8 @@ class WorldWeatherOnlineMode final : public ModeModule void update(); -protected: - ~WorldWeatherOnlineMode() = default; - public: - WorldWeatherOnlineMode() : ModeModule("World Weather Online") {}; - WorldWeatherOnlineMode(const WorldWeatherOnlineMode &) = delete; - WorldWeatherOnlineMode &operator=(const WorldWeatherOnlineMode &) = delete; + explicit WorldWeatherOnlineMode() : ModeModule("World Weather Online") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/WttrInMode.h b/firmware/include/modes/WttrInMode.h index 5e1bd7bf..37b58388 100644 --- a/firmware/include/modes/WttrInMode.h +++ b/firmware/include/modes/WttrInMode.h @@ -61,13 +61,8 @@ class WttrInMode final : public ModeModule void update(); -protected: - ~WttrInMode() = default; - public: - WttrInMode() : ModeModule("Wttr.in") {}; - WttrInMode(const WttrInMode &) = delete; - WttrInMode &operator=(const WttrInMode &) = delete; + explicit WttrInMode() : ModeModule("Wttr.in") {}; void begin() override; void handle() override; diff --git a/firmware/include/modes/YrMode.h b/firmware/include/modes/YrMode.h index d5e6d1e9..1cc8b21d 100644 --- a/firmware/include/modes/YrMode.h +++ b/firmware/include/modes/YrMode.h @@ -152,13 +152,8 @@ class YrMode final : public ModeModule void update(); -protected: - ~YrMode() = default; - public: - YrMode() : ModeModule("Yr") {}; - YrMode(const YrMode &) = delete; - YrMode &operator=(const YrMode &) = delete; + explicit YrMode() : ModeModule("Yr") {}; void begin() override; void handle() override; diff --git a/firmware/include/modules/ExtensionModule.h b/firmware/include/modules/ExtensionModule.h index 358a52a9..f3b40805 100644 --- a/firmware/include/modules/ExtensionModule.h +++ b/firmware/include/modules/ExtensionModule.h @@ -5,13 +5,9 @@ class ExtensionModule { protected: - ExtensionModule(const char *const name) : name(name) {}; - ~ExtensionModule() = default; + explicit ExtensionModule(const char *const name) : name(name) {}; public: - ExtensionModule(const ExtensionModule &) = delete; - ExtensionModule &operator=(const ExtensionModule &) = delete; - const char *const name; virtual void configure(); diff --git a/firmware/include/modules/FontModule.h b/firmware/include/modules/FontModule.h index 8a33de5a..86f5bc5c 100644 --- a/firmware/include/modules/FontModule.h +++ b/firmware/include/modules/FontModule.h @@ -6,13 +6,9 @@ class FontModule { protected: - FontModule(const char *const name) : name(name) {}; - ~FontModule() = default; + explicit FontModule(const char *const name) : name(name) {}; public: - FontModule(const FontModule &) = delete; - FontModule &operator=(const FontModule &) = delete; - struct Symbol { const std::vector bitmap = {}; diff --git a/firmware/include/modules/ModeModule.h b/firmware/include/modules/ModeModule.h index 35142ceb..f420d984 100644 --- a/firmware/include/modules/ModeModule.h +++ b/firmware/include/modules/ModeModule.h @@ -5,13 +5,9 @@ class ModeModule { protected: - ModeModule(const char *const name) : name(name) {}; - ~ModeModule() = default; + explicit ModeModule(const char *const name) : name(name) {}; public: - ModeModule(const ModeModule &) = delete; - ModeModule &operator=(const ModeModule &) = delete; - const char *const name; virtual void configure(); diff --git a/firmware/include/modules/ServiceModule.h b/firmware/include/modules/ServiceModule.h index bcbc4470..da2b0e14 100644 --- a/firmware/include/modules/ServiceModule.h +++ b/firmware/include/modules/ServiceModule.h @@ -5,13 +5,9 @@ class ServiceModule { protected: - ServiceModule(const char *const name) : name(name) {}; - ~ServiceModule() = default; + explicit ServiceModule(const char *const name) : name(name) {}; public: - ServiceModule(const ServiceModule &) = delete; - ServiceModule &operator=(const ServiceModule &) = delete; - const char *const name; virtual void onReceive(const JsonDocument &doc, const char *source); diff --git a/firmware/include/services/ConnectivityService.h b/firmware/include/services/ConnectivityService.h index c7ab10b3..cf168e52 100644 --- a/firmware/include/services/ConnectivityService.h +++ b/firmware/include/services/ConnectivityService.h @@ -9,10 +9,6 @@ class ConnectivityService final : public ServiceModule { private: - static constexpr std::string_view _name = "Connectivity"; - - ConnectivityService() : ServiceModule(_name.data()) {}; - bool mDNS = false; bool pending = false; bool routable = false; @@ -36,12 +32,11 @@ class ConnectivityService final : public ServiceModule static void onScan(WiFiEvent_t event, WiFiEventInfo_t info); protected: - ~ConnectivityService() = default; + static constexpr std::string_view _name = "Connectivity"; -public: - ConnectivityService(const ConnectivityService &) = delete; - ConnectivityService &operator=(const ConnectivityService &) = delete; + explicit ConnectivityService() : ServiceModule(_name.data()) {}; +public: static constexpr std::string_view userAgent = "Frekvens/" VERSION " (ESP32; +https://github.com/VIPnytt/Frekvens)"; void configure(); diff --git a/firmware/include/services/DeviceService.h b/firmware/include/services/DeviceService.h index afcac84c..443db0eb 100644 --- a/firmware/include/services/DeviceService.h +++ b/firmware/include/services/DeviceService.h @@ -8,8 +8,6 @@ class DeviceService final : public ServiceModule { private: - DeviceService() : ServiceModule("Device") {}; - bool operational = false; unsigned long lastMillis = 0; @@ -21,12 +19,9 @@ class DeviceService final : public ServiceModule void onReceive(const JsonDocument &doc, const char *source) override; protected: - ~DeviceService() = default; + explicit DeviceService() : ServiceModule("Device") {}; public: - DeviceService(const DeviceService &) = delete; - DeviceService &operator=(const DeviceService &) = delete; - TaskHandle_t taskHandle = nullptr; void begin(); diff --git a/firmware/include/services/DisplayService.h b/firmware/include/services/DisplayService.h index 49ed62be..ac95bd16 100644 --- a/firmware/include/services/DisplayService.h +++ b/firmware/include/services/DisplayService.h @@ -8,8 +8,6 @@ class DisplayService final : public ServiceModule { private: - DisplayService() : ServiceModule("Display") {}; - #ifdef FRAME_RATE static constexpr uint8_t frameRate = FRAME_RATE; #else @@ -60,12 +58,9 @@ class DisplayService final : public ServiceModule static IRAM_ATTR void onTimer(); protected: - ~DisplayService() = default; + explicit DisplayService() : ServiceModule("Display") {}; public: - DisplayService(const DisplayService &) = delete; - DisplayService &operator=(const DisplayService &) = delete; - hw_timer_t *timer = nullptr; void configure(); diff --git a/firmware/include/services/ExtensionsService.h b/firmware/include/services/ExtensionsService.h index 93008ba0..fa46afca 100644 --- a/firmware/include/services/ExtensionsService.h +++ b/firmware/include/services/ExtensionsService.h @@ -25,8 +25,6 @@ class ExtensionsService final : public ServiceModule { private: - ExtensionsService() : ServiceModule("Extensions") {}; - const std::vector modules = { #if EXTENSION_ALEXA new AlexaExtension(), @@ -88,12 +86,9 @@ class ExtensionsService final : public ServiceModule static void onTask(void *parameter = nullptr); protected: - ~ExtensionsService() = default; + explicit ExtensionsService() : ServiceModule("Extensions") {}; public: - ExtensionsService(const ExtensionsService &) = delete; - ExtensionsService &operator=(const ExtensionsService &) = delete; - TaskHandle_t taskHandle = nullptr; static constexpr uint16_t stackSize = 1 << 12; // 4 kB diff --git a/firmware/include/services/FontsService.h b/firmware/include/services/FontsService.h index a5b95149..2f96edea 100644 --- a/firmware/include/services/FontsService.h +++ b/firmware/include/services/FontsService.h @@ -12,8 +12,6 @@ class FontsService final : public ServiceModule { private: - FontsService() : ServiceModule("Fonts") {}; - const std::vector modules = { #if FONT_BRAILLE new BrailleFont(), @@ -29,12 +27,9 @@ class FontsService final : public ServiceModule void transmit(); protected: - ~FontsService() = default; + explicit FontsService() : ServiceModule("Fonts") {}; public: - FontsService(const FontsService &) = delete; - FontsService &operator=(const FontsService &) = delete; - void begin(); [[nodiscard]] const std::vector &getAll() const; diff --git a/firmware/include/services/ModesService.h b/firmware/include/services/ModesService.h index 2455f0ff..3160e973 100644 --- a/firmware/include/services/ModesService.h +++ b/firmware/include/services/ModesService.h @@ -50,8 +50,6 @@ class ModesService final : public ServiceModule { private: - ModesService() : ServiceModule("Modes") {}; - const std::vector modes = { #if MODE_ANIMATION new AnimationMode(), @@ -191,12 +189,9 @@ class ModesService final : public ServiceModule static void onTask(void *parameter = nullptr); protected: - ~ModesService() = default; + explicit ModesService() : ServiceModule("Modes") {}; public: - ModesService(const ModesService &) = delete; - ModesService &operator=(const ModesService &) = delete; - static constexpr uint16_t stackSize = 1 << 13; // 8 kB ModeModule *mode = nullptr; diff --git a/firmware/include/services/WebServerService.h b/firmware/include/services/WebServerService.h index aaa9793c..f53b78af 100644 --- a/firmware/include/services/WebServerService.h +++ b/firmware/include/services/WebServerService.h @@ -7,17 +7,12 @@ class WebServerService final : public ServiceModule { private: - WebServerService() : ServiceModule("WebServer") {}; - static void onNotFound(AsyncWebServerRequest *request); protected: - ~WebServerService() = default; + explicit WebServerService() : ServiceModule("WebServer") {}; public: - WebServerService(const WebServerService &) = delete; - WebServerService &operator=(const WebServerService &) = delete; - AsyncWebServer *http = new AsyncWebServer(80); void configure() const; diff --git a/firmware/src/handlers/WeatherHandler.cpp b/firmware/src/handlers/WeatherHandler.cpp index 34088859..d437a655 100644 --- a/firmware/src/handlers/WeatherHandler.cpp +++ b/firmware/src/handlers/WeatherHandler.cpp @@ -7,6 +7,8 @@ #include "services/DisplayService.h" #include "services/FontsService.h" +WeatherHandler::WeatherHandler() {} + void WeatherHandler::parse(std::string code, std::vector codesets) { for (const WeatherHandler::Codeset codeset : codesets) diff --git a/firmware/src/modes/LargeClockMode.cpp b/firmware/src/modes/LargeClockMode.cpp index 6fd14c44..54982971 100644 --- a/firmware/src/modes/LargeClockMode.cpp +++ b/firmware/src/modes/LargeClockMode.cpp @@ -112,7 +112,7 @@ void LargeClockMode::handle() } { TextHandler m2 = TextHandler(std::to_string(minute % 10), font); - m2.draw(GRID_COLUMNS / 2 + 1 + ((7 - m2.getWidth()) / 2), + m2.draw((GRID_COLUMNS / 2) + 1 + ((7 - m2.getWidth()) / 2), (GRID_ROWS / 2) + 1 + ((7 - m2.getHeight()) / 2)); } pending = false; diff --git a/firmware/src/modes/MetaballsMode.cpp b/firmware/src/modes/MetaballsMode.cpp index b14a9ec5..c76f59ed 100644 --- a/firmware/src/modes/MetaballsMode.cpp +++ b/firmware/src/modes/MetaballsMode.cpp @@ -27,9 +27,9 @@ void MetaballsMode::handle() #endif // EXTENSION_MICROPHONE { const bool rotated = (Display.getOrientation() % 2) != 0; - const float xRatio = 2.0f * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / + const float xRatio = 2.0f * static_cast(rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / static_cast(PITCH_VERTICAL + PITCH_HORIZONTAL); - const float yRatio = 2.0f * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / + const float yRatio = 2.0f * static_cast(rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / static_cast(PITCH_VERTICAL + PITCH_HORIZONTAL); for (const Ball &ball : balls) { diff --git a/firmware/src/services/DisplayService.cpp b/firmware/src/services/DisplayService.cpp index 80d35471..82315767 100644 --- a/firmware/src/services/DisplayService.cpp +++ b/firmware/src/services/DisplayService.cpp @@ -322,10 +322,10 @@ void DisplayService::setPixel(uint8_t x, uint8_t y, uint8_t brightness) void DisplayService::drawEllipse(float x, float y, float radius, float ratio, bool fill, uint8_t brightness) { const bool rotated = (orientation % 2) != 0; - const float xRatio = - 2.0f * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); - const float yRatio = - 2.0f * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); + const float xRatio = 2.0f * static_cast(rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / + (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); + const float yRatio = 2.0f * static_cast(rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / + (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); const uint8_t xMax = min(GRID_COLUMNS - 1, ceilf(x + (radius / xRatio))); const uint8_t xMin = max(0, floorf(x - (radius / xRatio))); const uint8_t yMax = min(GRID_COLUMNS - 1, ceilf(y + (radius / yRatio))); From 83ca097d74dae774c8e9a217a87881f1157985f7 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Tue, 3 Feb 2026 19:15:20 +0100 Subject: [PATCH 19/26] WIP --- .github/workflows/clang.yml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index af8beea6..24933bef 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -77,8 +77,19 @@ jobs: strategy: matrix: + device: + - IKEA_FREKVENS + - IKEA_OBEGRANSAD + environment: ${{ fromJson(needs.platformio.outputs.environments) }} include: + - clang-threshold: 268 + device: IKEA_FREKVENS + + - clang-threshold: 266 + device: IKEA_OBEGRANSAD + + toolchain: - clang-version: 21 steps: @@ -213,25 +224,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: ${{ matrix.clang-version }} + version: ${{ matrix.toolchain.clang-version }} files-changed-only: false passive-reviews: true step-summary: true style: "" tidy-checks: "" - - name: GitHub Script file count - id: changed - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - const { data } = await github.rest.pulls.listFiles({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - }); - core.setOutput('count', data.length); - - - name: Clang tidy checks failed - if: steps.tidy.outputs.clang-tidy-checks-failed > steps.changed.outputs.count + - name: Clang tidy check failures above threshold + if: steps.tidy.outputs.clang-tidy-checks-failed > matrix.clang-threshold run: exit 1 From fd2cef89bc5d7495ddab1b8ee5b55a6741fadf9f Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Tue, 3 Feb 2026 19:38:58 +0100 Subject: [PATCH 20/26] WIP --- .github/workflows/clang.yml | 2 +- firmware/include/services/DisplayService.h | 20 +++--- firmware/src/handlers/WeatherHandler.cpp | 2 +- firmware/src/modes/MetaballsMode.cpp | 11 +++- firmware/src/services/DisplayService.cpp | 76 ++++++++++++---------- 5 files changed, 61 insertions(+), 50 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 24933bef..79e833fc 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -120,6 +120,7 @@ jobs: - name: PlatformIO compilation database run: | cat <<'EOL' > .env + ${{ matrix.device }}='true' EXTENSION_ALEXA='true' EXTENSION_BUTTON='true' EXTENSION_HEAP='true' @@ -139,7 +140,6 @@ jobs: EXTENSION_WEBSOCKET='true' FONT_BRAILLE='true' HOSTNAME='frekvens' - IKEA_FREKVENS='true' MODE_ANIMATION='true' MODE_ARROW='true' MODE_BINARYCLOCK='true' diff --git a/firmware/include/services/DisplayService.h b/firmware/include/services/DisplayService.h index ac95bd16..c938d2de 100644 --- a/firmware/include/services/DisplayService.h +++ b/firmware/include/services/DisplayService.h @@ -42,7 +42,7 @@ class DisplayService final : public ServiceModule bool pending = false; bool power = false; - float ratio = PITCH_HORIZONTAL / (float)PITCH_VERTICAL; + float ratio = static_cast(PITCH_HORIZONTAL) / static_cast(PITCH_VERTICAL); uint8_t brightness = 0; uint8_t _frame[GRID_COLUMNS * GRID_ROWS] = {0}; @@ -74,24 +74,24 @@ class DisplayService final : public ServiceModule void setOrientation(Orientation _orientation); [[nodiscard]] bool getPower() const; - void setPower(bool power); + void setPower(bool _power); [[nodiscard]] uint8_t getBrightness() const; - void setBrightness(uint8_t brightness); + void setBrightness(uint8_t _brightness); - void getFrame(uint8_t frame[GRID_COLUMNS * GRID_ROWS]); - void setFrame(const uint8_t frame[GRID_COLUMNS * GRID_ROWS]); + void getFrame(uint8_t __frame[GRID_COLUMNS * GRID_ROWS]); + void setFrame(const uint8_t __frame[GRID_COLUMNS * GRID_ROWS]); - void clearFrame(uint8_t brightness = 0); + void clearFrame(uint8_t _brightness = 0); void invertFrame(); [[nodiscard]] uint8_t getPixel(uint8_t x, uint8_t y) const; - void setPixel(uint8_t x, uint8_t y, uint8_t brightness = UINT8_MAX); + void setPixel(uint8_t x, uint8_t y, uint8_t _brightness = UINT8_MAX); - void drawEllipse(float x, float y, float radius, float ratio = 1, bool fill = false, - uint8_t brightness = UINT8_MAX); + void drawEllipse(float x, float y, float radius, float _ratio = 1, bool fill = false, + uint8_t _brightness = UINT8_MAX); void drawRectangle(uint8_t minX, uint8_t minY, uint8_t maxX, uint8_t maxY, bool fill = true, - uint8_t brightness = UINT8_MAX); + uint8_t _brightness = UINT8_MAX); void flush(); diff --git a/firmware/src/handlers/WeatherHandler.cpp b/firmware/src/handlers/WeatherHandler.cpp index d437a655..97c878ae 100644 --- a/firmware/src/handlers/WeatherHandler.cpp +++ b/firmware/src/handlers/WeatherHandler.cpp @@ -7,7 +7,7 @@ #include "services/DisplayService.h" #include "services/FontsService.h" -WeatherHandler::WeatherHandler() {} +WeatherHandler::WeatherHandler() = default; void WeatherHandler::parse(std::string code, std::vector codesets) { diff --git a/firmware/src/modes/MetaballsMode.cpp b/firmware/src/modes/MetaballsMode.cpp index c76f59ed..5f4bc92e 100644 --- a/firmware/src/modes/MetaballsMode.cpp +++ b/firmware/src/modes/MetaballsMode.cpp @@ -26,11 +26,13 @@ void MetaballsMode::handle() if (Microphone->isTriggered()) #endif // EXTENSION_MICROPHONE { +#if PITCH_HORIZONTAL != PITCH_VERTICAL const bool rotated = (Display.getOrientation() % 2) != 0; - const float xRatio = 2.0f * static_cast(rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / + const float xRatio = static_cast(2 * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL)) / static_cast(PITCH_VERTICAL + PITCH_HORIZONTAL); - const float yRatio = 2.0f * static_cast(rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / + const float yRatio = static_cast(2 * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL)) / static_cast(PITCH_VERTICAL + PITCH_HORIZONTAL); +#endif // PITCH_HORIZONTAL == PITCH_VERTICAL for (const Ball &ball : balls) { const uint8_t xMin = max(ball.x - radius - max(ball.xVelocity, 0), 0); @@ -44,8 +46,13 @@ void MetaballsMode::handle() uint8_t brightness = 0; for (const Ball &ball : balls) { +#if PITCH_HORIZONTAL == PITCH_VERTICAL + const float xDistance = (ball.x - static_cast(x)); + const float yDistance = (ball.y - static_cast(y)); +#else const float xDistance = (ball.x - static_cast(x)) * xRatio; const float yDistance = (ball.y - static_cast(y)) * yRatio; +#endif // PITCH_HORIZONTAL == PITCH_VERTICAL const float distanceSq = (xDistance * xDistance) + (yDistance * yDistance); if (distanceSq < radiusSq) { diff --git a/firmware/src/services/DisplayService.cpp b/firmware/src/services/DisplayService.cpp index 82315767..68a0ffe9 100644 --- a/firmware/src/services/DisplayService.cpp +++ b/firmware/src/services/DisplayService.cpp @@ -93,7 +93,7 @@ void DisplayService::handle() IRAM_ATTR void DisplayService::onTimer() { static uint8_t filter = 0; - static uint8_t bytes[(GRID_COLUMNS * GRID_ROWS + 7) / 8]; + static uint8_t bytes[((GRID_COLUMNS * GRID_ROWS) + 7) / 8]; uint8_t *frame = Display.frame; uint8_t *out = bytes; uint8_t bitMask = 0x80; @@ -132,10 +132,10 @@ float DisplayService::getRatio() const { return ratio; } DisplayService::Orientation DisplayService::getOrientation() const { return orientation; } -void DisplayService::setOrientation(Orientation orientation) +void DisplayService::setOrientation(Orientation _orientation) { std::vector _pixel(GRID_COLUMNS * GRID_ROWS); - switch ((orientation - this->orientation + 4) % 4) + switch ((_orientation - orientation + 4) % 4) { case Orientation::deg180: for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; ++i) @@ -163,30 +163,30 @@ void DisplayService::setOrientation(Orientation orientation) default: return; } - ESP_LOGI(name, "orientation %d°", orientation * 90); + ESP_LOGI(name, "orientation %d°", _orientation * 90); memcpy(pixel, _pixel.data(), _pixel.size()); - this->orientation = orientation; -#if GRID_COLUMNS == GRID_ROWS - ratio = (this->orientation % 2) == 0 ? PITCH_HORIZONTAL / (float)PITCH_VERTICAL - : PITCH_VERTICAL / (float)PITCH_HORIZONTAL; -#endif + orientation = _orientation; +#if GRID_COLUMNS == GRID_ROWS && PITCH_HORIZONTAL != PITCH_VERTICAL + ratio = (orientation % 2) == 0 ? PITCH_HORIZONTAL / static_cast(PITCH_VERTICAL) + : PITCH_VERTICAL / static_cast(PITCH_HORIZONTAL); +#endif // GRID_COLUMNS == GRID_ROWS && PITCH_HORIZONTAL != PITCH_VERTICAL Preferences Storage; Storage.begin(name); - Storage.putUShort("orientation", this->orientation); + Storage.putUShort("orientation", orientation); Storage.end(); pending = true; } bool DisplayService::getPower() const { return power; } -void DisplayService::setPower(bool power) +void DisplayService::setPower(bool _power) { - if (power == this->power) + if (_power == power) { return; } ESP_LOGI(name, "power"); - if (power) + if (_power) { #ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED ledcFadeGamma(PIN_OE, @@ -200,7 +200,7 @@ void DisplayService::setPower(bool power) max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), (1 << 5) * brightness); // -2 offset due to `ledcFade` stability issues. #endif // SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED - this->power = true; + power = true; pending = true; Modes.setActive(true); } @@ -234,13 +234,13 @@ void DisplayService::onPowerOff() uint8_t DisplayService::getBrightness() const { return brightness; } -void DisplayService::setBrightness(uint8_t brightness) +void DisplayService::setBrightness(uint8_t _brightness) { - if (power && brightness == this->brightness) + if (power && _brightness == brightness) { return; } - if (brightness == 0) + if (_brightness == 0) { setPower(false); return; @@ -249,45 +249,42 @@ void DisplayService::setBrightness(uint8_t brightness) #ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED ledcFadeGamma( PIN_OE, - power ? max(this->brightness, powf(this->brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) - : 0, - max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), - (1 << 4) * abs(this->brightness - - brightness)); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGamma`. + power ? max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) : 0, + max(_brightness, powf(_brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + (1 << 4) * abs(brightness - + _brightness)); // -2 offset due to `ledcFade` stability issues. Unconfirmed for `ledcFadeGamma`. #else - ledcFade( - PIN_OE, - power ? max(this->brightness, powf(this->brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) - : 0, - max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), - (1 << 4) * abs(this->brightness - brightness)); // -2 offset due to `ledcFade` stability issues. + ledcFade(PIN_OE, + power ? max(brightness, powf(brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)) : 0, + max(_brightness, powf(_brightness / (float)UINT8_MAX, GAMMA) * ((1 << depth) - 2)), + (1 << 4) * abs(brightness - _brightness)); // -2 offset due to `ledcFade` stability issues. #endif // SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED if (!power) { power = true; Modes.setActive(true); } - this->brightness = brightness; + brightness = _brightness; Preferences Storage; Storage.begin(name); - Storage.putUShort("brightness", this->brightness); + Storage.putUShort("brightness", brightness); Storage.end(); pending = true; } -void DisplayService::getFrame(uint8_t frame[GRID_COLUMNS * GRID_ROWS]) +void DisplayService::getFrame(uint8_t __frame[GRID_COLUMNS * GRID_ROWS]) { for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; ++i) { - frame[i] = this->frame[pixel[i]]; + __frame[i] = frame[pixel[i]]; } } -void DisplayService::setFrame(const uint8_t frame[GRID_COLUMNS * GRID_ROWS]) +void DisplayService::setFrame(const uint8_t __frame[GRID_COLUMNS * GRID_ROWS]) { for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; ++i) { - this->_frame[pixel[i]] = frame[i]; + _frame[pixel[i]] = __frame[i]; } } @@ -321,11 +318,18 @@ void DisplayService::setPixel(uint8_t x, uint8_t y, uint8_t brightness) void DisplayService::drawEllipse(float x, float y, float radius, float ratio, bool fill, uint8_t brightness) { +#if PITCH_HORIZONTAL == PITCH_VERTICAL + const float xRatio = + static_cast(2 * PITCH_HORIZONTAL) / (ratio * static_cast(PITCH_VERTICAL + PITCH_HORIZONTAL)); + const float yRatio = + static_cast(2 * PITCH_VERTICAL) / (ratio * static_cast(PITCH_VERTICAL + PITCH_HORIZONTAL)); +#else const bool rotated = (orientation % 2) != 0; - const float xRatio = 2.0f * static_cast(rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL) / + const float xRatio = static_cast(2 * (rotated ? PITCH_VERTICAL : PITCH_HORIZONTAL)) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); - const float yRatio = 2.0f * static_cast(rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL) / + const float yRatio = static_cast(2 * (rotated ? PITCH_HORIZONTAL : PITCH_VERTICAL)) / (ratio * (PITCH_VERTICAL + PITCH_HORIZONTAL)); +#endif // PITCH_HORIZONTAL == PITCH_VERTICAL const uint8_t xMax = min(GRID_COLUMNS - 1, ceilf(x + (radius / xRatio))); const uint8_t xMin = max(0, floorf(x - (radius / xRatio))); const uint8_t yMax = min(GRID_COLUMNS - 1, ceilf(y + (radius / yRatio))); From 1804e60d17c391ab5447a1f6c7d3aeabdd6cc21b Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Tue, 3 Feb 2026 20:12:58 +0100 Subject: [PATCH 21/26] WIP --- .clang-tidy | 1 + .github/workflows/clang.yml | 30 +++++++++---------- .github/workflows/generate.yml | 5 +++- .../ikea-frekvens-led-multi-use-light.yml | 5 +++- .../ikea-obegransad-led-wall-lamp.yml | 5 +++- .github/workflows/miscellaneous.yml | 5 +++- .../include/extensions/MessageExtension.h | 4 +-- firmware/include/modes/PingPongMode.h | 8 ++--- firmware/include/services/DisplayService.h | 4 +-- firmware/src/handlers/BitmapHandler.cpp | 2 +- firmware/src/handlers/TextHandler.cpp | 2 +- firmware/src/modes/PingPongMode.cpp | 4 +++ firmware/src/services/ConnectivityService.cpp | 4 +-- firmware/src/services/DisplayService.cpp | 12 ++++---- 14 files changed, 53 insertions(+), 38 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 43bef074..21b1fbb6 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -11,6 +11,7 @@ Checks: > -cppcoreguidelines-init-variables, -cppcoreguidelines-macro-to-enum, -cppcoreguidelines-macro-usage, + -cppcoreguidelines-pro-bounds-constant-array-index, -modernize-macro-to-enum, -modernize-use-auto, -modernize-use-trailing-return-type, diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 79e833fc..963e4e67 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -19,6 +19,9 @@ jobs: environments: ${{ steps.print.outputs.environments }} version: ${{ steps.print.outputs.version }} + env: + python-version: 3.13 + steps: - name: Checkout uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -26,7 +29,7 @@ jobs: - name: Set up Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: - python-version: 3.13 + python-version: ${{ env.python-version }} cache: pip cache-dependency-path: .github/platformio/requirements.txt @@ -43,10 +46,8 @@ jobs: name: Format runs-on: ubuntu-latest - strategy: - matrix: - include: - - clang-version: 21 + env: + clang-version: 21 steps: - name: Checkout @@ -58,7 +59,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: ${{ matrix.clang-version }} + version: ${{ env.clang-version }} files-changed-only: false format-review: true passive-reviews: true @@ -75,23 +76,20 @@ jobs: needs: platformio runs-on: ubuntu-latest + env: + clang-version: 21 + python-version: 3.13 + strategy: matrix: - device: - - IKEA_FREKVENS - - IKEA_OBEGRANSAD - environment: ${{ fromJson(needs.platformio.outputs.environments) }} include: - clang-threshold: 268 device: IKEA_FREKVENS - - clang-threshold: 266 + - clang-threshold: 268 device: IKEA_OBEGRANSAD - toolchain: - - clang-version: 21 - steps: - name: Checkout uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -99,7 +97,7 @@ jobs: - name: Set up Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: - python-version: 3.13 + python-version: ${{ env.python-version }} cache: pip cache-dependency-path: | .github/platformio/requirements.txt @@ -224,7 +222,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: ${{ matrix.toolchain.clang-version }} + version: ${{ env.clang-version }} files-changed-only: false passive-reviews: true step-summary: true diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 35be75da..1fcfbd56 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -17,6 +17,9 @@ jobs: outputs: version: ${{ steps.print.outputs.version }} + env: + python-version: 3.13 + steps: - name: Checkout uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -24,7 +27,7 @@ jobs: - name: Set up Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: - python-version: 3.13 + python-version: ${{ env.python-version }} cache: pip cache-dependency-path: .github/platformio/requirements.txt diff --git a/.github/workflows/ikea-frekvens-led-multi-use-light.yml b/.github/workflows/ikea-frekvens-led-multi-use-light.yml index b7b81f55..026f6473 100644 --- a/.github/workflows/ikea-frekvens-led-multi-use-light.yml +++ b/.github/workflows/ikea-frekvens-led-multi-use-light.yml @@ -26,6 +26,9 @@ jobs: environments: ${{ steps.print.outputs.environments }} version: ${{ steps.print.outputs.version }} + env: + python-version: 3.13 + steps: - name: Checkout uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -33,7 +36,7 @@ jobs: - name: Set up Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: - python-version: 3.13 + python-version: ${{ env.python-version }} cache: pip cache-dependency-path: .github/platformio/requirements.txt diff --git a/.github/workflows/ikea-obegransad-led-wall-lamp.yml b/.github/workflows/ikea-obegransad-led-wall-lamp.yml index 03d7013b..fb5874fb 100644 --- a/.github/workflows/ikea-obegransad-led-wall-lamp.yml +++ b/.github/workflows/ikea-obegransad-led-wall-lamp.yml @@ -26,6 +26,9 @@ jobs: environments: ${{ steps.print.outputs.environments }} version: ${{ steps.print.outputs.version }} + env: + python-version: 3.13 + steps: - name: Checkout uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -33,7 +36,7 @@ jobs: - name: Set up Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: - python-version: 3.13 + python-version: ${{ env.python-version }} cache: pip cache-dependency-path: .github/platformio/requirements.txt diff --git a/.github/workflows/miscellaneous.yml b/.github/workflows/miscellaneous.yml index b98aa091..b2820db1 100644 --- a/.github/workflows/miscellaneous.yml +++ b/.github/workflows/miscellaneous.yml @@ -17,6 +17,9 @@ jobs: outputs: version: ${{ steps.print.outputs.version }} + env: + python-version: 3.13 + steps: - name: Checkout uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -24,7 +27,7 @@ jobs: - name: Set up Python uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: - python-version: 3.13 + python-version: ${{ env.python-version }} cache: pip cache-dependency-path: .github/platformio/requirements.txt diff --git a/firmware/include/extensions/MessageExtension.h b/firmware/include/extensions/MessageExtension.h index 0599bcd0..a8fc2935 100644 --- a/firmware/include/extensions/MessageExtension.h +++ b/firmware/include/extensions/MessageExtension.h @@ -20,14 +20,14 @@ class MessageExtension final : public ExtensionModule int16_t offsetX = GRID_COLUMNS; int16_t width = 0; - uint8_t frame[GRID_COLUMNS * GRID_ROWS]; + uint8_t frame[GRID_COLUMNS * GRID_ROWS] = {0}; uint8_t repeat = 3; unsigned long lastMillis = 0; FontModule *font = nullptr; - std::vector messages; + std::vector messages = {}; std::unique_ptr text = {}; diff --git a/firmware/include/modes/PingPongMode.h b/firmware/include/modes/PingPongMode.h index c18b838e..cf7c7d95 100644 --- a/firmware/include/modes/PingPongMode.h +++ b/firmware/include/modes/PingPongMode.h @@ -15,11 +15,11 @@ class PingPongMode final : public ModeModule bool clock = true; bool pending = false; - float xDec; - float yDec; + float xDec = .0f; + float yDec = .0f; - std::deque paddleA; - std::deque paddleB; + std::deque paddleA = {}; + std::deque paddleB = {}; tm local = {}; diff --git a/firmware/include/services/DisplayService.h b/firmware/include/services/DisplayService.h index c938d2de..8b1a5708 100644 --- a/firmware/include/services/DisplayService.h +++ b/firmware/include/services/DisplayService.h @@ -79,8 +79,8 @@ class DisplayService final : public ServiceModule [[nodiscard]] uint8_t getBrightness() const; void setBrightness(uint8_t _brightness); - void getFrame(uint8_t __frame[GRID_COLUMNS * GRID_ROWS]); - void setFrame(const uint8_t __frame[GRID_COLUMNS * GRID_ROWS]); + void getFrame(uint8_t frameCurrent[GRID_COLUMNS * GRID_ROWS]); + void setFrame(const uint8_t frameNext[GRID_COLUMNS * GRID_ROWS]); void clearFrame(uint8_t _brightness = 0); void invertFrame(); diff --git a/firmware/src/handlers/BitmapHandler.cpp b/firmware/src/handlers/BitmapHandler.cpp index f1608b97..71901fe7 100644 --- a/firmware/src/handlers/BitmapHandler.cpp +++ b/firmware/src/handlers/BitmapHandler.cpp @@ -42,7 +42,7 @@ void BitmapHandler::draw(uint8_t x, uint8_t y, uint8_t brightness) msbMax = msb; } } - for (uint8_t _x = 0; _x <= msbMax; ++_x) + for (uint16_t _x = 0; _x <= msbMax; ++_x) { for (uint8_t _y = 0; _y < height; ++_y) { diff --git a/firmware/src/handlers/TextHandler.cpp b/firmware/src/handlers/TextHandler.cpp index 7276e299..631f2d4d 100644 --- a/firmware/src/handlers/TextHandler.cpp +++ b/firmware/src/handlers/TextHandler.cpp @@ -65,7 +65,7 @@ void TextHandler::draw(int16_t x, int8_t y, uint8_t brightness) if (_height != 0) { const uint8_t msbMax = calcMsbMax(character); - for (uint8_t _x = 0; _x <= msbMax; ++_x) + for (uint16_t _x = 0; _x <= msbMax; ++_x) { for (uint8_t _y = 0; _y < _height; ++_y) { diff --git a/firmware/src/modes/PingPongMode.cpp b/firmware/src/modes/PingPongMode.cpp index 8774cf65..5227b42b 100644 --- a/firmware/src/modes/PingPongMode.cpp +++ b/firmware/src/modes/PingPongMode.cpp @@ -51,7 +51,11 @@ void PingPongMode::begin() Display.clearFrame(); paddleA.clear(); paddleB.clear(); +#if GRID_COLUMNS == GRID_ROWS + const uint8_t _paddle = random(clock ? 5 : 0, GRID_COLUMNS - 3); +#else const uint8_t _paddle = random(clock ? 5 : 0, clock ? GRID_ROWS - 3 : GRID_COLUMNS - 3); +#endif // GRID_COLUMNS == GRID_ROWS for (uint8_t i = 0; i < 3; ++i) { paddleA.push_back(_paddle + i); diff --git a/firmware/src/services/ConnectivityService.cpp b/firmware/src/services/ConnectivityService.cpp index 78e0e5fc..ee8a88c6 100644 --- a/firmware/src/services/ConnectivityService.cpp +++ b/firmware/src/services/ConnectivityService.cpp @@ -125,11 +125,11 @@ void ConnectivityService::initStation() wifi_config_t config; if (esp_wifi_get_config(wifi_interface_t::WIFI_IF_STA, &config) == ESP_OK) { - const char *ssid_ptr = static_cast(static_cast(config.sta.ssid)); + const char *ssid_ptr = reinterpret_cast(config.sta.ssid); const std::string_view ssid(ssid_ptr, strnlen(ssid_ptr, sizeof(config.sta.ssid))); if (!ssid.empty()) { - const char *key_ptr = static_cast(static_cast(config.sta.password)); + const char *key_ptr = reinterpret_cast(config.sta.password); const std::string_view key(key_ptr, strnlen(key_ptr, sizeof(config.sta.password))); doc[ssid] = key.length() ? key : nullptr; } diff --git a/firmware/src/services/DisplayService.cpp b/firmware/src/services/DisplayService.cpp index 68a0ffe9..37b41250 100644 --- a/firmware/src/services/DisplayService.cpp +++ b/firmware/src/services/DisplayService.cpp @@ -272,19 +272,19 @@ void DisplayService::setBrightness(uint8_t _brightness) pending = true; } -void DisplayService::getFrame(uint8_t __frame[GRID_COLUMNS * GRID_ROWS]) +void DisplayService::getFrame(uint8_t frameCurrent[GRID_COLUMNS * GRID_ROWS]) { for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; ++i) { - __frame[i] = frame[pixel[i]]; + frameCurrent[i] = frame[pixel[i]]; } } -void DisplayService::setFrame(const uint8_t __frame[GRID_COLUMNS * GRID_ROWS]) +void DisplayService::setFrame(const uint8_t frameNext[GRID_COLUMNS * GRID_ROWS]) { for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; ++i) { - _frame[pixel[i]] = __frame[i]; + _frame[pixel[i]] = frameNext[i]; } } @@ -334,9 +334,9 @@ void DisplayService::drawEllipse(float x, float y, float radius, float ratio, bo const uint8_t xMin = max(0, floorf(x - (radius / xRatio))); const uint8_t yMax = min(GRID_COLUMNS - 1, ceilf(y + (radius / yRatio))); const uint8_t yMin = max(0, floorf(y - (radius / yRatio))); - for (uint8_t _x = xMin; _x <= xMax; ++_x) + for (uint16_t _x = xMin; _x <= xMax; ++_x) { - for (uint8_t _y = yMin; _y <= yMax; ++_y) + for (uint16_t _y = yMin; _y <= yMax; ++_y) { const float xDistance = xRatio * (_x - x); const float yDistance = yRatio * (_y - y); From 462352e924fe2d7f9f170a1053ac1dfc909d3ac0 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Tue, 3 Feb 2026 20:49:50 +0100 Subject: [PATCH 22/26] WIP --- .github/workflows/clang.yml | 13 ++++++------- firmware/src/services/DisplayService.cpp | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 963e4e67..d325643b 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -78,17 +78,16 @@ jobs: env: clang-version: 21 + clang-threshold: 361 python-version: 3.13 strategy: matrix: - environment: ${{ fromJson(needs.platformio.outputs.environments) }} - include: - - clang-threshold: 268 - device: IKEA_FREKVENS + device: + - IKEA_FREKVENS + - IKEA_OBEGRANSAD - - clang-threshold: 268 - device: IKEA_OBEGRANSAD + environment: ${{ fromJson(needs.platformio.outputs.environments) }} steps: - name: Checkout @@ -230,5 +229,5 @@ jobs: tidy-checks: "" - name: Clang tidy check failures above threshold - if: steps.tidy.outputs.clang-tidy-checks-failed > matrix.clang-threshold + if: steps.tidy.outputs.clang-tidy-checks-failed > env.clang-threshold run: exit 1 diff --git a/firmware/src/services/DisplayService.cpp b/firmware/src/services/DisplayService.cpp index 37b41250..a8cab9c6 100644 --- a/firmware/src/services/DisplayService.cpp +++ b/firmware/src/services/DisplayService.cpp @@ -94,30 +94,31 @@ IRAM_ATTR void DisplayService::onTimer() { static uint8_t filter = 0; static uint8_t bytes[((GRID_COLUMNS * GRID_ROWS) + 7) / 8]; - uint8_t *frame = Display.frame; - uint8_t *out = bytes; + const uint8_t* frame = Display.frame; + uint16_t outIndex = 0; uint8_t bitMask = 0x80; uint8_t outByte = 0; - for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; i++) + for (uint16_t i = 0; i < GRID_COLUMNS * GRID_ROWS; ++i) { - if (*frame++ > filter) + if (frame[i] > filter) { outByte |= bitMask; } - if ((bitMask >>= 1) == 0) + bitMask >>= 1; + if (bitMask == 0) { - *out++ = outByte; + bytes[outIndex++] = outByte; outByte = 0; bitMask = 0x80; } } #if GRID_COLUMNS * GRID_ROWS % 8 - *out = outByte; + bytes[outIndex] = outByte; #endif // GRID_COLUMNS * GRID_ROWS % 8 ++filter; - gpio_set_level((gpio_num_t)PIN_CS, LOW); + gpio_set_level(static_cast(PIN_CS), LOW); SPI.transferBytes(bytes, nullptr, sizeof(bytes)); - gpio_set_level((gpio_num_t)PIN_CS, HIGH); + gpio_set_level(static_cast(PIN_CS), HIGH); } void DisplayService::flush() From 8d74a7d396acd1f937ae9d569df25198cc47cdbd Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Tue, 3 Feb 2026 21:30:15 +0100 Subject: [PATCH 23/26] WIP --- .github/workflows/clang.yml | 25 +++++++++--- .github/workflows/generate.yml | 51 +++++++++++++++++++----- firmware/src/services/DisplayService.cpp | 2 +- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index d325643b..b7c5f636 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -69,7 +69,14 @@ jobs: - name: Clang format checks failed if: steps.format.outputs.clang-format-checks-failed != 0 - run: exit 1 + run: | + echo "Job summary:" + if [ -n "${{ github.event.pull_request.number }}" ]; then + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" + else + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" + fi + exit 1 tidy: name: Tidy @@ -77,13 +84,13 @@ jobs: runs-on: ubuntu-latest env: + clang-threshold: 358 clang-version: 21 - clang-threshold: 361 python-version: 3.13 strategy: matrix: - device: + device-id: - IKEA_FREKVENS - IKEA_OBEGRANSAD @@ -117,7 +124,7 @@ jobs: - name: PlatformIO compilation database run: | cat <<'EOL' > .env - ${{ matrix.device }}='true' + ${{ matrix.device-id }}='true' EXTENSION_ALEXA='true' EXTENSION_BUTTON='true' EXTENSION_HEAP='true' @@ -227,7 +234,15 @@ jobs: step-summary: true style: "" tidy-checks: "" + tidy-review: true - name: Clang tidy check failures above threshold if: steps.tidy.outputs.clang-tidy-checks-failed > env.clang-threshold - run: exit 1 + run: | + echo "Job summary:" + if [ -n "${{ github.event.pull_request.number }}" ]; then + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" + else + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" + fi + exit 1 diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 1fcfbd56..305119ac 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -43,6 +43,10 @@ jobs: needs: platformio runs-on: ubuntu-latest + env: + clang-threshold: 3 + clang-version: 21 + strategy: matrix: toolchain: @@ -142,14 +146,25 @@ jobs: tidy-review: true - name: Clang checks failed - if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed != 0 - run: exit 1 + if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed > env.clang-threshold + run: | + echo "Job summary:" + if [ -n "${{ github.event.pull_request.number }}" ]; then + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" + else + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" + fi + exit 1 mode-dynamic: name: Dynamic mode needs: platformio runs-on: ubuntu-latest + env: + clang-threshold: 0 + clang-version: 21 + strategy: matrix: toolchain: @@ -279,21 +294,30 @@ jobs: tidy-review: true - name: Clang checks failed - if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed != 0 - run: exit 1 + if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed > env.clang-threshold + run: | + echo "Job summary:" + if [ -n "${{ github.event.pull_request.number }}" ]; then + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" + else + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" + fi + exit 1 mode-static: name: Static mode needs: platformio runs-on: ubuntu-latest + env: + clang-threshold: 0 + clang-version: 21 + strategy: matrix: toolchain: - python-version: 3.11 - - - clang-version: 21 - python-version: 3.13 + - python-version: 3.13 steps: - name: Checkout @@ -399,6 +423,13 @@ jobs: tidy-checks: "" tidy-review: true - - name: Clang checks failed - if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed != 0 - run: exit 1 + - name: Clang check failures above threshold + if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed > env.clang-threshold + run: | + echo "Job summary:" + if [ -n "${{ github.event.pull_request.number }}" ]; then + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" + else + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" + fi + exit 1 diff --git a/firmware/src/services/DisplayService.cpp b/firmware/src/services/DisplayService.cpp index a8cab9c6..9252710a 100644 --- a/firmware/src/services/DisplayService.cpp +++ b/firmware/src/services/DisplayService.cpp @@ -94,7 +94,7 @@ IRAM_ATTR void DisplayService::onTimer() { static uint8_t filter = 0; static uint8_t bytes[((GRID_COLUMNS * GRID_ROWS) + 7) / 8]; - const uint8_t* frame = Display.frame; + const uint8_t *frame = Display.frame; uint16_t outIndex = 0; uint8_t bitMask = 0x80; uint8_t outByte = 0; From 48d216e86b5c18dfb8c057a3632fbb54420d7f12 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Tue, 3 Feb 2026 22:12:21 +0100 Subject: [PATCH 24/26] WIP --- .github/workflows/clang.yml | 15 +++++++------- .github/workflows/generate.yml | 36 +++++++++++++--------------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index b7c5f636..607f5afe 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -67,16 +67,15 @@ jobs: style: file tidy-checks: -* - - name: Clang format checks failed - if: steps.format.outputs.clang-format-checks-failed != 0 + - name: Summary run: | - echo "Job summary:" + echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" else echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" fi - exit 1 + exit $(( ${{ steps.format.outputs.clang-format-checks-failed }} != 0 )) tidy: name: Tidy @@ -236,13 +235,13 @@ jobs: tidy-checks: "" tidy-review: true - - name: Clang tidy check failures above threshold - if: steps.tidy.outputs.clang-tidy-checks-failed > env.clang-threshold + - name: Summary run: | - echo "Job summary:" + echo "${{ steps.tidy.outputs.clang-tidy-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." + echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" else echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" fi - exit 1 + exit $(( ${{ steps.tidy.outputs.clang-tidy-checks-failed }} > ${{ env.clang-threshold }} )) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 305119ac..667206c9 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -51,9 +51,7 @@ jobs: matrix: toolchain: - python-version: 3.11 - - - clang-version: 21 - python-version: 3.13 + - python-version: 3.13 steps: - name: Checkout @@ -145,16 +143,16 @@ jobs: tidy-checks: "" tidy-review: true - - name: Clang checks failed - if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed > env.clang-threshold + - name: Summary run: | - echo "Job summary:" + echo "${{ steps.clang.outputs.clang-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." + echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" else echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" fi - exit 1 + exit $(( ${{ steps.clang.outputs.checks-failed }} > ${{ env.clang-threshold }} )) mode-dynamic: name: Dynamic mode @@ -169,9 +167,7 @@ jobs: matrix: toolchain: - python-version: 3.11 - - - clang-version: 21 - python-version: 3.13 + - python-version: 3.13 steps: - name: Checkout @@ -273,11 +269,9 @@ jobs: pio run -e esp32dev - name: PlatformIO compilation database - if: matrix.toolchain.clang-version run: pio run -e esp32dev -t compiledb - name: Clang - if: matrix.toolchain.clang-version uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 id: clang env: @@ -293,16 +287,16 @@ jobs: tidy-checks: "" tidy-review: true - - name: Clang checks failed - if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed > env.clang-threshold + - name: Summary run: | - echo "Job summary:" + echo "${{ steps.clang.outputs.clang-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." + echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" else echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" fi - exit 1 + exit $(( ${{ steps.clang.outputs.checks-failed }} > ${{ env.clang-threshold }} )) mode-static: name: Static mode @@ -403,11 +397,9 @@ jobs: pio run -e esp32dev - name: PlatformIO compilation database - if: matrix.toolchain.clang-version run: pio run -e esp32dev -t compiledb - name: Clang - if: matrix.toolchain.clang-version uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 id: clang env: @@ -423,13 +415,13 @@ jobs: tidy-checks: "" tidy-review: true - - name: Clang check failures above threshold - if: matrix.toolchain.clang-version && steps.clang.outputs.checks-failed > env.clang-threshold + - name: Summary run: | - echo "Job summary:" + echo "${{ steps.clang.outputs.clang-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." + echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" else echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" fi - exit 1 + exit $(( ${{ steps.clang.outputs.checks-failed }} > ${{ env.clang-threshold }} )) From 55917fd0b0ec40a1805a9d9dd223fe602aea39e3 Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Tue, 3 Feb 2026 22:18:28 +0100 Subject: [PATCH 25/26] WIP --- .github/workflows/clang.yml | 8 ++++---- .github/workflows/generate.yml | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 607f5afe..b70f96af 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -71,9 +71,9 @@ jobs: run: | echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job.check_run_id }}" else - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job.check_run_id }}" fi exit $(( ${{ steps.format.outputs.clang-format-checks-failed }} != 0 )) @@ -240,8 +240,8 @@ jobs: echo "${{ steps.tidy.outputs.clang-tidy-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job.check_run_id }}" else - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job.check_run_id }}" fi exit $(( ${{ steps.tidy.outputs.clang-tidy-checks-failed }} > ${{ env.clang-threshold }} )) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 667206c9..5d510b68 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -148,9 +148,9 @@ jobs: echo "${{ steps.clang.outputs.clang-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job.check_run_id }}" else - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job.check_run_id }}" fi exit $(( ${{ steps.clang.outputs.checks-failed }} > ${{ env.clang-threshold }} )) @@ -292,9 +292,9 @@ jobs: echo "${{ steps.clang.outputs.clang-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job.check_run_id }}" else - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job.check_run_id }}" fi exit $(( ${{ steps.clang.outputs.checks-failed }} > ${{ env.clang-threshold }} )) @@ -420,8 +420,8 @@ jobs: echo "${{ steps.clang.outputs.clang-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job.check_run_id }}" else - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job.check_run_id }}" fi exit $(( ${{ steps.clang.outputs.checks-failed }} > ${{ env.clang-threshold }} )) From 4116b80d2cb1ec75e1de9f2fd2ad1eefca8685eb Mon Sep 17 00:00:00 2001 From: Jan-Petter Gundersen Date: Tue, 3 Feb 2026 23:10:04 +0100 Subject: [PATCH 26/26] WIP --- .github/workflows/clang.yml | 10 +++++----- .github/workflows/generate.yml | 26 ++++++++++++-------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index b70f96af..0f8d957b 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -71,9 +71,9 @@ jobs: run: | echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job.check_run_id }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}" else - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job.check_run_id }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" fi exit $(( ${{ steps.format.outputs.clang-format-checks-failed }} != 0 )) @@ -237,11 +237,11 @@ jobs: - name: Summary run: | - echo "${{ steps.tidy.outputs.clang-tidy-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." + echo "Status: ${{ steps.tidy.outputs.clang-tidy-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job.check_run_id }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}" else - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job.check_run_id }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" fi exit $(( ${{ steps.tidy.outputs.clang-tidy-checks-failed }} > ${{ env.clang-threshold }} )) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 5d510b68..79e6ae95 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -123,17 +123,15 @@ jobs: pio run -e esp32dev - name: PlatformIO compilation database - if: matrix.toolchain.clang-version run: pio run -e esp32dev -t compiledb - name: Clang - if: matrix.toolchain.clang-version uses: cpp-linter/cpp-linter-action@b6edc0625e3941baa1797f4b4326adeab6890c97 # v2.16.7 id: clang env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: ${{ matrix.toolchain.clang-version }} + version: ${{ env.clang-version }} files-changed-only: false format-review: true ignore: "*|!firmware/src/fonts/DejaVuSansFont.cpp|!firmware/include/fonts/DejaVuSansFont.h" @@ -145,12 +143,12 @@ jobs: - name: Summary run: | - echo "${{ steps.clang.outputs.clang-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." + echo "Status: ${{ steps.clang.outputs.checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job.check_run_id }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}" else - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job.check_run_id }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" fi exit $(( ${{ steps.clang.outputs.checks-failed }} > ${{ env.clang-threshold }} )) @@ -277,7 +275,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: ${{ matrix.toolchain.clang-version }} + version: ${{ env.clang-version }} files-changed-only: false format-review: true ignore: "*|!firmware/src/modes/DynamicMode.cpp|!firmware/include/modes/DynamicMode.h" @@ -289,12 +287,12 @@ jobs: - name: Summary run: | - echo "${{ steps.clang.outputs.clang-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." + echo "Status: ${{ steps.clang.outputs.checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job.check_run_id }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}" else - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job.check_run_id }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" fi exit $(( ${{ steps.clang.outputs.checks-failed }} > ${{ env.clang-threshold }} )) @@ -405,7 +403,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: ${{ matrix.toolchain.clang-version }} + version: ${{ env.clang-version }} files-changed-only: false format-review: true ignore: "*|!firmware/src/modes/StaticMode.cpp|!firmware/include/modes/StaticMode.h" @@ -417,11 +415,11 @@ jobs: - name: Summary run: | - echo "${{ steps.clang.outputs.clang-checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." + echo "Status: ${{ steps.clang.outputs.checks-failed }} checks failed, threshold for success is ${{ env.clang-threshold }}." echo "Clang report:" if [ -n "${{ github.event.pull_request.number }}" ]; then - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}#summary-${{ github.job.check_run_id }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}" else - echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ github.job.check_run_id }}" + echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" fi exit $(( ${{ steps.clang.outputs.checks-failed }} > ${{ env.clang-threshold }} ))