mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-16 15:52:34 +00:00
Compare commits
130 Commits
no-arduino
...
v2.7.0.705
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
705515ace2 | ||
|
|
a97df4bb52 | ||
|
|
f6743798e2 | ||
|
|
2ea70927c8 | ||
|
|
de5b55921e | ||
|
|
2b97576b18 | ||
|
|
29e7a71c97 | ||
|
|
18fbc2149d | ||
|
|
50424d1035 | ||
|
|
e87c991975 | ||
|
|
2ab717cebb | ||
|
|
ad23c065f6 | ||
|
|
eeb52a1221 | ||
|
|
8ae05f6b33 | ||
|
|
f6630cd31d | ||
|
|
c144bd03dc | ||
|
|
7512673b09 | ||
|
|
3870d81bf6 | ||
|
|
a7dcf580ad | ||
|
|
ecfaf3a095 | ||
|
|
91bcf072a0 | ||
|
|
4802cef3ca | ||
|
|
38896198f2 | ||
|
|
012f88e56f | ||
|
|
0808f5215f | ||
|
|
247e05bb10 | ||
|
|
4308bbc156 | ||
|
|
ce1480df98 | ||
|
|
0108ad7992 | ||
|
|
e1df4e19e5 | ||
|
|
8ba98ae873 | ||
|
|
7a38368494 | ||
|
|
195b7cc30a | ||
|
|
4feaec651f | ||
|
|
82b7cb5dd0 | ||
|
|
30bbb449db | ||
|
|
14421c3609 | ||
|
|
2cf7e51061 | ||
|
|
7fd12782a1 | ||
|
|
c914a62d93 | ||
|
|
12680ad9cd | ||
|
|
0561f2ca4b | ||
|
|
58743021c8 | ||
|
|
2fb46ce5d5 | ||
|
|
8be76a56c7 | ||
|
|
2c206febab | ||
|
|
db1eac12af | ||
|
|
56e67cb434 | ||
|
|
e9d5e36738 | ||
|
|
f71fdef3fd | ||
|
|
5e92145324 | ||
|
|
89a4589b68 | ||
|
|
20991d8b53 | ||
|
|
3ab9005b2f | ||
|
|
aabc5b7cf2 | ||
|
|
afcd97c154 | ||
|
|
cbdd7eae70 | ||
|
|
6374ffea35 | ||
|
|
1a6bb97f16 | ||
|
|
4f0b95e910 | ||
|
|
a81b41cbfb | ||
|
|
465fe18a89 | ||
|
|
bd0e25f3f5 | ||
|
|
9861e82f0a | ||
|
|
fcefd592e2 | ||
|
|
8a8a7cdefc | ||
|
|
8f9e569825 | ||
|
|
b0c5327585 | ||
|
|
f1dd623ce9 | ||
|
|
ac52edd11a | ||
|
|
66d5dde956 | ||
|
|
7dfbcc8f1d | ||
|
|
28244148a2 | ||
|
|
e623c70bd0 | ||
|
|
425f384b1f | ||
|
|
1557219bad | ||
|
|
691917b956 | ||
|
|
cc0fbfbd21 | ||
|
|
5d0bf03b01 | ||
|
|
8ff99437cb | ||
|
|
ba93097bb7 | ||
|
|
de098cca4c | ||
|
|
8faa04afdb | ||
|
|
fede1b8597 | ||
|
|
8557bd031d | ||
|
|
4e6418b635 | ||
|
|
a1a5503fe9 | ||
|
|
3b94981e56 | ||
|
|
f299447216 | ||
|
|
5f0c8863fd | ||
|
|
f9d17cdee0 | ||
|
|
68a28a177f | ||
|
|
60ec05e536 | ||
|
|
730cd388d6 | ||
|
|
6549b0477c | ||
|
|
8304cae010 | ||
|
|
0ad9758cfd | ||
|
|
e5f6804421 | ||
|
|
720add72b2 | ||
|
|
693b11db1d | ||
|
|
4bf2dd04ae | ||
|
|
c6c2a4d4dd | ||
|
|
79b8e7b1cf | ||
|
|
cf4f088337 | ||
|
|
22cb20d294 | ||
|
|
1eacdd0629 | ||
|
|
67e3d57412 | ||
|
|
7924ef87b5 | ||
|
|
3dec521f75 | ||
|
|
57a33790ed | ||
|
|
484af8eb9f | ||
|
|
b8970d66a1 | ||
|
|
e78033bb85 | ||
|
|
8bd7adca47 | ||
|
|
f67aec40e8 | ||
|
|
46c7d74760 | ||
|
|
15d2ae17f8 | ||
|
|
91579c4650 | ||
|
|
79b710a108 | ||
|
|
ba296db701 | ||
|
|
c0e1616382 | ||
|
|
070deb290f | ||
|
|
76f7207463 | ||
|
|
55b2bbf937 | ||
|
|
a5716cf25c | ||
|
|
4d81280ac2 | ||
|
|
9ce44556ce | ||
|
|
be0c7d73a3 | ||
|
|
d833a9ea61 | ||
|
|
5cd74f4b53 |
3
.github/FUNDING.yml
vendored
Normal file
3
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
open_collective: meshtastic
|
||||||
50
.github/actions/build-variant/action.yml
vendored
50
.github/actions/build-variant/action.yml
vendored
@@ -27,10 +27,10 @@ inputs:
|
|||||||
description: A newline separated list of paths to store as artifacts
|
description: A newline separated list of paths to store as artifacts
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
include-web-ui:
|
# include-web-ui:
|
||||||
description: Include the web UI in the build
|
# description: Include the web UI in the build
|
||||||
required: false
|
# required: false
|
||||||
default: "false"
|
# default: "false"
|
||||||
arch:
|
arch:
|
||||||
description: Processor arch name
|
description: Processor arch name
|
||||||
required: true
|
required: true
|
||||||
@@ -43,29 +43,29 @@ runs:
|
|||||||
id: base
|
id: base
|
||||||
uses: ./.github/actions/setup-base
|
uses: ./.github/actions/setup-base
|
||||||
|
|
||||||
- name: Get web ui version
|
# - name: Get web ui version
|
||||||
if: inputs.include-web-ui == 'true'
|
# if: inputs.include-web-ui == 'true'
|
||||||
id: webver
|
# id: webver
|
||||||
shell: bash
|
# shell: bash
|
||||||
run: |
|
# run: |
|
||||||
echo "ver=$(cat bin/web.version)" >> $GITHUB_OUTPUT
|
# echo "ver=$(cat bin/web.version)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Pull web ui
|
# - name: Pull web ui
|
||||||
if: inputs.include-web-ui == 'true'
|
# if: inputs.include-web-ui == 'true'
|
||||||
uses: dsaltares/fetch-gh-release-asset@master
|
# uses: dsaltares/fetch-gh-release-asset@master
|
||||||
with:
|
# with:
|
||||||
repo: meshtastic/web
|
# repo: meshtastic/web
|
||||||
file: build.tar
|
# file: build.tar
|
||||||
target: build.tar
|
# target: build.tar
|
||||||
token: ${{ inputs.github_token }}
|
# token: ${{ inputs.github_token }}
|
||||||
version: tags/v${{ steps.webver.outputs.ver }}
|
# version: tags/v${{ steps.webver.outputs.ver }}
|
||||||
|
|
||||||
- name: Unpack web ui
|
# - name: Unpack web ui
|
||||||
if: inputs.include-web-ui == 'true'
|
# if: inputs.include-web-ui == 'true'
|
||||||
shell: bash
|
# shell: bash
|
||||||
run: |
|
# run: |
|
||||||
tar -xf build.tar -C data/static
|
# tar -xf build.tar -C data/static
|
||||||
rm build.tar
|
# rm build.tar
|
||||||
|
|
||||||
- name: Remove debug flags for release
|
- name: Remove debug flags for release
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
5
.github/pull_request_template.md
vendored
5
.github/pull_request_template.md
vendored
@@ -1,6 +1,7 @@
|
|||||||
## 🙏 Thank you for sending in a pull request, here's some tips to get started!
|
## 🙏 Thank you for sending in a pull request, here's some tips to get started!
|
||||||
|
|
||||||
### ❌ (Please delete all these tips and replace them with your text) ❌
|
### ❌ (Please delete all these tips and replace them with your text) ❌
|
||||||
|
|
||||||
- Before starting on some new big chunk of code, it it is optional but highly recommended to open an issue first
|
- Before starting on some new big chunk of code, it it is optional but highly recommended to open an issue first
|
||||||
to say "Hey, I think this idea X should be implemented and I'm starting work on it. My general plan is Y, any feedback
|
to say "Hey, I think this idea X should be implemented and I'm starting work on it. My general plan is Y, any feedback
|
||||||
is appreciated." This will allow other devs to potentially save you time by not accidentially duplicating work etc...
|
is appreciated." This will allow other devs to potentially save you time by not accidentially duplicating work etc...
|
||||||
@@ -15,12 +16,12 @@
|
|||||||
- If you do not have the affected hardware to test your code changes adequately against regressions, please indicate this, so that contributors and commnunity members can help test your changes.
|
- If you do not have the affected hardware to test your code changes adequately against regressions, please indicate this, so that contributors and commnunity members can help test your changes.
|
||||||
- If your PR gets accepted you can request a "Contributor" role in the Meshtastic Discord
|
- If your PR gets accepted you can request a "Contributor" role in the Meshtastic Discord
|
||||||
|
|
||||||
|
|
||||||
## 🤝 Attestations
|
## 🤝 Attestations
|
||||||
|
|
||||||
- [ ] I have tested that my proposed changes behave as described.
|
- [ ] I have tested that my proposed changes behave as described.
|
||||||
- [ ] I have tested that my proposed changes do not cause any obvious regressions on the following devices:
|
- [ ] I have tested that my proposed changes do not cause any obvious regressions on the following devices:
|
||||||
- [ ] Heltec (Lora32) V3
|
- [ ] Heltec (Lora32) V3
|
||||||
- [ ] LilyGo T-Deck
|
- [ ] LilyGo T-Deck
|
||||||
- [ ] LilyGo T-Beam
|
- [ ] LilyGo T-Beam
|
||||||
- [ ] RAK WisBlock 4631
|
- [ ] RAK WisBlock 4631
|
||||||
- [ ] Seeed Studio T-1000E tracker card
|
- [ ] Seeed Studio T-1000E tracker card
|
||||||
|
|||||||
2
.github/workflows/build_esp32.yml
vendored
2
.github/workflows/build_esp32.yml
vendored
@@ -33,5 +33,5 @@ jobs:
|
|||||||
artifact-paths: |
|
artifact-paths: |
|
||||||
release/*.bin
|
release/*.bin
|
||||||
release/*.elf
|
release/*.elf
|
||||||
include-web-ui: true
|
#include-web-ui: true
|
||||||
arch: esp32
|
arch: esp32
|
||||||
|
|||||||
2
.github/workflows/build_esp32_c3.yml
vendored
2
.github/workflows/build_esp32_c3.yml
vendored
@@ -33,5 +33,5 @@ jobs:
|
|||||||
artifact-paths: |
|
artifact-paths: |
|
||||||
release/*.bin
|
release/*.bin
|
||||||
release/*.elf
|
release/*.elf
|
||||||
include-web-ui: true
|
#include-web-ui: true
|
||||||
arch: esp32c3
|
arch: esp32c3
|
||||||
|
|||||||
2
.github/workflows/build_esp32_c6.yml
vendored
2
.github/workflows/build_esp32_c6.yml
vendored
@@ -33,5 +33,5 @@ jobs:
|
|||||||
artifact-paths: |
|
artifact-paths: |
|
||||||
release/*.bin
|
release/*.bin
|
||||||
release/*.elf
|
release/*.elf
|
||||||
include-web-ui: true
|
#include-web-ui: true
|
||||||
arch: esp32c6
|
arch: esp32c6
|
||||||
|
|||||||
2
.github/workflows/build_esp32_s3.yml
vendored
2
.github/workflows/build_esp32_s3.yml
vendored
@@ -33,5 +33,5 @@ jobs:
|
|||||||
artifact-paths: |
|
artifact-paths: |
|
||||||
release/*.bin
|
release/*.bin
|
||||||
release/*.elf
|
release/*.elf
|
||||||
include-web-ui: true
|
#include-web-ui: true
|
||||||
arch: esp32s3
|
arch: esp32s3
|
||||||
|
|||||||
2
.github/workflows/daily_packaging.yml
vendored
2
.github/workflows/daily_packaging.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: Daily Packaging
|
name: Daily Packaging
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: 0 9 * * *
|
- cron: 0 2 * * *
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
|||||||
1
.github/workflows/main_matrix.yml
vendored
1
.github/workflows/main_matrix.yml
vendored
@@ -257,7 +257,6 @@ jobs:
|
|||||||
./device-*.sh
|
./device-*.sh
|
||||||
./device-*.bat
|
./device-*.bat
|
||||||
./littlefs-*.bin
|
./littlefs-*.bin
|
||||||
./littlefswebui-*.bin
|
|
||||||
./bleota*bin
|
./bleota*bin
|
||||||
./Meshtastic_nRF52_factory_erase*.uf2
|
./Meshtastic_nRF52_factory_erase*.uf2
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
|||||||
1
.github/workflows/release_channels.yml
vendored
1
.github/workflows/release_channels.yml
vendored
@@ -98,6 +98,7 @@ jobs:
|
|||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@v7
|
||||||
with:
|
with:
|
||||||
base: ${{ github.event.repository.default_branch }}
|
base: ${{ github.event.repository.default_branch }}
|
||||||
|
branch: create-pull-request/bump-version
|
||||||
title: Bump release version
|
title: Bump release version
|
||||||
commit-message: automated bumps
|
commit-message: automated bumps
|
||||||
add-paths: |
|
add-paths: |
|
||||||
|
|||||||
1
.github/workflows/update_protobufs.yml
vendored
1
.github/workflows/update_protobufs.yml
vendored
@@ -33,6 +33,7 @@ jobs:
|
|||||||
- name: Create pull request
|
- name: Create pull request
|
||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@v7
|
||||||
with:
|
with:
|
||||||
|
branch: create-pull-request/update-protobufs
|
||||||
title: Update protobufs and classes
|
title: Update protobufs and classes
|
||||||
add-paths: |
|
add-paths: |
|
||||||
protobufs
|
protobufs
|
||||||
|
|||||||
@@ -4,31 +4,31 @@ cli:
|
|||||||
plugins:
|
plugins:
|
||||||
sources:
|
sources:
|
||||||
- id: trunk
|
- id: trunk
|
||||||
ref: v1.7.0
|
ref: v1.7.1
|
||||||
uri: https://github.com/trunk-io/plugins
|
uri: https://github.com/trunk-io/plugins
|
||||||
lint:
|
lint:
|
||||||
enabled:
|
enabled:
|
||||||
- checkov@3.2.435
|
- checkov@3.2.446
|
||||||
- renovate@40.34.4
|
- renovate@41.10.0
|
||||||
- prettier@3.5.3
|
- prettier@3.6.1
|
||||||
- trufflehog@3.88.34
|
- trufflehog@3.89.2
|
||||||
- yamllint@1.37.1
|
- yamllint@1.37.1
|
||||||
- bandit@1.8.3
|
- bandit@1.8.5
|
||||||
- trivy@0.62.1
|
- trivy@0.63.0
|
||||||
- taplo@0.9.3
|
- taplo@0.9.3
|
||||||
- ruff@0.11.11
|
- ruff@0.12.0
|
||||||
- isort@6.0.1
|
- isort@6.0.1
|
||||||
- markdownlint@0.45.0
|
- markdownlint@0.45.0
|
||||||
- oxipng@9.1.5
|
- oxipng@9.1.5
|
||||||
- svgo@3.3.2
|
- svgo@4.0.0
|
||||||
- actionlint@1.7.7
|
- actionlint@1.7.7
|
||||||
- flake8@7.2.0
|
- flake8@7.3.0
|
||||||
- hadolint@2.12.1-beta
|
- hadolint@2.12.1-beta
|
||||||
- shfmt@3.6.0
|
- shfmt@3.6.0
|
||||||
- shellcheck@0.10.0
|
- shellcheck@0.10.0
|
||||||
- black@25.1.0
|
- black@25.1.0
|
||||||
- git-diff-check
|
- git-diff-check
|
||||||
- gitleaks@8.26.0
|
- gitleaks@8.27.2
|
||||||
- clang-format@16.0.3
|
- clang-format@16.0.3
|
||||||
ignore:
|
ignore:
|
||||||
- linters: [ALL]
|
- linters: [ALL]
|
||||||
|
|||||||
54
.vscode/settings.json
vendored
54
.vscode/settings.json
vendored
@@ -10,59 +10,5 @@
|
|||||||
},
|
},
|
||||||
"[powershell]": {
|
"[powershell]": {
|
||||||
"editor.defaultFormatter": "ms-vscode.powershell"
|
"editor.defaultFormatter": "ms-vscode.powershell"
|
||||||
},
|
|
||||||
"files.associations": {
|
|
||||||
"array": "cpp",
|
|
||||||
"atomic": "cpp",
|
|
||||||
"*.tcc": "cpp",
|
|
||||||
"cctype": "cpp",
|
|
||||||
"clocale": "cpp",
|
|
||||||
"cmath": "cpp",
|
|
||||||
"csignal": "cpp",
|
|
||||||
"cstdarg": "cpp",
|
|
||||||
"cstddef": "cpp",
|
|
||||||
"cstdint": "cpp",
|
|
||||||
"cstdio": "cpp",
|
|
||||||
"cstdlib": "cpp",
|
|
||||||
"cstring": "cpp",
|
|
||||||
"ctime": "cpp",
|
|
||||||
"cwchar": "cpp",
|
|
||||||
"cwctype": "cpp",
|
|
||||||
"deque": "cpp",
|
|
||||||
"list": "cpp",
|
|
||||||
"unordered_map": "cpp",
|
|
||||||
"unordered_set": "cpp",
|
|
||||||
"vector": "cpp",
|
|
||||||
"exception": "cpp",
|
|
||||||
"algorithm": "cpp",
|
|
||||||
"functional": "cpp",
|
|
||||||
"iterator": "cpp",
|
|
||||||
"map": "cpp",
|
|
||||||
"memory": "cpp",
|
|
||||||
"memory_resource": "cpp",
|
|
||||||
"numeric": "cpp",
|
|
||||||
"optional": "cpp",
|
|
||||||
"random": "cpp",
|
|
||||||
"string": "cpp",
|
|
||||||
"string_view": "cpp",
|
|
||||||
"system_error": "cpp",
|
|
||||||
"tuple": "cpp",
|
|
||||||
"type_traits": "cpp",
|
|
||||||
"utility": "cpp",
|
|
||||||
"fstream": "cpp",
|
|
||||||
"initializer_list": "cpp",
|
|
||||||
"iomanip": "cpp",
|
|
||||||
"iosfwd": "cpp",
|
|
||||||
"iostream": "cpp",
|
|
||||||
"istream": "cpp",
|
|
||||||
"limits": "cpp",
|
|
||||||
"new": "cpp",
|
|
||||||
"ostream": "cpp",
|
|
||||||
"sstream": "cpp",
|
|
||||||
"stdexcept": "cpp",
|
|
||||||
"streambuf": "cpp",
|
|
||||||
"cinttypes": "cpp",
|
|
||||||
"typeinfo": "cpp",
|
|
||||||
"*.xbm": "cpp"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,3 +37,4 @@ Join our community and help improve Meshtastic! 🚀
|
|||||||
## Stats
|
## Stats
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# trunk-ignore-all(hadolint/DL3018): Do not pin apk package versions
|
# trunk-ignore-all(hadolint/DL3018): Do not pin apk package versions
|
||||||
# trunk-ignore-all(hadolint/DL3013): Do not pin pip package versions
|
# trunk-ignore-all(hadolint/DL3013): Do not pin pip package versions
|
||||||
|
|
||||||
FROM python:3.13-alpine3.21 AS builder
|
FROM python:3.13-alpine3.22 AS builder
|
||||||
ARG PIO_ENV=native
|
ARG PIO_ENV=native
|
||||||
ENV PIP_ROOT_USER_ACTION=ignore
|
ENV PIP_ROOT_USER_ACTION=ignore
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ RUN bash ./bin/build-native.sh "$PIO_ENV" && \
|
|||||||
|
|
||||||
# ##### PRODUCTION BUILD #############
|
# ##### PRODUCTION BUILD #############
|
||||||
|
|
||||||
FROM alpine:3.21
|
FROM alpine:3.22
|
||||||
LABEL org.opencontainers.image.title="Meshtastic" \
|
LABEL org.opencontainers.image.title="Meshtastic" \
|
||||||
org.opencontainers.image.description="Alpine Meshtastic daemon" \
|
org.opencontainers.image.description="Alpine Meshtastic daemon" \
|
||||||
org.opencontainers.image.url="https://meshtastic.org" \
|
org.opencontainers.image.url="https://meshtastic.org" \
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ extends = arduino_base
|
|||||||
custom_esp32_kind = esp32
|
custom_esp32_kind = esp32
|
||||||
platform =
|
platform =
|
||||||
# renovate: datasource=custom.pio depName=platformio/espressif32 packageName=platformio/platform/espressif32
|
# renovate: datasource=custom.pio depName=platformio/espressif32 packageName=platformio/platform/espressif32
|
||||||
platformio/espressif32@6.10.0
|
platformio/espressif32@6.11.0
|
||||||
|
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2xx0> -<mesh/eth/> -<mesh/raspihttp>
|
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2xx0> -<mesh/eth/> -<mesh/raspihttp>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
[portduino_base]
|
[portduino_base]
|
||||||
platform =
|
platform =
|
||||||
# renovate: datasource=git-refs depName=platform-native packageName=https://github.com/meshtastic/platform-native gitBranch=develop
|
# renovate: datasource=git-refs depName=platform-native packageName=https://github.com/meshtastic/platform-native gitBranch=develop
|
||||||
https://github.com/meshtastic/platform-native/archive/622341c6de8a239704318b10c3dbb00c21a3eab3.zip
|
https://github.com/meshtastic/platform-native/archive/681ee029207e9fd040afa223df6e54074cbbe084.zip
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
extends = arduino_base
|
extends = arduino_base
|
||||||
platform =
|
platform =
|
||||||
# renovate: datasource=custom.pio depName=platformio/ststm32 packageName=platformio/platform/ststm32
|
# renovate: datasource=custom.pio depName=platformio/ststm32 packageName=platformio/platform/ststm32
|
||||||
platformio/ststm32@19.1.0
|
platformio/ststm32@19.2.0
|
||||||
platform_packages =
|
platform_packages =
|
||||||
# TODO renovate
|
# TODO renovate
|
||||||
platformio/framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/2.10.1.zip
|
platformio/framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/2.10.1.zip
|
||||||
|
|||||||
@@ -34,11 +34,12 @@ SRCBIN=.pio/build/$1/firmware.bin
|
|||||||
cp $SRCBIN $OUTDIR/$basename-update.bin
|
cp $SRCBIN $OUTDIR/$basename-update.bin
|
||||||
|
|
||||||
echo "Building Filesystem for ESP32 targets"
|
echo "Building Filesystem for ESP32 targets"
|
||||||
pio run --environment $1 -t buildfs
|
# If you want to build the webui, uncomment the following lines
|
||||||
cp .pio/build/$1/littlefs.bin $OUTDIR/littlefswebui-$1-$VERSION.bin
|
# pio run --environment $1 -t buildfs
|
||||||
# Remove webserver files from the filesystem and rebuild
|
# cp .pio/build/$1/littlefs.bin $OUTDIR/littlefswebui-$1-$VERSION.bin
|
||||||
ls -l data/static # Diagnostic list of files
|
# # Remove webserver files from the filesystem and rebuild
|
||||||
rm -rf data/static
|
# ls -l data/static # Diagnostic list of files
|
||||||
|
# rm -rf data/static
|
||||||
pio run --environment $1 -t buildfs
|
pio run --environment $1 -t buildfs
|
||||||
cp .pio/build/$1/littlefs.bin $OUTDIR/littlefs-$1-$VERSION.bin
|
cp .pio/build/$1/littlefs.bin $OUTDIR/littlefs-$1-$VERSION.bin
|
||||||
cp bin/device-install.* $OUTDIR
|
cp bin/device-install.* $OUTDIR
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ for BOARD in $BOARDS; do
|
|||||||
CHECK="${CHECK} -e ${BOARD}"
|
CHECK="${CHECK} -e ${BOARD}"
|
||||||
done
|
done
|
||||||
|
|
||||||
pio check --flags "-DAPP_VERSION=${APP_VERSION} --suppressions-list=suppressions.txt" $CHECK --skip-packages --pattern="src/" --fail-on-defect=medium --fail-on-defect=high
|
pio check --flags "-DAPP_VERSION=${APP_VERSION} --suppressions-list=suppressions.txt --inline-suppr" $CHECK --skip-packages --pattern="src/" --fail-on-defect=medium --fail-on-defect=high
|
||||||
|
|||||||
@@ -96,9 +96,9 @@ Lora:
|
|||||||
### Some devices, like the pinedio, may require spidev0.1 as a workaround.
|
### Some devices, like the pinedio, may require spidev0.1 as a workaround.
|
||||||
# spidev: spidev0.0
|
# spidev: spidev0.0
|
||||||
|
|
||||||
### Define GPIO buttons here:
|
### Deprecated location for User Button:
|
||||||
|
|
||||||
GPIO:
|
#GPIO:
|
||||||
# User: 6
|
# User: 6
|
||||||
|
|
||||||
### Define GPS
|
### Define GPS
|
||||||
@@ -115,17 +115,6 @@ I2C:
|
|||||||
|
|
||||||
Display:
|
Display:
|
||||||
|
|
||||||
### Waveshare 1.44inch LCD HAT
|
|
||||||
# Panel: ST7735S
|
|
||||||
# CS: 8 #Chip Select
|
|
||||||
# DC: 25 # Data/Command pin
|
|
||||||
# Backlight: 24
|
|
||||||
# Width: 128
|
|
||||||
# Height: 128
|
|
||||||
# Reset: 27
|
|
||||||
# OffsetX: 0
|
|
||||||
# OffsetY: 0
|
|
||||||
|
|
||||||
### Adafruit PiTFT 2.8 TFT+Touchscreen
|
### Adafruit PiTFT 2.8 TFT+Touchscreen
|
||||||
# Panel: ILI9341
|
# Panel: ILI9341
|
||||||
# CS: 8
|
# CS: 8
|
||||||
@@ -180,6 +169,16 @@ Input:
|
|||||||
|
|
||||||
# KeyboardDevice: /dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd
|
# KeyboardDevice: /dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd
|
||||||
|
|
||||||
|
### Standard User Button Config
|
||||||
|
# UserButton: 6
|
||||||
|
|
||||||
|
### Trackball/Joystick input
|
||||||
|
# TrackballUp: 6
|
||||||
|
# TrackballDown: 19
|
||||||
|
# TrackballLeft: 5
|
||||||
|
# TrackballRight: 26
|
||||||
|
# TrackballPress: 13
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
Logging:
|
Logging:
|
||||||
|
|||||||
26
bin/config.d/display-waveshare-1-44.yaml
Normal file
26
bin/config.d/display-waveshare-1-44.yaml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
### Waveshare 1.44inch LCD HAT
|
||||||
|
Display:
|
||||||
|
Panel: ST7735S
|
||||||
|
spidev: spidev0.0 # Specify either the spidev here, or the CS below
|
||||||
|
# CS: 8 #Chip Select # Optional, as this is the default pin for spidev0.0
|
||||||
|
DC: 25 # Data/Command pin
|
||||||
|
Backlight: 24
|
||||||
|
Width: 128
|
||||||
|
Height: 128
|
||||||
|
Reset: 27
|
||||||
|
OffsetX: 2
|
||||||
|
OffsetY: 1
|
||||||
|
|
||||||
|
|
||||||
|
# OffsetY: 31 # These two options are used to properly flip the screen 180 degrees
|
||||||
|
# OffsetRotate: 3
|
||||||
|
|
||||||
|
|
||||||
|
Input:
|
||||||
|
TrackballUp: 6
|
||||||
|
TrackballDown: 19
|
||||||
|
TrackballLeft: 5
|
||||||
|
TrackballRight: 26
|
||||||
|
TrackballPress: 13
|
||||||
|
|
||||||
|
# User: 21
|
||||||
@@ -6,6 +6,6 @@ Lora:
|
|||||||
IRQ: 16
|
IRQ: 16
|
||||||
Busy: 20
|
Busy: 20
|
||||||
Reset: 24
|
Reset: 24
|
||||||
TXen: 13
|
RXen: 12
|
||||||
DIO2_AS_RF_SWITCH: true
|
DIO2_AS_RF_SWITCH: true
|
||||||
DIO3_TCXO_VOLTAGE: true
|
DIO3_TCXO_VOLTAGE: true
|
||||||
|
|||||||
21
bin/config.d/lora-RAK6421.yaml
Normal file
21
bin/config.d/lora-RAK6421.yaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Lora:
|
||||||
|
|
||||||
|
### RAK13300in Slot 1
|
||||||
|
Module: sx1262
|
||||||
|
IRQ: 22 #IO6
|
||||||
|
Reset: 16 # IO4
|
||||||
|
Busy: 24 # IO5
|
||||||
|
# Ant_sw: 13 # IO3
|
||||||
|
DIO3_TCXO_VOLTAGE: true
|
||||||
|
DIO2_AS_RF_SWITCH: true
|
||||||
|
spidev: spidev0.0
|
||||||
|
# CS: 8
|
||||||
|
|
||||||
|
|
||||||
|
### RAK13300in Slot 2 pins
|
||||||
|
# IRQ: 18 #IO6
|
||||||
|
# Reset: 24 # IO4
|
||||||
|
# Busy: 19 # IO5
|
||||||
|
# # Ant_sw: 23 # IO3
|
||||||
|
# spidev: spidev0.1
|
||||||
|
# # CS: 7
|
||||||
18
bin/config.d/lora-lyra-picocalc-wio-sx1262.yaml
Normal file
18
bin/config.d/lora-lyra-picocalc-wio-sx1262.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
Lora:
|
||||||
|
Module: sx1262
|
||||||
|
DIO2_AS_RF_SWITCH: true
|
||||||
|
DIO3_TCXO_VOLTAGE: true
|
||||||
|
gpiochip: 0
|
||||||
|
MOSI: 12
|
||||||
|
MISO: 13
|
||||||
|
IRQ: 1
|
||||||
|
Busy: 23
|
||||||
|
Reset: 22
|
||||||
|
RXen: 0
|
||||||
|
gpiochip: 1
|
||||||
|
CS: 9
|
||||||
|
SCK: 11
|
||||||
|
# TXen: bridge to DIO2 on E22 module
|
||||||
|
SX126X_MAX_POWER: 22
|
||||||
|
spidev: spidev1.0
|
||||||
|
spiSpeed: 2000000
|
||||||
@@ -5,13 +5,13 @@ TITLE Meshtastic device-install
|
|||||||
SET "SCRIPT_NAME=%~nx0"
|
SET "SCRIPT_NAME=%~nx0"
|
||||||
SET "DEBUG=0"
|
SET "DEBUG=0"
|
||||||
SET "PYTHON="
|
SET "PYTHON="
|
||||||
SET "WEB_APP=0"
|
|
||||||
SET "TFT_BUILD=0"
|
SET "TFT_BUILD=0"
|
||||||
SET "BIGDB8=0"
|
SET "BIGDB8=0"
|
||||||
SET "BIGDB16=0"
|
SET "BIGDB16=0"
|
||||||
SET "ESPTOOL_BAUD=115200"
|
SET "ESPTOOL_BAUD=115200"
|
||||||
SET "ESPTOOL_CMD="
|
SET "ESPTOOL_CMD="
|
||||||
SET "LOGCOUNTER=0"
|
SET "LOGCOUNTER=0"
|
||||||
|
SET "BPS_RESET=0"
|
||||||
|
|
||||||
@REM FIXME: Determine mcu from PlatformIO variant, this is unmaintainable.
|
@REM FIXME: Determine mcu from PlatformIO variant, this is unmaintainable.
|
||||||
SET "S3=s3 v3 t-deck wireless-paper wireless-tracker station-g2 unphone"
|
SET "S3=s3 v3 t-deck wireless-paper wireless-tracker station-g2 unphone"
|
||||||
@@ -24,7 +24,7 @@ GOTO getopts
|
|||||||
:help
|
:help
|
||||||
ECHO Flash image file to device, but first erasing and writing system information.
|
ECHO Flash image file to device, but first erasing and writing system information.
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO Usage: %SCRIPT_NAME% -f filename [-p PORT] [-P python] (--web)
|
ECHO Usage: %SCRIPT_NAME% -f filename [-p PORT] [-P python] [--1200bps-reset]
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO Options:
|
ECHO Options:
|
||||||
ECHO -f filename The firmware .bin file to flash. Custom to your device type and region. (required)
|
ECHO -f filename The firmware .bin file to flash. Custom to your device type and region. (required)
|
||||||
@@ -34,14 +34,16 @@ ECHO If not set, ESPTOOL iterates all ports (Dangerous).
|
|||||||
ECHO -P python Specify alternate python interpreter to use to invoke esptool. (default: python)
|
ECHO -P python Specify alternate python interpreter to use to invoke esptool. (default: python)
|
||||||
ECHO If supplied the script will use python.
|
ECHO If supplied the script will use python.
|
||||||
ECHO If not supplied the script will try to find esptool in Path.
|
ECHO If not supplied the script will try to find esptool in Path.
|
||||||
ECHO --web Enable WebUI. (default: false)
|
ECHO --1200bps-reset Attempt to place the device in correct mode. (1200bps Reset)
|
||||||
|
ECHO Some hardware requires this twice.
|
||||||
ECHO.
|
ECHO.
|
||||||
|
ECHO Example: %SCRIPT_NAME% -p COM17 --1200bps-reset
|
||||||
ECHO Example: %SCRIPT_NAME% -f firmware-t-deck-tft-2.6.0.0b106d4.bin -p COM11
|
ECHO Example: %SCRIPT_NAME% -f firmware-t-deck-tft-2.6.0.0b106d4.bin -p COM11
|
||||||
ECHO Example: %SCRIPT_NAME% -f firmware-unphone-2.6.0.0b106d4.bin -p COM11 --web
|
ECHO Example: %SCRIPT_NAME% -f firmware-unphone-2.6.0.0b106d4.bin -p COM11
|
||||||
GOTO eof
|
GOTO eof
|
||||||
|
|
||||||
:version
|
:version
|
||||||
ECHO %SCRIPT_NAME% [Version 2.6.1]
|
ECHO %SCRIPT_NAME% [Version 2.6.2]
|
||||||
ECHO Meshtastic
|
ECHO Meshtastic
|
||||||
GOTO eof
|
GOTO eof
|
||||||
|
|
||||||
@@ -57,11 +59,13 @@ IF /I "%~1"=="-f" SET "FILENAME=%~2" & SHIFT
|
|||||||
IF "%~1"=="-p" SET "ESPTOOL_PORT=%~2" & SHIFT
|
IF "%~1"=="-p" SET "ESPTOOL_PORT=%~2" & SHIFT
|
||||||
IF /I "%~1"=="--port" SET "ESPTOOL_PORT=%~2" & SHIFT
|
IF /I "%~1"=="--port" SET "ESPTOOL_PORT=%~2" & SHIFT
|
||||||
IF "%~1"=="-P" SET "PYTHON=%~2" & SHIFT
|
IF "%~1"=="-P" SET "PYTHON=%~2" & SHIFT
|
||||||
IF /I "%~1"=="--web" SET "WEB_APP=1"
|
IF /I "%~1"=="--1200bps-reset" SET "BPS_RESET=1"
|
||||||
SHIFT
|
SHIFT
|
||||||
GOTO getopts
|
GOTO getopts
|
||||||
:endopts
|
:endopts
|
||||||
|
|
||||||
|
IF %BPS_RESET% EQU 1 GOTO skip-filename
|
||||||
|
|
||||||
CALL :LOG_MESSAGE DEBUG "Checking FILENAME parameter..."
|
CALL :LOG_MESSAGE DEBUG "Checking FILENAME parameter..."
|
||||||
IF "__!FILENAME!__"=="____" (
|
IF "__!FILENAME!__"=="____" (
|
||||||
CALL :LOG_MESSAGE DEBUG "Missing -f filename input."
|
CALL :LOG_MESSAGE DEBUG "Missing -f filename input."
|
||||||
@@ -95,6 +99,9 @@ IF NOT "!FILENAME:update=!"=="!FILENAME!" (
|
|||||||
CALL :LOG_MESSAGE DEBUG "We are NOT working with a *update* file. !FILENAME!"
|
CALL :LOG_MESSAGE DEBUG "We are NOT working with a *update* file. !FILENAME!"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
:skip-filename
|
||||||
|
SET "ESPTOOL_BAUD=1200"
|
||||||
|
|
||||||
CALL :LOG_MESSAGE DEBUG "Determine the correct esptool command to use..."
|
CALL :LOG_MESSAGE DEBUG "Determine the correct esptool command to use..."
|
||||||
IF NOT "__%PYTHON%__"=="____" (
|
IF NOT "__%PYTHON%__"=="____" (
|
||||||
SET "ESPTOOL_CMD=!PYTHON! -m esptool"
|
SET "ESPTOOL_CMD=!PYTHON! -m esptool"
|
||||||
@@ -133,13 +140,16 @@ IF "__!ESPTOOL_PORT!__" == "____" (
|
|||||||
)
|
)
|
||||||
CALL :LOG_MESSAGE INFO "Using esptool baud: !ESPTOOL_BAUD!."
|
CALL :LOG_MESSAGE INFO "Using esptool baud: !ESPTOOL_BAUD!."
|
||||||
|
|
||||||
|
IF %BPS_RESET% EQU 1 (
|
||||||
|
@REM Attempt to change mode via 1200bps Reset.
|
||||||
|
CALL :RUN_ESPTOOL !ESPTOOL_BAUD! --after no_reset read_flash_status
|
||||||
|
GOTO eof
|
||||||
|
)
|
||||||
|
|
||||||
@REM Check if FILENAME contains "-tft-" and set target partitionScheme accordingly.
|
@REM Check if FILENAME contains "-tft-" and set target partitionScheme accordingly.
|
||||||
@REM https://github.com/meshtastic/web-flasher/blob/main/types/resources.ts#L3
|
@REM https://github.com/meshtastic/web-flasher/blob/main/types/resources.ts#L3
|
||||||
IF NOT "!FILENAME:-tft-=!"=="!FILENAME!" (
|
IF NOT "!FILENAME:-tft-=!"=="!FILENAME!" (
|
||||||
CALL :LOG_MESSAGE DEBUG "We are working with a *-tft-* file. !FILENAME!"
|
CALL :LOG_MESSAGE DEBUG "We are working with a *-tft-* file. !FILENAME!"
|
||||||
IF %WEB_APP% EQU 1 (
|
|
||||||
CALL :LOG_MESSAGE ERROR "Cannot enable WebUI (--web) and MUI." & GOTO eof
|
|
||||||
)
|
|
||||||
SET "TFT_BUILD=1"
|
SET "TFT_BUILD=1"
|
||||||
) ELSE (
|
) ELSE (
|
||||||
CALL :LOG_MESSAGE DEBUG "We are NOT working with a *-tft-* file. !FILENAME!"
|
CALL :LOG_MESSAGE DEBUG "We are NOT working with a *-tft-* file. !FILENAME!"
|
||||||
@@ -193,13 +203,8 @@ SET "OTA_FILENAME=bleota.bin"
|
|||||||
:end_loop_c3
|
:end_loop_c3
|
||||||
CALL :LOG_MESSAGE DEBUG "Set OTA_FILENAME to: !OTA_FILENAME!"
|
CALL :LOG_MESSAGE DEBUG "Set OTA_FILENAME to: !OTA_FILENAME!"
|
||||||
|
|
||||||
@REM Check if (--web) is enabled and prefix BASENAME with "littlefswebui-" else "littlefs-".
|
@REM Set SPIFFS filename with "littlefs-" prefix.
|
||||||
IF %WEB_APP% EQU 1 (
|
SET "SPIFFS_FILENAME=littlefs-%BASENAME%"
|
||||||
CALL :LOG_MESSAGE INFO "WebUI selected."
|
|
||||||
SET "SPIFFS_FILENAME=littlefswebui-%BASENAME%"
|
|
||||||
) ELSE (
|
|
||||||
SET "SPIFFS_FILENAME=littlefs-%BASENAME%"
|
|
||||||
)
|
|
||||||
CALL :LOG_MESSAGE DEBUG "Set SPIFFS_FILENAME to: !SPIFFS_FILENAME!"
|
CALL :LOG_MESSAGE DEBUG "Set SPIFFS_FILENAME to: !SPIFFS_FILENAME!"
|
||||||
|
|
||||||
@REM Default offsets.
|
@REM Default offsets.
|
||||||
@@ -254,6 +259,7 @@ EXIT /B %ERRORLEVEL%
|
|||||||
IF %DEBUG% EQU 1 CALL :LOG_MESSAGE DEBUG "About to run command: !ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4"
|
IF %DEBUG% EQU 1 CALL :LOG_MESSAGE DEBUG "About to run command: !ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4"
|
||||||
CALL :RESET_ERROR
|
CALL :RESET_ERROR
|
||||||
!ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4
|
!ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4
|
||||||
|
IF %BPS_RESET% EQU 1 GOTO :eof
|
||||||
IF %ERRORLEVEL% NEQ 0 (
|
IF %ERRORLEVEL% NEQ 0 (
|
||||||
CALL :LOG_MESSAGE ERROR "Error running command: !ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4"
|
CALL :LOG_MESSAGE ERROR "Error running command: !ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4"
|
||||||
EXIT /B %ERRORLEVEL%
|
EXIT /B %ERRORLEVEL%
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
PYTHON=${PYTHON:-$(which python3 python | head -n 1)}
|
PYTHON=${PYTHON:-$(which python3 python | head -n 1)}
|
||||||
WEB_APP=false
|
BPS_RESET=false
|
||||||
TFT_BUILD=false
|
TFT_BUILD=false
|
||||||
MCU=""
|
MCU=""
|
||||||
|
|
||||||
# Variant groups
|
# Variant groups
|
||||||
BIGDB_8MB=(
|
BIGDB_8MB=(
|
||||||
"picomputer-s3"
|
# Check if FILENAME contains "-tft-" and set target partitionScheme accordingly.
|
||||||
|
if [[ $FILENAME == *"-tft-"* ]]; then
|
||||||
|
TFT_BUILD=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract BASENAME from %FILENAME% for later use.r-s3"
|
||||||
"unphone"
|
"unphone"
|
||||||
"seeed-sensecap-indicator"
|
"seeed-sensecap-indicator"
|
||||||
"crowpanel-esp32s3"
|
"crowpanel-esp32s3"
|
||||||
@@ -32,185 +37,185 @@ BIGDB_16MB=(
|
|||||||
"ESP32-S3-Pico"
|
"ESP32-S3-Pico"
|
||||||
"m5stack-cores3"
|
"m5stack-cores3"
|
||||||
"station-g2"
|
"station-g2"
|
||||||
"t-eth-elite"
|
"t-eth-elite"
|
||||||
"t-watch-s3"
|
"t-watch-s3"
|
||||||
|
"elecrow-adv-35-tft"
|
||||||
|
"elecrow-adv-24-28-tft"
|
||||||
|
"elecrow-adv1-43-50-70-tft"
|
||||||
)
|
)
|
||||||
S3_VARIANTS=(
|
S3_VARIANTS=(
|
||||||
"s3"
|
"s3"
|
||||||
"-v3"
|
"-v3"
|
||||||
"t-deck"
|
"t-deck"
|
||||||
"wireless-paper"
|
"wireless-paper"
|
||||||
"wireless-tracker"
|
"wireless-tracker"
|
||||||
"station-g2"
|
"station-g2"
|
||||||
"unphone"
|
"unphone"
|
||||||
"t-eth-elite"
|
"t-eth-elite"
|
||||||
"mesh-tab"
|
"mesh-tab"
|
||||||
"dreamcatcher"
|
"dreamcatcher"
|
||||||
"ESP32-S3-Pico"
|
"ESP32-S3-Pico"
|
||||||
"seeed-sensecap-indicator"
|
"seeed-sensecap-indicator"
|
||||||
"heltec_capsule_sensor_v3"
|
"heltec_capsule_sensor_v3"
|
||||||
"vision-master"
|
"vision-master"
|
||||||
"icarus"
|
"icarus"
|
||||||
"tracksenger"
|
"tracksenger"
|
||||||
"elecrow-adv"
|
"elecrow-adv"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Determine the correct esptool command to use
|
# Determine the correct esptool command to use
|
||||||
if "$PYTHON" -m esptool version >/dev/null 2>&1; then
|
if "$PYTHON" -m esptool version >/dev/null 2>&1; then
|
||||||
ESPTOOL_CMD="$PYTHON -m esptool"
|
ESPTOOL_CMD="$PYTHON -m esptool"
|
||||||
elif command -v esptool >/dev/null 2>&1; then
|
elif command -v esptool >/dev/null 2>&1; then
|
||||||
ESPTOOL_CMD="esptool"
|
ESPTOOL_CMD="esptool"
|
||||||
elif command -v esptool.py >/dev/null 2>&1; then
|
elif command -v esptool.py >/dev/null 2>&1; then
|
||||||
ESPTOOL_CMD="esptool.py"
|
ESPTOOL_CMD="esptool.py"
|
||||||
else
|
else
|
||||||
echo "Error: esptool not found"
|
echo "Error: esptool not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Usage info
|
# Usage info
|
||||||
show_help() {
|
show_help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME] [--web]
|
Usage: $(basename "$0") [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME] [--1200bps-reset]
|
||||||
Flash image file to device, but first erasing and writing system information.
|
Flash image file to device, but first erasing and writing system information.
|
||||||
|
|
||||||
-h Display this help and exit.
|
-h Display this help and exit.
|
||||||
-p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerous).
|
-p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerous).
|
||||||
-P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON")
|
-P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON")
|
||||||
-f FILENAME The firmware .bin file to flash. Custom to your device type and region.
|
-f FILENAME The firmware .bin file to flash. Custom to your device type and region.
|
||||||
--web Enable WebUI. (Default: false)
|
--1200bps-reset Attempt to place the device in correct mode. Some hardware requires this twice. (1200bps Reset)
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
# Parse arguments using a single while loop
|
# Parse arguments using a single while loop
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h | --help)
|
-h | --help)
|
||||||
show_help
|
show_help
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-p)
|
-p)
|
||||||
ESPTOOL_CMD="$ESPTOOL_CMD --port $2"
|
ESPTOOL_CMD="$ESPTOOL_CMD --port $2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-P)
|
-P)
|
||||||
PYTHON="$2"
|
PYTHON="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-f)
|
-f)
|
||||||
FILENAME="$2"
|
FILENAME="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--web)
|
--1200bps-reset)
|
||||||
WEB_APP=true
|
BPS_RESET=true
|
||||||
;;
|
;;
|
||||||
--) # Stop parsing options
|
--) # Stop parsing options
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown argument: $1" >&2
|
echo "Unknown argument: $1" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift # Move to the next argument
|
shift # Move to the next argument
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -z "$FILENAME" -a -n "$1" ] && {
|
if [[ $BPS_RESET == true ]]; then
|
||||||
FILENAME=$1
|
$ESPTOOL_CMD --baud 1200 --after no_reset read_flash_status
|
||||||
shift
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -z "$FILENAME" ] && [ -n "$1" ] && {
|
||||||
|
FILENAME="$1"
|
||||||
|
shift
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $FILENAME != firmware-* ]]; then
|
if [[ "$FILENAME" != firmware-* ]]; then
|
||||||
echo "Filename must be a firmware-* file."
|
echo "Filename must be a firmware-* file."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if FILENAME contains "-tft-" and prevent web/mui comingling.
|
# Check if FILENAME contains "-tft-" and set target partitionScheme accordingly.
|
||||||
if [[ ${FILENAME//-tft-/} != "$FILENAME" ]]; then
|
if [[ "${FILENAME//-tft-/}" != "$FILENAME" ]]; then
|
||||||
TFT_BUILD=true
|
TFT_BUILD=true
|
||||||
if [[ $WEB_APP == true ]] && [[ $TFT_BUILD == true ]]; then
|
|
||||||
echo "Cannot enable WebUI (--web) and MUI."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract BASENAME from %FILENAME% for later use.
|
# Extract BASENAME from %FILENAME% for later use.
|
||||||
BASENAME="${FILENAME/firmware-/}"
|
BASENAME="${FILENAME/firmware-/}"
|
||||||
|
|
||||||
if [ -f "${FILENAME}" ] && [ -n "${FILENAME##*"update"*}" ]; then
|
if [ -f "${FILENAME}" ] && [ -n "${FILENAME##*"update"*}" ]; then
|
||||||
# Default littlefs* offset (--web).
|
# Default littlefs* offset.
|
||||||
OFFSET=0x300000
|
OFFSET=0x300000
|
||||||
|
|
||||||
# Default OTA Offset
|
# Default OTA Offset
|
||||||
OTA_OFFSET=0x260000
|
OTA_OFFSET=0x260000
|
||||||
|
|
||||||
# littlefs* offset for BigDB 8mb and OTA OFFSET.
|
# littlefs* offset for BigDB 8mb and OTA OFFSET.
|
||||||
for variant in "${BIGDB_8MB[@]}"; do
|
for variant in "${BIGDB_8MB[@]}"; do
|
||||||
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
||||||
OFFSET=0x670000
|
OFFSET=0x670000
|
||||||
OTA_OFFSET=0x340000
|
OTA_OFFSET=0x340000
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# littlefs* offset for BigDB 16mb and OTA OFFSET.
|
# littlefs* offset for BigDB 16mb and OTA OFFSET.
|
||||||
for variant in "${BIGDB_16MB[@]}"; do
|
for variant in "${BIGDB_16MB[@]}"; do
|
||||||
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
||||||
OFFSET=0xc90000
|
OFFSET=0xc90000
|
||||||
OTA_OFFSET=0x650000
|
OTA_OFFSET=0x650000
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Account for S3 board's different OTA partition
|
# Account for S3 board's different OTA partition
|
||||||
# FIXME: Use PlatformIO info to determine MCU type, this is unmaintainable
|
# FIXME: Use PlatformIO info to determine MCU type, this is unmaintainable
|
||||||
for variant in "${S3_VARIANTS[@]}"; do
|
for variant in "${S3_VARIANTS[@]}"; do
|
||||||
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
||||||
MCU="esp32s3"
|
MCU="esp32s3"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$MCU" != "esp32s3" ]; then
|
if [ "$MCU" != "esp32s3" ]; then
|
||||||
if [ -n "${FILENAME##*"esp32c3"*}" ]; then
|
if [ -n "${FILENAME##*"esp32c3"*}" ]; then
|
||||||
OTAFILE=bleota.bin
|
OTAFILE=bleota.bin
|
||||||
else
|
else
|
||||||
OTAFILE=bleota-c3.bin
|
OTAFILE=bleota-c3.bin
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
OTAFILE=bleota-s3.bin
|
OTAFILE=bleota-s3.bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if WEB_APP (--web) is enabled and add "littlefswebui-" to BASENAME else "littlefs-".
|
# Set SPIFFS filename with "littlefs-" prefix.
|
||||||
if [ "$WEB_APP" = true ]; then
|
SPIFFSFILE=littlefs-${BASENAME}
|
||||||
SPIFFSFILE=littlefswebui-${BASENAME}
|
|
||||||
else
|
|
||||||
SPIFFSFILE=littlefs-${BASENAME}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -f $FILENAME ]]; then
|
if [[ ! -f "$FILENAME" ]]; then
|
||||||
echo "Error: file ${FILENAME} wasn't found. Terminating."
|
echo "Error: file ${FILENAME} wasn't found. Terminating."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ ! -f $OTAFILE ]]; then
|
if [[ ! -f "$OTAFILE" ]]; then
|
||||||
echo "Error: file ${OTAFILE} wasn't found. Terminating."
|
echo "Error: file ${OTAFILE} wasn't found. Terminating."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ ! -f $SPIFFSFILE ]]; then
|
if [[ ! -f "$SPIFFSFILE" ]]; then
|
||||||
echo "Error: file ${SPIFFSFILE} wasn't found. Terminating."
|
echo "Error: file ${SPIFFSFILE} wasn't found. Terminating."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
|
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
|
||||||
$ESPTOOL_CMD erase_flash
|
$ESPTOOL_CMD erase_flash
|
||||||
$ESPTOOL_CMD write_flash 0x00 "${FILENAME}"
|
$ESPTOOL_CMD write_flash 0x00 "${FILENAME}"
|
||||||
echo "Trying to flash ${OTAFILE} at offset ${OTA_OFFSET}"
|
echo "Trying to flash ${OTAFILE} at offset ${OTA_OFFSET}"
|
||||||
$ESPTOOL_CMD write_flash $OTA_OFFSET "${OTAFILE}"
|
$ESPTOOL_CMD write_flash $OTA_OFFSET "${OTAFILE}"
|
||||||
echo "Trying to flash ${SPIFFSFILE}, at offset ${OFFSET}"
|
echo "Trying to flash ${SPIFFSFILE}, at offset ${OFFSET}"
|
||||||
$ESPTOOL_CMD write_flash $OFFSET "${SPIFFSFILE}"
|
$ESPTOOL_CMD write_flash $OFFSET "${SPIFFSFILE}"
|
||||||
|
|
||||||
else
|
else
|
||||||
show_help
|
show_help
|
||||||
echo "Invalid file: ${FILENAME}"
|
echo "Invalid file: ${FILENAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ SET "PYTHON="
|
|||||||
SET "ESPTOOL_BAUD=115200"
|
SET "ESPTOOL_BAUD=115200"
|
||||||
SET "ESPTOOL_CMD="
|
SET "ESPTOOL_CMD="
|
||||||
SET "LOGCOUNTER=0"
|
SET "LOGCOUNTER=0"
|
||||||
|
SET "CHANGE_MODE=0"
|
||||||
|
|
||||||
GOTO getopts
|
GOTO getopts
|
||||||
:help
|
:help
|
||||||
ECHO Flash image file to device, but leave existing system intact.
|
ECHO Flash image file to device, but leave existing system intact.
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO Usage: %SCRIPT_NAME% -f filename [-p PORT] [-P python]
|
ECHO Usage: %SCRIPT_NAME% -f filename [-p PORT] [-P python] [--change-mode]
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO Options:
|
ECHO Options:
|
||||||
ECHO -f filename The update .bin file to flash. Custom to your device type and region. (required)
|
ECHO -f filename The update .bin file to flash. Custom to your device type and region. (required)
|
||||||
@@ -23,12 +24,15 @@ ECHO If not set, ESPTOOL iterates all ports (Dangerous).
|
|||||||
ECHO -P python Specify alternate python interpreter to use to invoke esptool. (default: python)
|
ECHO -P python Specify alternate python interpreter to use to invoke esptool. (default: python)
|
||||||
ECHO If supplied the script will use python.
|
ECHO If supplied the script will use python.
|
||||||
ECHO If not supplied the script will try to find esptool in Path.
|
ECHO If not supplied the script will try to find esptool in Path.
|
||||||
|
ECHO --change-mode Attempt to place the device in correct mode. (1200bps Reset)
|
||||||
|
ECHO Some hardware requires this twice.
|
||||||
ECHO.
|
ECHO.
|
||||||
|
ECHO Example: %SCRIPT_NAME% -p COM17 --change-mode
|
||||||
ECHO Example: %SCRIPT_NAME% -f firmware-t-deck-tft-2.6.0.0b106d4-update.bin -p COM11
|
ECHO Example: %SCRIPT_NAME% -f firmware-t-deck-tft-2.6.0.0b106d4-update.bin -p COM11
|
||||||
GOTO eof
|
GOTO eof
|
||||||
|
|
||||||
:version
|
:version
|
||||||
ECHO %SCRIPT_NAME% [Version 2.6.1]
|
ECHO %SCRIPT_NAME% [Version 2.6.2]
|
||||||
ECHO Meshtastic
|
ECHO Meshtastic
|
||||||
GOTO eof
|
GOTO eof
|
||||||
|
|
||||||
@@ -44,10 +48,13 @@ IF /I "%~1"=="-f" SET "FILENAME=%~2" & SHIFT
|
|||||||
IF "%~1"=="-p" SET "ESPTOOL_PORT=%~2" & SHIFT
|
IF "%~1"=="-p" SET "ESPTOOL_PORT=%~2" & SHIFT
|
||||||
IF /I "%~1"=="--port" SET "ESPTOOL_PORT=%~2" & SHIFT
|
IF /I "%~1"=="--port" SET "ESPTOOL_PORT=%~2" & SHIFT
|
||||||
IF "%~1"=="-P" SET "PYTHON=%~2" & SHIFT
|
IF "%~1"=="-P" SET "PYTHON=%~2" & SHIFT
|
||||||
|
IF /I "%~1"=="--change-mode" SET "CHANGE_MODE=1"
|
||||||
SHIFT
|
SHIFT
|
||||||
GOTO getopts
|
GOTO getopts
|
||||||
:endopts
|
:endopts
|
||||||
|
|
||||||
|
IF %CHANGE_MODE% EQU 1 GOTO skip-filename
|
||||||
|
|
||||||
CALL :LOG_MESSAGE DEBUG "Checking FILENAME parameter..."
|
CALL :LOG_MESSAGE DEBUG "Checking FILENAME parameter..."
|
||||||
IF "__!FILENAME!__"=="____" (
|
IF "__!FILENAME!__"=="____" (
|
||||||
CALL :LOG_MESSAGE DEBUG "Missing -f filename input."
|
CALL :LOG_MESSAGE DEBUG "Missing -f filename input."
|
||||||
@@ -77,6 +84,9 @@ IF "!FILENAME:update=!"=="!FILENAME!" (
|
|||||||
CALL :LOG_MESSAGE DEBUG "We are working with a *update* file. !FILENAME!"
|
CALL :LOG_MESSAGE DEBUG "We are working with a *update* file. !FILENAME!"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
:skip-filename
|
||||||
|
SET "ESPTOOL_BAUD=1200"
|
||||||
|
|
||||||
CALL :LOG_MESSAGE DEBUG "Determine the correct esptool command to use..."
|
CALL :LOG_MESSAGE DEBUG "Determine the correct esptool command to use..."
|
||||||
IF NOT "__%PYTHON%__"=="____" (
|
IF NOT "__%PYTHON%__"=="____" (
|
||||||
SET "ESPTOOL_CMD=!PYTHON! -m esptool"
|
SET "ESPTOOL_CMD=!PYTHON! -m esptool"
|
||||||
@@ -115,6 +125,12 @@ IF "__!ESPTOOL_PORT!__" == "____" (
|
|||||||
)
|
)
|
||||||
CALL :LOG_MESSAGE INFO "Using esptool baud: !ESPTOOL_BAUD!."
|
CALL :LOG_MESSAGE INFO "Using esptool baud: !ESPTOOL_BAUD!."
|
||||||
|
|
||||||
|
IF %CHANGE_MODE% EQU 1 (
|
||||||
|
@REM Attempt to change mode via 1200bps Reset.
|
||||||
|
CALL :RUN_ESPTOOL !ESPTOOL_BAUD! --after no_reset read_flash_status
|
||||||
|
GOTO eof
|
||||||
|
)
|
||||||
|
|
||||||
@REM Flashing operations.
|
@REM Flashing operations.
|
||||||
CALL :LOG_MESSAGE INFO "Trying to flash update "!FILENAME!" at OFFSET 0x10000..."
|
CALL :LOG_MESSAGE INFO "Trying to flash update "!FILENAME!" at OFFSET 0x10000..."
|
||||||
CALL :RUN_ESPTOOL !ESPTOOL_BAUD! write_flash 0x10000 "!FILENAME!" || GOTO eof
|
CALL :RUN_ESPTOOL !ESPTOOL_BAUD! write_flash 0x10000 "!FILENAME!" || GOTO eof
|
||||||
@@ -135,6 +151,7 @@ EXIT /B %ERRORLEVEL%
|
|||||||
IF %DEBUG% EQU 1 CALL :LOG_MESSAGE DEBUG "About to run command: !ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4"
|
IF %DEBUG% EQU 1 CALL :LOG_MESSAGE DEBUG "About to run command: !ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4"
|
||||||
CALL :RESET_ERROR
|
CALL :RESET_ERROR
|
||||||
!ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4
|
!ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4
|
||||||
|
IF %CHANGE_MODE% EQU 1 GOTO :eof
|
||||||
IF %ERRORLEVEL% NEQ 0 (
|
IF %ERRORLEVEL% NEQ 0 (
|
||||||
CALL :LOG_MESSAGE ERROR "Error running command: !ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4"
|
CALL :LOG_MESSAGE ERROR "Error running command: !ESPTOOL_CMD! --baud %~1 %~2 %~3 %~4"
|
||||||
EXIT /B %ERRORLEVEL%
|
EXIT /B %ERRORLEVEL%
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
PYTHON=${PYTHON:-$(which python3 python|head -n 1)}
|
PYTHON=${PYTHON:-$(which python3 python|head -n 1)}
|
||||||
|
CHANGE_MODE=false
|
||||||
|
|
||||||
# Determine the correct esptool command to use
|
# Determine the correct esptool command to use
|
||||||
if "$PYTHON" -m esptool version >/dev/null 2>&1; then
|
if "$PYTHON" -m esptool version >/dev/null 2>&1; then
|
||||||
@@ -17,14 +18,15 @@ fi
|
|||||||
# Usage info
|
# Usage info
|
||||||
show_help() {
|
show_help() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME]
|
Usage: $(basename "$0") [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME] [--change-mode]
|
||||||
Flash image file to device, leave existing system intact."
|
Flash image file to device, leave existing system intact."
|
||||||
|
|
||||||
-h Display this help and exit
|
-h Display this help and exit
|
||||||
-p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerous).
|
-p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerous).
|
||||||
-P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON")
|
-P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON")
|
||||||
-f FILENAME The *update.bin file to flash. Custom to your device type.
|
-f FILENAME The *update.bin file to flash. Custom to your device type.
|
||||||
|
--change-mode Attempt to place the device in correct mode. Some hardware requires this twice. (1200bps Reset)
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,13 +38,16 @@ while getopts ":hp:P:f:" opt; do
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
p) ESPTOOL_CMD="$ESPTOOL_CMD --port ${OPTARG}"
|
p) ESPTOOL_CMD="$ESPTOOL_CMD --port ${OPTARG}"
|
||||||
;;
|
;;
|
||||||
P) PYTHON=${OPTARG}
|
P) PYTHON=${OPTARG}
|
||||||
;;
|
;;
|
||||||
f) FILENAME=${OPTARG}
|
f) FILENAME=${OPTARG}
|
||||||
;;
|
;;
|
||||||
|
--change-mode)
|
||||||
|
CHANGE_MODE=true
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid flag."
|
echo "Invalid flag."
|
||||||
show_help >&2
|
show_help >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
@@ -50,17 +55,22 @@ while getopts ":hp:P:f:" opt; do
|
|||||||
done
|
done
|
||||||
shift "$((OPTIND-1))"
|
shift "$((OPTIND-1))"
|
||||||
|
|
||||||
[ -z "$FILENAME" -a -n "$1" ] && {
|
if [[ $CHANGE_MODE == true ]]; then
|
||||||
FILENAME=$1
|
$ESPTOOL_CMD --baud 1200 --after no_reset read_flash_status
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -z "$FILENAME" ] && [ -n "$1" ] && {
|
||||||
|
FILENAME="$1"
|
||||||
shift
|
shift
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -f "${FILENAME}" ] && [ -z "${FILENAME##*"update"*}" ]; then
|
if [ -f "${FILENAME}" ] && [ -z "${FILENAME##*"update"*}" ]; then
|
||||||
printf "Trying to flash update ${FILENAME}"
|
echo "Trying to flash update ${FILENAME}"
|
||||||
$ESPTOOL_CMD --baud 115200 write_flash 0x10000 ${FILENAME}
|
$ESPTOOL_CMD --baud 115200 write_flash 0x10000 "${FILENAME}"
|
||||||
else
|
else
|
||||||
show_help
|
show_help
|
||||||
echo "Invalid file: ${FILENAME}"
|
echo "Invalid file: ${FILENAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ for subdir, dirs, files in os.walk(rootdir):
|
|||||||
if c.startswith("env:"):
|
if c.startswith("env:"):
|
||||||
section = config[c].name[4:]
|
section = config[c].name[4:]
|
||||||
if "extends" in config[config[c].name]:
|
if "extends" in config[config[c].name]:
|
||||||
if config[config[c].name]["extends"] == options[0] + "_base":
|
if options[0] + "_base" in config[config[c].name]["extends"]:
|
||||||
if "board_level" in config[config[c].name]:
|
if "board_level" in config[config[c].name]:
|
||||||
if (
|
if (
|
||||||
config[config[c].name]["board_level"] == "extra"
|
config[config[c].name]["board_level"] == "extra"
|
||||||
|
|||||||
@@ -87,6 +87,18 @@
|
|||||||
</screenshots>
|
</screenshots>
|
||||||
|
|
||||||
<releases>
|
<releases>
|
||||||
|
<release version="2.7.0" date="2025-06-20">
|
||||||
|
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.7.0</url>
|
||||||
|
</release>
|
||||||
|
<release version="2.6.13" date="2025-06-16">
|
||||||
|
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.6.13</url>
|
||||||
|
</release>
|
||||||
|
<release version="2.6.12" date="2025-06-15">
|
||||||
|
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.6.12</url>
|
||||||
|
</release>
|
||||||
|
<release version="2.6.11" date="2025-06-02">
|
||||||
|
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.6.11</url>
|
||||||
|
</release>
|
||||||
<release version="2.6.10" date="2025-05-25">
|
<release version="2.6.10" date="2025-05-25">
|
||||||
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.6.10</url>
|
<url type="details">https://github.com/meshtastic/firmware/releases?q=tag%3Av2.6.10</url>
|
||||||
</release>
|
</release>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.5.3
|
2.6.4
|
||||||
@@ -48,6 +48,6 @@
|
|||||||
"require_upload_port": true,
|
"require_upload_port": true,
|
||||||
"wait_for_upload_port": true
|
"wait_for_upload_port": true
|
||||||
},
|
},
|
||||||
"url": "FIXME",
|
"url": "https://www.elecrow.com/thinknode-m1-meshtastic-lora-signal-transceiver-powered-by-nrf52840-with-154-screen-support-gps.html",
|
||||||
"vendor": "ELECROW"
|
"vendor": "ELECROW"
|
||||||
}
|
}
|
||||||
|
|||||||
52
boards/gat562_mesh_trial_tracker.json
Normal file
52
boards/gat562_mesh_trial_tracker.json
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"arduino": {
|
||||||
|
"ldscript": "nrf52840_s140_v6.ld"
|
||||||
|
},
|
||||||
|
"core": "nRF5",
|
||||||
|
"cpu": "cortex-m4",
|
||||||
|
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
|
||||||
|
"f_cpu": "64000000L",
|
||||||
|
"hwids": [
|
||||||
|
["0x239A", "0x8029"],
|
||||||
|
["0x239A", "0x0029"],
|
||||||
|
["0x239A", "0x002A"],
|
||||||
|
["0x239A", "0x802A"]
|
||||||
|
],
|
||||||
|
"usb_product": "GAT562 Mesh Trial Tracker",
|
||||||
|
"mcu": "nrf52840",
|
||||||
|
"variant": "gat562_mesh_trial_tracker",
|
||||||
|
"bsp": {
|
||||||
|
"name": "adafruit"
|
||||||
|
},
|
||||||
|
"softdevice": {
|
||||||
|
"sd_flags": "-DS140",
|
||||||
|
"sd_name": "s140",
|
||||||
|
"sd_version": "6.1.1",
|
||||||
|
"sd_fwid": "0x00B6"
|
||||||
|
},
|
||||||
|
"bootloader": {
|
||||||
|
"settings_addr": "0xFF000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"connectivity": ["bluetooth"],
|
||||||
|
"debug": {
|
||||||
|
"jlink_device": "nRF52840_xxAA",
|
||||||
|
"svd_path": "nrf52840.svd",
|
||||||
|
"openocd_target": "nrf52840-mdk-rs"
|
||||||
|
},
|
||||||
|
"frameworks": ["arduino", "freertos"],
|
||||||
|
"name": "GAT562 Mesh Trial Tracker",
|
||||||
|
"upload": {
|
||||||
|
"maximum_ram_size": 248832,
|
||||||
|
"maximum_size": 815104,
|
||||||
|
"speed": 115200,
|
||||||
|
"protocol": "nrfutil",
|
||||||
|
"protocols": ["jlink", "nrfjprog", "nrfutil", "stlink"],
|
||||||
|
"use_1200bps_touch": true,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"wait_for_upload_port": true
|
||||||
|
},
|
||||||
|
"url": "http://www.gat-iot.com/",
|
||||||
|
"vendor": "GAT-IOT"
|
||||||
|
}
|
||||||
@@ -48,6 +48,6 @@
|
|||||||
"require_upload_port": true,
|
"require_upload_port": true,
|
||||||
"wait_for_upload_port": true
|
"wait_for_upload_port": true
|
||||||
},
|
},
|
||||||
"url": "FIXME",
|
"url": "https://heltec.org/project/mesh-node-t114/",
|
||||||
"vendor": "Heltec"
|
"vendor": "Heltec"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,7 @@
|
|||||||
"cpu": "cortex-m4",
|
"cpu": "cortex-m4",
|
||||||
"extra_flags": "-DARDUINO_MDBT50Q_RX -DNRF52840_XXAA",
|
"extra_flags": "-DARDUINO_MDBT50Q_RX -DNRF52840_XXAA",
|
||||||
"f_cpu": "64000000L",
|
"f_cpu": "64000000L",
|
||||||
"hwids": [
|
"hwids": [["0x2886", "0x0166"]],
|
||||||
["0x2886", "0x0166"]
|
|
||||||
],
|
|
||||||
"usb_product": "XIAO-BOOT",
|
"usb_product": "XIAO-BOOT",
|
||||||
"mcu": "nrf52840",
|
"mcu": "nrf52840",
|
||||||
"variant": "seeed_xiao_nrf52840_kit",
|
"variant": "seeed_xiao_nrf52840_kit",
|
||||||
|
|||||||
10
debian/changelog
vendored
10
debian/changelog
vendored
@@ -1,4 +1,4 @@
|
|||||||
meshtasticd (2.6.10.0) UNRELEASED; urgency=medium
|
meshtasticd (2.7.0.0) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
[ Austin Lane ]
|
[ Austin Lane ]
|
||||||
* Initial packaging
|
* Initial packaging
|
||||||
@@ -16,4 +16,10 @@ meshtasticd (2.6.10.0) UNRELEASED; urgency=medium
|
|||||||
[ ]
|
[ ]
|
||||||
* GitHub Actions Automatic version bump
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
-- <github-actions[bot]@users.noreply.github.com> Sun, 25 May 2025 20:46:49 +0000
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
[ ]
|
||||||
|
* GitHub Actions Automatic version bump
|
||||||
|
|
||||||
|
-- <github-actions[bot]@users.noreply.github.com> Mon, 16 Jun 2025 02:10:49 +0000
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ build_flags = -Wno-missing-field-initializers
|
|||||||
-DMESHTASTIC_EXCLUDE_HEALTH_TELEMETRY=1
|
-DMESHTASTIC_EXCLUDE_HEALTH_TELEMETRY=1
|
||||||
-DMESHTASTIC_EXCLUDE_POWERSTRESS=1 ; exclude power stress test module from main firmware
|
-DMESHTASTIC_EXCLUDE_POWERSTRESS=1 ; exclude power stress test module from main firmware
|
||||||
-DMESHTASTIC_EXCLUDE_GENERIC_THREAD_MODULE=1
|
-DMESHTASTIC_EXCLUDE_GENERIC_THREAD_MODULE=1
|
||||||
|
-D MAX_THREADS=40 ; As we've split modules, we have more threads to manage
|
||||||
#-DBUILD_EPOCH=$UNIX_TIME
|
#-DBUILD_EPOCH=$UNIX_TIME
|
||||||
#-D OLED_PL=1
|
#-D OLED_PL=1
|
||||||
|
|
||||||
@@ -103,12 +104,12 @@ lib_deps =
|
|||||||
[radiolib_base]
|
[radiolib_base]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
# renovate: datasource=custom.pio depName=RadioLib packageName=jgromes/library/RadioLib
|
# renovate: datasource=custom.pio depName=RadioLib packageName=jgromes/library/RadioLib
|
||||||
jgromes/RadioLib@7.1.2
|
jgromes/RadioLib@7.2.0
|
||||||
|
|
||||||
[device-ui_base]
|
[device-ui_base]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
# renovate: datasource=git-refs depName=meshtastic/device-ui packageName=https://github.com/meshtastic/device-ui gitBranch=master
|
# renovate: datasource=git-refs depName=meshtastic/device-ui packageName=https://github.com/meshtastic/device-ui gitBranch=master
|
||||||
https://github.com/meshtastic/device-ui/archive/37e2fb84a8d1b7d8cc1e2ed00d34cfb1f284bd59.zip
|
https://github.com/meshtastic/device-ui/archive/cdc6e5bdeedb8293d10e4a02be6ca64e95a7c515.zip
|
||||||
|
|
||||||
; Common libs for environmental measurements in telemetry module
|
; Common libs for environmental measurements in telemetry module
|
||||||
[environmental_base]
|
[environmental_base]
|
||||||
@@ -165,6 +166,8 @@ lib_deps =
|
|||||||
adafruit/Adafruit LTR390 Library@1.1.2
|
adafruit/Adafruit LTR390 Library@1.1.2
|
||||||
# renovate: datasource=custom.pio depName=Adafruit PCT2075 packageName=adafruit/library/Adafruit PCT2075
|
# renovate: datasource=custom.pio depName=Adafruit PCT2075 packageName=adafruit/library/Adafruit PCT2075
|
||||||
adafruit/Adafruit PCT2075@1.0.5
|
adafruit/Adafruit PCT2075@1.0.5
|
||||||
|
# renovate: datasource=custom.pio depName=DFRobot_BMM150 packageName=dfrobot/library/DFRobot_BMM150
|
||||||
|
dfrobot/DFRobot_BMM150@1.0.0
|
||||||
|
|
||||||
; (not included in native / portduino)
|
; (not included in native / portduino)
|
||||||
[environmental_extra]
|
[environmental_extra]
|
||||||
|
|||||||
Submodule protobufs updated: 24c7a3d287...386fa53c15
@@ -59,82 +59,82 @@ class AmbientLightingThread : public concurrency::OSThread
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG_DEBUG("AmbientLighting init");
|
LOG_DEBUG("AmbientLighting init");
|
||||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
#ifdef HAS_NCP5623
|
||||||
if (_type == ScanI2C::NCP5623) {
|
if (_type == ScanI2C::NCP5623) {
|
||||||
rgb.begin();
|
rgb.begin();
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_LP5562
|
#ifdef HAS_LP5562
|
||||||
} else if (_type == ScanI2C::LP5562) {
|
if (_type == ScanI2C::LP5562) {
|
||||||
rgbw.begin();
|
rgbw.begin();
|
||||||
#endif
|
#endif
|
||||||
#ifdef RGBLED_RED
|
#ifdef RGBLED_RED
|
||||||
pinMode(RGBLED_RED, OUTPUT);
|
pinMode(RGBLED_RED, OUTPUT);
|
||||||
pinMode(RGBLED_GREEN, OUTPUT);
|
pinMode(RGBLED_GREEN, OUTPUT);
|
||||||
pinMode(RGBLED_BLUE, OUTPUT);
|
pinMode(RGBLED_BLUE, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_NEOPIXEL
|
#ifdef HAS_NEOPIXEL
|
||||||
pixels.begin(); // Initialise the pixel(s)
|
pixels.begin(); // Initialise the pixel(s)
|
||||||
pixels.clear(); // Set all pixel colors to 'off'
|
pixels.clear(); // Set all pixel colors to 'off'
|
||||||
pixels.setBrightness(moduleConfig.ambient_lighting.current);
|
pixels.setBrightness(moduleConfig.ambient_lighting.current);
|
||||||
#endif
|
#endif
|
||||||
setLighting();
|
setLighting();
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int32_t runOnce() override
|
int32_t runOnce() override
|
||||||
{
|
{
|
||||||
#ifdef HAS_RGB_LED
|
#ifdef HAS_RGB_LED
|
||||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
||||||
if ((_type == ScanI2C::NCP5623 || _type == ScanI2C::LP5562) && moduleConfig.ambient_lighting.led_state) {
|
if ((_type == ScanI2C::NCP5623 || _type == ScanI2C::LP5562) && moduleConfig.ambient_lighting.led_state) {
|
||||||
#endif
|
#endif
|
||||||
setLighting();
|
setLighting();
|
||||||
return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification
|
return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification
|
||||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return disable();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
return disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
// When shutdown() is issued, setLightingOff will be called.
|
// When shutdown() is issued, setLightingOff will be called.
|
||||||
CallbackObserver<AmbientLightingThread, void *> notifyDeepSleepObserver =
|
CallbackObserver<AmbientLightingThread, void *> notifyDeepSleepObserver =
|
||||||
CallbackObserver<AmbientLightingThread, void *>(this, &AmbientLightingThread::setLightingOff);
|
CallbackObserver<AmbientLightingThread, void *>(this, &AmbientLightingThread::setLightingOff);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScanI2C::DeviceType _type = ScanI2C::DeviceType::NONE;
|
ScanI2C::DeviceType _type = ScanI2C::DeviceType::NONE;
|
||||||
|
|
||||||
// Turn RGB lighting off, is used in junction to shutdown()
|
// Turn RGB lighting off, is used in junction to shutdown()
|
||||||
int setLightingOff(void *unused)
|
int setLightingOff(void *unused)
|
||||||
{
|
{
|
||||||
#ifdef HAS_NCP5623
|
#ifdef HAS_NCP5623
|
||||||
rgb.setCurrent(0);
|
rgb.setCurrent(0);
|
||||||
rgb.setRed(0);
|
rgb.setRed(0);
|
||||||
rgb.setGreen(0);
|
rgb.setGreen(0);
|
||||||
rgb.setBlue(0);
|
rgb.setBlue(0);
|
||||||
LOG_INFO("OFF: NCP5623 Ambient lighting");
|
LOG_INFO("OFF: NCP5623 Ambient lighting");
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_LP5562
|
#ifdef HAS_LP5562
|
||||||
rgbw.setCurrent(0);
|
rgbw.setCurrent(0);
|
||||||
rgbw.setRed(0);
|
rgbw.setRed(0);
|
||||||
rgbw.setGreen(0);
|
rgbw.setGreen(0);
|
||||||
rgbw.setBlue(0);
|
rgbw.setBlue(0);
|
||||||
rgbw.setWhite(0);
|
rgbw.setWhite(0);
|
||||||
LOG_INFO("OFF: LP5562 Ambient lighting");
|
LOG_INFO("OFF: LP5562 Ambient lighting");
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_NEOPIXEL
|
#ifdef HAS_NEOPIXEL
|
||||||
pixels.clear();
|
pixels.clear();
|
||||||
pixels.show();
|
pixels.show();
|
||||||
LOG_INFO("OFF: NeoPixel Ambient lighting");
|
LOG_INFO("OFF: NeoPixel Ambient lighting");
|
||||||
#endif
|
#endif
|
||||||
#ifdef RGBLED_CA
|
#ifdef RGBLED_CA
|
||||||
analogWrite(RGBLED_RED, 255 - 0);
|
analogWrite(RGBLED_RED, 255 - 0);
|
||||||
analogWrite(RGBLED_GREEN, 255 - 0);
|
analogWrite(RGBLED_GREEN, 255 - 0);
|
||||||
analogWrite(RGBLED_BLUE, 255 - 0);
|
analogWrite(RGBLED_BLUE, 255 - 0);
|
||||||
LOG_INFO("OFF: Ambient light RGB Common Anode");
|
LOG_INFO("OFF: Ambient light RGB Common Anode");
|
||||||
#elif defined(RGBLED_RED)
|
#elif defined(RGBLED_RED)
|
||||||
analogWrite(RGBLED_RED, 0);
|
analogWrite(RGBLED_RED, 0);
|
||||||
analogWrite(RGBLED_GREEN, 0);
|
analogWrite(RGBLED_GREEN, 0);
|
||||||
@@ -142,56 +142,57 @@ class AmbientLightingThread : public concurrency::OSThread
|
|||||||
LOG_INFO("OFF: Ambient light RGB Common Cathode");
|
LOG_INFO("OFF: Ambient light RGB Common Cathode");
|
||||||
#endif
|
#endif
|
||||||
#ifdef UNPHONE
|
#ifdef UNPHONE
|
||||||
unphone.rgb(0, 0, 0);
|
unphone.rgb(0, 0, 0);
|
||||||
LOG_INFO("OFF: unPhone Ambient lighting");
|
LOG_INFO("OFF: unPhone Ambient lighting");
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLighting()
|
void setLighting()
|
||||||
{
|
{
|
||||||
#ifdef HAS_NCP5623
|
#ifdef HAS_NCP5623
|
||||||
rgb.setCurrent(moduleConfig.ambient_lighting.current);
|
rgb.setCurrent(moduleConfig.ambient_lighting.current);
|
||||||
rgb.setRed(moduleConfig.ambient_lighting.red);
|
rgb.setRed(moduleConfig.ambient_lighting.red);
|
||||||
rgb.setGreen(moduleConfig.ambient_lighting.green);
|
rgb.setGreen(moduleConfig.ambient_lighting.green);
|
||||||
rgb.setBlue(moduleConfig.ambient_lighting.blue);
|
rgb.setBlue(moduleConfig.ambient_lighting.blue);
|
||||||
LOG_DEBUG("Init NCP5623 Ambient light w/ current=%d, red=%d, green=%d, blue=%d", moduleConfig.ambient_lighting.current,
|
LOG_DEBUG("Init NCP5623 Ambient light w/ current=%d, red=%d, green=%d, blue=%d",
|
||||||
moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red,
|
||||||
|
moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_LP5562
|
#ifdef HAS_LP5562
|
||||||
rgbw.setCurrent(moduleConfig.ambient_lighting.current);
|
rgbw.setCurrent(moduleConfig.ambient_lighting.current);
|
||||||
rgbw.setRed(moduleConfig.ambient_lighting.red);
|
rgbw.setRed(moduleConfig.ambient_lighting.red);
|
||||||
rgbw.setGreen(moduleConfig.ambient_lighting.green);
|
rgbw.setGreen(moduleConfig.ambient_lighting.green);
|
||||||
rgbw.setBlue(moduleConfig.ambient_lighting.blue);
|
rgbw.setBlue(moduleConfig.ambient_lighting.blue);
|
||||||
LOG_DEBUG("Init LP5562 Ambient light w/ current=%d, red=%d, green=%d, blue=%d", moduleConfig.ambient_lighting.current,
|
LOG_DEBUG("Init LP5562 Ambient light w/ current=%d, red=%d, green=%d, blue=%d", moduleConfig.ambient_lighting.current,
|
||||||
moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_NEOPIXEL
|
#ifdef HAS_NEOPIXEL
|
||||||
pixels.fill(pixels.Color(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green,
|
pixels.fill(pixels.Color(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green,
|
||||||
moduleConfig.ambient_lighting.blue),
|
moduleConfig.ambient_lighting.blue),
|
||||||
0, NEOPIXEL_COUNT);
|
0, NEOPIXEL_COUNT);
|
||||||
|
|
||||||
// RadioMaster Bandit has addressable LED at the two buttons
|
// RadioMaster Bandit has addressable LED at the two buttons
|
||||||
// this allow us to set different lighting for them in variant.h file.
|
// this allow us to set different lighting for them in variant.h file.
|
||||||
#ifdef RADIOMASTER_900_BANDIT
|
#ifdef RADIOMASTER_900_BANDIT
|
||||||
#if defined(BUTTON1_COLOR) && defined(BUTTON1_COLOR_INDEX)
|
#if defined(BUTTON1_COLOR) && defined(BUTTON1_COLOR_INDEX)
|
||||||
pixels.fill(BUTTON1_COLOR, BUTTON1_COLOR_INDEX, 1);
|
pixels.fill(BUTTON1_COLOR, BUTTON1_COLOR_INDEX, 1);
|
||||||
#endif
|
#endif
|
||||||
#if defined(BUTTON2_COLOR) && defined(BUTTON2_COLOR_INDEX)
|
#if defined(BUTTON2_COLOR) && defined(BUTTON2_COLOR_INDEX)
|
||||||
pixels.fill(BUTTON2_COLOR, BUTTON2_COLOR_INDEX, 1);
|
pixels.fill(BUTTON2_COLOR, BUTTON2_COLOR_INDEX, 1);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
pixels.show();
|
pixels.show();
|
||||||
LOG_DEBUG("Init NeoPixel Ambient light w/ brightness(current)=%d, red=%d, green=%d, blue=%d",
|
LOG_DEBUG("Init NeoPixel Ambient light w/ brightness(current)=%d, red=%d, green=%d, blue=%d",
|
||||||
moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green,
|
moduleConfig.ambient_lighting.current, moduleConfig.ambient_lighting.red,
|
||||||
moduleConfig.ambient_lighting.blue);
|
moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
||||||
#endif
|
#endif
|
||||||
#ifdef RGBLED_CA
|
#ifdef RGBLED_CA
|
||||||
analogWrite(RGBLED_RED, 255 - moduleConfig.ambient_lighting.red);
|
analogWrite(RGBLED_RED, 255 - moduleConfig.ambient_lighting.red);
|
||||||
analogWrite(RGBLED_GREEN, 255 - moduleConfig.ambient_lighting.green);
|
analogWrite(RGBLED_GREEN, 255 - moduleConfig.ambient_lighting.green);
|
||||||
analogWrite(RGBLED_BLUE, 255 - moduleConfig.ambient_lighting.blue);
|
analogWrite(RGBLED_BLUE, 255 - moduleConfig.ambient_lighting.blue);
|
||||||
LOG_DEBUG("Init Ambient light RGB Common Anode w/ red=%d, green=%d, blue=%d", moduleConfig.ambient_lighting.red,
|
LOG_DEBUG("Init Ambient light RGB Common Anode w/ red=%d, green=%d, blue=%d", moduleConfig.ambient_lighting.red,
|
||||||
moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
||||||
#elif defined(RGBLED_RED)
|
#elif defined(RGBLED_RED)
|
||||||
analogWrite(RGBLED_RED, moduleConfig.ambient_lighting.red);
|
analogWrite(RGBLED_RED, moduleConfig.ambient_lighting.red);
|
||||||
analogWrite(RGBLED_GREEN, moduleConfig.ambient_lighting.green);
|
analogWrite(RGBLED_GREEN, moduleConfig.ambient_lighting.green);
|
||||||
@@ -200,11 +201,12 @@ class AmbientLightingThread : public concurrency::OSThread
|
|||||||
moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
||||||
#endif
|
#endif
|
||||||
#ifdef UNPHONE
|
#ifdef UNPHONE
|
||||||
unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
unphone.rgb(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green,
|
||||||
LOG_DEBUG("Init unPhone Ambient light w/ red=%d, green=%d, blue=%d", moduleConfig.ambient_lighting.red,
|
moduleConfig.ambient_lighting.blue);
|
||||||
moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
LOG_DEBUG("Init unPhone Ambient light w/ red=%d, green=%d, blue=%d", moduleConfig.ambient_lighting.red,
|
||||||
|
moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace concurrency
|
} // namespace concurrency
|
||||||
|
|||||||
@@ -47,6 +47,20 @@ class AudioThread : public concurrency::OSThread
|
|||||||
setCPUFast(false);
|
setCPUFast(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void readAloud(const char *text)
|
||||||
|
{
|
||||||
|
if (i2sRtttl != nullptr) {
|
||||||
|
i2sRtttl->stop();
|
||||||
|
delete i2sRtttl;
|
||||||
|
i2sRtttl = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ESP8266SAM *sam = new ESP8266SAM;
|
||||||
|
sam->Say(audioOut, text);
|
||||||
|
delete sam;
|
||||||
|
setCPUFast(false);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int32_t runOnce() override
|
int32_t runOnce() override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,10 +88,16 @@ class BluetoothStatus : public Status
|
|||||||
break;
|
break;
|
||||||
case ConnectionState::CONNECTED:
|
case ConnectionState::CONNECTED:
|
||||||
LOG_DEBUG("BluetoothStatus CONNECTED");
|
LOG_DEBUG("BluetoothStatus CONNECTED");
|
||||||
|
#ifdef BLE_LED
|
||||||
|
digitalWrite(BLE_LED, HIGH);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ConnectionState::DISCONNECTED:
|
case ConnectionState::DISCONNECTED:
|
||||||
LOG_DEBUG("BluetoothStatus DISCONNECTED");
|
LOG_DEBUG("BluetoothStatus DISCONNECTED");
|
||||||
|
#ifdef BLE_LED
|
||||||
|
digitalWrite(BLE_LED, LOW);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,4 +108,4 @@ class BluetoothStatus : public Status
|
|||||||
|
|
||||||
} // namespace meshtastic
|
} // namespace meshtastic
|
||||||
|
|
||||||
extern meshtastic::BluetoothStatus *bluetoothStatus;
|
extern meshtastic::BluetoothStatus *bluetoothStatus;
|
||||||
|
|||||||
@@ -1,497 +0,0 @@
|
|||||||
#include "ButtonThread.h"
|
|
||||||
|
|
||||||
#include "configuration.h"
|
|
||||||
#if !MESHTASTIC_EXCLUDE_GPS
|
|
||||||
#include "GPS.h"
|
|
||||||
#endif
|
|
||||||
#include "MeshService.h"
|
|
||||||
#include "PowerFSM.h"
|
|
||||||
#include "RadioLibInterface.h"
|
|
||||||
#include "buzz.h"
|
|
||||||
#include "main.h"
|
|
||||||
#include "modules/CannedMessageModule.h"
|
|
||||||
#include "modules/ExternalNotificationModule.h"
|
|
||||||
#include "power.h"
|
|
||||||
#include "sleep.h"
|
|
||||||
#ifdef ARCH_PORTDUINO
|
|
||||||
#include "platform/portduino/PortduinoGlue.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEBUG_BUTTONS 0
|
|
||||||
#if DEBUG_BUTTONS
|
|
||||||
#define LOG_BUTTON(...) LOG_DEBUG(__VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define LOG_BUTTON(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace concurrency;
|
|
||||||
|
|
||||||
ButtonThread *buttonThread; // Declared extern in header
|
|
||||||
extern CannedMessageModule *cannedMessageModule;
|
|
||||||
volatile ButtonThread::ButtonEventType ButtonThread::btnEvent = ButtonThread::BUTTON_EVENT_NONE;
|
|
||||||
|
|
||||||
#if defined(BUTTON_PIN) || defined(ARCH_PORTDUINO) || defined(USERPREFS_BUTTON_PIN)
|
|
||||||
OneButton ButtonThread::userButton; // Get reference to static member
|
|
||||||
#endif
|
|
||||||
ButtonThread::ButtonThread() : OSThread("Button")
|
|
||||||
{
|
|
||||||
#if defined(BUTTON_PIN) || defined(ARCH_PORTDUINO) || defined(USERPREFS_BUTTON_PIN)
|
|
||||||
|
|
||||||
#if defined(ARCH_PORTDUINO)
|
|
||||||
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC) {
|
|
||||||
this->userButton = OneButton(settingsMap[user], true, true);
|
|
||||||
LOG_DEBUG("Use GPIO%02d for button", settingsMap[user]);
|
|
||||||
}
|
|
||||||
#elif defined(BUTTON_PIN)
|
|
||||||
#if !defined(USERPREFS_BUTTON_PIN)
|
|
||||||
int pin = config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN; // Resolved button pin
|
|
||||||
#endif
|
|
||||||
#ifdef USERPREFS_BUTTON_PIN
|
|
||||||
int pin = config.device.button_gpio ? config.device.button_gpio : USERPREFS_BUTTON_PIN; // Resolved button pin
|
|
||||||
#endif
|
|
||||||
#if defined(HELTEC_CAPSULE_SENSOR_V3) || defined(HELTEC_SENSOR_HUB)
|
|
||||||
this->userButton = OneButton(pin, false, false);
|
|
||||||
#elif defined(BUTTON_ACTIVE_LOW)
|
|
||||||
this->userButton = OneButton(pin, BUTTON_ACTIVE_LOW, BUTTON_ACTIVE_PULLUP);
|
|
||||||
#else
|
|
||||||
this->userButton = OneButton(pin, true, true);
|
|
||||||
#endif
|
|
||||||
LOG_DEBUG("Use GPIO%02d for button", pin);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef INPUT_PULLUP_SENSE
|
|
||||||
// Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did
|
|
||||||
#ifdef BUTTON_SENSE_TYPE
|
|
||||||
pinMode(pin, BUTTON_SENSE_TYPE);
|
|
||||||
#else
|
|
||||||
pinMode(pin, INPUT_PULLUP_SENSE);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(BUTTON_PIN) || defined(ARCH_PORTDUINO) || defined(USERPREFS_BUTTON_PIN)
|
|
||||||
userButton.attachClick(userButtonPressed);
|
|
||||||
userButton.setClickMs(BUTTON_CLICK_MS);
|
|
||||||
userButton.setPressMs(BUTTON_LONGPRESS_MS);
|
|
||||||
userButton.setDebounceMs(1);
|
|
||||||
userButton.attachDoubleClick(userButtonDoublePressed);
|
|
||||||
userButton.attachMultiClick(userButtonMultiPressed, this); // Reference to instance: get click count from non-static OneButton
|
|
||||||
#if !defined(T_DECK) && \
|
|
||||||
!defined( \
|
|
||||||
ELECROW_ThinkNode_M2) // T-Deck immediately wakes up after shutdown, Thinknode M2 has this on the smaller ALT button
|
|
||||||
userButton.attachLongPressStart(userButtonPressedLongStart);
|
|
||||||
userButton.attachLongPressStop(userButtonPressedLongStop);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUTTON_PIN_ALT
|
|
||||||
#if defined(ELECROW_ThinkNode_M2)
|
|
||||||
this->userButtonAlt = OneButton(BUTTON_PIN_ALT, false, false);
|
|
||||||
#else
|
|
||||||
this->userButtonAlt = OneButton(BUTTON_PIN_ALT, true, true);
|
|
||||||
#endif
|
|
||||||
#ifdef INPUT_PULLUP_SENSE
|
|
||||||
// Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did
|
|
||||||
pinMode(BUTTON_PIN_ALT, INPUT_PULLUP_SENSE);
|
|
||||||
#endif
|
|
||||||
userButtonAlt.attachClick(userButtonPressedScreen);
|
|
||||||
userButtonAlt.setClickMs(BUTTON_CLICK_MS);
|
|
||||||
userButtonAlt.setPressMs(BUTTON_LONGPRESS_MS);
|
|
||||||
userButtonAlt.setDebounceMs(1);
|
|
||||||
userButtonAlt.attachLongPressStart(userButtonPressedLongStart);
|
|
||||||
userButtonAlt.attachLongPressStop(userButtonPressedLongStop);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUTTON_PIN_TOUCH
|
|
||||||
userButtonTouch = OneButton(BUTTON_PIN_TOUCH, true, true);
|
|
||||||
userButtonTouch.setPressMs(BUTTON_TOUCH_MS);
|
|
||||||
userButtonTouch.attachLongPressStart(touchPressedLongStart); // Better handling with longpress than click?
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
|
||||||
// Register callbacks for before and after lightsleep
|
|
||||||
// Used to detach and reattach interrupts
|
|
||||||
lsObserver.observe(¬ifyLightSleep);
|
|
||||||
lsEndObserver.observe(¬ifyLightSleepEnd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
attachButtonInterrupts();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void ButtonThread::switchPage()
|
|
||||||
{
|
|
||||||
// Prevent screen switch if CannedMessageModule is focused and intercepting input
|
|
||||||
#if HAS_SCREEN
|
|
||||||
extern CannedMessageModule *cannedMessageModule;
|
|
||||||
|
|
||||||
if (cannedMessageModule && cannedMessageModule->isInterceptingAndFocused()) {
|
|
||||||
LOG_DEBUG("User button ignored during canned message input");
|
|
||||||
return; // Skip screen change
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Default behavior if not blocked
|
|
||||||
#ifdef BUTTON_PIN
|
|
||||||
#if !defined(USERPREFS_BUTTON_PIN)
|
|
||||||
if (((config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN) !=
|
|
||||||
moduleConfig.canned_message.inputbroker_pin_press) ||
|
|
||||||
!(moduleConfig.canned_message.updown1_enabled || moduleConfig.canned_message.rotary1_enabled) ||
|
|
||||||
!moduleConfig.canned_message.enabled) {
|
|
||||||
powerFSM.trigger(EVENT_PRESS);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if defined(USERPREFS_BUTTON_PIN)
|
|
||||||
if (((config.device.button_gpio ? config.device.button_gpio : USERPREFS_BUTTON_PIN) !=
|
|
||||||
moduleConfig.canned_message.inputbroker_pin_press) ||
|
|
||||||
!(moduleConfig.canned_message.updown1_enabled || moduleConfig.canned_message.rotary1_enabled) ||
|
|
||||||
!moduleConfig.canned_message.enabled) {
|
|
||||||
powerFSM.trigger(EVENT_PRESS);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARCH_PORTDUINO)
|
|
||||||
if ((settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC) &&
|
|
||||||
(settingsMap[user] != moduleConfig.canned_message.inputbroker_pin_press) ||
|
|
||||||
!moduleConfig.canned_message.enabled) {
|
|
||||||
powerFSM.trigger(EVENT_PRESS);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void ButtonThread::sendAdHocPosition()
|
|
||||||
{
|
|
||||||
service->refreshLocalMeshNode();
|
|
||||||
auto sentPosition = service->trySendPosition(NODENUM_BROADCAST, true);
|
|
||||||
if (screen) {
|
|
||||||
if (sentPosition)
|
|
||||||
screen->print("Sent ad-hoc position\n");
|
|
||||||
else
|
|
||||||
screen->print("Sent ad-hoc nodeinfo\n");
|
|
||||||
screen->forceDisplay(true); // Force a new UI frame, then force an EInk update
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ButtonThread::runOnce()
|
|
||||||
{
|
|
||||||
// If the button is pressed we suppress CPU sleep until release
|
|
||||||
canSleep = true; // Assume we should not keep the board awake
|
|
||||||
|
|
||||||
#if defined(BUTTON_PIN) || defined(USERPREFS_BUTTON_PIN)
|
|
||||||
userButton.tick();
|
|
||||||
canSleep &= userButton.isIdle();
|
|
||||||
#elif defined(ARCH_PORTDUINO)
|
|
||||||
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC) {
|
|
||||||
userButton.tick();
|
|
||||||
canSleep &= userButton.isIdle();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef BUTTON_PIN_ALT
|
|
||||||
userButtonAlt.tick();
|
|
||||||
canSleep &= userButtonAlt.isIdle();
|
|
||||||
#endif
|
|
||||||
#ifdef BUTTON_PIN_TOUCH
|
|
||||||
userButtonTouch.tick();
|
|
||||||
canSleep &= userButtonTouch.isIdle();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (btnEvent != BUTTON_EVENT_NONE) {
|
|
||||||
switch (btnEvent) {
|
|
||||||
case BUTTON_EVENT_PRESSED: {
|
|
||||||
LOG_BUTTON("press!");
|
|
||||||
// If a nag notification is running, stop it and prevent other actions
|
|
||||||
if (moduleConfig.external_notification.enabled && (externalNotificationModule->nagCycleCutoff != UINT32_MAX)) {
|
|
||||||
externalNotificationModule->stopNow();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#ifdef ELECROW_ThinkNode_M1
|
|
||||||
sendAdHocPosition();
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
switchPage();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case BUTTON_EVENT_PRESSED_SCREEN: {
|
|
||||||
LOG_BUTTON("AltPress!");
|
|
||||||
#ifdef ELECROW_ThinkNode_M1
|
|
||||||
// If a nag notification is running, stop it and prevent other actions
|
|
||||||
if (moduleConfig.external_notification.enabled && (externalNotificationModule->nagCycleCutoff != UINT32_MAX)) {
|
|
||||||
externalNotificationModule->stopNow();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switchPage();
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
// turn screen on or off
|
|
||||||
screen_flag = !screen_flag;
|
|
||||||
if (screen)
|
|
||||||
screen->setOn(screen_flag);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case BUTTON_EVENT_DOUBLE_PRESSED: {
|
|
||||||
LOG_BUTTON("Double press!");
|
|
||||||
|
|
||||||
#ifdef ELECROW_ThinkNode_M1
|
|
||||||
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Send GPS position immediately
|
|
||||||
sendAdHocPosition();
|
|
||||||
|
|
||||||
// Show temporary on-screen confirmation banner for 3 seconds
|
|
||||||
screen->showOverlayBanner("Ad-hoc Ping Sent", 3000);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case BUTTON_EVENT_MULTI_PRESSED: {
|
|
||||||
LOG_BUTTON("Mulitipress! %hux", multipressClickCount);
|
|
||||||
switch (multipressClickCount) {
|
|
||||||
#if HAS_GPS && !defined(ELECROW_ThinkNode_M1)
|
|
||||||
// 3 clicks: toggle GPS
|
|
||||||
case 3:
|
|
||||||
if (!config.device.disable_triple_click && (gps != nullptr)) {
|
|
||||||
gps->toggleGpsMode();
|
|
||||||
|
|
||||||
const char *statusMsg = (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED)
|
|
||||||
? "GPS Enabled"
|
|
||||||
: "GPS Disabled";
|
|
||||||
|
|
||||||
if (screen) {
|
|
||||||
screen->forceDisplay(true); // Force a new UI frame, then force an EInk update
|
|
||||||
screen->showOverlayBanner(statusMsg, 3000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#elif defined(ELECROW_ThinkNode_M1) || defined(ELECROW_ThinkNode_M2)
|
|
||||||
case 3:
|
|
||||||
LOG_INFO("3 clicks: toggle buzzer");
|
|
||||||
buzzer_flag = !buzzer_flag;
|
|
||||||
if (!buzzer_flag)
|
|
||||||
noTone(PIN_BUZZER);
|
|
||||||
break;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(USE_EINK) && defined(PIN_EINK_EN) && !defined(ELECROW_ThinkNode_M1) // i.e. T-Echo
|
|
||||||
// 4 clicks: toggle backlight
|
|
||||||
case 4:
|
|
||||||
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#if !MESHTASTIC_EXCLUDE_SCREEN && HAS_SCREEN
|
|
||||||
// 5 clicks: start accelerometer/magenetometer calibration for 30 seconds
|
|
||||||
case 5:
|
|
||||||
if (accelerometerThread) {
|
|
||||||
accelerometerThread->calibrate(30);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// 6 clicks: start accelerometer/magenetometer calibration for 60 seconds
|
|
||||||
case 6:
|
|
||||||
if (accelerometerThread) {
|
|
||||||
accelerometerThread->calibrate(60);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
// No valid multipress action
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
} // end switch: click count
|
|
||||||
|
|
||||||
break;
|
|
||||||
} // end multipress event
|
|
||||||
|
|
||||||
case BUTTON_EVENT_LONG_PRESSED: {
|
|
||||||
LOG_BUTTON("Long press!");
|
|
||||||
powerFSM.trigger(EVENT_PRESS);
|
|
||||||
|
|
||||||
if (screen) {
|
|
||||||
// Show shutdown message as a temporary overlay banner
|
|
||||||
screen->showOverlayBanner("Shutting Down..."); // Display for 3 seconds
|
|
||||||
}
|
|
||||||
|
|
||||||
playBeep();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do actual shutdown when button released, otherwise the button release
|
|
||||||
// may wake the board immediatedly.
|
|
||||||
case BUTTON_EVENT_LONG_RELEASED: {
|
|
||||||
LOG_INFO("Shutdown from long press");
|
|
||||||
playShutdownMelody();
|
|
||||||
delay(3000);
|
|
||||||
power->shutdown();
|
|
||||||
nodeDB->saveToDisk();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef BUTTON_PIN_TOUCH
|
|
||||||
case BUTTON_EVENT_TOUCH_LONG_PRESSED: {
|
|
||||||
LOG_BUTTON("Touch press!");
|
|
||||||
// Ignore if: no screen
|
|
||||||
if (!screen)
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef TTGO_T_ECHO
|
|
||||||
// Ignore if: TX in progress
|
|
||||||
// Uncommon T-Echo hardware bug, LoRa TX triggers touch button
|
|
||||||
if (!RadioLibInterface::instance || RadioLibInterface::instance->isSending())
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Wake if asleep
|
|
||||||
if (powerFSM.getState() == &stateDARK)
|
|
||||||
powerFSM.trigger(EVENT_PRESS);
|
|
||||||
|
|
||||||
// Update display (legacy behaviour)
|
|
||||||
screen->forceDisplay();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif // BUTTON_PIN_TOUCH
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
btnEvent = BUTTON_EVENT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Attach (or re-attach) hardware interrupts for buttons
|
|
||||||
* Public method. Used outside class when waking from MCU sleep
|
|
||||||
*/
|
|
||||||
void ButtonThread::attachButtonInterrupts()
|
|
||||||
{
|
|
||||||
#if defined(ARCH_PORTDUINO)
|
|
||||||
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC)
|
|
||||||
wakeOnIrq(settingsMap[user], FALLING);
|
|
||||||
#elif defined(BUTTON_PIN)
|
|
||||||
// Interrupt for user button, during normal use. Improves responsiveness.
|
|
||||||
attachInterrupt(
|
|
||||||
#if !defined(USERPREFS_BUTTON_PIN)
|
|
||||||
config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN,
|
|
||||||
#endif
|
|
||||||
#if defined(USERPREFS_BUTTON_PIN)
|
|
||||||
config.device.button_gpio ? config.device.button_gpio : USERPREFS_BUTTON_PIN,
|
|
||||||
#endif
|
|
||||||
[]() {
|
|
||||||
ButtonThread::userButton.tick();
|
|
||||||
runASAP = true;
|
|
||||||
BaseType_t higherWake = 0;
|
|
||||||
mainDelay.interruptFromISR(&higherWake);
|
|
||||||
},
|
|
||||||
CHANGE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUTTON_PIN_ALT
|
|
||||||
#ifdef ELECROW_ThinkNode_M2
|
|
||||||
wakeOnIrq(BUTTON_PIN_ALT, RISING);
|
|
||||||
#else
|
|
||||||
wakeOnIrq(BUTTON_PIN_ALT, FALLING);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUTTON_PIN_TOUCH
|
|
||||||
wakeOnIrq(BUTTON_PIN_TOUCH, FALLING);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Detach the "normal" button interrupts.
|
|
||||||
* Public method. Used before attaching a "wake-on-button" interrupt for MCU sleep
|
|
||||||
*/
|
|
||||||
void ButtonThread::detachButtonInterrupts()
|
|
||||||
{
|
|
||||||
#if defined(ARCH_PORTDUINO)
|
|
||||||
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC)
|
|
||||||
detachInterrupt(settingsMap[user]);
|
|
||||||
#elif defined(BUTTON_PIN)
|
|
||||||
#if !defined(USERPREFS_BUTTON_PIN)
|
|
||||||
detachInterrupt(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN);
|
|
||||||
#endif
|
|
||||||
#if defined(USERPREFS_BUTTON_PIN)
|
|
||||||
detachInterrupt(config.device.button_gpio ? config.device.button_gpio : USERPREFS_BUTTON_PIN);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUTTON_PIN_ALT
|
|
||||||
detachInterrupt(BUTTON_PIN_ALT);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUTTON_PIN_TOUCH
|
|
||||||
detachInterrupt(BUTTON_PIN_TOUCH);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
|
||||||
|
|
||||||
// Detach our class' interrupts before lightsleep
|
|
||||||
// Allows sleep.cpp to configure its own interrupts, which wake the device on user-button press
|
|
||||||
int ButtonThread::beforeLightSleep(void *unused)
|
|
||||||
{
|
|
||||||
detachButtonInterrupts();
|
|
||||||
return 0; // Indicates success
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reconfigure our interrupts
|
|
||||||
// Our class' interrupts were disconnected during sleep, to allow the user button to wake the device from sleep
|
|
||||||
int ButtonThread::afterLightSleep(esp_sleep_wakeup_cause_t cause)
|
|
||||||
{
|
|
||||||
attachButtonInterrupts();
|
|
||||||
return 0; // Indicates success
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Watch a GPIO and if we get an IRQ, wake the main thread.
|
|
||||||
* Use to add wake on button press
|
|
||||||
*/
|
|
||||||
void ButtonThread::wakeOnIrq(int irq, int mode)
|
|
||||||
{
|
|
||||||
attachInterrupt(
|
|
||||||
irq,
|
|
||||||
[] {
|
|
||||||
BaseType_t higherWake = 0;
|
|
||||||
mainDelay.interruptFromISR(&higherWake);
|
|
||||||
runASAP = true;
|
|
||||||
},
|
|
||||||
FALLING);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static callback
|
|
||||||
void ButtonThread::userButtonMultiPressed(void *callerThread)
|
|
||||||
{
|
|
||||||
// Grab click count from non-static button, while the info is still valid
|
|
||||||
ButtonThread *thread = (ButtonThread *)callerThread;
|
|
||||||
thread->storeClickCount();
|
|
||||||
|
|
||||||
// Then handle later, in the usual way
|
|
||||||
btnEvent = BUTTON_EVENT_MULTI_PRESSED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Non-static method, runs during callback. Grabs info while still valid
|
|
||||||
void ButtonThread::storeClickCount()
|
|
||||||
{
|
|
||||||
#if defined(BUTTON_PIN) || defined(USERPREFS_BUTTON_PIN)
|
|
||||||
multipressClickCount = userButton.getNumberClicks();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void ButtonThread::userButtonPressedLongStart()
|
|
||||||
{
|
|
||||||
if (millis() > c_holdOffTime) {
|
|
||||||
btnEvent = BUTTON_EVENT_LONG_PRESSED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ButtonThread::userButtonPressedLongStop()
|
|
||||||
{
|
|
||||||
if (millis() > c_holdOffTime) {
|
|
||||||
btnEvent = BUTTON_EVENT_LONG_RELEASED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "OneButton.h"
|
|
||||||
#include "concurrency/OSThread.h"
|
|
||||||
#include "configuration.h"
|
|
||||||
|
|
||||||
#ifndef BUTTON_CLICK_MS
|
|
||||||
#define BUTTON_CLICK_MS 250
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BUTTON_LONGPRESS_MS
|
|
||||||
#define BUTTON_LONGPRESS_MS 5000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BUTTON_TOUCH_MS
|
|
||||||
#define BUTTON_TOUCH_MS 400
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class ButtonThread : public concurrency::OSThread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const uint32_t c_holdOffTime = 30000; // hold off 30s after boot
|
|
||||||
|
|
||||||
enum ButtonEventType {
|
|
||||||
BUTTON_EVENT_NONE,
|
|
||||||
BUTTON_EVENT_PRESSED,
|
|
||||||
BUTTON_EVENT_PRESSED_SCREEN,
|
|
||||||
BUTTON_EVENT_DOUBLE_PRESSED,
|
|
||||||
BUTTON_EVENT_MULTI_PRESSED,
|
|
||||||
BUTTON_EVENT_LONG_PRESSED,
|
|
||||||
BUTTON_EVENT_LONG_RELEASED,
|
|
||||||
BUTTON_EVENT_TOUCH_LONG_PRESSED,
|
|
||||||
};
|
|
||||||
|
|
||||||
ButtonThread();
|
|
||||||
int32_t runOnce() override;
|
|
||||||
void attachButtonInterrupts();
|
|
||||||
void detachButtonInterrupts();
|
|
||||||
void storeClickCount();
|
|
||||||
bool isBuzzing() { return buzzer_flag; }
|
|
||||||
void setScreenFlag(bool flag) { screen_flag = flag; }
|
|
||||||
bool getScreenFlag() { return screen_flag; }
|
|
||||||
bool isInterceptingAndFocused();
|
|
||||||
|
|
||||||
// Disconnect and reconnect interrupts for light sleep
|
|
||||||
#ifdef ARCH_ESP32
|
|
||||||
int beforeLightSleep(void *unused);
|
|
||||||
int afterLightSleep(esp_sleep_wakeup_cause_t cause);
|
|
||||||
#endif
|
|
||||||
private:
|
|
||||||
#if defined(BUTTON_PIN) || defined(ARCH_PORTDUINO) || defined(USERPREFS_BUTTON_PIN)
|
|
||||||
static OneButton userButton; // Static - accessed from an interrupt
|
|
||||||
#endif
|
|
||||||
#ifdef BUTTON_PIN_ALT
|
|
||||||
OneButton userButtonAlt;
|
|
||||||
#endif
|
|
||||||
#ifdef BUTTON_PIN_TOUCH
|
|
||||||
OneButton userButtonTouch;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
|
||||||
// Get notified when lightsleep begins and ends
|
|
||||||
CallbackObserver<ButtonThread, void *> lsObserver =
|
|
||||||
CallbackObserver<ButtonThread, void *>(this, &ButtonThread::beforeLightSleep);
|
|
||||||
CallbackObserver<ButtonThread, esp_sleep_wakeup_cause_t> lsEndObserver =
|
|
||||||
CallbackObserver<ButtonThread, esp_sleep_wakeup_cause_t>(this, &ButtonThread::afterLightSleep);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set during IRQ
|
|
||||||
static volatile ButtonEventType btnEvent;
|
|
||||||
bool buzzer_flag = false;
|
|
||||||
bool screen_flag = true;
|
|
||||||
|
|
||||||
// Store click count during callback, for later use
|
|
||||||
volatile int multipressClickCount = 0;
|
|
||||||
|
|
||||||
static void wakeOnIrq(int irq, int mode);
|
|
||||||
|
|
||||||
static void sendAdHocPosition();
|
|
||||||
static void switchPage();
|
|
||||||
|
|
||||||
// IRQ callbacks
|
|
||||||
static void userButtonPressed() { btnEvent = BUTTON_EVENT_PRESSED; }
|
|
||||||
static void userButtonPressedScreen() { btnEvent = BUTTON_EVENT_PRESSED_SCREEN; }
|
|
||||||
static void userButtonDoublePressed() { btnEvent = BUTTON_EVENT_DOUBLE_PRESSED; }
|
|
||||||
static void userButtonMultiPressed(void *callerThread); // Retrieve click count from non-static Onebutton while still valid
|
|
||||||
static void userButtonPressedLongStart();
|
|
||||||
static void userButtonPressedLongStop();
|
|
||||||
static void touchPressedLongStart() { btnEvent = BUTTON_EVENT_TOUCH_LONG_PRESSED; }
|
|
||||||
};
|
|
||||||
|
|
||||||
extern ButtonThread *buttonThread;
|
|
||||||
@@ -661,12 +661,14 @@ bool Power::analogInit()
|
|||||||
*/
|
*/
|
||||||
bool Power::setup()
|
bool Power::setup()
|
||||||
{
|
{
|
||||||
// initialise one power sensor (only)
|
bool found = false;
|
||||||
bool found = axpChipInit();
|
if (axpChipInit()) {
|
||||||
if (!found)
|
found = true;
|
||||||
found = lipoInit();
|
} else if (lipoInit()) {
|
||||||
if (!found)
|
found = true;
|
||||||
found = analogInit();
|
} else if (analogInit()) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef NRF_APM
|
#ifdef NRF_APM
|
||||||
found = true;
|
found = true;
|
||||||
@@ -680,7 +682,7 @@ bool Power::setup()
|
|||||||
|
|
||||||
void Power::shutdown()
|
void Power::shutdown()
|
||||||
{
|
{
|
||||||
LOG_INFO("Shutting down");
|
LOG_INFO("Shutting Down");
|
||||||
|
|
||||||
#if defined(ARCH_NRF52) || defined(ARCH_ESP32) || defined(ARCH_RP2040)
|
#if defined(ARCH_NRF52) || defined(ARCH_ESP32) || defined(ARCH_RP2040)
|
||||||
#ifdef PIN_LED1
|
#ifdef PIN_LED1
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#ifndef SLEEP_TIME
|
#ifndef SLEEP_TIME
|
||||||
#define SLEEP_TIME 30
|
#define SLEEP_TIME 30
|
||||||
#endif
|
#endif
|
||||||
#if EXCLUDE_POWER_FSM
|
#if MESHTASTIC_EXCLUDE_POWER_FSM
|
||||||
FakeFsm powerFSM;
|
FakeFsm powerFSM;
|
||||||
void PowerFSM_setup(){};
|
void PowerFSM_setup(){};
|
||||||
#else
|
#else
|
||||||
@@ -184,7 +184,6 @@ static void serialEnter()
|
|||||||
setBluetoothEnable(false);
|
setBluetoothEnable(false);
|
||||||
if (screen) {
|
if (screen) {
|
||||||
screen->setOn(true);
|
screen->setOn(true);
|
||||||
screen->print("Serial connected\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,8 +191,6 @@ static void serialExit()
|
|||||||
{
|
{
|
||||||
// Turn bluetooth back on when we leave serial stream API
|
// Turn bluetooth back on when we leave serial stream API
|
||||||
setBluetoothEnable(true);
|
setBluetoothEnable(true);
|
||||||
if (screen)
|
|
||||||
screen->print("Serial disconnected\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void powerEnter()
|
static void powerEnter()
|
||||||
@@ -208,12 +205,6 @@ static void powerEnter()
|
|||||||
screen->setOn(true);
|
screen->setOn(true);
|
||||||
setBluetoothEnable(true);
|
setBluetoothEnable(true);
|
||||||
// within enter() the function getState() returns the state we came from
|
// within enter() the function getState() returns the state we came from
|
||||||
|
|
||||||
// Mothballed: print change of power-state to device screen
|
|
||||||
/* if (strcmp(powerFSM.getState()->name, "BOOT") != 0 && strcmp(powerFSM.getState()->name, "POWER") != 0 &&
|
|
||||||
strcmp(powerFSM.getState()->name, "DARK") != 0) {
|
|
||||||
screen->print("Powered...\n");
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,10 +222,6 @@ static void powerExit()
|
|||||||
if (screen)
|
if (screen)
|
||||||
screen->setOn(true);
|
screen->setOn(true);
|
||||||
setBluetoothEnable(true);
|
setBluetoothEnable(true);
|
||||||
|
|
||||||
// Mothballed: print change of power-state to device screen
|
|
||||||
/*if (!isPowered())
|
|
||||||
screen->print("Unpowered...\n");*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onEnter()
|
static void onEnter()
|
||||||
@@ -253,12 +240,6 @@ static void onIdle()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void screenPress()
|
|
||||||
{
|
|
||||||
if (screen)
|
|
||||||
screen->onPress();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void bootEnter()
|
static void bootEnter()
|
||||||
{
|
{
|
||||||
LOG_DEBUG("State: BOOT");
|
LOG_DEBUG("State: BOOT");
|
||||||
@@ -302,9 +283,9 @@ void PowerFSM_setup()
|
|||||||
powerFSM.add_transition(&stateLS, &stateON, EVENT_PRESS, NULL, "Press");
|
powerFSM.add_transition(&stateLS, &stateON, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&stateNB, &stateON, EVENT_PRESS, NULL, "Press");
|
powerFSM.add_transition(&stateNB, &stateON, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&stateDARK, isPowered() ? &statePOWER : &stateON, EVENT_PRESS, NULL, "Press");
|
powerFSM.add_transition(&stateDARK, isPowered() ? &statePOWER : &stateON, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&statePOWER, &statePOWER, EVENT_PRESS, screenPress, "Press");
|
powerFSM.add_transition(&statePOWER, &statePOWER, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&stateON, &stateON, EVENT_PRESS, screenPress, "Press"); // reenter On to restart our timers
|
powerFSM.add_transition(&stateON, &stateON, EVENT_PRESS, NULL, "Press"); // reenter On to restart our timers
|
||||||
powerFSM.add_transition(&stateSERIAL, &stateSERIAL, EVENT_PRESS, screenPress,
|
powerFSM.add_transition(&stateSERIAL, &stateSERIAL, EVENT_PRESS, NULL,
|
||||||
"Press"); // Allow button to work while in serial API
|
"Press"); // Allow button to work while in serial API
|
||||||
|
|
||||||
// Handle critically low power battery by forcing deep sleep
|
// Handle critically low power battery by forcing deep sleep
|
||||||
@@ -338,10 +319,10 @@ void PowerFSM_setup()
|
|||||||
// if any packet destined for phone arrives, turn on bluetooth at least
|
// if any packet destined for phone arrives, turn on bluetooth at least
|
||||||
powerFSM.add_transition(&stateNB, &stateDARK, EVENT_PACKET_FOR_PHONE, NULL, "Packet for phone");
|
powerFSM.add_transition(&stateNB, &stateDARK, EVENT_PACKET_FOR_PHONE, NULL, "Packet for phone");
|
||||||
|
|
||||||
// show the latest node when we get a new node db update
|
// Removed 2.7: we don't show the nodes individually for every node on the screen anymore
|
||||||
powerFSM.add_transition(&stateNB, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
|
// powerFSM.add_transition(&stateNB, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
|
||||||
powerFSM.add_transition(&stateDARK, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
|
// powerFSM.add_transition(&stateDARK, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
|
||||||
powerFSM.add_transition(&stateON, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
|
// powerFSM.add_transition(&stateON, &stateON, EVENT_NODEDB_UPDATED, NULL, "NodeDB update");
|
||||||
|
|
||||||
// Show the received text message
|
// Show the received text message
|
||||||
powerFSM.add_transition(&stateLS, &stateON, EVENT_RECEIVED_MSG, NULL, "Received text");
|
powerFSM.add_transition(&stateLS, &stateON, EVENT_RECEIVED_MSG, NULL, "Received text");
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#define EVENT_RECEIVED_MSG 5
|
#define EVENT_RECEIVED_MSG 5
|
||||||
// #define EVENT_BOOT 6 // now done with a timed transition
|
// #define EVENT_BOOT 6 // now done with a timed transition
|
||||||
#define EVENT_BLUETOOTH_PAIR 7
|
#define EVENT_BLUETOOTH_PAIR 7
|
||||||
#define EVENT_NODEDB_UPDATED 8 // NodeDB has a big enough change that we think you should turn on the screen
|
// #define EVENT_NODEDB_UPDATED 8 // Now defunct: NodeDB has a big enough change that we think you should turn on the screen
|
||||||
#define EVENT_CONTACT_FROM_PHONE 9 // the phone just talked to us over bluetooth
|
#define EVENT_CONTACT_FROM_PHONE 9 // the phone just talked to us over bluetooth
|
||||||
#define EVENT_LOW_BATTERY 10 // Battery is critically low, go to sleep
|
#define EVENT_LOW_BATTERY 10 // Battery is critically low, go to sleep
|
||||||
#define EVENT_SERIAL_CONNECTED 11
|
#define EVENT_SERIAL_CONNECTED 11
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
#define EVENT_SHUTDOWN 16 // force a full shutdown now (not just sleep)
|
#define EVENT_SHUTDOWN 16 // force a full shutdown now (not just sleep)
|
||||||
#define EVENT_INPUT 17 // input broker wants something, we need to wake up and enable screen
|
#define EVENT_INPUT 17 // input broker wants something, we need to wake up and enable screen
|
||||||
|
|
||||||
#if EXCLUDE_POWER_FSM
|
#if MESHTASTIC_EXCLUDE_POWER_FSM
|
||||||
class FakeFsm
|
class FakeFsm
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class PowerFSMThread : public OSThread
|
|||||||
protected:
|
protected:
|
||||||
int32_t runOnce() override
|
int32_t runOnce() override
|
||||||
{
|
{
|
||||||
#if !EXCLUDE_POWER_FSM
|
#if !MESHTASTIC_EXCLUDE_POWER_FSM
|
||||||
powerFSM.run_machine();
|
powerFSM.run_machine();
|
||||||
|
|
||||||
/// If we are in power state we force the CPU to wake every 10ms to check for serial characters (we don't yet wake
|
/// If we are in power state we force the CPU to wake every 10ms to check for serial characters (we don't yet wake
|
||||||
|
|||||||
@@ -352,8 +352,8 @@ void RedirectablePrint::hexDump(const char *logLevel, unsigned char *buf, uint16
|
|||||||
for (uint16_t i = 0; i < len; i += 16) {
|
for (uint16_t i = 0; i < len; i += 16) {
|
||||||
if (i % 128 == 0)
|
if (i % 128 == 0)
|
||||||
log(logLevel, " +------------------------------------------------+ +----------------+");
|
log(logLevel, " +------------------------------------------------+ +----------------+");
|
||||||
char s[] = "| | | |\n";
|
char s[] = " | | | |\n";
|
||||||
uint8_t ix = 1, iy = 52;
|
uint8_t ix = 5, iy = 56;
|
||||||
for (uint8_t j = 0; j < 16; j++) {
|
for (uint8_t j = 0; j < 16; j++) {
|
||||||
if (i + j < len) {
|
if (i + j < len) {
|
||||||
uint8_t c = buf[i + j];
|
uint8_t c = buf[i + j];
|
||||||
@@ -367,10 +367,8 @@ void RedirectablePrint::hexDump(const char *logLevel, unsigned char *buf, uint16
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint8_t index = i / 16;
|
uint8_t index = i / 16;
|
||||||
if (i < 256)
|
sprintf(s, "%03x", index);
|
||||||
log(logLevel, " ");
|
s[3] = '.';
|
||||||
log(logLevel, "%02x", index);
|
|
||||||
log(logLevel, ".");
|
|
||||||
log(logLevel, s);
|
log(logLevel, s);
|
||||||
}
|
}
|
||||||
log(logLevel, " +------------------------------------------------+ +----------------+");
|
log(logLevel, " +------------------------------------------------+ +----------------+");
|
||||||
@@ -393,4 +391,4 @@ std::string RedirectablePrint::mt_sprintf(const std::string fmt_str, ...)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return std::string(formatted.get());
|
return std::string(formatted.get());
|
||||||
}
|
}
|
||||||
|
|||||||
79
src/buzz/BuzzerFeedbackThread.cpp
Normal file
79
src/buzz/BuzzerFeedbackThread.cpp
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#include "BuzzerFeedbackThread.h"
|
||||||
|
#include "NodeDB.h"
|
||||||
|
#include "buzz.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
|
BuzzerFeedbackThread *buzzerFeedbackThread;
|
||||||
|
|
||||||
|
BuzzerFeedbackThread::BuzzerFeedbackThread() : OSThread("BuzzerFeedback")
|
||||||
|
{
|
||||||
|
if (inputBroker)
|
||||||
|
inputObserver.observe(inputBroker);
|
||||||
|
}
|
||||||
|
|
||||||
|
int BuzzerFeedbackThread::handleInputEvent(const InputEvent *event)
|
||||||
|
{
|
||||||
|
// Only provide feedback if buzzer is enabled for notifications
|
||||||
|
if (config.device.buzzer_mode == meshtastic_Config_DeviceConfig_BuzzerMode_DISABLED ||
|
||||||
|
config.device.buzzer_mode == meshtastic_Config_DeviceConfig_BuzzerMode_NOTIFICATIONS_ONLY) {
|
||||||
|
return 0; // Let other handlers process the event
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track last event time for potential future use
|
||||||
|
lastEventTime = millis();
|
||||||
|
needsUpdate = true;
|
||||||
|
|
||||||
|
// Handle different input events with appropriate buzzer feedback
|
||||||
|
switch (event->inputEvent) {
|
||||||
|
case INPUT_BROKER_USER_PRESS:
|
||||||
|
case INPUT_BROKER_ALT_PRESS:
|
||||||
|
case INPUT_BROKER_SELECT:
|
||||||
|
playBeep(); // Confirmation feedback
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INPUT_BROKER_UP:
|
||||||
|
case INPUT_BROKER_DOWN:
|
||||||
|
case INPUT_BROKER_LEFT:
|
||||||
|
case INPUT_BROKER_RIGHT:
|
||||||
|
playChirp(); // Navigation feedback
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INPUT_BROKER_CANCEL:
|
||||||
|
case INPUT_BROKER_BACK:
|
||||||
|
playBoop(); // Cancel/back feedback
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INPUT_BROKER_SEND_PING:
|
||||||
|
playComboTune(); // Ping sent feedback
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INPUT_BROKER_SHUTDOWN:
|
||||||
|
playShutdownMelody(); // Shutdown feedback
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// For other events, check if it's a printable character
|
||||||
|
if (event->kbchar >= 32 && event->kbchar <= 126) {
|
||||||
|
// Typing feedback - very short boop
|
||||||
|
// Removing this for now, too chatty
|
||||||
|
// playChirp();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; // Allow other handlers to process the event
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t BuzzerFeedbackThread::runOnce()
|
||||||
|
{
|
||||||
|
// This thread is primarily event-driven, but we can use runOnce
|
||||||
|
// for any periodic tasks if needed in the future
|
||||||
|
|
||||||
|
if (needsUpdate) {
|
||||||
|
needsUpdate = false;
|
||||||
|
// Could add any periodic processing here
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run every 100ms when active, less frequently when idle
|
||||||
|
return needsUpdate ? 100 : 1000;
|
||||||
|
}
|
||||||
24
src/buzz/BuzzerFeedbackThread.h
Normal file
24
src/buzz/BuzzerFeedbackThread.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Observer.h"
|
||||||
|
#include "concurrency/OSThread.h"
|
||||||
|
#include "input/InputBroker.h"
|
||||||
|
|
||||||
|
class BuzzerFeedbackThread : public concurrency::OSThread
|
||||||
|
{
|
||||||
|
CallbackObserver<BuzzerFeedbackThread, const InputEvent *> inputObserver =
|
||||||
|
CallbackObserver<BuzzerFeedbackThread, const InputEvent *>(this, &BuzzerFeedbackThread::handleInputEvent);
|
||||||
|
|
||||||
|
public:
|
||||||
|
BuzzerFeedbackThread();
|
||||||
|
int handleInputEvent(const InputEvent *event);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual int32_t runOnce() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t lastEventTime = 0;
|
||||||
|
bool needsUpdate = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern BuzzerFeedbackThread *buzzerFeedbackThread;
|
||||||
@@ -38,6 +38,11 @@ const int DURATION_1_1 = 1000; // 1/1 note
|
|||||||
|
|
||||||
void playTones(const ToneDuration *tone_durations, int size)
|
void playTones(const ToneDuration *tone_durations, int size)
|
||||||
{
|
{
|
||||||
|
if (config.device.buzzer_mode == meshtastic_Config_DeviceConfig_BuzzerMode_DISABLED ||
|
||||||
|
config.device.buzzer_mode == meshtastic_Config_DeviceConfig_BuzzerMode_NOTIFICATIONS_ONLY) {
|
||||||
|
// Buzzer is disabled or not set to system tones
|
||||||
|
return;
|
||||||
|
}
|
||||||
#ifdef PIN_BUZZER
|
#ifdef PIN_BUZZER
|
||||||
if (!config.device.buzzer_gpio)
|
if (!config.device.buzzer_gpio)
|
||||||
config.device.buzzer_gpio = PIN_BUZZER;
|
config.device.buzzer_gpio = PIN_BUZZER;
|
||||||
@@ -54,7 +59,7 @@ void playTones(const ToneDuration *tone_durations, int size)
|
|||||||
|
|
||||||
void playBeep()
|
void playBeep()
|
||||||
{
|
{
|
||||||
ToneDuration melody[] = {{NOTE_B3, DURATION_1_4}};
|
ToneDuration melody[] = {{NOTE_B3, DURATION_1_8}};
|
||||||
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,3 +92,72 @@ void playShutdownMelody()
|
|||||||
ToneDuration melody[] = {{NOTE_CS4, DURATION_1_8}, {NOTE_AS3, DURATION_1_8}, {NOTE_FS3, DURATION_1_4}};
|
ToneDuration melody[] = {{NOTE_CS4, DURATION_1_8}, {NOTE_AS3, DURATION_1_8}, {NOTE_FS3, DURATION_1_4}};
|
||||||
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void playChirp()
|
||||||
|
{
|
||||||
|
// A short, friendly "chirp" sound for key presses
|
||||||
|
ToneDuration melody[] = {{NOTE_AS3, 20}}; // Very short AS3 note
|
||||||
|
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||||
|
}
|
||||||
|
|
||||||
|
void playBoop()
|
||||||
|
{
|
||||||
|
// A short, friendly "boop" sound for button presses
|
||||||
|
ToneDuration melody[] = {{NOTE_A3, 50}}; // Very short A3 note
|
||||||
|
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||||
|
}
|
||||||
|
|
||||||
|
void playLongPressLeadUp()
|
||||||
|
{
|
||||||
|
// An ascending lead-up sequence for long press - builds anticipation
|
||||||
|
ToneDuration melody[] = {
|
||||||
|
{NOTE_C3, 100}, // Start low
|
||||||
|
{NOTE_E3, 100}, // Step up
|
||||||
|
{NOTE_G3, 100}, // Keep climbing
|
||||||
|
{NOTE_B3, 150} // Peak with longer note for emphasis
|
||||||
|
};
|
||||||
|
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Static state for progressive lead-up notes
|
||||||
|
static int leadUpNoteIndex = 0;
|
||||||
|
static const ToneDuration leadUpNotes[] = {
|
||||||
|
{NOTE_C3, 100}, // Start low
|
||||||
|
{NOTE_E3, 100}, // Step up
|
||||||
|
{NOTE_G3, 100}, // Keep climbing
|
||||||
|
{NOTE_B3, 150} // Peak with longer note for emphasis
|
||||||
|
};
|
||||||
|
static const int leadUpNotesCount = sizeof(leadUpNotes) / sizeof(ToneDuration);
|
||||||
|
|
||||||
|
bool playNextLeadUpNote()
|
||||||
|
{
|
||||||
|
if (leadUpNoteIndex >= leadUpNotesCount) {
|
||||||
|
return false; // All notes have been played
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use playTones to handle buzzer logic consistently
|
||||||
|
const auto ¬e = leadUpNotes[leadUpNoteIndex];
|
||||||
|
playTones(¬e, 1); // Play single note using existing playTones function
|
||||||
|
|
||||||
|
leadUpNoteIndex++;
|
||||||
|
return true; // Note was played (playTones handles buzzer availability internally)
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetLeadUpSequence()
|
||||||
|
{
|
||||||
|
leadUpNoteIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void playComboTune()
|
||||||
|
{
|
||||||
|
// Quick high-pitched notes with trills
|
||||||
|
ToneDuration melody[] = {
|
||||||
|
{NOTE_G3, 80}, // Quick chirp
|
||||||
|
{NOTE_B3, 60}, // Higher chirp
|
||||||
|
{NOTE_CS4, 80}, // Even higher
|
||||||
|
{NOTE_G3, 60}, // Quick trill down
|
||||||
|
{NOTE_CS4, 60}, // Quick trill up
|
||||||
|
{NOTE_B3, 120} // Ending chirp
|
||||||
|
};
|
||||||
|
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,4 +5,10 @@ void playLongBeep();
|
|||||||
void playStartMelody();
|
void playStartMelody();
|
||||||
void playShutdownMelody();
|
void playShutdownMelody();
|
||||||
void playGPSEnableBeep();
|
void playGPSEnableBeep();
|
||||||
void playGPSDisableBeep();
|
void playGPSDisableBeep();
|
||||||
|
void playComboTune();
|
||||||
|
void playBoop();
|
||||||
|
void playChirp();
|
||||||
|
void playLongPressLeadUp();
|
||||||
|
bool playNextLeadUpNote(); // Play the next note in the lead-up sequence
|
||||||
|
void resetLeadUpSequence(); // Reset the lead-up sequence to start from beginning
|
||||||
@@ -12,7 +12,6 @@ enum class Cmd {
|
|||||||
STOP_ALERT_FRAME,
|
STOP_ALERT_FRAME,
|
||||||
START_FIRMWARE_UPDATE_SCREEN,
|
START_FIRMWARE_UPDATE_SCREEN,
|
||||||
STOP_BOOT_SCREEN,
|
STOP_BOOT_SCREEN,
|
||||||
PRINT,
|
|
||||||
SHOW_PREV_FRAME,
|
SHOW_PREV_FRAME,
|
||||||
SHOW_NEXT_FRAME
|
SHOW_NEXT_FRAME
|
||||||
};
|
};
|
||||||
@@ -9,17 +9,23 @@ namespace concurrency
|
|||||||
Lock::Lock() : handle(xSemaphoreCreateBinary())
|
Lock::Lock() : handle(xSemaphoreCreateBinary())
|
||||||
{
|
{
|
||||||
assert(handle);
|
assert(handle);
|
||||||
assert(xSemaphoreGive(handle));
|
if (xSemaphoreGive(handle) == false) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lock::lock()
|
void Lock::lock()
|
||||||
{
|
{
|
||||||
assert(xSemaphoreTake(handle, portMAX_DELAY));
|
if (xSemaphoreTake(handle, portMAX_DELAY) == false) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lock::unlock()
|
void Lock::unlock()
|
||||||
{
|
{
|
||||||
assert(xSemaphoreGive(handle));
|
if (xSemaphoreGive(handle) == false) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Lock::Lock() {}
|
Lock::Lock() {}
|
||||||
|
|||||||
@@ -81,7 +81,43 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
// #define REGULATORY_LORA_REGIONCODE meshtastic_Config_LoRaConfig_RegionCode_SG_923
|
// #define REGULATORY_LORA_REGIONCODE meshtastic_Config_LoRaConfig_RegionCode_SG_923
|
||||||
|
|
||||||
// Total system gain in dBm to subtract from Tx power to remain within regulatory and Tx PA limits
|
// Total system gain in dBm to subtract from Tx power to remain within regulatory and Tx PA limits
|
||||||
// This value should be set in variant.h and is PA gain + antenna gain (if variant has a non-removable antenna)
|
// The value consists of PA gain + antenna gain (if variant has a non-removable antenna)
|
||||||
|
// TX_GAIN_LORA should be set with definitions below for common modules, or in variant.h.
|
||||||
|
|
||||||
|
// Gain for common modules with transmit PAs
|
||||||
|
#ifdef EBYTE_E22_900M30S
|
||||||
|
// 10dB PA gain and 30dB rated output; based on measurements from
|
||||||
|
// https://github.com/S5NC/EBYTE_ESP32-S3/blob/main/E22-900M30S%20power%20output%20testing.txt
|
||||||
|
#define TX_GAIN_LORA 7
|
||||||
|
#define SX126X_MAX_POWER 22
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef EBYTE_E22_900M33S
|
||||||
|
// 25dB PA gain and 33dB rated output; based on TX Power Curve from E22-900M33S_UserManual_EN_v1.0.pdf
|
||||||
|
#define TX_GAIN_LORA 25
|
||||||
|
#define SX126X_MAX_POWER 8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NICERF_MINIF27
|
||||||
|
// Note that datasheet power level of 9 corresponds with SX1262 at 22dBm
|
||||||
|
// Maximum output power of 29dBm with VCC_PA = 5V
|
||||||
|
#define TX_GAIN_LORA 7
|
||||||
|
#define SX126X_MAX_POWER 22
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NICERF_F30_HF
|
||||||
|
// Maximum output power of 29.6dBm with VCC = 5V and SX1262 at 22dBm
|
||||||
|
#define TX_GAIN_LORA 8
|
||||||
|
#define SX126X_MAX_POWER 22
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NICERF_F30_LF
|
||||||
|
// Maximum output power of 32.0dBm with VCC = 5V and SX1262 at 22dBm
|
||||||
|
#define TX_GAIN_LORA 10
|
||||||
|
#define SX126X_MAX_POWER 22
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Default system gain to 0 if not defined
|
||||||
#ifndef TX_GAIN_LORA
|
#ifndef TX_GAIN_LORA
|
||||||
#define TX_GAIN_LORA 0
|
#define TX_GAIN_LORA 0
|
||||||
#endif
|
#endif
|
||||||
@@ -171,6 +207,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define BMX160_ADDR 0x69
|
#define BMX160_ADDR 0x69
|
||||||
#define ICM20948_ADDR 0x69
|
#define ICM20948_ADDR 0x69
|
||||||
#define ICM20948_ADDR_ALT 0x68
|
#define ICM20948_ADDR_ALT 0x68
|
||||||
|
#define BMM150_ADDR 0x13
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// LED
|
// LED
|
||||||
@@ -193,6 +230,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
#define FT6336U_ADDR 0x48
|
#define FT6336U_ADDR 0x48
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// RAK12035VB Soil Monitor (using RAK12023 up to 3 RAK12035 monitors can be connected)
|
||||||
|
// - the default i2c address for this sensor is 0x20, and users are instructed to
|
||||||
|
// set 0x21 and 0x22 for the second and third sensor if present.
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
#define RAK120351_ADDR 0x20
|
||||||
|
#define RAK120352_ADDR 0x21
|
||||||
|
#define RAK120353_ADDR 0x22
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// BIAS-T Generator
|
// BIAS-T Generator
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -302,11 +348,41 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#error HW_VENDOR must be defined
|
#error HW_VENDOR must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TB_DOWN
|
||||||
|
#define TB_DOWN 255
|
||||||
|
#endif
|
||||||
|
#ifndef TB_UP
|
||||||
|
#define TB_UP 255
|
||||||
|
#endif
|
||||||
|
#ifndef TB_LEFT
|
||||||
|
#define TB_LEFT 255
|
||||||
|
#endif
|
||||||
|
#ifndef TB_RIGHT
|
||||||
|
#define TB_RIGHT 255
|
||||||
|
#endif
|
||||||
|
#ifndef TB_PRESS
|
||||||
|
#define TB_PRESS 255
|
||||||
|
#endif
|
||||||
|
|
||||||
// Support multiple RGB LED configuration
|
// Support multiple RGB LED configuration
|
||||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE)
|
#if defined(HAS_NCP5623) || defined(HAS_LP5562) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE)
|
||||||
#define HAS_RGB_LED
|
#define HAS_RGB_LED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// default mapping of pins
|
||||||
|
#if defined(PIN_BUTTON2) && !defined(CANCEL_BUTTON_PIN)
|
||||||
|
#define ALT_BUTTON_PIN PIN_BUTTON2
|
||||||
|
#endif
|
||||||
|
#if defined ALT_BUTTON_PIN
|
||||||
|
|
||||||
|
#ifndef ALT_BUTTON_ACTIVE_LOW
|
||||||
|
#define ALT_BUTTON_ACTIVE_LOW true
|
||||||
|
#endif
|
||||||
|
#ifndef ALT_BUTTON_ACTIVE_PULLUP
|
||||||
|
#define ALT_BUTTON_ACTIVE_PULLUP true
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Global switches to turn off features for a minimized build
|
// Global switches to turn off features for a minimized build
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ ScanI2C::FoundDevice ScanI2C::firstKeyboard() const
|
|||||||
|
|
||||||
ScanI2C::FoundDevice ScanI2C::firstAccelerometer() const
|
ScanI2C::FoundDevice ScanI2C::firstAccelerometer() const
|
||||||
{
|
{
|
||||||
ScanI2C::DeviceType types[] = {MPU6050, LIS3DH, BMA423, LSM6DS3, BMX160, STK8BAXX, ICM20948, QMA6100P};
|
ScanI2C::DeviceType types[] = {MPU6050, LIS3DH, BMA423, LSM6DS3, BMX160, STK8BAXX, ICM20948, QMA6100P, BMM150};
|
||||||
return firstOfOrNONE(8, types);
|
return firstOfOrNONE(9, types);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScanI2C::FoundDevice ScanI2C::firstRGBLED() const
|
ScanI2C::FoundDevice ScanI2C::firstRGBLED() const
|
||||||
|
|||||||
@@ -70,8 +70,10 @@ class ScanI2C
|
|||||||
DFROBOT_RAIN,
|
DFROBOT_RAIN,
|
||||||
DPS310,
|
DPS310,
|
||||||
LTR390UV,
|
LTR390UV,
|
||||||
|
RAK12035,
|
||||||
TCA8418KB,
|
TCA8418KB,
|
||||||
PCT2075,
|
PCT2075,
|
||||||
|
BMM150,
|
||||||
} DeviceType;
|
} DeviceType;
|
||||||
|
|
||||||
// typedef uint8_t DeviceAddress;
|
// typedef uint8_t DeviceAddress;
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
|||||||
case SHT31_4x_ADDR: // same as OPT3001_ADDR_ALT
|
case SHT31_4x_ADDR: // same as OPT3001_ADDR_ALT
|
||||||
case SHT31_4x_ADDR_ALT: // same as OPT3001_ADDR
|
case SHT31_4x_ADDR_ALT: // same as OPT3001_ADDR
|
||||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2);
|
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2);
|
||||||
if (registerValue == 0x11a2 || registerValue == 0x11da || registerValue == 0xe9c) {
|
if (registerValue == 0x11a2 || registerValue == 0x11da || registerValue == 0xe9c || registerValue == 0xc8d) {
|
||||||
type = SHT4X;
|
type = SHT4X;
|
||||||
logFoundDevice("SHT4X", (uint8_t)addr.address);
|
logFoundDevice("SHT4X", (uint8_t)addr.address);
|
||||||
} else if (getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x7E), 2) == 0x5449) {
|
} else if (getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x7E), 2) == 0x5449) {
|
||||||
@@ -423,9 +423,21 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
|||||||
logFoundDevice("BMA423", (uint8_t)addr.address);
|
logFoundDevice("BMA423", (uint8_t)addr.address);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TCA9535_ADDR:
|
||||||
|
case RAK120352_ADDR:
|
||||||
|
case RAK120353_ADDR:
|
||||||
|
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x02), 1);
|
||||||
|
if (registerValue == addr.address) { // RAK12035 returns its I2C address at 0x02 (eg 0x20)
|
||||||
|
type = RAK12035;
|
||||||
|
logFoundDevice("RAK12035", (uint8_t)addr.address);
|
||||||
|
} else {
|
||||||
|
type = TCA9535;
|
||||||
|
logFoundDevice("TCA9535", (uint8_t)addr.address);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3", (uint8_t)addr.address);
|
SCAN_SIMPLE_CASE(LSM6DS3_ADDR, LSM6DS3, "LSM6DS3", (uint8_t)addr.address);
|
||||||
SCAN_SIMPLE_CASE(TCA9535_ADDR, TCA9535, "TCA9535", (uint8_t)addr.address);
|
|
||||||
SCAN_SIMPLE_CASE(TCA9555_ADDR, TCA9555, "TCA9555", (uint8_t)addr.address);
|
SCAN_SIMPLE_CASE(TCA9555_ADDR, TCA9555, "TCA9555", (uint8_t)addr.address);
|
||||||
SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700", (uint8_t)addr.address);
|
SCAN_SIMPLE_CASE(VEML7700_ADDR, VEML7700, "VEML7700", (uint8_t)addr.address);
|
||||||
SCAN_SIMPLE_CASE(TSL25911_ADDR, TSL2591, "TSL2591", (uint8_t)addr.address);
|
SCAN_SIMPLE_CASE(TSL25911_ADDR, TSL2591, "TSL2591", (uint8_t)addr.address);
|
||||||
@@ -435,6 +447,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
|||||||
SCAN_SIMPLE_CASE(DFROBOT_RAIN_ADDR, DFROBOT_RAIN, "DFRobot Rain Gauge", (uint8_t)addr.address);
|
SCAN_SIMPLE_CASE(DFROBOT_RAIN_ADDR, DFROBOT_RAIN, "DFRobot Rain Gauge", (uint8_t)addr.address);
|
||||||
SCAN_SIMPLE_CASE(LTR390UV_ADDR, LTR390UV, "LTR390UV", (uint8_t)addr.address);
|
SCAN_SIMPLE_CASE(LTR390UV_ADDR, LTR390UV, "LTR390UV", (uint8_t)addr.address);
|
||||||
SCAN_SIMPLE_CASE(PCT2075_ADDR, PCT2075, "PCT2075", (uint8_t)addr.address);
|
SCAN_SIMPLE_CASE(PCT2075_ADDR, PCT2075, "PCT2075", (uint8_t)addr.address);
|
||||||
|
SCAN_SIMPLE_CASE(BMM150_ADDR, BMM150, "BMM150", (uint8_t)addr.address);
|
||||||
#ifdef HAS_TPS65233
|
#ifdef HAS_TPS65233
|
||||||
SCAN_SIMPLE_CASE(TPS65233_ADDR, TPS65233, "TPS65233", (uint8_t)addr.address);
|
SCAN_SIMPLE_CASE(TPS65233_ADDR, TPS65233, "TPS65233", (uint8_t)addr.address);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -18,11 +18,19 @@ namespace graphics
|
|||||||
class Screen
|
class Screen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum FrameFocus : uint8_t {
|
||||||
|
FOCUS_DEFAULT, // No specific frame
|
||||||
|
FOCUS_PRESERVE, // Return to the previous frame
|
||||||
|
FOCUS_FAULT,
|
||||||
|
FOCUS_TEXTMESSAGE,
|
||||||
|
FOCUS_MODULE, // Note: target module should call requestFocus(), otherwise no info about which module to focus
|
||||||
|
FOCUS_CLOCK,
|
||||||
|
};
|
||||||
|
|
||||||
explicit Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY);
|
explicit Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY);
|
||||||
void onPress() {}
|
void onPress() {}
|
||||||
void setup() {}
|
void setup() {}
|
||||||
void setOn(bool) {}
|
void setOn(bool) {}
|
||||||
void print(const char *) {}
|
|
||||||
void doDeepSleep() {}
|
void doDeepSleep() {}
|
||||||
void forceDisplay(bool forceUiUpdate = false) {}
|
void forceDisplay(bool forceUiUpdate = false) {}
|
||||||
void startFirmwareUpdateScreen() {}
|
void startFirmwareUpdateScreen() {}
|
||||||
@@ -31,6 +39,11 @@ class Screen
|
|||||||
void setFunctionSymbol(std::string) {}
|
void setFunctionSymbol(std::string) {}
|
||||||
void removeFunctionSymbol(std::string) {}
|
void removeFunctionSymbol(std::string) {}
|
||||||
void startAlert(const char *) {}
|
void startAlert(const char *) {}
|
||||||
|
void showOverlayBanner(const char *message, uint32_t durationMs = 3000, const char **optionsArrayPtr = nullptr,
|
||||||
|
uint8_t options = 0, std::function<void(int)> bannerCallback = NULL, int8_t InitialSelected = 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void setFrames(FrameFocus focus) {}
|
||||||
void endAlert() {}
|
void endAlert() {}
|
||||||
};
|
};
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
@@ -66,6 +79,7 @@ class Screen
|
|||||||
#include "concurrency/OSThread.h"
|
#include "concurrency/OSThread.h"
|
||||||
#include "input/InputBroker.h"
|
#include "input/InputBroker.h"
|
||||||
#include "mesh/MeshModule.h"
|
#include "mesh/MeshModule.h"
|
||||||
|
#include "modules/AdminModule.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -181,8 +195,8 @@ class Screen : public concurrency::OSThread
|
|||||||
CallbackObserver<Screen, const UIFrameEvent *>(this, &Screen::handleUIFrameEvent); // Sent by Mesh Modules
|
CallbackObserver<Screen, const UIFrameEvent *>(this, &Screen::handleUIFrameEvent); // Sent by Mesh Modules
|
||||||
CallbackObserver<Screen, const InputEvent *> inputObserver =
|
CallbackObserver<Screen, const InputEvent *> inputObserver =
|
||||||
CallbackObserver<Screen, const InputEvent *>(this, &Screen::handleInputEvent);
|
CallbackObserver<Screen, const InputEvent *>(this, &Screen::handleInputEvent);
|
||||||
CallbackObserver<Screen, const meshtastic_AdminMessage *> adminMessageObserver =
|
CallbackObserver<Screen, AdminModule_ObserverData *> adminMessageObserver =
|
||||||
CallbackObserver<Screen, const meshtastic_AdminMessage *>(this, &Screen::handleAdminMessage);
|
CallbackObserver<Screen, AdminModule_ObserverData *>(this, &Screen::handleAdminMessage);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY);
|
explicit Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY);
|
||||||
@@ -196,6 +210,7 @@ class Screen : public concurrency::OSThread
|
|||||||
FOCUS_FAULT,
|
FOCUS_FAULT,
|
||||||
FOCUS_TEXTMESSAGE,
|
FOCUS_TEXTMESSAGE,
|
||||||
FOCUS_MODULE, // Note: target module should call requestFocus(), otherwise no info about which module to focus
|
FOCUS_MODULE, // Note: target module should call requestFocus(), otherwise no info about which module to focus
|
||||||
|
FOCUS_CLOCK,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Regenerate the normal set of frames, focusing a specific frame if requested
|
// Regenerate the normal set of frames, focusing a specific frame if requested
|
||||||
@@ -210,6 +225,14 @@ class Screen : public concurrency::OSThread
|
|||||||
meshtastic_Config_DisplayConfig_OledType model;
|
meshtastic_Config_DisplayConfig_OledType model;
|
||||||
OLEDDISPLAY_GEOMETRY geometry;
|
OLEDDISPLAY_GEOMETRY geometry;
|
||||||
|
|
||||||
|
bool ignoreCompass = false;
|
||||||
|
|
||||||
|
bool isOverlayBannerShowing();
|
||||||
|
|
||||||
|
// Stores the last 4 of our hardware ID, to make finding the device for pairing easier
|
||||||
|
// FIXME: Needs refactoring and getMacAddr needs to be moved to a utility class
|
||||||
|
char ourId[5];
|
||||||
|
|
||||||
/// Initializes the UI, turns on the display, starts showing boot screen.
|
/// Initializes the UI, turns on the display, starts showing boot screen.
|
||||||
//
|
//
|
||||||
// Not thread safe - must be called before any other methods are called.
|
// Not thread safe - must be called before any other methods are called.
|
||||||
@@ -233,8 +256,6 @@ class Screen : public concurrency::OSThread
|
|||||||
|
|
||||||
void blink();
|
void blink();
|
||||||
|
|
||||||
void getTimeAgoStr(uint32_t agoSecs, char *timeStr, uint8_t maxLength);
|
|
||||||
|
|
||||||
// Draw north
|
// Draw north
|
||||||
float estimatedHeading(double lat, double lon);
|
float estimatedHeading(double lat, double lon);
|
||||||
|
|
||||||
@@ -269,7 +290,8 @@ class Screen : public concurrency::OSThread
|
|||||||
enqueueCmd(cmd);
|
enqueueCmd(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showOverlayBanner(const char *message, uint32_t durationMs = 3000);
|
void showOverlayBanner(const char *message, uint32_t durationMs = 3000, const char **optionsArrayPtr = nullptr,
|
||||||
|
uint8_t options = 0, std::function<void(int)> bannerCallback = NULL, int8_t InitialSelected = 0);
|
||||||
|
|
||||||
void startFirmwareUpdateScreen()
|
void startFirmwareUpdateScreen()
|
||||||
{
|
{
|
||||||
@@ -283,7 +305,7 @@ class Screen : public concurrency::OSThread
|
|||||||
void setHeading(long _heading)
|
void setHeading(long _heading)
|
||||||
{
|
{
|
||||||
hasCompass = true;
|
hasCompass = true;
|
||||||
compassHeading = _heading;
|
compassHeading = fmod(_heading, 360);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasHeading() { return hasCompass; }
|
bool hasHeading() { return hasCompass; }
|
||||||
@@ -303,20 +325,6 @@ class Screen : public concurrency::OSThread
|
|||||||
/// Stops showing the boot screen.
|
/// Stops showing the boot screen.
|
||||||
void stopBootScreen() { enqueueCmd(ScreenCmd{.cmd = Cmd::STOP_BOOT_SCREEN}); }
|
void stopBootScreen() { enqueueCmd(ScreenCmd{.cmd = Cmd::STOP_BOOT_SCREEN}); }
|
||||||
|
|
||||||
/// Writes a string to the screen.
|
|
||||||
void print(const char *text)
|
|
||||||
{
|
|
||||||
ScreenCmd cmd;
|
|
||||||
cmd.cmd = Cmd::PRINT;
|
|
||||||
// TODO(girts): strdup() here is scary, but we can't use std::string as
|
|
||||||
// FreeRTOS queue is just dumbly copying memory contents. It would be
|
|
||||||
// nice if we had a queue that could copy objects by value.
|
|
||||||
cmd.print_text = strdup(text);
|
|
||||||
if (!enqueueCmd(cmd)) {
|
|
||||||
free(cmd.print_text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Overrides the default utf8 character conversion, to replace empty space with question marks
|
/// Overrides the default utf8 character conversion, to replace empty space with question marks
|
||||||
static char customFontTableLookup(const uint8_t ch)
|
static char customFontTableLookup(const uint8_t ch)
|
||||||
{
|
{
|
||||||
@@ -541,7 +549,7 @@ class Screen : public concurrency::OSThread
|
|||||||
int handleTextMessage(const meshtastic_MeshPacket *arg);
|
int handleTextMessage(const meshtastic_MeshPacket *arg);
|
||||||
int handleUIFrameEvent(const UIFrameEvent *arg);
|
int handleUIFrameEvent(const UIFrameEvent *arg);
|
||||||
int handleInputEvent(const InputEvent *arg);
|
int handleInputEvent(const InputEvent *arg);
|
||||||
int handleAdminMessage(const meshtastic_AdminMessage *arg);
|
int handleAdminMessage(AdminModule_ObserverData *arg);
|
||||||
|
|
||||||
/// Used to force (super slow) eink displays to draw critical frames
|
/// Used to force (super slow) eink displays to draw critical frames
|
||||||
void forceDisplay(bool forceUiUpdate = false);
|
void forceDisplay(bool forceUiUpdate = false);
|
||||||
@@ -549,8 +557,6 @@ class Screen : public concurrency::OSThread
|
|||||||
/// Draws our SSL cert screen during boot (called from WebServer)
|
/// Draws our SSL cert screen during boot (called from WebServer)
|
||||||
void setSSLFrames();
|
void setSSLFrames();
|
||||||
|
|
||||||
void setWelcomeFrames();
|
|
||||||
|
|
||||||
// Dismiss the currently focussed frame, if possible (e.g. text message, waypoint)
|
// Dismiss the currently focussed frame, if possible (e.g. text message, waypoint)
|
||||||
void dismissCurrentFrame();
|
void dismissCurrentFrame();
|
||||||
|
|
||||||
@@ -599,7 +605,6 @@ class Screen : public concurrency::OSThread
|
|||||||
void handleOnPress();
|
void handleOnPress();
|
||||||
void handleShowNextFrame();
|
void handleShowNextFrame();
|
||||||
void handleShowPrevFrame();
|
void handleShowPrevFrame();
|
||||||
void handlePrint(const char *text);
|
|
||||||
void handleStartFirmwareUpdateScreen();
|
void handleStartFirmwareUpdateScreen();
|
||||||
|
|
||||||
// Info collected by setFrames method.
|
// Info collected by setFrames method.
|
||||||
@@ -609,7 +614,6 @@ class Screen : public concurrency::OSThread
|
|||||||
struct FramesetInfo {
|
struct FramesetInfo {
|
||||||
struct FramePositions {
|
struct FramePositions {
|
||||||
uint8_t fault = 255;
|
uint8_t fault = 255;
|
||||||
uint8_t textMessage = 255;
|
|
||||||
uint8_t waypoint = 255;
|
uint8_t waypoint = 255;
|
||||||
uint8_t focusedModule = 255;
|
uint8_t focusedModule = 255;
|
||||||
uint8_t log = 255;
|
uint8_t log = 255;
|
||||||
@@ -617,6 +621,18 @@ class Screen : public concurrency::OSThread
|
|||||||
uint8_t wifi = 255;
|
uint8_t wifi = 255;
|
||||||
uint8_t deviceFocused = 255;
|
uint8_t deviceFocused = 255;
|
||||||
uint8_t memory = 255;
|
uint8_t memory = 255;
|
||||||
|
uint8_t gps = 255;
|
||||||
|
uint8_t home = 255;
|
||||||
|
uint8_t textMessage = 255;
|
||||||
|
uint8_t nodelist = 255;
|
||||||
|
uint8_t nodelist_lastheard = 255;
|
||||||
|
uint8_t nodelist_hopsignal = 255;
|
||||||
|
uint8_t nodelist_distance = 255;
|
||||||
|
uint8_t nodelist_bearings = 255;
|
||||||
|
uint8_t clock = 255;
|
||||||
|
uint8_t firstFavorite = 255;
|
||||||
|
uint8_t lastFavorite = 255;
|
||||||
|
uint8_t lora = 255;
|
||||||
} positions;
|
} positions;
|
||||||
|
|
||||||
uint8_t frameCount = 0;
|
uint8_t frameCount = 0;
|
||||||
@@ -635,27 +651,6 @@ class Screen : public concurrency::OSThread
|
|||||||
// Sets frame up for immediate drawing
|
// Sets frame up for immediate drawing
|
||||||
void setFrameImmediateDraw(FrameCallback *drawFrames);
|
void setFrameImmediateDraw(FrameCallback *drawFrames);
|
||||||
|
|
||||||
#if defined(DISPLAY_CLOCK_FRAME)
|
|
||||||
static void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
|
||||||
|
|
||||||
static void drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
|
||||||
|
|
||||||
static void drawSegmentedDisplayCharacter(OLEDDisplay *display, int x, int y, uint8_t number, float scale = 1);
|
|
||||||
|
|
||||||
static void drawHorizontalSegment(OLEDDisplay *display, int x, int y, int width, int height);
|
|
||||||
|
|
||||||
static void drawVerticalSegment(OLEDDisplay *display, int x, int y, int width, int height);
|
|
||||||
|
|
||||||
static void drawSegmentedDisplayColon(OLEDDisplay *display, int x, int y, float scale = 1);
|
|
||||||
|
|
||||||
static void drawWatchFaceToggleButton(OLEDDisplay *display, int16_t x, int16_t y, bool digitalMode = true, float scale = 1);
|
|
||||||
|
|
||||||
static void drawBluetoothConnectedIcon(OLEDDisplay *display, int16_t x, int16_t y);
|
|
||||||
|
|
||||||
// Whether we are showing the digital watch face or the analog one
|
|
||||||
bool digitalWatchFace = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// callback for current alert frame
|
/// callback for current alert frame
|
||||||
FrameCallback alertFrame;
|
FrameCallback alertFrame;
|
||||||
|
|
||||||
@@ -688,13 +683,9 @@ class Screen : public concurrency::OSThread
|
|||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
extern char *alertBannerMessage;
|
|
||||||
extern uint32_t alertBannerUntil;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extern declarations for function symbols used in UIRenderer
|
// Extern declarations for function symbols used in UIRenderer
|
||||||
extern std::vector<std::string> functionSymbol;
|
extern std::vector<std::string> functionSymbol;
|
||||||
extern std::string functionSymbolString;
|
extern std::string functionSymbolString;
|
||||||
|
extern graphics::Screen *screen;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -10,9 +10,22 @@
|
|||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
|
|
||||||
|
void determineResolution(int16_t screenheight, int16_t screenwidth)
|
||||||
|
{
|
||||||
|
if (screenwidth > 128) {
|
||||||
|
isHighResolution = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special case for Heltec Wireless Tracker v1.1
|
||||||
|
if (screenwidth == 160 && screenheight == 80) {
|
||||||
|
isHighResolution = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// === Shared External State ===
|
// === Shared External State ===
|
||||||
bool hasUnreadMessage = false;
|
bool hasUnreadMessage = false;
|
||||||
bool isMuted = false;
|
bool isMuted = false;
|
||||||
|
bool isHighResolution = false;
|
||||||
|
|
||||||
// === Internal State ===
|
// === Internal State ===
|
||||||
bool isBoltVisibleShared = true;
|
bool isBoltVisibleShared = true;
|
||||||
@@ -40,7 +53,7 @@ void drawRoundedHighlight(OLEDDisplay *display, int16_t x, int16_t y, int16_t w,
|
|||||||
// *************************
|
// *************************
|
||||||
// * Common Header Drawing *
|
// * Common Header Drawing *
|
||||||
// *************************
|
// *************************
|
||||||
void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *titleStr, bool battery_only)
|
||||||
{
|
{
|
||||||
constexpr int HEADER_OFFSET_Y = 1;
|
constexpr int HEADER_OFFSET_Y = 1;
|
||||||
y += HEADER_OFFSET_Y;
|
y += HEADER_OFFSET_Y;
|
||||||
@@ -56,25 +69,40 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
|||||||
const int screenW = display->getWidth();
|
const int screenW = display->getWidth();
|
||||||
const int screenH = display->getHeight();
|
const int screenH = display->getHeight();
|
||||||
|
|
||||||
const bool useBigIcons = (screenW > 128);
|
if (!battery_only) {
|
||||||
|
// === Inverted Header Background ===
|
||||||
// === Inverted Header Background ===
|
if (isInverted) {
|
||||||
if (isInverted) {
|
display->setColor(BLACK);
|
||||||
drawRoundedHighlight(display, x, y, screenW, highlightHeight, 2);
|
display->fillRect(0, 0, screenW, highlightHeight + 2);
|
||||||
display->setColor(BLACK);
|
display->setColor(WHITE);
|
||||||
} else {
|
drawRoundedHighlight(display, x, y, screenW, highlightHeight, 2);
|
||||||
if (screenW > 128) {
|
display->setColor(BLACK);
|
||||||
display->drawLine(0, 20, screenW, 20);
|
|
||||||
} else {
|
} else {
|
||||||
display->drawLine(0, 14, screenW, 14);
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(0, 0, screenW, highlightHeight + 2);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
if (isHighResolution) {
|
||||||
|
display->drawLine(0, 20, screenW, 20);
|
||||||
|
} else {
|
||||||
|
display->drawLine(0, 14, screenW, 14);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Screen Title ===
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
|
display->drawString(SCREEN_WIDTH / 2, y, titleStr);
|
||||||
|
if (config.display.heading_bold) {
|
||||||
|
display->drawString((SCREEN_WIDTH / 2) + 1, y, titleStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
// === Battery State ===
|
// === Battery State ===
|
||||||
int chargePercent = powerStatus->getBatteryChargePercent();
|
int chargePercent = powerStatus->getBatteryChargePercent();
|
||||||
bool isCharging = powerStatus->getIsCharging() == meshtastic::OptionalBool::OptTrue;
|
bool isCharging = powerStatus->getIsCharging() == meshtastic::OptionalBool::OptTrue;
|
||||||
static uint32_t lastBlinkShared = 0;
|
if (chargePercent == 100) {
|
||||||
static bool isBoltVisibleShared = true;
|
isCharging = false;
|
||||||
|
}
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
|
|
||||||
#ifndef USE_EINK
|
#ifndef USE_EINK
|
||||||
@@ -84,20 +112,22 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool useHorizontalBattery = (screenW > 128 && screenW >= screenH);
|
bool useHorizontalBattery = (isHighResolution && screenW >= screenH);
|
||||||
const int textY = y + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
const int textY = y + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
||||||
|
|
||||||
// === Battery Icons ===
|
// === Battery Icons ===
|
||||||
if (useHorizontalBattery) {
|
if (useHorizontalBattery) {
|
||||||
int batteryX = 2;
|
int batteryX = 2;
|
||||||
int batteryY = HEADER_OFFSET_Y + 2;
|
int batteryY = HEADER_OFFSET_Y + 3;
|
||||||
display->drawXbm(batteryX, batteryY, 29, 15, batteryBitmap_h);
|
display->drawXbm(batteryX, batteryY, 9, 13, batteryBitmap_h_bottom);
|
||||||
|
display->drawXbm(batteryX + 9, batteryY, 9, 13, batteryBitmap_h_top);
|
||||||
if (isCharging && isBoltVisibleShared)
|
if (isCharging && isBoltVisibleShared)
|
||||||
display->drawXbm(batteryX + 9, batteryY + 1, 9, 13, lightning_bolt_h);
|
display->drawXbm(batteryX + 4, batteryY, 9, 13, lightning_bolt_h);
|
||||||
else {
|
else {
|
||||||
display->drawXbm(batteryX + 8, batteryY, 12, 15, batteryBitmap_sidegaps_h);
|
display->drawLine(batteryX + 5, batteryY, batteryX + 10, batteryY);
|
||||||
int fillWidth = 24 * chargePercent / 100;
|
display->drawLine(batteryX + 5, batteryY + 12, batteryX + 10, batteryY + 12);
|
||||||
display->fillRect(batteryX + 1, batteryY + 1, fillWidth, 13);
|
int fillWidth = 14 * chargePercent / 100;
|
||||||
|
display->fillRect(batteryX + 1, batteryY + 1, fillWidth, 11);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int batteryX = 1;
|
int batteryX = 1;
|
||||||
@@ -120,12 +150,8 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
|||||||
char chargeStr[4];
|
char chargeStr[4];
|
||||||
snprintf(chargeStr, sizeof(chargeStr), "%d", chargePercent);
|
snprintf(chargeStr, sizeof(chargeStr), "%d", chargePercent);
|
||||||
int chargeNumWidth = display->getStringWidth(chargeStr);
|
int chargeNumWidth = display->getStringWidth(chargeStr);
|
||||||
const int batteryOffset = useHorizontalBattery ? 28 : 6;
|
const int batteryOffset = useHorizontalBattery ? 19 : 9;
|
||||||
#ifdef USE_EINK
|
const int percentX = x + batteryOffset;
|
||||||
const int percentX = x + xOffset + batteryOffset - 2;
|
|
||||||
#else
|
|
||||||
const int percentX = x + xOffset + batteryOffset;
|
|
||||||
#endif
|
|
||||||
display->drawString(percentX, textY, chargeStr);
|
display->drawString(percentX, textY, chargeStr);
|
||||||
display->drawString(percentX + chargeNumWidth - 1, textY, "%");
|
display->drawString(percentX + chargeNumWidth - 1, textY, "%");
|
||||||
if (isBold) {
|
if (isBold) {
|
||||||
@@ -139,7 +165,7 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
|||||||
int timeStrWidth = display->getStringWidth("12:34"); // Default alignment
|
int timeStrWidth = display->getStringWidth("12:34"); // Default alignment
|
||||||
int timeX = screenW - xOffset - timeStrWidth + 4;
|
int timeX = screenW - xOffset - timeStrWidth + 4;
|
||||||
|
|
||||||
if (rtc_sec > 0) {
|
if (rtc_sec > 0 && !battery_only) {
|
||||||
// === Build Time String ===
|
// === Build Time String ===
|
||||||
long hms = (rtc_sec % SEC_PER_DAY + SEC_PER_DAY) % SEC_PER_DAY;
|
long hms = (rtc_sec % SEC_PER_DAY + SEC_PER_DAY) % SEC_PER_DAY;
|
||||||
int hour = hms / SEC_PER_HOUR;
|
int hour = hms / SEC_PER_HOUR;
|
||||||
@@ -155,13 +181,99 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
timeStrWidth = display->getStringWidth(timeStr);
|
timeStrWidth = display->getStringWidth(timeStr);
|
||||||
timeX = screenW - xOffset - timeStrWidth + 4;
|
timeX = screenW - xOffset - timeStrWidth + 3;
|
||||||
|
|
||||||
// === Show Mail or Mute Icon to the Left of Time ===
|
// === Show Mail or Mute Icon to the Left of Time ===
|
||||||
int iconRightEdge = timeX - 2;
|
int iconRightEdge = timeX - 1;
|
||||||
|
|
||||||
|
bool showMail = false;
|
||||||
|
|
||||||
|
#ifndef USE_EINK
|
||||||
|
if (hasUnreadMessage) {
|
||||||
|
if (now - lastMailBlink > 500) {
|
||||||
|
isMailIconVisible = !isMailIconVisible;
|
||||||
|
lastMailBlink = now;
|
||||||
|
}
|
||||||
|
showMail = isMailIconVisible;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (hasUnreadMessage) {
|
||||||
|
showMail = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (showMail) {
|
||||||
|
if (useHorizontalBattery) {
|
||||||
|
int iconW = 16, iconH = 12;
|
||||||
|
int iconX = iconRightEdge - iconW;
|
||||||
|
int iconY = textY + (FONT_HEIGHT_SMALL - iconH) / 2 - 1;
|
||||||
|
if (isInverted) {
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, iconW + 3, iconH + 2);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
} else {
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, iconW + 3, iconH + 2);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
}
|
||||||
|
display->drawRect(iconX, iconY, iconW + 1, iconH);
|
||||||
|
display->drawLine(iconX, iconY, iconX + iconW / 2, iconY + iconH - 4);
|
||||||
|
display->drawLine(iconX + iconW, iconY, iconX + iconW / 2, iconY + iconH - 4);
|
||||||
|
} else {
|
||||||
|
int iconX = iconRightEdge - (mail_width - 2);
|
||||||
|
int iconY = textY + (FONT_HEIGHT_SMALL - mail_height) / 2;
|
||||||
|
if (isInverted) {
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mail_width + 2, mail_height + 2);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
} else {
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mail_width + 2, mail_height + 2);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
}
|
||||||
|
display->drawXbm(iconX, iconY, mail_width, mail_height, mail);
|
||||||
|
}
|
||||||
|
} else if (isMuted) {
|
||||||
|
if (isHighResolution) {
|
||||||
|
int iconX = iconRightEdge - mute_symbol_big_width;
|
||||||
|
int iconY = textY + (FONT_HEIGHT_SMALL - mute_symbol_big_height) / 2;
|
||||||
|
|
||||||
|
if (isInverted) {
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mute_symbol_big_width + 2, mute_symbol_big_height + 2);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
} else {
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mute_symbol_big_width + 2, mute_symbol_big_height + 2);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
}
|
||||||
|
display->drawXbm(iconX, iconY, mute_symbol_big_width, mute_symbol_big_height, mute_symbol_big);
|
||||||
|
} else {
|
||||||
|
int iconX = iconRightEdge - mute_symbol_width;
|
||||||
|
int iconY = textY + (FONT_HEIGHT_SMALL - mail_height) / 2;
|
||||||
|
|
||||||
|
if (isInverted) {
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mute_symbol_width + 2, mute_symbol_height + 2);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
} else {
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(iconX - 1, iconY - 1, mute_symbol_width + 2, mute_symbol_height + 2);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
}
|
||||||
|
display->drawXbm(iconX, iconY, mute_symbol_width, mute_symbol_height, mute_symbol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Draw Time ===
|
||||||
|
display->drawString(timeX, textY, timeStr);
|
||||||
|
if (isBold)
|
||||||
|
display->drawString(timeX - 1, textY, timeStr);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// === No Time Available: Mail/Mute Icon Moves to Far Right ===
|
||||||
|
int iconRightEdge = screenW - xOffset;
|
||||||
|
|
||||||
static bool isMailIconVisible = true;
|
|
||||||
static uint32_t lastMailBlink = 0;
|
|
||||||
bool showMail = false;
|
bool showMail = false;
|
||||||
|
|
||||||
#ifndef USE_EINK
|
#ifndef USE_EINK
|
||||||
@@ -192,53 +304,7 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
|||||||
display->drawXbm(iconX, iconY, mail_width, mail_height, mail);
|
display->drawXbm(iconX, iconY, mail_width, mail_height, mail);
|
||||||
}
|
}
|
||||||
} else if (isMuted) {
|
} else if (isMuted) {
|
||||||
if (useBigIcons) {
|
if (isHighResolution) {
|
||||||
int iconX = iconRightEdge - mute_symbol_big_width;
|
|
||||||
int iconY = textY + (FONT_HEIGHT_SMALL - mute_symbol_big_height) / 2;
|
|
||||||
display->drawXbm(iconX, iconY, mute_symbol_big_width, mute_symbol_big_height, mute_symbol_big);
|
|
||||||
} else {
|
|
||||||
int iconX = iconRightEdge - mute_symbol_width;
|
|
||||||
int iconY = textY + (FONT_HEIGHT_SMALL - mail_height) / 2;
|
|
||||||
display->drawXbm(iconX, iconY, mute_symbol_width, mute_symbol_height, mute_symbol);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// === Draw Time ===
|
|
||||||
display->drawString(timeX, textY, timeStr);
|
|
||||||
if (isBold)
|
|
||||||
display->drawString(timeX - 1, textY, timeStr);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// === No Time Available: Mail/Mute Icon Moves to Far Right ===
|
|
||||||
int iconRightEdge = screenW - xOffset;
|
|
||||||
|
|
||||||
static bool isMailIconVisible = true;
|
|
||||||
static uint32_t lastMailBlink = 0;
|
|
||||||
bool showMail = false;
|
|
||||||
|
|
||||||
if (hasUnreadMessage) {
|
|
||||||
if (now - lastMailBlink > 500) {
|
|
||||||
isMailIconVisible = !isMailIconVisible;
|
|
||||||
lastMailBlink = now;
|
|
||||||
}
|
|
||||||
showMail = isMailIconVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showMail) {
|
|
||||||
if (useHorizontalBattery) {
|
|
||||||
int iconW = 16, iconH = 12;
|
|
||||||
int iconX = iconRightEdge - iconW;
|
|
||||||
int iconY = textY + (FONT_HEIGHT_SMALL - iconH) / 2 - 1;
|
|
||||||
display->drawRect(iconX, iconY, iconW + 1, iconH);
|
|
||||||
display->drawLine(iconX, iconY, iconX + iconW / 2, iconY + iconH - 4);
|
|
||||||
display->drawLine(iconX + iconW, iconY, iconX + iconW / 2, iconY + iconH - 4);
|
|
||||||
} else {
|
|
||||||
int iconX = iconRightEdge - mail_width;
|
|
||||||
int iconY = textY + (FONT_HEIGHT_SMALL - mail_height) / 2;
|
|
||||||
display->drawXbm(iconX, iconY, mail_width, mail_height, mail);
|
|
||||||
}
|
|
||||||
} else if (isMuted) {
|
|
||||||
if (useBigIcons) {
|
|
||||||
int iconX = iconRightEdge - mute_symbol_big_width;
|
int iconX = iconRightEdge - mute_symbol_big_width;
|
||||||
int iconY = textY + (FONT_HEIGHT_SMALL - mute_symbol_big_height) / 2;
|
int iconY = textY + (FONT_HEIGHT_SMALL - mute_symbol_big_height) / 2;
|
||||||
display->drawXbm(iconX, iconY, mute_symbol_big_width, mute_symbol_big_height, mute_symbol_big);
|
display->drawXbm(iconX, iconY, mute_symbol_big_width, mute_symbol_big_height, mute_symbol_big);
|
||||||
@@ -253,4 +319,28 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
|||||||
display->setColor(WHITE); // Reset for other UI
|
display->setColor(WHITE); // Reset for other UI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int *getTextPositions(OLEDDisplay *display)
|
||||||
|
{
|
||||||
|
static int textPositions[7]; // Static array that persists beyond function scope
|
||||||
|
|
||||||
|
if (isHighResolution) {
|
||||||
|
textPositions[0] = textZeroLine;
|
||||||
|
textPositions[1] = textFirstLine_medium;
|
||||||
|
textPositions[2] = textSecondLine_medium;
|
||||||
|
textPositions[3] = textThirdLine_medium;
|
||||||
|
textPositions[4] = textFourthLine_medium;
|
||||||
|
textPositions[5] = textFifthLine_medium;
|
||||||
|
textPositions[6] = textSixthLine_medium;
|
||||||
|
} else {
|
||||||
|
textPositions[0] = textZeroLine;
|
||||||
|
textPositions[1] = textFirstLine;
|
||||||
|
textPositions[2] = textSecondLine;
|
||||||
|
textPositions[3] = textThirdLine;
|
||||||
|
textPositions[4] = textFourthLine;
|
||||||
|
textPositions[5] = textFifthLine;
|
||||||
|
textPositions[6] = textSixthLine;
|
||||||
|
}
|
||||||
|
return textPositions;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
|||||||
@@ -9,25 +9,30 @@ namespace graphics
|
|||||||
// Shared UI Helpers
|
// Shared UI Helpers
|
||||||
// =======================
|
// =======================
|
||||||
|
|
||||||
// Compact line layout
|
#define textZeroLine 0
|
||||||
#define compactFirstLine ((FONT_HEIGHT_SMALL - 1) * 1)
|
// Consistent Line Spacing - this is standard for all display and the fall-back spacing
|
||||||
#define compactSecondLine ((FONT_HEIGHT_SMALL - 1) * 2) - 2
|
#define textFirstLine (FONT_HEIGHT_SMALL - 1)
|
||||||
#define compactThirdLine ((FONT_HEIGHT_SMALL - 1) * 3) - 4
|
#define textSecondLine (textFirstLine + (FONT_HEIGHT_SMALL - 5))
|
||||||
#define compactFourthLine ((FONT_HEIGHT_SMALL - 1) * 4) - 6
|
#define textThirdLine (textSecondLine + (FONT_HEIGHT_SMALL - 5))
|
||||||
#define compactFifthLine ((FONT_HEIGHT_SMALL - 1) * 5) - 8
|
#define textFourthLine (textThirdLine + (FONT_HEIGHT_SMALL - 5))
|
||||||
|
#define textFifthLine (textFourthLine + (FONT_HEIGHT_SMALL - 5))
|
||||||
|
#define textSixthLine (textFifthLine + (FONT_HEIGHT_SMALL - 5))
|
||||||
|
|
||||||
// Standard line layout
|
// Consistent Line Spacing for devices like T114 and TEcho/ThinkNode M1 of devices
|
||||||
#define standardFirstLine (FONT_HEIGHT_SMALL + 1) * 1
|
#define textFirstLine_medium (FONT_HEIGHT_SMALL + 1)
|
||||||
#define standardSecondLine (FONT_HEIGHT_SMALL + 1) * 2
|
#define textSecondLine_medium (textFirstLine_medium + FONT_HEIGHT_SMALL)
|
||||||
#define standardThirdLine (FONT_HEIGHT_SMALL + 1) * 3
|
#define textThirdLine_medium (textSecondLine_medium + FONT_HEIGHT_SMALL)
|
||||||
#define standardFourthLine (FONT_HEIGHT_SMALL + 1) * 4
|
#define textFourthLine_medium (textThirdLine_medium + FONT_HEIGHT_SMALL)
|
||||||
|
#define textFifthLine_medium (textFourthLine_medium + FONT_HEIGHT_SMALL)
|
||||||
|
#define textSixthLine_medium (textFifthLine_medium + FONT_HEIGHT_SMALL)
|
||||||
|
|
||||||
// More Compact line layout
|
// Consistent Line Spacing for devices like VisionMaster T190
|
||||||
#define moreCompactFirstLine compactFirstLine
|
#define textFirstLine_large (FONT_HEIGHT_SMALL + 1)
|
||||||
#define moreCompactSecondLine (moreCompactFirstLine + (FONT_HEIGHT_SMALL - 5))
|
#define textSecondLine_large (textFirstLine_large + (FONT_HEIGHT_SMALL + 5))
|
||||||
#define moreCompactThirdLine (moreCompactSecondLine + (FONT_HEIGHT_SMALL - 5))
|
#define textThirdLine_large (textSecondLine_large + (FONT_HEIGHT_SMALL + 5))
|
||||||
#define moreCompactFourthLine (moreCompactThirdLine + (FONT_HEIGHT_SMALL - 5))
|
#define textFourthLine_large (textThirdLine_large + (FONT_HEIGHT_SMALL + 5))
|
||||||
#define moreCompactFifthLine (moreCompactFourthLine + (FONT_HEIGHT_SMALL - 5))
|
#define textFifthLine_large (textFourthLine_large + (FONT_HEIGHT_SMALL + 5))
|
||||||
|
#define textSixthLine_large (textFifthLine_large + (FONT_HEIGHT_SMALL + 5))
|
||||||
|
|
||||||
// Quick screen access
|
// Quick screen access
|
||||||
#define SCREEN_WIDTH display->getWidth()
|
#define SCREEN_WIDTH display->getWidth()
|
||||||
@@ -36,11 +41,15 @@ namespace graphics
|
|||||||
// Shared state (declare inside namespace)
|
// Shared state (declare inside namespace)
|
||||||
extern bool hasUnreadMessage;
|
extern bool hasUnreadMessage;
|
||||||
extern bool isMuted;
|
extern bool isMuted;
|
||||||
|
extern bool isHighResolution;
|
||||||
|
void determineResolution(int16_t screenheight, int16_t screenwidth);
|
||||||
|
|
||||||
// Rounded highlight (used for inverted headers)
|
// Rounded highlight (used for inverted headers)
|
||||||
void drawRoundedHighlight(OLEDDisplay *display, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r);
|
void drawRoundedHighlight(OLEDDisplay *display, int16_t x, int16_t y, int16_t w, int16_t h, int16_t r);
|
||||||
|
|
||||||
// Shared battery/time/mail header
|
// Shared battery/time/mail header
|
||||||
void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y);
|
void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const char *titleStr = "", bool battery_only = false);
|
||||||
|
|
||||||
|
const int *getTextPositions(OLEDDisplay *display);
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
|||||||
@@ -467,18 +467,27 @@ class LGFX : public lgfx::LGFX_Device
|
|||||||
|
|
||||||
// The following setting values are general initial values for each panel, so please comment out any
|
// The following setting values are general initial values for each panel, so please comment out any
|
||||||
// unknown items and try them.
|
// unknown items and try them.
|
||||||
|
#if defined(T_WATCH_S3)
|
||||||
cfg.memory_width = TFT_WIDTH; // Maximum width supported by the driver IC
|
cfg.panel_width = 240;
|
||||||
cfg.memory_height = TFT_HEIGHT; // Maximum height supported by the driver IC
|
cfg.panel_height = 240;
|
||||||
cfg.panel_width = TFT_WIDTH; // actual displayable width
|
cfg.memory_width = 240;
|
||||||
cfg.panel_height = TFT_HEIGHT; // actual displayable height
|
cfg.memory_height = 320;
|
||||||
cfg.offset_x = TFT_OFFSET_X; // Panel offset amount in X direction
|
cfg.offset_x = 0;
|
||||||
cfg.offset_y = TFT_OFFSET_Y; // Panel offset amount in Y direction
|
cfg.offset_y = 0; // No vertical shift needed — panel is top-aligned
|
||||||
cfg.offset_rotation = TFT_OFFSET_ROTATION; // Rotation direction value offset 0~7 (4~7 is mirrored)
|
cfg.offset_rotation = 2; // Rotate 180° to correct upside-down layout
|
||||||
|
#else
|
||||||
|
cfg.memory_width = TFT_WIDTH; // Maximum width supported by the driver IC
|
||||||
|
cfg.memory_height = TFT_HEIGHT; // Maximum height supported by the driver IC
|
||||||
|
cfg.panel_width = TFT_WIDTH; // actual displayable width
|
||||||
|
cfg.panel_height = TFT_HEIGHT; // actual displayable height
|
||||||
|
cfg.offset_x = TFT_OFFSET_X; // Panel offset amount in X direction
|
||||||
|
cfg.offset_y = TFT_OFFSET_Y; // Panel offset amount in Y direction
|
||||||
|
cfg.offset_rotation = TFT_OFFSET_ROTATION; // Rotation direction value offset 0~7 (4~7 is mirrored)
|
||||||
|
#endif
|
||||||
#ifdef TFT_DUMMY_READ_PIXELS
|
#ifdef TFT_DUMMY_READ_PIXELS
|
||||||
cfg.dummy_read_pixel = TFT_DUMMY_READ_PIXELS; // Number of bits for dummy read before pixel readout
|
cfg.dummy_read_pixel = TFT_DUMMY_READ_PIXELS; // Number of bits for dummy read before pixel readout
|
||||||
#else
|
#else
|
||||||
cfg.dummy_read_pixel = 9; // Number of bits for dummy read before pixel readout
|
cfg.dummy_read_pixel = 9; // Number of bits for dummy read before pixel readout
|
||||||
#endif
|
#endif
|
||||||
cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read
|
cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read
|
||||||
cfg.readable = true; // Set to true if data can be read
|
cfg.readable = true; // Set to true if data can be read
|
||||||
@@ -1175,7 +1184,7 @@ bool TFTDisplay::connect()
|
|||||||
#elif defined(T_WATCH_S3) || defined(SENSECAP_INDICATOR)
|
#elif defined(T_WATCH_S3) || defined(SENSECAP_INDICATOR)
|
||||||
tft->setRotation(2); // T-Watch S3 left-handed orientation
|
tft->setRotation(2); // T-Watch S3 left-handed orientation
|
||||||
#elif ARCH_PORTDUINO
|
#elif ARCH_PORTDUINO
|
||||||
tft->setRotation(0);
|
tft->setRotation(0); // use config.yaml to set rotation
|
||||||
#else
|
#else
|
||||||
tft->setRotation(3); // Orient horizontal and wide underneath the silkscreen name label
|
tft->setRotation(3); // Orient horizontal and wide underneath the silkscreen name label
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
103
src/graphics/TimeFormatters.cpp
Normal file
103
src/graphics/TimeFormatters.cpp
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
#include "TimeFormatters.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
#include "gps/RTC.h"
|
||||||
|
#include "mesh/NodeDB.h"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
bool deltaToTimestamp(uint32_t secondsAgo, uint8_t *hours, uint8_t *minutes, int32_t *daysAgo)
|
||||||
|
{
|
||||||
|
// Cache the result - avoid frequent recalculation
|
||||||
|
static uint8_t hoursCached = 0, minutesCached = 0;
|
||||||
|
static uint32_t daysAgoCached = 0;
|
||||||
|
static uint32_t secondsAgoCached = 0;
|
||||||
|
static bool validCached = false;
|
||||||
|
|
||||||
|
// Abort: if timezone not set
|
||||||
|
if (strlen(config.device.tzdef) == 0) {
|
||||||
|
validCached = false;
|
||||||
|
return validCached;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abort: if invalid pointers passed
|
||||||
|
if (hours == nullptr || minutes == nullptr || daysAgo == nullptr) {
|
||||||
|
validCached = false;
|
||||||
|
return validCached;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abort: if time seems invalid.. (> 6 months ago, probably seen before RTC set)
|
||||||
|
if (secondsAgo > SEC_PER_DAY * 30UL * 6) {
|
||||||
|
validCached = false;
|
||||||
|
return validCached;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If repeated request, don't bother recalculating
|
||||||
|
if (secondsAgo - secondsAgoCached < 60 && secondsAgoCached != 0) {
|
||||||
|
if (validCached) {
|
||||||
|
*hours = hoursCached;
|
||||||
|
*minutes = minutesCached;
|
||||||
|
*daysAgo = daysAgoCached;
|
||||||
|
}
|
||||||
|
return validCached;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get local time
|
||||||
|
uint32_t secondsRTC = getValidTime(RTCQuality::RTCQualityDevice, true); // Get local time
|
||||||
|
|
||||||
|
// Abort: if RTC not set
|
||||||
|
if (!secondsRTC) {
|
||||||
|
validCached = false;
|
||||||
|
return validCached;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get absolute time when last seen
|
||||||
|
uint32_t secondsSeenAt = secondsRTC - secondsAgo;
|
||||||
|
|
||||||
|
// Calculate daysAgo
|
||||||
|
*daysAgo = (secondsRTC / SEC_PER_DAY) - (secondsSeenAt / SEC_PER_DAY); // How many "midnights" have passed
|
||||||
|
|
||||||
|
// Get seconds since midnight
|
||||||
|
uint32_t hms = (secondsRTC - secondsAgo) % SEC_PER_DAY;
|
||||||
|
hms = (hms + SEC_PER_DAY) % SEC_PER_DAY;
|
||||||
|
|
||||||
|
// Tear apart hms into hours and minutes
|
||||||
|
*hours = hms / SEC_PER_HOUR;
|
||||||
|
*minutes = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
|
||||||
|
|
||||||
|
// Cache the result
|
||||||
|
daysAgoCached = *daysAgo;
|
||||||
|
hoursCached = *hours;
|
||||||
|
minutesCached = *minutes;
|
||||||
|
secondsAgoCached = secondsAgo;
|
||||||
|
|
||||||
|
validCached = true;
|
||||||
|
return validCached;
|
||||||
|
}
|
||||||
|
|
||||||
|
void getTimeAgoStr(uint32_t agoSecs, char *timeStr, uint8_t maxLength)
|
||||||
|
{
|
||||||
|
// Use an absolute timestamp in some cases.
|
||||||
|
// Particularly useful with E-Ink displays. Static UI, fewer refreshes.
|
||||||
|
uint8_t timestampHours, timestampMinutes;
|
||||||
|
int32_t daysAgo;
|
||||||
|
bool useTimestamp = deltaToTimestamp(agoSecs, ×tampHours, ×tampMinutes, &daysAgo);
|
||||||
|
|
||||||
|
if (agoSecs < 120) // last 2 mins?
|
||||||
|
snprintf(timeStr, maxLength, "%u seconds ago", agoSecs);
|
||||||
|
// -- if suitable for timestamp --
|
||||||
|
else if (useTimestamp && agoSecs < 15 * SECONDS_IN_MINUTE) // Last 15 minutes
|
||||||
|
snprintf(timeStr, maxLength, "%u minutes ago", agoSecs / SECONDS_IN_MINUTE);
|
||||||
|
else if (useTimestamp && daysAgo == 0) // Today
|
||||||
|
snprintf(timeStr, maxLength, "Last seen: %02u:%02u", (unsigned int)timestampHours, (unsigned int)timestampMinutes);
|
||||||
|
else if (useTimestamp && daysAgo == 1) // Yesterday
|
||||||
|
snprintf(timeStr, maxLength, "Seen yesterday");
|
||||||
|
else if (useTimestamp && daysAgo > 1) // Last six months (capped by deltaToTimestamp method)
|
||||||
|
snprintf(timeStr, maxLength, "%li days ago", (long)daysAgo);
|
||||||
|
// -- if using time delta instead --
|
||||||
|
else if (agoSecs < 120 * 60) // last 2 hrs
|
||||||
|
snprintf(timeStr, maxLength, "%u minutes ago", agoSecs / 60);
|
||||||
|
// Only show hours ago if it's been less than 6 months. Otherwise, we may have bad data.
|
||||||
|
else if ((agoSecs / 60 / 60) < (730 * 6))
|
||||||
|
snprintf(timeStr, maxLength, "%u hours ago", agoSecs / 60 / 60);
|
||||||
|
else
|
||||||
|
snprintf(timeStr, maxLength, "unknown age");
|
||||||
|
}
|
||||||
26
src/graphics/TimeFormatters.h
Normal file
26
src/graphics/TimeFormatters.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "configuration.h"
|
||||||
|
#include "gps/RTC.h"
|
||||||
|
#include <airtime.h>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a delta in seconds ago to timestamp information (hours, minutes, days ago).
|
||||||
|
*
|
||||||
|
* @param secondsAgo Number of seconds ago to convert
|
||||||
|
* @param hours Pointer to store the hours (0-23)
|
||||||
|
* @param minutes Pointer to store the minutes (0-59)
|
||||||
|
* @param daysAgo Pointer to store the number of days ago
|
||||||
|
* @return true if conversion was successful, false if invalid input or time not available
|
||||||
|
*/
|
||||||
|
bool deltaToTimestamp(uint32_t secondsAgo, uint8_t *hours, uint8_t *minutes, int32_t *daysAgo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a human-readable string representing the time ago in a format like "2 days, 3 hours, 15 minutes".
|
||||||
|
*
|
||||||
|
* @param agoSecs Number of seconds ago to convert
|
||||||
|
* @param timeStr Pointer to store the resulting string
|
||||||
|
* @param maxLength Maximum length of the resulting string buffer
|
||||||
|
*/
|
||||||
|
void getTimeAgoStr(uint32_t agoSecs, char *timeStr, uint8_t maxLength);
|
||||||
514
src/graphics/draw/ClockRenderer.cpp
Normal file
514
src/graphics/draw/ClockRenderer.cpp
Normal file
@@ -0,0 +1,514 @@
|
|||||||
|
#include "configuration.h"
|
||||||
|
#if HAS_SCREEN
|
||||||
|
#include "ClockRenderer.h"
|
||||||
|
#include "NodeDB.h"
|
||||||
|
#include "UIRenderer.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
#include "gps/GeoCoord.h"
|
||||||
|
#include "gps/RTC.h"
|
||||||
|
#include "graphics/ScreenFonts.h"
|
||||||
|
#include "graphics/SharedUIDisplay.h"
|
||||||
|
#include "graphics/emotes.h"
|
||||||
|
#include "graphics/images.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#if !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
|
#include "nimble/NimbleBluetooth.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace graphics
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace ClockRenderer
|
||||||
|
{
|
||||||
|
bool digitalWatchFace = true;
|
||||||
|
|
||||||
|
void drawSegmentedDisplayColon(OLEDDisplay *display, int x, int y, float scale)
|
||||||
|
{
|
||||||
|
uint16_t segmentWidth = SEGMENT_WIDTH * scale;
|
||||||
|
uint16_t segmentHeight = SEGMENT_HEIGHT * scale;
|
||||||
|
|
||||||
|
uint16_t cellHeight = (segmentWidth * 2) + (segmentHeight * 3) + 8;
|
||||||
|
|
||||||
|
uint16_t topAndBottomX = x + (4 * scale);
|
||||||
|
|
||||||
|
uint16_t quarterCellHeight = cellHeight / 4;
|
||||||
|
|
||||||
|
uint16_t topY = y + quarterCellHeight;
|
||||||
|
uint16_t bottomY = y + (quarterCellHeight * 3);
|
||||||
|
|
||||||
|
display->fillRect(topAndBottomX, topY, segmentHeight, segmentHeight);
|
||||||
|
display->fillRect(topAndBottomX, bottomY, segmentHeight, segmentHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawSegmentedDisplayCharacter(OLEDDisplay *display, int x, int y, uint8_t number, float scale)
|
||||||
|
{
|
||||||
|
// the numbers 0-9, each expressed as an array of seven boolean (0|1) values encoding the on/off state of
|
||||||
|
// segment {innerIndex + 1}
|
||||||
|
// e.g., to display the numeral '0', segments 1-6 are on, and segment 7 is off.
|
||||||
|
uint8_t numbers[10][7] = {
|
||||||
|
{1, 1, 1, 1, 1, 1, 0}, // 0 Display segment key
|
||||||
|
{0, 1, 1, 0, 0, 0, 0}, // 1 1
|
||||||
|
{1, 1, 0, 1, 1, 0, 1}, // 2 ___
|
||||||
|
{1, 1, 1, 1, 0, 0, 1}, // 3 6 | | 2
|
||||||
|
{0, 1, 1, 0, 0, 1, 1}, // 4 |_7̲_|
|
||||||
|
{1, 0, 1, 1, 0, 1, 1}, // 5 5 | | 3
|
||||||
|
{1, 0, 1, 1, 1, 1, 1}, // 6 |___|
|
||||||
|
{1, 1, 1, 0, 0, 1, 0}, // 7
|
||||||
|
{1, 1, 1, 1, 1, 1, 1}, // 8 4
|
||||||
|
{1, 1, 1, 1, 0, 1, 1}, // 9
|
||||||
|
};
|
||||||
|
|
||||||
|
// the width and height of each segment's central rectangle:
|
||||||
|
// _____________________
|
||||||
|
// ⋰| (only this part, |⋱
|
||||||
|
// ⋰ | not including | ⋱
|
||||||
|
// ⋱ | the triangles | ⋰
|
||||||
|
// ⋱| on the ends) |⋰
|
||||||
|
// ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
|
uint16_t segmentWidth = SEGMENT_WIDTH * scale;
|
||||||
|
uint16_t segmentHeight = SEGMENT_HEIGHT * scale;
|
||||||
|
|
||||||
|
// segment x and y coordinates
|
||||||
|
uint16_t segmentOneX = x + segmentHeight + 2;
|
||||||
|
uint16_t segmentOneY = y;
|
||||||
|
|
||||||
|
uint16_t segmentTwoX = segmentOneX + segmentWidth + 2;
|
||||||
|
uint16_t segmentTwoY = segmentOneY + segmentHeight + 2;
|
||||||
|
|
||||||
|
uint16_t segmentThreeX = segmentTwoX;
|
||||||
|
uint16_t segmentThreeY = segmentTwoY + segmentWidth + 2 + segmentHeight + 2;
|
||||||
|
|
||||||
|
uint16_t segmentFourX = segmentOneX;
|
||||||
|
uint16_t segmentFourY = segmentThreeY + segmentWidth + 2;
|
||||||
|
|
||||||
|
uint16_t segmentFiveX = x;
|
||||||
|
uint16_t segmentFiveY = segmentThreeY;
|
||||||
|
|
||||||
|
uint16_t segmentSixX = x;
|
||||||
|
uint16_t segmentSixY = segmentTwoY;
|
||||||
|
|
||||||
|
uint16_t segmentSevenX = segmentOneX;
|
||||||
|
uint16_t segmentSevenY = segmentTwoY + segmentWidth + 2;
|
||||||
|
|
||||||
|
if (numbers[number][0]) {
|
||||||
|
graphics::ClockRenderer::drawHorizontalSegment(display, segmentOneX, segmentOneY, segmentWidth, segmentHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numbers[number][1]) {
|
||||||
|
graphics::ClockRenderer::drawVerticalSegment(display, segmentTwoX, segmentTwoY, segmentWidth, segmentHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numbers[number][2]) {
|
||||||
|
graphics::ClockRenderer::drawVerticalSegment(display, segmentThreeX, segmentThreeY, segmentWidth, segmentHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numbers[number][3]) {
|
||||||
|
graphics::ClockRenderer::drawHorizontalSegment(display, segmentFourX, segmentFourY, segmentWidth, segmentHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numbers[number][4]) {
|
||||||
|
graphics::ClockRenderer::drawVerticalSegment(display, segmentFiveX, segmentFiveY, segmentWidth, segmentHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numbers[number][5]) {
|
||||||
|
graphics::ClockRenderer::drawVerticalSegment(display, segmentSixX, segmentSixY, segmentWidth, segmentHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numbers[number][6]) {
|
||||||
|
graphics::ClockRenderer::drawHorizontalSegment(display, segmentSevenX, segmentSevenY, segmentWidth, segmentHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawHorizontalSegment(OLEDDisplay *display, int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
int halfHeight = height / 2;
|
||||||
|
|
||||||
|
// draw central rectangle
|
||||||
|
display->fillRect(x, y, width, height);
|
||||||
|
|
||||||
|
// draw end triangles
|
||||||
|
display->fillTriangle(x, y, x, y + height - 1, x - halfHeight, y + halfHeight);
|
||||||
|
|
||||||
|
display->fillTriangle(x + width, y, x + width + halfHeight, y + halfHeight, x + width, y + height - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawVerticalSegment(OLEDDisplay *display, int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
int halfHeight = height / 2;
|
||||||
|
|
||||||
|
// draw central rectangle
|
||||||
|
display->fillRect(x, y, height, width);
|
||||||
|
|
||||||
|
// draw end triangles
|
||||||
|
display->fillTriangle(x + halfHeight, y - halfHeight, x + height - 1, y, x, y);
|
||||||
|
|
||||||
|
display->fillTriangle(x, y + width, x + height - 1, y + width, x + halfHeight, y + width + halfHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void drawWatchFaceToggleButton(OLEDDisplay *display, int16_t x, int16_t y, bool digitalMode, float scale)
|
||||||
|
{
|
||||||
|
uint16_t segmentWidth = SEGMENT_WIDTH * scale;
|
||||||
|
uint16_t segmentHeight = SEGMENT_HEIGHT * scale;
|
||||||
|
|
||||||
|
if (digitalMode) {
|
||||||
|
uint16_t radius = (segmentWidth + (segmentHeight * 2) + 4) / 2;
|
||||||
|
uint16_t centerX = (x + segmentHeight + 2) + (radius / 2);
|
||||||
|
uint16_t centerY = (y + segmentHeight + 2) + (radius / 2);
|
||||||
|
|
||||||
|
display->drawCircle(centerX, centerY, radius);
|
||||||
|
display->drawCircle(centerX, centerY, radius + 1);
|
||||||
|
display->drawLine(centerX, centerY, centerX, centerY - radius + 3);
|
||||||
|
display->drawLine(centerX, centerY, centerX + radius - 3, centerY);
|
||||||
|
} else {
|
||||||
|
uint16_t segmentOneX = x + segmentHeight + 2;
|
||||||
|
uint16_t segmentOneY = y;
|
||||||
|
|
||||||
|
uint16_t segmentTwoX = segmentOneX + segmentWidth + 2;
|
||||||
|
uint16_t segmentTwoY = segmentOneY + segmentHeight + 2;
|
||||||
|
|
||||||
|
uint16_t segmentThreeX = segmentOneX;
|
||||||
|
uint16_t segmentThreeY = segmentTwoY + segmentWidth + 2;
|
||||||
|
|
||||||
|
uint16_t segmentFourX = x;
|
||||||
|
uint16_t segmentFourY = y + segmentHeight + 2;
|
||||||
|
|
||||||
|
drawHorizontalSegment(display, segmentOneX, segmentOneY, segmentWidth, segmentHeight);
|
||||||
|
drawVerticalSegment(display, segmentTwoX, segmentTwoY, segmentWidth, segmentHeight);
|
||||||
|
drawHorizontalSegment(display, segmentThreeX, segmentThreeY, segmentWidth, segmentHeight);
|
||||||
|
drawVerticalSegment(display, segmentFourX, segmentFourY, segmentWidth, segmentHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
// Draw a digital clock
|
||||||
|
void drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
|
{
|
||||||
|
display->clear();
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
int line = 1;
|
||||||
|
// === Set Title, Blank for Clock
|
||||||
|
const char *titleStr = "";
|
||||||
|
// === Header ===
|
||||||
|
graphics::drawCommonHeader(display, x, y, titleStr, true);
|
||||||
|
|
||||||
|
#ifdef T_WATCH_S3
|
||||||
|
if (nimbleBluetooth && nimbleBluetooth->isConnected()) {
|
||||||
|
graphics::ClockRenderer::drawBluetoothConnectedIcon(display, display->getWidth() - 18, display->getHeight() - 14);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint32_t rtc_sec = getValidTime(RTCQuality::RTCQualityDevice, true); // Display local timezone
|
||||||
|
char timeString[16];
|
||||||
|
int hour = 0;
|
||||||
|
int minute = 0;
|
||||||
|
int second = 0;
|
||||||
|
if (rtc_sec > 0) {
|
||||||
|
long hms = rtc_sec % SEC_PER_DAY;
|
||||||
|
hms = (hms + SEC_PER_DAY) % SEC_PER_DAY;
|
||||||
|
|
||||||
|
hour = hms / SEC_PER_HOUR;
|
||||||
|
minute = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
|
||||||
|
second = (hms % SEC_PER_HOUR) % SEC_PER_MIN; // or hms % SEC_PER_MIN
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isPM = hour >= 12;
|
||||||
|
// hour = hour > 12 ? hour - 12 : hour;
|
||||||
|
if (config.display.use_12h_clock) {
|
||||||
|
hour %= 12;
|
||||||
|
if (hour == 0)
|
||||||
|
hour = 12;
|
||||||
|
bool isPM = hour >= 12;
|
||||||
|
snprintf(timeString, sizeof(timeString), "%d:%02d", hour, minute);
|
||||||
|
} else {
|
||||||
|
snprintf(timeString, sizeof(timeString), "%02d:%02d", hour, minute);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format seconds string
|
||||||
|
char secondString[8];
|
||||||
|
snprintf(secondString, sizeof(secondString), "%02d", second);
|
||||||
|
|
||||||
|
#ifdef T_WATCH_S3
|
||||||
|
float scale = 1.5;
|
||||||
|
#else
|
||||||
|
float scale = 0.75;
|
||||||
|
if (isHighResolution) {
|
||||||
|
scale = 1.5;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint16_t segmentWidth = SEGMENT_WIDTH * scale;
|
||||||
|
uint16_t segmentHeight = SEGMENT_HEIGHT * scale;
|
||||||
|
|
||||||
|
// calculate hours:minutes string width
|
||||||
|
uint16_t timeStringWidth = strlen(timeString) * 5;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < strlen(timeString); i++) {
|
||||||
|
char character = timeString[i];
|
||||||
|
|
||||||
|
if (character == ':') {
|
||||||
|
timeStringWidth += segmentHeight;
|
||||||
|
} else {
|
||||||
|
timeStringWidth += segmentWidth + (segmentHeight * 2) + 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t hourMinuteTextX = (display->getWidth() / 2) - (timeStringWidth / 2);
|
||||||
|
|
||||||
|
uint16_t startingHourMinuteTextX = hourMinuteTextX;
|
||||||
|
|
||||||
|
uint16_t hourMinuteTextY = (display->getHeight() / 2) - (((segmentWidth * 2) + (segmentHeight * 3) + 8) / 2);
|
||||||
|
|
||||||
|
// iterate over characters in hours:minutes string and draw segmented characters
|
||||||
|
for (uint8_t i = 0; i < strlen(timeString); i++) {
|
||||||
|
char character = timeString[i];
|
||||||
|
|
||||||
|
if (character == ':') {
|
||||||
|
drawSegmentedDisplayColon(display, hourMinuteTextX, hourMinuteTextY, scale);
|
||||||
|
|
||||||
|
hourMinuteTextX += segmentHeight + 6;
|
||||||
|
} else {
|
||||||
|
drawSegmentedDisplayCharacter(display, hourMinuteTextX, hourMinuteTextY, character - '0', scale);
|
||||||
|
|
||||||
|
hourMinuteTextX += segmentWidth + (segmentHeight * 2) + 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
hourMinuteTextX += 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw seconds string
|
||||||
|
display->setFont(FONT_SMALL);
|
||||||
|
int xOffset = (isHighResolution) ? 0 : -1;
|
||||||
|
if (hour >= 10) {
|
||||||
|
xOffset += (isHighResolution) ? 32 : 18;
|
||||||
|
}
|
||||||
|
int yOffset = (isHighResolution) ? 3 : 1;
|
||||||
|
if (config.display.use_12h_clock) {
|
||||||
|
display->drawString(startingHourMinuteTextX + xOffset, (display->getHeight() - hourMinuteTextY) - yOffset - 2,
|
||||||
|
isPM ? "pm" : "am");
|
||||||
|
}
|
||||||
|
#ifndef USE_EINK
|
||||||
|
xOffset = (isHighResolution) ? 18 : 10;
|
||||||
|
display->drawString(startingHourMinuteTextX + timeStringWidth - xOffset, (display->getHeight() - hourMinuteTextY) - yOffset,
|
||||||
|
secondString);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawBluetoothConnectedIcon(OLEDDisplay *display, int16_t x, int16_t y)
|
||||||
|
{
|
||||||
|
display->drawFastImage(x, y, 18, 14, bluetoothConnectedIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw an analog clock
|
||||||
|
void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
|
{
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
// === Set Title, Blank for Clock
|
||||||
|
const char *titleStr = "";
|
||||||
|
// === Header ===
|
||||||
|
graphics::drawCommonHeader(display, x, y, titleStr, true);
|
||||||
|
|
||||||
|
#ifdef T_WATCH_S3
|
||||||
|
if (nimbleBluetooth && nimbleBluetooth->isConnected()) {
|
||||||
|
drawBluetoothConnectedIcon(display, display->getWidth() - 18, display->getHeight() - 14);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// clock face center coordinates
|
||||||
|
int16_t centerX = display->getWidth() / 2;
|
||||||
|
int16_t centerY = display->getHeight() / 2;
|
||||||
|
|
||||||
|
// clock face radius
|
||||||
|
int16_t radius = 0;
|
||||||
|
if (display->getHeight() < display->getWidth()) {
|
||||||
|
radius = (display->getHeight() / 2) * 0.9;
|
||||||
|
} else {
|
||||||
|
radius = (display->getWidth() / 2) * 0.9;
|
||||||
|
}
|
||||||
|
#ifdef T_WATCH_S3
|
||||||
|
radius = (display->getWidth() / 2) * 0.8;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// noon (0 deg) coordinates (outermost circle)
|
||||||
|
int16_t noonX = centerX;
|
||||||
|
int16_t noonY = centerY - radius;
|
||||||
|
|
||||||
|
// second hand radius and y coordinate (outermost circle)
|
||||||
|
int16_t secondHandNoonY = noonY + 1;
|
||||||
|
|
||||||
|
// tick mark outer y coordinate; (first nested circle)
|
||||||
|
int16_t tickMarkOuterNoonY = secondHandNoonY;
|
||||||
|
|
||||||
|
// seconds tick mark inner y coordinate; (second nested circle)
|
||||||
|
double secondsTickMarkInnerNoonY = (double)noonY + 4;
|
||||||
|
if (isHighResolution) {
|
||||||
|
secondsTickMarkInnerNoonY = (double)noonY + 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hours tick mark inner y coordinate; (third nested circle)
|
||||||
|
double hoursTickMarkInnerNoonY = (double)noonY + 6;
|
||||||
|
if (isHighResolution) {
|
||||||
|
hoursTickMarkInnerNoonY = (double)noonY + 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
// minute hand y coordinate
|
||||||
|
int16_t minuteHandNoonY = secondsTickMarkInnerNoonY + 4;
|
||||||
|
|
||||||
|
// hour string y coordinate
|
||||||
|
int16_t hourStringNoonY = minuteHandNoonY + 18;
|
||||||
|
|
||||||
|
// hour hand radius and y coordinate
|
||||||
|
int16_t hourHandRadius = radius * 0.35;
|
||||||
|
if (isHighResolution) {
|
||||||
|
int16_t hourHandRadius = radius * 0.55;
|
||||||
|
}
|
||||||
|
int16_t hourHandNoonY = centerY - hourHandRadius;
|
||||||
|
|
||||||
|
display->setColor(OLEDDISPLAY_COLOR::WHITE);
|
||||||
|
display->drawCircle(centerX, centerY, radius);
|
||||||
|
|
||||||
|
uint32_t rtc_sec = getValidTime(RTCQuality::RTCQualityDevice, true); // Display local timezone
|
||||||
|
if (rtc_sec > 0) {
|
||||||
|
long hms = rtc_sec % SEC_PER_DAY;
|
||||||
|
hms = (hms + SEC_PER_DAY) % SEC_PER_DAY;
|
||||||
|
|
||||||
|
// Tear apart hms into h:m:s
|
||||||
|
int hour = hms / SEC_PER_HOUR;
|
||||||
|
int minute = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
|
||||||
|
int second = (hms % SEC_PER_HOUR) % SEC_PER_MIN; // or hms % SEC_PER_MIN
|
||||||
|
|
||||||
|
bool isPM = hour >= 12;
|
||||||
|
if (config.display.use_12h_clock) {
|
||||||
|
bool isPM = hour >= 12;
|
||||||
|
display->setFont(FONT_SMALL);
|
||||||
|
int yOffset = isHighResolution ? 1 : 0;
|
||||||
|
#ifdef USE_EINK
|
||||||
|
yOffset += 3;
|
||||||
|
#endif
|
||||||
|
display->drawString(centerX - (display->getStringWidth(isPM ? "pm" : "am") / 2), centerY + yOffset,
|
||||||
|
isPM ? "pm" : "am");
|
||||||
|
}
|
||||||
|
hour %= 12;
|
||||||
|
if (hour == 0)
|
||||||
|
hour = 12;
|
||||||
|
|
||||||
|
int16_t degreesPerHour = 30;
|
||||||
|
int16_t degreesPerMinuteOrSecond = 6;
|
||||||
|
|
||||||
|
double hourBaseAngle = hour * degreesPerHour;
|
||||||
|
double hourAngleOffset = ((double)minute / 60) * degreesPerHour;
|
||||||
|
double hourAngle = radians(hourBaseAngle + hourAngleOffset);
|
||||||
|
|
||||||
|
double minuteBaseAngle = minute * degreesPerMinuteOrSecond;
|
||||||
|
double minuteAngleOffset = ((double)second / 60) * degreesPerMinuteOrSecond;
|
||||||
|
double minuteAngle = radians(minuteBaseAngle + minuteAngleOffset);
|
||||||
|
|
||||||
|
double secondAngle = radians(second * degreesPerMinuteOrSecond);
|
||||||
|
|
||||||
|
double hourX = sin(-hourAngle) * (hourHandNoonY - centerY) + noonX;
|
||||||
|
double hourY = cos(-hourAngle) * (hourHandNoonY - centerY) + centerY;
|
||||||
|
|
||||||
|
double minuteX = sin(-minuteAngle) * (minuteHandNoonY - centerY) + noonX;
|
||||||
|
double minuteY = cos(-minuteAngle) * (minuteHandNoonY - centerY) + centerY;
|
||||||
|
|
||||||
|
double secondX = sin(-secondAngle) * (secondHandNoonY - centerY) + noonX;
|
||||||
|
double secondY = cos(-secondAngle) * (secondHandNoonY - centerY) + centerY;
|
||||||
|
|
||||||
|
display->setFont(FONT_MEDIUM);
|
||||||
|
|
||||||
|
// draw minute and hour tick marks and hour numbers
|
||||||
|
for (uint16_t angle = 0; angle < 360; angle += 6) {
|
||||||
|
double angleInRadians = radians(angle);
|
||||||
|
|
||||||
|
double sineAngleInRadians = sin(-angleInRadians);
|
||||||
|
double cosineAngleInRadians = cos(-angleInRadians);
|
||||||
|
|
||||||
|
double endX = sineAngleInRadians * (tickMarkOuterNoonY - centerY) + noonX;
|
||||||
|
double endY = cosineAngleInRadians * (tickMarkOuterNoonY - centerY) + centerY;
|
||||||
|
|
||||||
|
if (angle % degreesPerHour == 0) {
|
||||||
|
double startX = sineAngleInRadians * (hoursTickMarkInnerNoonY - centerY) + noonX;
|
||||||
|
double startY = cosineAngleInRadians * (hoursTickMarkInnerNoonY - centerY) + centerY;
|
||||||
|
|
||||||
|
// draw hour tick mark
|
||||||
|
display->drawLine(startX, startY, endX, endY);
|
||||||
|
|
||||||
|
static char buffer[2];
|
||||||
|
|
||||||
|
uint8_t hourInt = (angle / 30);
|
||||||
|
|
||||||
|
if (hourInt == 0) {
|
||||||
|
hourInt = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hour number x offset needs to be adjusted for some cases
|
||||||
|
int8_t hourStringXOffset;
|
||||||
|
int8_t hourStringYOffset = 13;
|
||||||
|
|
||||||
|
switch (hourInt) {
|
||||||
|
case 3:
|
||||||
|
hourStringXOffset = 5;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
hourStringXOffset = 7;
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
case 11:
|
||||||
|
hourStringXOffset = 8;
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
hourStringXOffset = 13;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
hourStringXOffset = 6;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
double hourStringX = (sineAngleInRadians * (hourStringNoonY - centerY) + noonX) - hourStringXOffset;
|
||||||
|
double hourStringY = (cosineAngleInRadians * (hourStringNoonY - centerY) + centerY) - hourStringYOffset;
|
||||||
|
|
||||||
|
#ifdef T_WATCH_S3
|
||||||
|
// draw hour number
|
||||||
|
display->drawStringf(hourStringX, hourStringY, buffer, "%d", hourInt);
|
||||||
|
#else
|
||||||
|
#ifdef USE_EINK
|
||||||
|
if (isHighResolution) {
|
||||||
|
// draw hour number
|
||||||
|
display->drawStringf(hourStringX, hourStringY, buffer, "%d", hourInt);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (isHighResolution && (hourInt == 3 || hourInt == 6 || hourInt == 9 || hourInt == 12)) {
|
||||||
|
// draw hour number
|
||||||
|
display->drawStringf(hourStringX, hourStringY, buffer, "%d", hourInt);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (angle % degreesPerMinuteOrSecond == 0) {
|
||||||
|
double startX = sineAngleInRadians * (secondsTickMarkInnerNoonY - centerY) + noonX;
|
||||||
|
double startY = cosineAngleInRadians * (secondsTickMarkInnerNoonY - centerY) + centerY;
|
||||||
|
|
||||||
|
if (isHighResolution) {
|
||||||
|
// draw minute tick mark
|
||||||
|
display->drawLine(startX, startY, endX, endY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw hour hand
|
||||||
|
display->drawLine(centerX, centerY, hourX, hourY);
|
||||||
|
|
||||||
|
// draw minute hand
|
||||||
|
display->drawLine(centerX, centerY, minuteX, minuteY);
|
||||||
|
#ifndef USE_EINK
|
||||||
|
// draw second hand
|
||||||
|
display->drawLine(centerX, centerY, secondX, secondY);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ClockRenderer
|
||||||
|
|
||||||
|
} // namespace graphics
|
||||||
|
#endif
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "graphics/Screen.h"
|
|
||||||
#include <OLEDDisplay.h>
|
#include <OLEDDisplay.h>
|
||||||
#include <OLEDDisplayUi.h>
|
#include <OLEDDisplayUi.h>
|
||||||
|
|
||||||
@@ -10,14 +9,11 @@ namespace graphics
|
|||||||
/// Forward declarations
|
/// Forward declarations
|
||||||
class Screen;
|
class Screen;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clock drawing functions
|
|
||||||
*
|
|
||||||
* Contains all functions related to drawing analog and digital clocks,
|
|
||||||
* segmented displays, and time-related UI elements.
|
|
||||||
*/
|
|
||||||
namespace ClockRenderer
|
namespace ClockRenderer
|
||||||
{
|
{
|
||||||
|
// Whether we are showing the digital watch face or the analog one
|
||||||
|
extern bool digitalWatchFace;
|
||||||
|
|
||||||
// Clock frame functions
|
// Clock frame functions
|
||||||
void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
void drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
void drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
@@ -29,12 +25,9 @@ void drawHorizontalSegment(OLEDDisplay *display, int x, int y, int width, int he
|
|||||||
void drawVerticalSegment(OLEDDisplay *display, int x, int y, int width, int height);
|
void drawVerticalSegment(OLEDDisplay *display, int x, int y, int width, int height);
|
||||||
|
|
||||||
// UI elements for clock displays
|
// UI elements for clock displays
|
||||||
void drawWatchFaceToggleButton(OLEDDisplay *display, int16_t x, int16_t y, bool digitalMode = true, float scale = 1);
|
// void drawWatchFaceToggleButton(OLEDDisplay *display, int16_t x, int16_t y, bool digitalMode = true, float scale = 1);
|
||||||
void drawBluetoothConnectedIcon(OLEDDisplay *display, int16_t x, int16_t y);
|
void drawBluetoothConnectedIcon(OLEDDisplay *display, int16_t x, int16_t y);
|
||||||
|
|
||||||
// Utility functions
|
|
||||||
bool deltaToTimestamp(uint32_t secondsAgo, uint8_t *hours, uint8_t *minutes, int32_t *daysAgo);
|
|
||||||
|
|
||||||
} // namespace ClockRenderer
|
} // namespace ClockRenderer
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "gps/GeoCoord.h"
|
#include "gps/GeoCoord.h"
|
||||||
#include "graphics/ScreenFonts.h"
|
#include "graphics/ScreenFonts.h"
|
||||||
|
#include "graphics/SharedUIDisplay.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace graphics
|
namespace graphics
|
||||||
@@ -39,28 +40,37 @@ struct Point {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t compassY, float myHeading)
|
void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t compassY, float myHeading, int16_t radius)
|
||||||
{
|
{
|
||||||
// Show the compass heading (not implemented in original)
|
// Show the compass heading (not implemented in original)
|
||||||
// This could draw a "N" indicator or north arrow
|
// This could draw a "N" indicator or north arrow
|
||||||
// For now, we'll draw a simple north indicator
|
// For now, we'll draw a simple north indicator
|
||||||
const float radius = 8.0f;
|
// const float radius = 17.0f;
|
||||||
|
if (isHighResolution) {
|
||||||
|
radius += 4;
|
||||||
|
}
|
||||||
Point north(0, -radius);
|
Point north(0, -radius);
|
||||||
north.rotate(-myHeading);
|
if (!config.display.compass_north_top)
|
||||||
|
north.rotate(-myHeading);
|
||||||
north.translate(compassX, compassY);
|
north.translate(compassX, compassY);
|
||||||
|
|
||||||
// Draw a small "N" or north indicator
|
|
||||||
display->drawCircle(north.x, north.y, 2);
|
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
if (isHighResolution) {
|
||||||
|
display->fillRect(north.x - 8, north.y - 1, display->getStringWidth("N") + 3, FONT_HEIGHT_SMALL - 6);
|
||||||
|
} else {
|
||||||
|
display->fillRect(north.x - 4, north.y - 1, display->getStringWidth("N") + 2, FONT_HEIGHT_SMALL - 6);
|
||||||
|
}
|
||||||
|
display->setColor(WHITE);
|
||||||
display->drawString(north.x, north.y - 3, "N");
|
display->drawString(north.x, north.y - 3, "N");
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t compassY, uint16_t compassDiam, float headingRadian)
|
void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t compassY, uint16_t compassDiam, float headingRadian)
|
||||||
{
|
{
|
||||||
Point tip(0.0f, 0.5f), tail(0.0f, -0.35f); // pointing up initially
|
Point tip(0.0f, -0.5f), tail(0.0f, 0.35f); // pointing up initially
|
||||||
float arrowOffsetX = 0.14f, arrowOffsetY = 1.0f;
|
float arrowOffsetX = 0.14f, arrowOffsetY = 0.9f;
|
||||||
Point leftArrow(tip.x - arrowOffsetX, tip.y - arrowOffsetY), rightArrow(tip.x + arrowOffsetX, tip.y - arrowOffsetY);
|
Point leftArrow(tip.x - arrowOffsetX, tip.y + arrowOffsetY), rightArrow(tip.x + arrowOffsetX, tip.y + arrowOffsetY);
|
||||||
|
|
||||||
Point *arrowPoints[] = {&tip, &tail, &leftArrow, &rightArrow};
|
Point *arrowPoints[] = {&tip, &tail, &leftArrow, &rightArrow};
|
||||||
|
|
||||||
@@ -83,18 +93,22 @@ void drawArrowToNode(OLEDDisplay *display, int16_t x, int16_t y, int16_t size, f
|
|||||||
float radians = bearing * DEG_TO_RAD;
|
float radians = bearing * DEG_TO_RAD;
|
||||||
|
|
||||||
Point tip(0, -size / 2);
|
Point tip(0, -size / 2);
|
||||||
Point left(-size / 4, size / 4);
|
Point left(-size / 6, size / 4);
|
||||||
Point right(size / 4, size / 4);
|
Point right(size / 6, size / 4);
|
||||||
|
Point tail(0, size / 4.5);
|
||||||
|
|
||||||
tip.rotate(radians);
|
tip.rotate(radians);
|
||||||
left.rotate(radians);
|
left.rotate(radians);
|
||||||
right.rotate(radians);
|
right.rotate(radians);
|
||||||
|
tail.rotate(radians);
|
||||||
|
|
||||||
tip.translate(x, y);
|
tip.translate(x, y);
|
||||||
left.translate(x, y);
|
left.translate(x, y);
|
||||||
right.translate(x, y);
|
right.translate(x, y);
|
||||||
|
tail.translate(x, y);
|
||||||
|
|
||||||
display->drawTriangle(tip.x, tip.y, left.x, left.y, right.x, right.y);
|
display->fillTriangle(tip.x, tip.y, left.x, left.y, tail.x, tail.y);
|
||||||
|
display->fillTriangle(tip.x, tip.y, right.x, right.y, tail.x, tail.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float estimatedHeading(double lat, double lon)
|
float estimatedHeading(double lat, double lon)
|
||||||
@@ -119,14 +133,5 @@ uint16_t getCompassDiam(uint32_t displayWidth, uint32_t displayHeight)
|
|||||||
return maxDiam;
|
return maxDiam;
|
||||||
}
|
}
|
||||||
|
|
||||||
float calculateBearing(double lat1, double lon1, double lat2, double lon2)
|
|
||||||
{
|
|
||||||
double dLon = (lon2 - lon1) * DEG_TO_RAD;
|
|
||||||
double y = sin(dLon) * cos(lat2 * DEG_TO_RAD);
|
|
||||||
double x = cos(lat1 * DEG_TO_RAD) * sin(lat2 * DEG_TO_RAD) - sin(lat1 * DEG_TO_RAD) * cos(lat2 * DEG_TO_RAD) * cos(dLon);
|
|
||||||
double bearing = atan2(y, x) * RAD_TO_DEG;
|
|
||||||
return fmod(bearing + 360.0, 360.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace CompassRenderer
|
} // namespace CompassRenderer
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Screen;
|
|||||||
namespace CompassRenderer
|
namespace CompassRenderer
|
||||||
{
|
{
|
||||||
// Compass drawing functions
|
// Compass drawing functions
|
||||||
void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t compassY, float myHeading);
|
void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t compassY, float myHeading, int16_t radius);
|
||||||
void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t compassY, uint16_t compassDiam, float headingRadian);
|
void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t compassY, uint16_t compassDiam, float headingRadian);
|
||||||
void drawArrowToNode(OLEDDisplay *display, int16_t x, int16_t y, int16_t size, float bearing);
|
void drawArrowToNode(OLEDDisplay *display, int16_t x, int16_t y, int16_t size, float bearing);
|
||||||
|
|
||||||
@@ -28,9 +28,6 @@ void drawArrowToNode(OLEDDisplay *display, int16_t x, int16_t y, int16_t size, f
|
|||||||
float estimatedHeading(double lat, double lon);
|
float estimatedHeading(double lat, double lon);
|
||||||
uint16_t getCompassDiam(uint32_t displayWidth, uint32_t displayHeight);
|
uint16_t getCompassDiam(uint32_t displayWidth, uint32_t displayHeight);
|
||||||
|
|
||||||
// Utility functions for bearing calculations
|
|
||||||
float calculateBearing(double lat1, double lon1, double lat2, double lon2);
|
|
||||||
|
|
||||||
} // namespace CompassRenderer
|
} // namespace CompassRenderer
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#include "DebugRenderer.h"
|
#include "configuration.h"
|
||||||
|
#if HAS_SCREEN
|
||||||
#include "../Screen.h"
|
#include "../Screen.h"
|
||||||
|
#include "DebugRenderer.h"
|
||||||
#include "FSCommon.h"
|
#include "FSCommon.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "Throttle.h"
|
#include "Throttle.h"
|
||||||
#include "UIRenderer.h"
|
#include "UIRenderer.h"
|
||||||
#include "airtime.h"
|
#include "airtime.h"
|
||||||
#include "configuration.h"
|
|
||||||
#include "gps/RTC.h"
|
#include "gps/RTC.h"
|
||||||
#include "graphics/ScreenFonts.h"
|
#include "graphics/ScreenFonts.h"
|
||||||
#include "graphics/SharedUIDisplay.h"
|
#include "graphics/SharedUIDisplay.h"
|
||||||
@@ -32,18 +33,12 @@
|
|||||||
|
|
||||||
using namespace meshtastic;
|
using namespace meshtastic;
|
||||||
|
|
||||||
// Battery icon array
|
|
||||||
static uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C};
|
|
||||||
|
|
||||||
// External variables
|
// External variables
|
||||||
extern graphics::Screen *screen;
|
extern graphics::Screen *screen;
|
||||||
extern PowerStatus *powerStatus;
|
extern PowerStatus *powerStatus;
|
||||||
extern NodeStatus *nodeStatus;
|
extern NodeStatus *nodeStatus;
|
||||||
extern GPSStatus *gpsStatus;
|
extern GPSStatus *gpsStatus;
|
||||||
extern Channels channels;
|
extern Channels channels;
|
||||||
extern "C" {
|
|
||||||
extern char ourId[5];
|
|
||||||
}
|
|
||||||
extern AirTime *airTime;
|
extern AirTime *airTime;
|
||||||
|
|
||||||
// External functions from Screen.cpp
|
// External functions from Screen.cpp
|
||||||
@@ -72,21 +67,6 @@ void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16
|
|||||||
|
|
||||||
char channelStr[20];
|
char channelStr[20];
|
||||||
snprintf(channelStr, sizeof(channelStr), "#%s", channels.getName(channels.getPrimaryIndex()));
|
snprintf(channelStr, sizeof(channelStr), "#%s", channels.getName(channels.getPrimaryIndex()));
|
||||||
|
|
||||||
// Display power status
|
|
||||||
if (powerStatus->getHasBattery()) {
|
|
||||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT) {
|
|
||||||
UIRenderer::drawBattery(display, x, y + 2, imgBattery, powerStatus);
|
|
||||||
} else {
|
|
||||||
UIRenderer::drawBattery(display, x + 1, y + 3, imgBattery, powerStatus);
|
|
||||||
}
|
|
||||||
} else if (powerStatus->knowsUSB()) {
|
|
||||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT) {
|
|
||||||
display->drawFastImage(x, y + 2, 16, 8, powerStatus->getHasUSB() ? imgUSB : imgPower);
|
|
||||||
} else {
|
|
||||||
display->drawFastImage(x + 1, y + 3, 16, 8, powerStatus->getHasUSB() ? imgUSB : imgPower);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Display nodes status
|
// Display nodes status
|
||||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT) {
|
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT) {
|
||||||
UIRenderer::drawNodes(display, x + (SCREEN_WIDTH * 0.25), y + 2, nodeStatus);
|
UIRenderer::drawNodes(display, x + (SCREEN_WIDTH * 0.25), y + 2, nodeStatus);
|
||||||
@@ -116,25 +96,25 @@ void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16
|
|||||||
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
||||||
defined(ST7789_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(HX8357_CS) || ARCH_PORTDUINO) && \
|
defined(ST7789_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(HX8357_CS) || ARCH_PORTDUINO) && \
|
||||||
!defined(DISPLAY_FORCE_SMALL_FONTS)
|
!defined(DISPLAY_FORCE_SMALL_FONTS)
|
||||||
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8,
|
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(screen->ourId), y + 3 + FONT_HEIGHT_SMALL, 12,
|
||||||
imgQuestionL1);
|
8, imgQuestionL1);
|
||||||
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8,
|
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(screen->ourId), y + 11 + FONT_HEIGHT_SMALL, 12,
|
||||||
imgQuestionL2);
|
8, imgQuestionL2);
|
||||||
#else
|
#else
|
||||||
display->drawFastImage(x + SCREEN_WIDTH - 10 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 8, 8,
|
display->drawFastImage(x + SCREEN_WIDTH - 10 - display->getStringWidth(screen->ourId), y + 2 + FONT_HEIGHT_SMALL, 8,
|
||||||
imgQuestion);
|
8, imgQuestion);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
||||||
defined(ST7789_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(HX8357_CS)) && \
|
defined(ST7789_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(HX8357_CS)) && \
|
||||||
!defined(DISPLAY_FORCE_SMALL_FONTS)
|
!defined(DISPLAY_FORCE_SMALL_FONTS)
|
||||||
display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 16, 8,
|
display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(screen->ourId), y + 3 + FONT_HEIGHT_SMALL, 16,
|
||||||
imgSFL1);
|
8, imgSFL1);
|
||||||
display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 16, 8,
|
display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(screen->ourId), y + 11 + FONT_HEIGHT_SMALL, 16,
|
||||||
imgSFL2);
|
8, imgSFL2);
|
||||||
#else
|
#else
|
||||||
display->drawFastImage(x + SCREEN_WIDTH - 13 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 11, 8,
|
display->drawFastImage(x + SCREEN_WIDTH - 13 - display->getStringWidth(screen->ourId), y + 2 + FONT_HEIGHT_SMALL, 11,
|
||||||
imgSF);
|
8, imgSF);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -143,16 +123,17 @@ void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16
|
|||||||
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
||||||
defined(ST7789_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(HX8357_CS) || ARCH_PORTDUINO) && \
|
defined(ST7789_CS) || defined(USE_ST7789) || defined(ILI9488_CS) || defined(HX8357_CS) || ARCH_PORTDUINO) && \
|
||||||
!defined(DISPLAY_FORCE_SMALL_FONTS)
|
!defined(DISPLAY_FORCE_SMALL_FONTS)
|
||||||
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8,
|
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(screen->ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8,
|
||||||
imgInfoL1);
|
imgInfoL1);
|
||||||
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8,
|
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(screen->ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8,
|
||||||
imgInfoL2);
|
imgInfoL2);
|
||||||
#else
|
#else
|
||||||
display->drawFastImage(x + SCREEN_WIDTH - 10 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 8, 8, imgInfo);
|
display->drawFastImage(x + SCREEN_WIDTH - 10 - display->getStringWidth(screen->ourId), y + 2 + FONT_HEIGHT_SMALL, 8, 8,
|
||||||
|
imgInfo);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(ourId), y + FONT_HEIGHT_SMALL, ourId);
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(screen->ourId), y + FONT_HEIGHT_SMALL, screen->ourId);
|
||||||
|
|
||||||
// Draw any log messages
|
// Draw any log messages
|
||||||
display->drawLogBuffer(x, y + (FONT_HEIGHT_SMALL * 2));
|
display->drawLogBuffer(x, y + (FONT_HEIGHT_SMALL * 2));
|
||||||
@@ -165,40 +146,35 @@ void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ****************************
|
||||||
|
// * WiFi Screen *
|
||||||
|
// ****************************
|
||||||
void drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
void drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
|
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
|
||||||
|
display->clear();
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
display->setFont(FONT_SMALL);
|
||||||
|
int line = 1;
|
||||||
|
|
||||||
|
// === Set Title
|
||||||
|
const char *titleStr = "WiFi";
|
||||||
|
|
||||||
|
// === Header ===
|
||||||
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
|
|
||||||
const char *wifiName = config.network.wifi_ssid;
|
const char *wifiName = config.network.wifi_ssid;
|
||||||
|
|
||||||
display->setFont(FONT_SMALL);
|
|
||||||
|
|
||||||
// The coordinates define the left starting point of the text
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
|
||||||
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
|
||||||
display->setColor(BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
display->drawString(x, y, "WiFi: Not Connected");
|
display->drawString(x, getTextPositions(display)[line++], "WiFi: Not Connected");
|
||||||
if (config.display.heading_bold)
|
|
||||||
display->drawString(x + 1, y, "WiFi: Not Connected");
|
|
||||||
} else {
|
} else {
|
||||||
display->drawString(x, y, "WiFi: Connected");
|
display->drawString(x, getTextPositions(display)[line++], "WiFi: Connected");
|
||||||
if (config.display.heading_bold)
|
|
||||||
display->drawString(x + 1, y, "WiFi: Connected");
|
|
||||||
|
|
||||||
char rssiStr[32];
|
char rssiStr[32];
|
||||||
snprintf(rssiStr, sizeof(rssiStr), "RSSI %d", WiFi.RSSI());
|
snprintf(rssiStr, sizeof(rssiStr), "RSSI: %d", WiFi.RSSI());
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(rssiStr), y, rssiStr);
|
display->drawString(x, getTextPositions(display)[line++], rssiStr);
|
||||||
if (config.display.heading_bold) {
|
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(rssiStr) - 1, y, rssiStr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
display->setColor(WHITE);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- WL_CONNECTED: assigned when connected to a WiFi network;
|
- WL_CONNECTED: assigned when connected to a WiFi network;
|
||||||
- WL_NO_SSID_AVAIL: assigned when no SSID are available;
|
- WL_NO_SSID_AVAIL: assigned when no SSID are available;
|
||||||
@@ -214,36 +190,36 @@ void drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, i
|
|||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
char ipStr[64];
|
char ipStr[64];
|
||||||
snprintf(ipStr, sizeof(ipStr), "IP: %s", WiFi.localIP().toString().c_str());
|
snprintf(ipStr, sizeof(ipStr), "IP: %s", WiFi.localIP().toString().c_str());
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, ipStr);
|
display->drawString(x, getTextPositions(display)[line++], ipStr);
|
||||||
} else if (WiFi.status() == WL_NO_SSID_AVAIL) {
|
} else if (WiFi.status() == WL_NO_SSID_AVAIL) {
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "SSID Not Found");
|
display->drawString(x, getTextPositions(display)[line++], "SSID Not Found");
|
||||||
} else if (WiFi.status() == WL_CONNECTION_LOST) {
|
} else if (WiFi.status() == WL_CONNECTION_LOST) {
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Connection Lost");
|
display->drawString(x, getTextPositions(display)[line++], "Connection Lost");
|
||||||
} else if (WiFi.status() == WL_IDLE_STATUS) {
|
} else if (WiFi.status() == WL_IDLE_STATUS) {
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Idle ... Reconnecting");
|
display->drawString(x, getTextPositions(display)[line++], "Idle ... Reconnecting");
|
||||||
} else if (WiFi.status() == WL_CONNECT_FAILED) {
|
} else if (WiFi.status() == WL_CONNECT_FAILED) {
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Connection Failed");
|
display->drawString(x, getTextPositions(display)[line++], "Connection Failed");
|
||||||
}
|
}
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
else {
|
else {
|
||||||
// Codes:
|
// Codes:
|
||||||
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wi-fi-reason-code
|
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wi-fi-reason-code
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1,
|
display->drawString(x, getTextPositions(display)[line++],
|
||||||
WiFi.disconnectReasonName(static_cast<wifi_err_reason_t>(getWifiDisconnectReason())));
|
WiFi.disconnectReasonName(static_cast<wifi_err_reason_t>(getWifiDisconnectReason())));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
else {
|
else {
|
||||||
char statusStr[32];
|
char statusStr[32];
|
||||||
snprintf(statusStr, sizeof(statusStr), "Unknown status: %d", WiFi.status());
|
snprintf(statusStr, sizeof(statusStr), "Unknown status: %d", WiFi.status());
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, statusStr);
|
display->drawString(x, getTextPositions(display)[line++], statusStr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char ssidStr[64];
|
char ssidStr[64];
|
||||||
snprintf(ssidStr, sizeof(ssidStr), "SSID: %s", wifiName);
|
snprintf(ssidStr, sizeof(ssidStr), "SSID: %s", wifiName);
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, ssidStr);
|
display->drawString(x, getTextPositions(display)[line++], ssidStr);
|
||||||
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 3, "http://meshtastic.local");
|
display->drawString(x, getTextPositions(display)[line++], "URL: http://meshtastic.local");
|
||||||
|
|
||||||
/* Display a heartbeat pixel that blinks every time the frame is redrawn */
|
/* Display a heartbeat pixel that blinks every time the frame is redrawn */
|
||||||
#ifdef SHOW_REDRAWS
|
#ifdef SHOW_REDRAWS
|
||||||
@@ -399,48 +375,36 @@ void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
display->clear();
|
display->clear();
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
|
int line = 1;
|
||||||
|
|
||||||
|
// === Set Title
|
||||||
|
const char *titleStr = (isHighResolution) ? "LoRa Info" : "LoRa";
|
||||||
|
|
||||||
// === Header ===
|
// === Header ===
|
||||||
graphics::drawCommonHeader(display, x, y);
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
|
|
||||||
// === Draw title (aligned with header baseline) ===
|
|
||||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const char *titleStr = (SCREEN_WIDTH > 128) ? "LoRa Info" : "LoRa";
|
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
|
||||||
display->setColor(BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->drawString(centerX, textY, titleStr);
|
|
||||||
if (config.display.heading_bold) {
|
|
||||||
display->drawString(centerX + 1, textY, titleStr);
|
|
||||||
}
|
|
||||||
display->setColor(WHITE);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
|
|
||||||
// === First Row: Region / BLE Name ===
|
// === First Row: Region / BLE Name ===
|
||||||
graphics::UIRenderer::drawNodes(display, x, compactFirstLine + 3, nodeStatus, 0, true, "");
|
graphics::UIRenderer::drawNodes(display, x, getTextPositions(display)[line] + 2, nodeStatus, 0, true, "");
|
||||||
|
|
||||||
uint8_t dmac[6];
|
uint8_t dmac[6];
|
||||||
char shortnameble[35];
|
char shortnameble[35];
|
||||||
getMacAddr(dmac);
|
getMacAddr(dmac);
|
||||||
snprintf(ourId, sizeof(ourId), "%02x%02x", dmac[4], dmac[5]);
|
snprintf(screen->ourId, sizeof(screen->ourId), "%02x%02x", dmac[4], dmac[5]);
|
||||||
snprintf(shortnameble, sizeof(shortnameble), "BLE: %s", ourId);
|
snprintf(shortnameble, sizeof(shortnameble), "BLE: %s", screen->ourId);
|
||||||
int textWidth = display->getStringWidth(shortnameble);
|
int textWidth = display->getStringWidth(shortnameble);
|
||||||
int nameX = (SCREEN_WIDTH - textWidth);
|
int nameX = (SCREEN_WIDTH - textWidth);
|
||||||
display->drawString(nameX, compactFirstLine, shortnameble);
|
display->drawString(nameX, getTextPositions(display)[line++], shortnameble);
|
||||||
|
|
||||||
// === Second Row: Radio Preset ===
|
// === Second Row: Radio Preset ===
|
||||||
auto mode = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false);
|
auto mode = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false);
|
||||||
char regionradiopreset[25];
|
char regionradiopreset[25];
|
||||||
const char *region = myRegion ? myRegion->name : NULL;
|
const char *region = myRegion ? myRegion->name : NULL;
|
||||||
snprintf(regionradiopreset, sizeof(regionradiopreset), "%s/%s", region, mode);
|
if (region != nullptr) {
|
||||||
|
snprintf(regionradiopreset, sizeof(regionradiopreset), "%s/%s", region, mode);
|
||||||
|
}
|
||||||
textWidth = display->getStringWidth(regionradiopreset);
|
textWidth = display->getStringWidth(regionradiopreset);
|
||||||
nameX = (SCREEN_WIDTH - textWidth) / 2;
|
nameX = (SCREEN_WIDTH - textWidth) / 2;
|
||||||
display->drawString(nameX, compactSecondLine, regionradiopreset);
|
display->drawString(nameX, getTextPositions(display)[line++], regionradiopreset);
|
||||||
|
|
||||||
// === Third Row: Frequency / ChanNum ===
|
// === Third Row: Frequency / ChanNum ===
|
||||||
char frequencyslot[35];
|
char frequencyslot[35];
|
||||||
@@ -448,9 +412,9 @@ void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
float freq = RadioLibInterface::instance->getFreq();
|
float freq = RadioLibInterface::instance->getFreq();
|
||||||
snprintf(freqStr, sizeof(freqStr), "%.3f", freq);
|
snprintf(freqStr, sizeof(freqStr), "%.3f", freq);
|
||||||
if (config.lora.channel_num == 0) {
|
if (config.lora.channel_num == 0) {
|
||||||
snprintf(frequencyslot, sizeof(frequencyslot), "Freq: %s", freqStr);
|
snprintf(frequencyslot, sizeof(frequencyslot), "Freq: %smhz", freqStr);
|
||||||
} else {
|
} else {
|
||||||
snprintf(frequencyslot, sizeof(frequencyslot), "Freq/Chan: %s (%d)", freqStr, config.lora.channel_num);
|
snprintf(frequencyslot, sizeof(frequencyslot), "Freq/Ch: %smhz (%d)", freqStr, config.lora.channel_num);
|
||||||
}
|
}
|
||||||
size_t len = strlen(frequencyslot);
|
size_t len = strlen(frequencyslot);
|
||||||
if (len >= 4 && strcmp(frequencyslot + len - 4, " (0)") == 0) {
|
if (len >= 4 && strcmp(frequencyslot + len - 4, " (0)") == 0) {
|
||||||
@@ -458,26 +422,26 @@ void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
}
|
}
|
||||||
textWidth = display->getStringWidth(frequencyslot);
|
textWidth = display->getStringWidth(frequencyslot);
|
||||||
nameX = (SCREEN_WIDTH - textWidth) / 2;
|
nameX = (SCREEN_WIDTH - textWidth) / 2;
|
||||||
display->drawString(nameX, compactThirdLine, frequencyslot);
|
display->drawString(nameX, getTextPositions(display)[line++], frequencyslot);
|
||||||
|
|
||||||
// === Fourth Row: Channel Utilization ===
|
// === Fourth Row: Channel Utilization ===
|
||||||
const char *chUtil = "ChUtil:";
|
const char *chUtil = "ChUtil:";
|
||||||
char chUtilPercentage[10];
|
char chUtilPercentage[10];
|
||||||
snprintf(chUtilPercentage, sizeof(chUtilPercentage), "%2.0f%%", airTime->channelUtilizationPercent());
|
snprintf(chUtilPercentage, sizeof(chUtilPercentage), "%2.0f%%", airTime->channelUtilizationPercent());
|
||||||
|
|
||||||
int chUtil_x = (SCREEN_WIDTH > 128) ? display->getStringWidth(chUtil) + 10 : display->getStringWidth(chUtil) + 5;
|
int chUtil_x = (isHighResolution) ? display->getStringWidth(chUtil) + 10 : display->getStringWidth(chUtil) + 5;
|
||||||
int chUtil_y = compactFourthLine + 3;
|
int chUtil_y = getTextPositions(display)[line] + 3;
|
||||||
|
|
||||||
int chutil_bar_width = (SCREEN_WIDTH > 128) ? 100 : 50;
|
int chutil_bar_width = (isHighResolution) ? 100 : 50;
|
||||||
int chutil_bar_height = (SCREEN_WIDTH > 128) ? 12 : 7;
|
int chutil_bar_height = (isHighResolution) ? 12 : 7;
|
||||||
int extraoffset = (SCREEN_WIDTH > 128) ? 6 : 3;
|
int extraoffset = (isHighResolution) ? 6 : 3;
|
||||||
int chutil_percent = airTime->channelUtilizationPercent();
|
int chutil_percent = airTime->channelUtilizationPercent();
|
||||||
|
|
||||||
int centerofscreen = SCREEN_WIDTH / 2;
|
int centerofscreen = SCREEN_WIDTH / 2;
|
||||||
int total_line_content_width = (chUtil_x + chutil_bar_width + display->getStringWidth(chUtilPercentage) + extraoffset) / 2;
|
int total_line_content_width = (chUtil_x + chutil_bar_width + display->getStringWidth(chUtilPercentage) + extraoffset) / 2;
|
||||||
int starting_position = centerofscreen - total_line_content_width;
|
int starting_position = centerofscreen - total_line_content_width;
|
||||||
|
|
||||||
display->drawString(starting_position, compactFourthLine, chUtil);
|
display->drawString(starting_position, getTextPositions(display)[line++], chUtil);
|
||||||
|
|
||||||
// Force 56% or higher to show a full 100% bar, text would still show related percent.
|
// Force 56% or higher to show a full 100% bar, text would still show related percent.
|
||||||
if (chutil_percent >= 61) {
|
if (chutil_percent >= 61) {
|
||||||
@@ -514,7 +478,8 @@ void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
display->fillRect(starting_position + chUtil_x, chUtil_y, fillRight, chutil_bar_height);
|
display->fillRect(starting_position + chUtil_x, chUtil_y, fillRight, chutil_bar_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
display->drawString(starting_position + chUtil_x + chutil_bar_width + extraoffset, compactFourthLine, chUtilPercentage);
|
display->drawString(starting_position + chUtil_x + chutil_bar_width + extraoffset, getTextPositions(display)[4],
|
||||||
|
chUtilPercentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ****************************
|
// ****************************
|
||||||
@@ -526,43 +491,19 @@ void drawMemoryUsage(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
|
// === Set Title
|
||||||
|
const char *titleStr = "System";
|
||||||
|
|
||||||
// === Header ===
|
// === Header ===
|
||||||
graphics::drawCommonHeader(display, x, y);
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
|
|
||||||
// === Draw title ===
|
|
||||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const char *titleStr = (SCREEN_WIDTH > 128) ? "Memory" : "Mem";
|
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
|
||||||
display->setColor(BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->drawString(centerX, textY, titleStr);
|
|
||||||
if (config.display.heading_bold) {
|
|
||||||
display->drawString(centerX + 1, textY, titleStr);
|
|
||||||
}
|
|
||||||
display->setColor(WHITE);
|
|
||||||
|
|
||||||
// === Layout ===
|
// === Layout ===
|
||||||
int contentY = y + FONT_HEIGHT_SMALL;
|
int line = 1;
|
||||||
const int rowYOffset = FONT_HEIGHT_SMALL - 3;
|
|
||||||
const int barHeight = 6;
|
const int barHeight = 6;
|
||||||
const int labelX = x;
|
const int labelX = x;
|
||||||
const int barsOffset = (SCREEN_WIDTH > 128) ? 24 : 0;
|
const int barsOffset = (isHighResolution) ? 24 : 0;
|
||||||
const int barX = x + 40 + barsOffset;
|
const int barX = x + 40 + barsOffset;
|
||||||
|
|
||||||
int rowY = contentY;
|
|
||||||
|
|
||||||
// === Heap delta tracking (disabled) ===
|
|
||||||
/*
|
|
||||||
static uint32_t previousHeapFree = 0;
|
|
||||||
static int32_t totalHeapDelta = 0;
|
|
||||||
static int deltaChangeCount = 0;
|
|
||||||
*/
|
|
||||||
|
|
||||||
auto drawUsageRow = [&](const char *label, uint32_t used, uint32_t total, bool isHeap = false) {
|
auto drawUsageRow = [&](const char *label, uint32_t used, uint32_t total, bool isHeap = false) {
|
||||||
if (total == 0)
|
if (total == 0)
|
||||||
return;
|
return;
|
||||||
@@ -570,8 +511,8 @@ void drawMemoryUsage(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
int percent = (used * 100) / total;
|
int percent = (used * 100) / total;
|
||||||
|
|
||||||
char combinedStr[24];
|
char combinedStr[24];
|
||||||
if (SCREEN_WIDTH > 128) {
|
if (isHighResolution) {
|
||||||
snprintf(combinedStr, sizeof(combinedStr), "%s%3d%% %lu/%luKB", (percent > 80) ? "! " : "", percent, used / 1024,
|
snprintf(combinedStr, sizeof(combinedStr), "%s%3d%% %u/%uKB", (percent > 80) ? "! " : "", percent, used / 1024,
|
||||||
total / 1024);
|
total / 1024);
|
||||||
} else {
|
} else {
|
||||||
snprintf(combinedStr, sizeof(combinedStr), "%s%3d%%", (percent > 80) ? "! " : "", percent);
|
snprintf(combinedStr, sizeof(combinedStr), "%s%3d%%", (percent > 80) ? "! " : "", percent);
|
||||||
@@ -586,10 +527,10 @@ void drawMemoryUsage(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
|
|
||||||
// Label
|
// Label
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->drawString(labelX, rowY, label);
|
display->drawString(labelX, getTextPositions(display)[line], label);
|
||||||
|
|
||||||
// Bar
|
// Bar
|
||||||
int barY = rowY + (FONT_HEIGHT_SMALL - barHeight) / 2;
|
int barY = getTextPositions(display)[line] + (FONT_HEIGHT_SMALL - barHeight) / 2;
|
||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
display->drawRect(barX, barY, adjustedBarWidth, barHeight);
|
display->drawRect(barX, barY, adjustedBarWidth, barHeight);
|
||||||
|
|
||||||
@@ -598,45 +539,7 @@ void drawMemoryUsage(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
|
|
||||||
// Value string
|
// Value string
|
||||||
display->setTextAlignment(TEXT_ALIGN_RIGHT);
|
display->setTextAlignment(TEXT_ALIGN_RIGHT);
|
||||||
display->drawString(SCREEN_WIDTH - 2, rowY, combinedStr);
|
display->drawString(SCREEN_WIDTH - 2, getTextPositions(display)[line], combinedStr);
|
||||||
|
|
||||||
rowY += rowYOffset;
|
|
||||||
|
|
||||||
// === Heap delta display (disabled) ===
|
|
||||||
/*
|
|
||||||
if (isHeap && previousHeapFree > 0) {
|
|
||||||
int32_t delta = (int32_t)(memGet.getFreeHeap() - previousHeapFree);
|
|
||||||
if (delta != 0) {
|
|
||||||
totalHeapDelta += delta;
|
|
||||||
deltaChangeCount++;
|
|
||||||
|
|
||||||
char deltaStr[16];
|
|
||||||
snprintf(deltaStr, sizeof(deltaStr), "%ld", delta);
|
|
||||||
|
|
||||||
int deltaX = centerX - display->getStringWidth(deltaStr) / 2 - 8;
|
|
||||||
int deltaY = rowY + 1;
|
|
||||||
|
|
||||||
// Triangle
|
|
||||||
if (delta > 0) {
|
|
||||||
display->drawLine(deltaX, deltaY + 6, deltaX + 3, deltaY);
|
|
||||||
display->drawLine(deltaX + 3, deltaY, deltaX + 6, deltaY + 6);
|
|
||||||
display->drawLine(deltaX, deltaY + 6, deltaX + 6, deltaY + 6);
|
|
||||||
} else {
|
|
||||||
display->drawLine(deltaX, deltaY, deltaX + 3, deltaY + 6);
|
|
||||||
display->drawLine(deltaX + 3, deltaY + 6, deltaX + 6, deltaY);
|
|
||||||
display->drawLine(deltaX, deltaY, deltaX + 6, deltaY);
|
|
||||||
}
|
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->drawString(centerX + 6, deltaY, deltaStr);
|
|
||||||
rowY += rowYOffset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isHeap) {
|
|
||||||
previousHeapFree = memGet.getFreeHeap();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// === Memory values ===
|
// === Memory values ===
|
||||||
@@ -665,13 +568,52 @@ void drawMemoryUsage(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
*/
|
*/
|
||||||
// === Draw memory rows
|
// === Draw memory rows
|
||||||
drawUsageRow("Heap:", heapUsed, heapTotal, true);
|
drawUsageRow("Heap:", heapUsed, heapTotal, true);
|
||||||
drawUsageRow("PSRAM:", psramUsed, psramTotal);
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
if (flashTotal > 0)
|
if (psramUsed > 0) {
|
||||||
|
line += 1;
|
||||||
|
drawUsageRow("PSRAM:", psramUsed, psramTotal);
|
||||||
|
}
|
||||||
|
if (flashTotal > 0) {
|
||||||
|
line += 1;
|
||||||
drawUsageRow("Flash:", flashUsed, flashTotal);
|
drawUsageRow("Flash:", flashUsed, flashTotal);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (hasSD && sdTotal > 0)
|
if (hasSD && sdTotal > 0) {
|
||||||
|
line += 1;
|
||||||
drawUsageRow("SD:", sdUsed, sdTotal);
|
drawUsageRow("SD:", sdUsed, sdTotal);
|
||||||
|
}
|
||||||
|
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
// System Uptime
|
||||||
|
if (line < 2) {
|
||||||
|
line += 1;
|
||||||
|
}
|
||||||
|
line += 1;
|
||||||
|
char appversionstr[35];
|
||||||
|
snprintf(appversionstr, sizeof(appversionstr), "Ver.: %s", optstr(APP_VERSION));
|
||||||
|
int textWidth = display->getStringWidth(appversionstr);
|
||||||
|
int nameX = (SCREEN_WIDTH - textWidth) / 2;
|
||||||
|
display->drawString(nameX, getTextPositions(display)[line], appversionstr);
|
||||||
|
|
||||||
|
if (SCREEN_HEIGHT > 64 || (SCREEN_HEIGHT <= 64 && line < 4)) { // Only show uptime if the screen can show it
|
||||||
|
line += 1;
|
||||||
|
char uptimeStr[32] = "";
|
||||||
|
uint32_t uptime = millis() / 1000;
|
||||||
|
uint32_t days = uptime / 86400;
|
||||||
|
uint32_t hours = (uptime % 86400) / 3600;
|
||||||
|
uint32_t mins = (uptime % 3600) / 60;
|
||||||
|
// Show as "Up: 2d 3h", "Up: 5h 14m", or "Up: 37m"
|
||||||
|
if (days)
|
||||||
|
snprintf(uptimeStr, sizeof(uptimeStr), " Up: %ud %uh", days, hours);
|
||||||
|
else if (hours)
|
||||||
|
snprintf(uptimeStr, sizeof(uptimeStr), " Up: %uh %um", hours, mins);
|
||||||
|
else
|
||||||
|
snprintf(uptimeStr, sizeof(uptimeStr), " Uptime: %um", mins);
|
||||||
|
textWidth = display->getStringWidth(uptimeStr);
|
||||||
|
nameX = (SCREEN_WIDTH - textWidth) / 2;
|
||||||
|
display->drawString(nameX, getTextPositions(display)[line], uptimeStr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // namespace DebugRenderer
|
} // namespace DebugRenderer
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
#endif
|
||||||
479
src/graphics/draw/MenuHandler.cpp
Normal file
479
src/graphics/draw/MenuHandler.cpp
Normal file
@@ -0,0 +1,479 @@
|
|||||||
|
#include "configuration.h"
|
||||||
|
#if HAS_SCREEN
|
||||||
|
#include "ClockRenderer.h"
|
||||||
|
#include "GPS.h"
|
||||||
|
#include "MenuHandler.h"
|
||||||
|
#include "MeshRadio.h"
|
||||||
|
#include "MeshService.h"
|
||||||
|
#include "NodeDB.h"
|
||||||
|
#include "buzz.h"
|
||||||
|
#include "graphics/Screen.h"
|
||||||
|
#include "graphics/draw/UIRenderer.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "modules/AdminModule.h"
|
||||||
|
#include "modules/CannedMessageModule.h"
|
||||||
|
|
||||||
|
namespace graphics
|
||||||
|
{
|
||||||
|
menuHandler::screenMenus menuHandler::menuQueue = menu_none;
|
||||||
|
|
||||||
|
void menuHandler::LoraRegionPicker(uint32_t duration)
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"Back",
|
||||||
|
"US",
|
||||||
|
"EU_433",
|
||||||
|
"EU_868",
|
||||||
|
"CN",
|
||||||
|
"JP",
|
||||||
|
"ANZ",
|
||||||
|
"KR",
|
||||||
|
"TW",
|
||||||
|
"RU",
|
||||||
|
"IN",
|
||||||
|
"NZ_865",
|
||||||
|
"TH",
|
||||||
|
"LORA_24",
|
||||||
|
"UA_433",
|
||||||
|
"UA_868",
|
||||||
|
"MY_433",
|
||||||
|
"MY_"
|
||||||
|
"919",
|
||||||
|
"SG_"
|
||||||
|
"923",
|
||||||
|
"PH_433",
|
||||||
|
"PH_868",
|
||||||
|
"PH_915",
|
||||||
|
"ANZ_433"};
|
||||||
|
screen->showOverlayBanner(
|
||||||
|
"Set the LoRa region", duration, optionsArray, 23,
|
||||||
|
[](int selected) -> void {
|
||||||
|
if (selected != 0 && config.lora.region != _meshtastic_Config_LoRaConfig_RegionCode(selected)) {
|
||||||
|
config.lora.region = _meshtastic_Config_LoRaConfig_RegionCode(selected);
|
||||||
|
// This is needed as we wait til picking the LoRa region to generate keys for the first time.
|
||||||
|
if (!owner.is_licensed) {
|
||||||
|
bool keygenSuccess = false;
|
||||||
|
if (config.security.private_key.size == 32) {
|
||||||
|
// public key is derived from private, so this will always have the same result.
|
||||||
|
if (crypto->regeneratePublicKey(config.security.public_key.bytes, config.security.private_key.bytes)) {
|
||||||
|
keygenSuccess = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG_INFO("Generate new PKI keys");
|
||||||
|
crypto->generateKeyPair(config.security.public_key.bytes, config.security.private_key.bytes);
|
||||||
|
keygenSuccess = true;
|
||||||
|
}
|
||||||
|
if (keygenSuccess) {
|
||||||
|
config.security.public_key.size = 32;
|
||||||
|
config.security.private_key.size = 32;
|
||||||
|
owner.public_key.size = 32;
|
||||||
|
memcpy(owner.public_key.bytes, config.security.public_key.bytes, 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
config.lora.tx_enabled = true;
|
||||||
|
initRegion();
|
||||||
|
if (myRegion->dutyCycle < 100) {
|
||||||
|
config.lora.ignore_mqtt = true; // Ignore MQTT by default if region has a duty cycle limit
|
||||||
|
}
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::TwelveHourPicker()
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"Back", "12-hour", "24-hour"};
|
||||||
|
screen->showOverlayBanner("Time Format", 30000, optionsArray, 3, [](int selected) -> void {
|
||||||
|
if (selected == 0) {
|
||||||
|
menuHandler::menuQueue = menuHandler::clock_menu;
|
||||||
|
} else if (selected == 1) {
|
||||||
|
config.display.use_12h_clock = true;
|
||||||
|
} else {
|
||||||
|
config.display.use_12h_clock = false;
|
||||||
|
}
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::ClockFacePicker()
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"Back", "Digital", "Analog"};
|
||||||
|
screen->showOverlayBanner("Which Face?", 30000, optionsArray, 3, [](int selected) -> void {
|
||||||
|
if (selected == 0) {
|
||||||
|
menuHandler::menuQueue = menuHandler::clock_menu;
|
||||||
|
} else if (selected == 1) {
|
||||||
|
graphics::ClockRenderer::digitalWatchFace = true;
|
||||||
|
screen->setFrames(Screen::FOCUS_CLOCK);
|
||||||
|
} else {
|
||||||
|
graphics::ClockRenderer::digitalWatchFace = false;
|
||||||
|
screen->setFrames(Screen::FOCUS_CLOCK);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::TZPicker()
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"Back",
|
||||||
|
"US/Hawaii",
|
||||||
|
"US/Alaska",
|
||||||
|
"US/Pacific",
|
||||||
|
"US/Arizona",
|
||||||
|
"US/Mountain",
|
||||||
|
"US/Central",
|
||||||
|
"US/Eastern",
|
||||||
|
"UTC",
|
||||||
|
"EU/Western",
|
||||||
|
"EU/"
|
||||||
|
"Central",
|
||||||
|
"EU/Eastern",
|
||||||
|
"Asia/Kolkata",
|
||||||
|
"Asia/Hong_Kong",
|
||||||
|
"AU/AWST",
|
||||||
|
"AU/ACST",
|
||||||
|
"AU/AEST",
|
||||||
|
"Pacific/NZ"};
|
||||||
|
screen->showOverlayBanner("Pick Timezone", 30000, optionsArray, 17, [](int selected) -> void {
|
||||||
|
if (selected == 0) {
|
||||||
|
menuHandler::menuQueue = menuHandler::clock_menu;
|
||||||
|
} else if (selected == 1) { // Hawaii
|
||||||
|
strncpy(config.device.tzdef, "HST10", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 2) { // Alaska
|
||||||
|
strncpy(config.device.tzdef, "AKST9AKDT,M3.2.0,M11.1.0", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 3) { // Pacific
|
||||||
|
strncpy(config.device.tzdef, "PST8PDT,M3.2.0,M11.1.0", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 4) { // Arizona
|
||||||
|
strncpy(config.device.tzdef, "MST7", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 5) { // Mountain
|
||||||
|
strncpy(config.device.tzdef, "MST7MDT,M3.2.0,M11.1.0", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 6) { // Central
|
||||||
|
strncpy(config.device.tzdef, "CST6CDT,M3.2.0,M11.1.0", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 7) { // Eastern
|
||||||
|
strncpy(config.device.tzdef, "EST5EDT,M3.2.0,M11.1.0", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 8) { // UTC
|
||||||
|
strncpy(config.device.tzdef, "UTC", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 9) { // EU/Western
|
||||||
|
strncpy(config.device.tzdef, "GMT0BST,M3.5.0/1,M10.5.0", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 10) { // EU/Central
|
||||||
|
strncpy(config.device.tzdef, "CET-1CEST,M3.5.0,M10.5.0/3", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 11) { // EU/Eastern
|
||||||
|
strncpy(config.device.tzdef, "EET-2EEST,M3.5.0/3,M10.5.0/4", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 12) { // Asia/Kolkata
|
||||||
|
strncpy(config.device.tzdef, "IST-5:30", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 13) { // China
|
||||||
|
strncpy(config.device.tzdef, "HKT-8", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 14) { // AU/AWST
|
||||||
|
strncpy(config.device.tzdef, "AWST-8", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 15) { // AU/ACST
|
||||||
|
strncpy(config.device.tzdef, "ACST-9:30ACDT,M10.1.0,M4.1.0/3", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 16) { // AU/AEST
|
||||||
|
strncpy(config.device.tzdef, "AEST-10AEDT,M10.1.0,M4.1.0/3", sizeof(config.device.tzdef));
|
||||||
|
} else if (selected == 17) { // NZ
|
||||||
|
strncpy(config.device.tzdef, "NZST-12NZDT,M9.5.0,M4.1.0/3", sizeof(config.device.tzdef));
|
||||||
|
}
|
||||||
|
if (selected != 0) {
|
||||||
|
setenv("TZ", config.device.tzdef, 1);
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::clockMenu()
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"Back", "Clock Face", "Time Format", "Timezone"};
|
||||||
|
screen->showOverlayBanner("Clock Action", 30000, optionsArray, 4, [](int selected) -> void {
|
||||||
|
if (selected == 1) {
|
||||||
|
menuHandler::menuQueue = menuHandler::clock_face_picker;
|
||||||
|
screen->setInterval(0);
|
||||||
|
runASAP = true;
|
||||||
|
} else if (selected == 2) {
|
||||||
|
menuHandler::menuQueue = menuHandler::twelve_hour_picker;
|
||||||
|
screen->setInterval(0);
|
||||||
|
runASAP = true;
|
||||||
|
} else if (selected == 3) {
|
||||||
|
menuHandler::menuQueue = menuHandler::TZ_picker;
|
||||||
|
screen->setInterval(0);
|
||||||
|
runASAP = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::messageResponseMenu()
|
||||||
|
{
|
||||||
|
|
||||||
|
static const char **optionsArrayPtr;
|
||||||
|
int options;
|
||||||
|
if (kb_found) {
|
||||||
|
static const char *optionsArray[] = {"Back", "Dismiss", "Reply via Preset", "Reply via Freetext"};
|
||||||
|
optionsArrayPtr = optionsArray;
|
||||||
|
options = 4;
|
||||||
|
} else {
|
||||||
|
static const char *optionsArray[] = {"Back", "Dismiss", "Reply via Preset"};
|
||||||
|
optionsArrayPtr = optionsArray;
|
||||||
|
options = 3;
|
||||||
|
}
|
||||||
|
#ifdef HAS_I2S
|
||||||
|
static const char *optionsArray[] = {"Back", "Dismiss", "Reply via Preset", "Reply via Freetext", "Read Aloud"};
|
||||||
|
optionsArrayPtr = optionsArray;
|
||||||
|
options = 5;
|
||||||
|
#endif
|
||||||
|
screen->showOverlayBanner("Message Action", 30000, optionsArrayPtr, options, [](int selected) -> void {
|
||||||
|
if (selected == 1) {
|
||||||
|
screen->dismissCurrentFrame();
|
||||||
|
} else if (selected == 2) {
|
||||||
|
if (devicestate.rx_text_message.to == NODENUM_BROADCAST) {
|
||||||
|
cannedMessageModule->LaunchWithDestination(NODENUM_BROADCAST, devicestate.rx_text_message.channel);
|
||||||
|
} else {
|
||||||
|
cannedMessageModule->LaunchWithDestination(devicestate.rx_text_message.from);
|
||||||
|
}
|
||||||
|
} else if (selected == 3) {
|
||||||
|
if (devicestate.rx_text_message.to == NODENUM_BROADCAST) {
|
||||||
|
cannedMessageModule->LaunchFreetextWithDestination(NODENUM_BROADCAST, devicestate.rx_text_message.channel);
|
||||||
|
} else {
|
||||||
|
cannedMessageModule->LaunchFreetextWithDestination(devicestate.rx_text_message.from);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef HAS_I2S
|
||||||
|
else if (selected == 4) {
|
||||||
|
const meshtastic_MeshPacket &mp = devicestate.rx_text_message;
|
||||||
|
const char *msg = reinterpret_cast<const char *>(mp.decoded.payload.bytes);
|
||||||
|
|
||||||
|
audioThread->readAloud(msg);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::homeBaseMenu()
|
||||||
|
{
|
||||||
|
int options;
|
||||||
|
static const char **optionsArrayPtr;
|
||||||
|
|
||||||
|
if (kb_found) {
|
||||||
|
#ifdef PIN_EINK_EN
|
||||||
|
static const char *optionsArray[] = {"Back", "Toggle Backlight", "Send Position", "New Preset Msg", "New Freetext Msg"};
|
||||||
|
#else
|
||||||
|
static const char *optionsArray[] = {"Back", "Sleep Screen", "Send Position", "New Preset Msg", "New Freetext Msg"};
|
||||||
|
#endif
|
||||||
|
optionsArrayPtr = optionsArray;
|
||||||
|
options = 5;
|
||||||
|
} else {
|
||||||
|
#ifdef PIN_EINK_EN
|
||||||
|
static const char *optionsArray[] = {"Back", "Toggle Backlight", "Send Position", "New Preset Msg"};
|
||||||
|
#else
|
||||||
|
static const char *optionsArray[] = {"Back", "Sleep Screen", "Send Position", "New Preset Msg"};
|
||||||
|
#endif
|
||||||
|
optionsArrayPtr = optionsArray;
|
||||||
|
options = 4;
|
||||||
|
}
|
||||||
|
screen->showOverlayBanner("Home Action", 30000, optionsArrayPtr, options, [](int selected) -> void {
|
||||||
|
if (selected == 1) {
|
||||||
|
#ifdef PIN_EINK_EN
|
||||||
|
if (digitalRead(PIN_EINK_EN) == HIGH) {
|
||||||
|
digitalWrite(PIN_EINK_EN, LOW);
|
||||||
|
} else {
|
||||||
|
digitalWrite(PIN_EINK_EN, HIGH);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
screen->setOn(false);
|
||||||
|
#endif
|
||||||
|
} else if (selected == 2) {
|
||||||
|
InputEvent event = {.inputEvent = (input_broker_event)175, .kbchar = 175, .touchX = 0, .touchY = 0};
|
||||||
|
inputBroker->injectInputEvent(&event);
|
||||||
|
} else if (selected == 3) {
|
||||||
|
cannedMessageModule->LaunchWithDestination(NODENUM_BROADCAST);
|
||||||
|
} else if (selected == 4) {
|
||||||
|
cannedMessageModule->LaunchFreetextWithDestination(NODENUM_BROADCAST);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::favoriteBaseMenu()
|
||||||
|
{
|
||||||
|
int options;
|
||||||
|
static const char **optionsArrayPtr;
|
||||||
|
|
||||||
|
if (kb_found) {
|
||||||
|
static const char *optionsArray[] = {"Back", "New Preset Msg", "New Freetext Msg"};
|
||||||
|
optionsArrayPtr = optionsArray;
|
||||||
|
options = 3;
|
||||||
|
} else {
|
||||||
|
static const char *optionsArray[] = {"Back", "New Preset Msg"};
|
||||||
|
optionsArrayPtr = optionsArray;
|
||||||
|
options = 2;
|
||||||
|
}
|
||||||
|
screen->showOverlayBanner("Favorites Action", 30000, optionsArrayPtr, options, [](int selected) -> void {
|
||||||
|
if (selected == 1) {
|
||||||
|
cannedMessageModule->LaunchWithDestination(graphics::UIRenderer::currentFavoriteNodeNum);
|
||||||
|
} else if (selected == 2) {
|
||||||
|
cannedMessageModule->LaunchFreetextWithDestination(graphics::UIRenderer::currentFavoriteNodeNum);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::positionBaseMenu()
|
||||||
|
{
|
||||||
|
int options;
|
||||||
|
static const char **optionsArrayPtr;
|
||||||
|
static const char *optionsArray[] = {"Back", "GPS Toggle", "Compass"};
|
||||||
|
static const char *optionsArrayCalibrate[] = {"Back", "GPS Toggle", "Compass", "Compass Calibrate"};
|
||||||
|
|
||||||
|
if (accelerometerThread) {
|
||||||
|
optionsArrayPtr = optionsArrayCalibrate;
|
||||||
|
options = 4;
|
||||||
|
} else {
|
||||||
|
optionsArrayPtr = optionsArray;
|
||||||
|
options = 3;
|
||||||
|
}
|
||||||
|
screen->showOverlayBanner("Position Action", 30000, optionsArrayPtr, options, [](int selected) -> void {
|
||||||
|
if (selected == 1) {
|
||||||
|
menuQueue = gps_toggle_menu;
|
||||||
|
} else if (selected == 2) {
|
||||||
|
menuQueue = compass_point_north_menu;
|
||||||
|
} else if (selected == 3) {
|
||||||
|
accelerometerThread->calibrate(30);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::nodeListMenu()
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"Back", "Reset NodeDB"};
|
||||||
|
screen->showOverlayBanner("Node Action", 30000, optionsArray, 2, [](int selected) -> void {
|
||||||
|
if (selected == 1) {
|
||||||
|
menuQueue = reset_node_db_menu;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::resetNodeDBMenu()
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"Back", "Confirm"};
|
||||||
|
screen->showOverlayBanner("Confirm Reset NodeDB", 30000, optionsArray, 2, [](int selected) -> void {
|
||||||
|
if (selected == 1) {
|
||||||
|
disableBluetooth();
|
||||||
|
LOG_INFO("Initiate node-db reset");
|
||||||
|
nodeDB->resetNodes();
|
||||||
|
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::compassNorthMenu()
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"Back", "Dynamic", "Fixed Ring", "Freeze Heading"};
|
||||||
|
screen->showOverlayBanner("North Directions?", 30000, optionsArray, 4, [](int selected) -> void {
|
||||||
|
if (selected == 1) {
|
||||||
|
if (config.display.compass_north_top != false) {
|
||||||
|
config.display.compass_north_top = false;
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
}
|
||||||
|
screen->ignoreCompass = false;
|
||||||
|
screen->setFrames(graphics::Screen::FOCUS_PRESERVE);
|
||||||
|
} else if (selected == 2) {
|
||||||
|
if (config.display.compass_north_top != true) {
|
||||||
|
config.display.compass_north_top = true;
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
}
|
||||||
|
screen->ignoreCompass = false;
|
||||||
|
screen->setFrames(graphics::Screen::FOCUS_PRESERVE);
|
||||||
|
} else if (selected == 3) {
|
||||||
|
if (config.display.compass_north_top != true) {
|
||||||
|
config.display.compass_north_top = true;
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
}
|
||||||
|
screen->ignoreCompass = true;
|
||||||
|
screen->setFrames(graphics::Screen::FOCUS_PRESERVE);
|
||||||
|
} else if (selected == 0) {
|
||||||
|
menuQueue = position_base_menu;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::GPSToggleMenu()
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"Back", "Enabled", "Disabled"};
|
||||||
|
screen->showOverlayBanner(
|
||||||
|
"Toggle GPS", 30000, optionsArray, 3,
|
||||||
|
[](int selected) -> void {
|
||||||
|
if (selected == 1) {
|
||||||
|
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
||||||
|
playGPSEnableBeep();
|
||||||
|
gps->enable();
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
} else if (selected == 2) {
|
||||||
|
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_DISABLED;
|
||||||
|
playGPSDisableBeep();
|
||||||
|
gps->disable();
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
} else {
|
||||||
|
menuQueue = position_base_menu;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED ? 1 : 2); // set inital selection
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::BuzzerModeMenu()
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"All Enabled", "Disabled", "Notifications", "System Only"};
|
||||||
|
screen->showOverlayBanner(
|
||||||
|
"Beep Action", 30000, optionsArray, 4,
|
||||||
|
[](int selected) -> void {
|
||||||
|
config.device.buzzer_mode = (meshtastic_Config_DeviceConfig_BuzzerMode)selected;
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
},
|
||||||
|
config.device.buzzer_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::switchToMUIMenu()
|
||||||
|
{
|
||||||
|
static const char *optionsArray[] = {"Yes", "No"};
|
||||||
|
screen->showOverlayBanner("Switch to MUI?", 30000, optionsArray, 2, [](int selected) -> void {
|
||||||
|
if (selected == 0) {
|
||||||
|
config.display.displaymode = meshtastic_Config_DisplayConfig_DisplayMode_COLOR;
|
||||||
|
config.bluetooth.enabled = false;
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void menuHandler::handleMenuSwitch()
|
||||||
|
{
|
||||||
|
switch (menuQueue) {
|
||||||
|
case menu_none:
|
||||||
|
break;
|
||||||
|
case lora_picker:
|
||||||
|
LoraRegionPicker();
|
||||||
|
break;
|
||||||
|
case TZ_picker:
|
||||||
|
TZPicker();
|
||||||
|
break;
|
||||||
|
case twelve_hour_picker:
|
||||||
|
TwelveHourPicker();
|
||||||
|
break;
|
||||||
|
case clock_face_picker:
|
||||||
|
ClockFacePicker();
|
||||||
|
break;
|
||||||
|
case clock_menu:
|
||||||
|
clockMenu();
|
||||||
|
break;
|
||||||
|
case position_base_menu:
|
||||||
|
positionBaseMenu();
|
||||||
|
break;
|
||||||
|
case gps_toggle_menu:
|
||||||
|
GPSToggleMenu();
|
||||||
|
break;
|
||||||
|
case compass_point_north_menu:
|
||||||
|
compassNorthMenu();
|
||||||
|
break;
|
||||||
|
case reset_node_db_menu:
|
||||||
|
resetNodeDBMenu();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
menuQueue = menu_none;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace graphics
|
||||||
|
|
||||||
|
#endif
|
||||||
40
src/graphics/draw/MenuHandler.h
Normal file
40
src/graphics/draw/MenuHandler.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include "configuration.h"
|
||||||
|
namespace graphics
|
||||||
|
{
|
||||||
|
|
||||||
|
class menuHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum screenMenus {
|
||||||
|
menu_none,
|
||||||
|
lora_picker,
|
||||||
|
TZ_picker,
|
||||||
|
twelve_hour_picker,
|
||||||
|
clock_face_picker,
|
||||||
|
clock_menu,
|
||||||
|
position_base_menu,
|
||||||
|
gps_toggle_menu,
|
||||||
|
compass_point_north_menu,
|
||||||
|
reset_node_db_menu
|
||||||
|
};
|
||||||
|
static screenMenus menuQueue;
|
||||||
|
|
||||||
|
static void LoraRegionPicker(uint32_t duration = 30000);
|
||||||
|
static void handleMenuSwitch();
|
||||||
|
static void clockMenu();
|
||||||
|
static void TZPicker();
|
||||||
|
static void TwelveHourPicker();
|
||||||
|
static void ClockFacePicker();
|
||||||
|
static void messageResponseMenu();
|
||||||
|
static void homeBaseMenu();
|
||||||
|
static void favoriteBaseMenu();
|
||||||
|
static void positionBaseMenu();
|
||||||
|
static void compassNorthMenu();
|
||||||
|
static void GPSToggleMenu();
|
||||||
|
static void BuzzerModeMenu();
|
||||||
|
static void switchToMUIMenu();
|
||||||
|
static void nodeListMenu();
|
||||||
|
static void resetNodeDBMenu();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace graphics
|
||||||
@@ -21,6 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "configuration.h"
|
||||||
|
#if HAS_SCREEN
|
||||||
#include "MessageRenderer.h"
|
#include "MessageRenderer.h"
|
||||||
|
|
||||||
// Core includes
|
// Core includes
|
||||||
@@ -35,6 +37,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
// Additional includes for UI rendering
|
// Additional includes for UI rendering
|
||||||
#include "UIRenderer.h"
|
#include "UIRenderer.h"
|
||||||
|
#include "graphics/TimeFormatters.h"
|
||||||
|
|
||||||
// Additional includes for dependencies
|
// Additional includes for dependencies
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -53,76 +56,10 @@ namespace graphics
|
|||||||
namespace MessageRenderer
|
namespace MessageRenderer
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration from Screen.cpp - this function needs to be accessible
|
// Simple cache based on text hash
|
||||||
// For now, we'll implement a local version that matches the Screen.cpp functionality
|
static size_t cachedKey = 0;
|
||||||
bool deltaToTimestamp(uint32_t secondsAgo, uint8_t *hours, uint8_t *minutes, int32_t *daysAgo)
|
static std::vector<std::string> cachedLines;
|
||||||
{
|
static std::vector<int> cachedHeights;
|
||||||
// Cache the result - avoid frequent recalculation
|
|
||||||
static uint8_t hoursCached = 0, minutesCached = 0;
|
|
||||||
static uint32_t daysAgoCached = 0;
|
|
||||||
static uint32_t secondsAgoCached = 0;
|
|
||||||
static bool validCached = false;
|
|
||||||
|
|
||||||
// Abort: if timezone not set
|
|
||||||
if (strlen(config.device.tzdef) == 0) {
|
|
||||||
validCached = false;
|
|
||||||
return validCached;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Abort: if invalid pointers passed
|
|
||||||
if (hours == nullptr || minutes == nullptr || daysAgo == nullptr) {
|
|
||||||
validCached = false;
|
|
||||||
return validCached;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Abort: if time seems invalid.. (> 6 months ago, probably seen before RTC set)
|
|
||||||
if (secondsAgo > SEC_PER_DAY * 30UL * 6) {
|
|
||||||
validCached = false;
|
|
||||||
return validCached;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If repeated request, don't bother recalculating
|
|
||||||
if (secondsAgo - secondsAgoCached < 60 && secondsAgoCached != 0) {
|
|
||||||
if (validCached) {
|
|
||||||
*hours = hoursCached;
|
|
||||||
*minutes = minutesCached;
|
|
||||||
*daysAgo = daysAgoCached;
|
|
||||||
}
|
|
||||||
return validCached;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get local time
|
|
||||||
uint32_t secondsRTC = getValidTime(RTCQuality::RTCQualityDevice, true); // Get local time
|
|
||||||
|
|
||||||
// Abort: if RTC not set
|
|
||||||
if (!secondsRTC) {
|
|
||||||
validCached = false;
|
|
||||||
return validCached;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get absolute time when last seen
|
|
||||||
uint32_t secondsSeenAt = secondsRTC - secondsAgo;
|
|
||||||
|
|
||||||
// Calculate daysAgo
|
|
||||||
*daysAgo = (secondsRTC / SEC_PER_DAY) - (secondsSeenAt / SEC_PER_DAY); // How many "midnights" have passed
|
|
||||||
|
|
||||||
// Get seconds since midnight
|
|
||||||
uint32_t hms = (secondsRTC - secondsAgo) % SEC_PER_DAY;
|
|
||||||
hms = (hms + SEC_PER_DAY) % SEC_PER_DAY;
|
|
||||||
|
|
||||||
// Tear apart hms into hours and minutes
|
|
||||||
*hours = hms / SEC_PER_HOUR;
|
|
||||||
*minutes = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
|
|
||||||
|
|
||||||
// Cache the result
|
|
||||||
daysAgoCached = *daysAgo;
|
|
||||||
hoursCached = *hours;
|
|
||||||
minutesCached = *minutes;
|
|
||||||
secondsAgoCached = secondsAgo;
|
|
||||||
|
|
||||||
validCached = true;
|
|
||||||
return validCached;
|
|
||||||
}
|
|
||||||
|
|
||||||
void drawStringWithEmotes(OLEDDisplay *display, int x, int y, const std::string &line, const Emote *emotes, int emoteCount)
|
void drawStringWithEmotes(OLEDDisplay *display, int x, int y, const std::string &line, const Emote *emotes, int emoteCount)
|
||||||
{
|
{
|
||||||
@@ -232,6 +169,7 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
const meshtastic_MeshPacket &mp = devicestate.rx_text_message;
|
const meshtastic_MeshPacket &mp = devicestate.rx_text_message;
|
||||||
const char *msg = reinterpret_cast<const char *>(mp.decoded.payload.bytes);
|
const char *msg = reinterpret_cast<const char *>(mp.decoded.payload.bytes);
|
||||||
|
|
||||||
|
display->clear();
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
|
|
||||||
@@ -239,11 +177,25 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
const int scrollBottom = SCREEN_HEIGHT - navHeight;
|
const int scrollBottom = SCREEN_HEIGHT - navHeight;
|
||||||
const int usableHeight = scrollBottom;
|
const int usableHeight = scrollBottom;
|
||||||
const int textWidth = SCREEN_WIDTH;
|
const int textWidth = SCREEN_WIDTH;
|
||||||
const int cornerRadius = 2;
|
|
||||||
|
|
||||||
bool isInverted = (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED);
|
bool isInverted = (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED);
|
||||||
bool isBold = config.display.heading_bold;
|
bool isBold = config.display.heading_bold;
|
||||||
|
|
||||||
|
// === Set Title
|
||||||
|
const char *titleStr = "Messages";
|
||||||
|
|
||||||
|
// Check if we have more than an empty message to show
|
||||||
|
char messageBuf[237];
|
||||||
|
snprintf(messageBuf, sizeof(messageBuf), "%s", msg);
|
||||||
|
if (strlen(messageBuf) == 0) {
|
||||||
|
// === Header ===
|
||||||
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
|
const char *messageString = "No messages";
|
||||||
|
int center_text = (SCREEN_WIDTH / 2) - (display->getStringWidth(messageString) / 2);
|
||||||
|
display->drawString(center_text, getTextPositions(display)[2], messageString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// === Header Construction ===
|
// === Header Construction ===
|
||||||
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(getFrom(&mp));
|
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(getFrom(&mp));
|
||||||
char headerStr[80];
|
char headerStr[80];
|
||||||
@@ -278,14 +230,14 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
sender);
|
sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t now = millis();
|
||||||
#ifndef EXCLUDE_EMOJI
|
#ifndef EXCLUDE_EMOJI
|
||||||
// === Bounce animation setup ===
|
// === Bounce animation setup ===
|
||||||
static uint32_t lastBounceTime = 0;
|
static uint32_t lastBounceTime = 0;
|
||||||
static int bounceY = 0;
|
static int bounceY = 0;
|
||||||
const int bounceRange = 2; // Max pixels to bounce up/down
|
const int bounceRange = 2; // Max pixels to bounce up/down
|
||||||
const int bounceInterval = 60; // How quickly to change bounce direction (ms)
|
const int bounceInterval = 10; // How quickly to change bounce direction (ms)
|
||||||
|
|
||||||
uint32_t now = millis();
|
|
||||||
if (now - lastBounceTime >= bounceInterval) {
|
if (now - lastBounceTime >= bounceInterval) {
|
||||||
lastBounceTime = now;
|
lastBounceTime = now;
|
||||||
bounceY = (bounceY + 1) % (bounceRange * 2);
|
bounceY = (bounceY + 1) % (bounceRange * 2);
|
||||||
@@ -293,88 +245,57 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
for (int i = 0; i < numEmotes; ++i) {
|
for (int i = 0; i < numEmotes; ++i) {
|
||||||
const Emote &e = emotes[i];
|
const Emote &e = emotes[i];
|
||||||
if (strcmp(msg, e.label) == 0) {
|
if (strcmp(msg, e.label) == 0) {
|
||||||
// Draw the header
|
int headerY = getTextPositions(display)[1]; // same as scrolling header line
|
||||||
if (isInverted) {
|
display->drawString(x + 3, headerY, headerStr);
|
||||||
drawRoundedHighlight(display, x, 0, SCREEN_WIDTH, FONT_HEIGHT_SMALL - 1, cornerRadius);
|
if (isInverted && isBold)
|
||||||
display->setColor(BLACK);
|
display->drawString(x + 4, headerY, headerStr);
|
||||||
display->drawString(x + 3, 0, headerStr);
|
|
||||||
if (isBold)
|
// Draw separator (same as scroll version)
|
||||||
display->drawString(x + 4, 0, headerStr);
|
for (int separatorX = 1; separatorX <= (display->getStringWidth(headerStr) + 2); separatorX += 2) {
|
||||||
display->setColor(WHITE);
|
display->setPixel(separatorX, headerY + ((isHighResolution) ? 19 : 13));
|
||||||
} else {
|
|
||||||
display->drawString(x, 0, headerStr);
|
|
||||||
if (SCREEN_WIDTH > 128) {
|
|
||||||
display->drawLine(0, 20, SCREEN_WIDTH, 20);
|
|
||||||
} else {
|
|
||||||
display->drawLine(0, 14, SCREEN_WIDTH, 14);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Center the emote below header + apply bounce
|
// Center the emote below the header line + separator + nav
|
||||||
int remainingHeight = SCREEN_HEIGHT - FONT_HEIGHT_SMALL - navHeight;
|
int remainingHeight = SCREEN_HEIGHT - (headerY + FONT_HEIGHT_SMALL) - navHeight;
|
||||||
int emoteY = FONT_HEIGHT_SMALL + (remainingHeight - e.height) / 2 + bounceY - bounceRange;
|
int emoteY = headerY + 6 + FONT_HEIGHT_SMALL + (remainingHeight - e.height) / 2 + bounceY - bounceRange;
|
||||||
display->drawXbm((SCREEN_WIDTH - e.width) / 2, emoteY, e.width, e.height, e.bitmap);
|
display->drawXbm((SCREEN_WIDTH - e.width) / 2, emoteY, e.width, e.height, e.bitmap);
|
||||||
|
|
||||||
|
// Draw header at the end to sort out overlapping elements
|
||||||
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// === Generate the cache key ===
|
||||||
|
size_t currentKey = (size_t)mp.from;
|
||||||
|
currentKey ^= ((size_t)mp.to << 8);
|
||||||
|
currentKey ^= ((size_t)mp.rx_time << 16);
|
||||||
|
currentKey ^= ((size_t)mp.id << 24);
|
||||||
|
|
||||||
// === Word-wrap and build line list ===
|
if (cachedKey != currentKey) {
|
||||||
char messageBuf[237];
|
LOG_INFO("Message cache key is misssed cachedKey=0x%0x, currentKey=0x%x", cachedKey, currentKey);
|
||||||
snprintf(messageBuf, sizeof(messageBuf), "%s", msg);
|
|
||||||
|
|
||||||
std::vector<std::string> lines;
|
// Cache miss - regenerate lines and heights
|
||||||
lines.push_back(std::string(headerStr)); // Header line is always first
|
cachedLines = generateLines(display, headerStr, messageBuf, textWidth);
|
||||||
|
cachedHeights = calculateLineHeights(cachedLines, emotes);
|
||||||
std::string line, word;
|
cachedKey = currentKey;
|
||||||
for (int i = 0; messageBuf[i]; ++i) {
|
} else {
|
||||||
char ch = messageBuf[i];
|
// Cache hit but update the header line with current time information
|
||||||
if (ch == '\n') {
|
cachedLines[0] = std::string(headerStr);
|
||||||
if (!word.empty())
|
// The header always has a fixed height since it doesn't contain emotes
|
||||||
line += word;
|
// As per calculateLineHeights logic for lines without emotes:
|
||||||
if (!line.empty())
|
cachedHeights[0] = FONT_HEIGHT_SMALL - 2;
|
||||||
lines.push_back(line);
|
if (cachedHeights[0] < 8)
|
||||||
line.clear();
|
cachedHeights[0] = 8; // minimum safety
|
||||||
word.clear();
|
|
||||||
} else if (ch == ' ') {
|
|
||||||
line += word + ' ';
|
|
||||||
word.clear();
|
|
||||||
} else {
|
|
||||||
word += ch;
|
|
||||||
std::string test = line + word;
|
|
||||||
if (display->getStringWidth(test.c_str()) > textWidth + 4) {
|
|
||||||
if (!line.empty())
|
|
||||||
lines.push_back(line);
|
|
||||||
line = word;
|
|
||||||
word.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!word.empty())
|
|
||||||
line += word;
|
|
||||||
if (!line.empty())
|
|
||||||
lines.push_back(line);
|
|
||||||
|
|
||||||
// === Scrolling logic ===
|
// === Scrolling logic ===
|
||||||
std::vector<int> rowHeights;
|
|
||||||
|
|
||||||
for (const auto &line : lines) {
|
|
||||||
int maxHeight = FONT_HEIGHT_SMALL;
|
|
||||||
for (int i = 0; i < numEmotes; ++i) {
|
|
||||||
const Emote &e = emotes[i];
|
|
||||||
if (line.find(e.label) != std::string::npos) {
|
|
||||||
if (e.height > maxHeight)
|
|
||||||
maxHeight = e.height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rowHeights.push_back(maxHeight);
|
|
||||||
}
|
|
||||||
int totalHeight = 0;
|
int totalHeight = 0;
|
||||||
for (size_t i = 1; i < rowHeights.size(); ++i) {
|
for (size_t i = 1; i < cachedHeights.size(); ++i) {
|
||||||
totalHeight += rowHeights[i];
|
totalHeight += cachedHeights[i];
|
||||||
}
|
}
|
||||||
int usableScrollHeight = usableHeight - rowHeights[0]; // remove header height
|
int usableScrollHeight = usableHeight - cachedHeights[0]; // remove header height
|
||||||
int scrollStop = std::max(0, totalHeight - usableScrollHeight);
|
int scrollStop = std::max(0, totalHeight - usableScrollHeight + cachedHeights.back());
|
||||||
|
|
||||||
static float scrollY = 0.0f;
|
static float scrollY = 0.0f;
|
||||||
static uint32_t lastTime = 0, scrollStartDelay = 0, pauseStart = 0;
|
static uint32_t lastTime = 0, scrollStartDelay = 0, pauseStart = 0;
|
||||||
@@ -394,7 +315,7 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
if (!scrollStarted && now - scrollStartDelay > 2000)
|
if (!scrollStarted && now - scrollStartDelay > 2000)
|
||||||
scrollStarted = true;
|
scrollStarted = true;
|
||||||
|
|
||||||
if (totalHeight > usableHeight) {
|
if (totalHeight > usableScrollHeight) {
|
||||||
if (scrollStarted) {
|
if (scrollStarted) {
|
||||||
if (!waitingToReset) {
|
if (!waitingToReset) {
|
||||||
scrollY += delta * scrollSpeed;
|
scrollY += delta * scrollSpeed;
|
||||||
@@ -415,28 +336,105 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
}
|
}
|
||||||
|
|
||||||
int scrollOffset = static_cast<int>(scrollY);
|
int scrollOffset = static_cast<int>(scrollY);
|
||||||
int yOffset = -scrollOffset;
|
int yOffset = -scrollOffset + getTextPositions(display)[1];
|
||||||
if (!isInverted) {
|
for (int separatorX = 1; separatorX <= (display->getStringWidth(headerStr) + 2); separatorX += 2) {
|
||||||
if (SCREEN_WIDTH > 128) {
|
display->setPixel(separatorX, yOffset + ((isHighResolution) ? 19 : 13));
|
||||||
display->drawLine(0, yOffset + 20, SCREEN_WIDTH, yOffset + 20);
|
|
||||||
} else {
|
|
||||||
display->drawLine(0, yOffset + 14, SCREEN_WIDTH, yOffset + 14);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Render visible lines ===
|
// === Render visible lines ===
|
||||||
|
renderMessageContent(display, cachedLines, cachedHeights, x, yOffset, scrollBottom, emotes, numEmotes, isInverted, isBold);
|
||||||
|
|
||||||
|
// Draw header at the end to sort out overlapping elements
|
||||||
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> generateLines(OLEDDisplay *display, const char *headerStr, const char *messageBuf, int textWidth)
|
||||||
|
{
|
||||||
|
std::vector<std::string> lines;
|
||||||
|
lines.push_back(std::string(headerStr)); // Header line is always first
|
||||||
|
|
||||||
|
std::string line, word;
|
||||||
|
for (int i = 0; messageBuf[i]; ++i) {
|
||||||
|
char ch = messageBuf[i];
|
||||||
|
if ((unsigned char)messageBuf[i] == 0xE2 && (unsigned char)messageBuf[i + 1] == 0x80 &&
|
||||||
|
(unsigned char)messageBuf[i + 2] == 0x99) {
|
||||||
|
ch = '\''; // plain apostrophe
|
||||||
|
i += 2; // skip over the extra UTF-8 bytes
|
||||||
|
}
|
||||||
|
if (ch == '\n') {
|
||||||
|
if (!word.empty())
|
||||||
|
line += word;
|
||||||
|
if (!line.empty())
|
||||||
|
lines.push_back(line);
|
||||||
|
line.clear();
|
||||||
|
word.clear();
|
||||||
|
} else if (ch == ' ') {
|
||||||
|
line += word + ' ';
|
||||||
|
word.clear();
|
||||||
|
} else {
|
||||||
|
word += ch;
|
||||||
|
std::string test = line + word;
|
||||||
|
// Keep these lines for diagnostics
|
||||||
|
// LOG_INFO("Char: '%c' (0x%02X)", ch, (unsigned char)ch);
|
||||||
|
// LOG_INFO("Current String: %s", test.c_str());
|
||||||
|
if (display->getStringWidth(test.c_str()) > textWidth) {
|
||||||
|
if (!line.empty())
|
||||||
|
lines.push_back(line);
|
||||||
|
line = word;
|
||||||
|
word.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!word.empty())
|
||||||
|
line += word;
|
||||||
|
if (!line.empty())
|
||||||
|
lines.push_back(line);
|
||||||
|
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int> calculateLineHeights(const std::vector<std::string> &lines, const Emote *emotes)
|
||||||
|
{
|
||||||
|
std::vector<int> rowHeights;
|
||||||
|
|
||||||
|
for (const auto &_line : lines) {
|
||||||
|
int lineHeight = FONT_HEIGHT_SMALL;
|
||||||
|
bool hasEmote = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < numEmotes; ++i) {
|
||||||
|
const Emote &e = emotes[i];
|
||||||
|
if (_line.find(e.label) != std::string::npos) {
|
||||||
|
lineHeight = std::max(lineHeight, e.height);
|
||||||
|
hasEmote = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply tighter spacing if no emotes on this line
|
||||||
|
if (!hasEmote) {
|
||||||
|
lineHeight -= 2; // reduce by 2px for tighter spacing
|
||||||
|
if (lineHeight < 8)
|
||||||
|
lineHeight = 8; // minimum safety
|
||||||
|
}
|
||||||
|
|
||||||
|
rowHeights.push_back(lineHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rowHeights;
|
||||||
|
}
|
||||||
|
|
||||||
|
void renderMessageContent(OLEDDisplay *display, const std::vector<std::string> &lines, const std::vector<int> &rowHeights, int x,
|
||||||
|
int yOffset, int scrollBottom, const Emote *emotes, int numEmotes, bool isInverted, bool isBold)
|
||||||
|
{
|
||||||
for (size_t i = 0; i < lines.size(); ++i) {
|
for (size_t i = 0; i < lines.size(); ++i) {
|
||||||
int lineY = yOffset;
|
int lineY = yOffset;
|
||||||
for (size_t j = 0; j < i; ++j)
|
for (size_t j = 0; j < i; ++j)
|
||||||
lineY += rowHeights[j];
|
lineY += rowHeights[j];
|
||||||
if (lineY > -rowHeights[i] && lineY < scrollBottom) {
|
if (lineY > -rowHeights[i] && lineY < scrollBottom) {
|
||||||
if (i == 0 && isInverted) {
|
if (i == 0 && isInverted) {
|
||||||
drawRoundedHighlight(display, x, lineY, SCREEN_WIDTH, FONT_HEIGHT_SMALL - 1, cornerRadius);
|
display->drawString(x, lineY, lines[i].c_str());
|
||||||
display->setColor(BLACK);
|
|
||||||
display->drawString(x + 3, lineY, lines[i].c_str());
|
|
||||||
if (isBold)
|
if (isBold)
|
||||||
display->drawString(x + 4, lineY, lines[i].c_str());
|
display->drawString(x, lineY, lines[i].c_str());
|
||||||
display->setColor(WHITE);
|
|
||||||
} else {
|
} else {
|
||||||
drawStringWithEmotes(display, x, lineY, lines[i], emotes, numEmotes);
|
drawStringWithEmotes(display, x, lineY, lines[i], emotes, numEmotes);
|
||||||
}
|
}
|
||||||
@@ -446,3 +444,4 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
|
|
||||||
} // namespace MessageRenderer
|
} // namespace MessageRenderer
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
#endif
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
#include "OLEDDisplay.h"
|
#include "OLEDDisplay.h"
|
||||||
#include "OLEDDisplayUi.h"
|
#include "OLEDDisplayUi.h"
|
||||||
#include "graphics/emotes.h"
|
#include "graphics/emotes.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
@@ -14,5 +16,15 @@ void drawStringWithEmotes(OLEDDisplay *display, int x, int y, const std::string
|
|||||||
/// Draws the text message frame for displaying received messages
|
/// Draws the text message frame for displaying received messages
|
||||||
void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
|
|
||||||
|
// Function to generate lines with word wrapping
|
||||||
|
std::vector<std::string> generateLines(OLEDDisplay *display, const char *headerStr, const char *messageBuf, int textWidth);
|
||||||
|
|
||||||
|
// Function to calculate heights for each line
|
||||||
|
std::vector<int> calculateLineHeights(const std::vector<std::string> &lines, const Emote *emotes);
|
||||||
|
|
||||||
|
// Function to render the message content
|
||||||
|
void renderMessageContent(OLEDDisplay *display, const std::vector<std::string> &lines, const std::vector<int> &rowHeights, int x,
|
||||||
|
int yOffset, int scrollBottom, const Emote *emotes, int numEmotes, bool isInverted, bool isBold);
|
||||||
|
|
||||||
} // namespace MessageRenderer
|
} // namespace MessageRenderer
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
#include "NodeListRenderer.h"
|
#include "configuration.h"
|
||||||
|
#if HAS_SCREEN
|
||||||
#include "CompassRenderer.h"
|
#include "CompassRenderer.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
|
#include "NodeListRenderer.h"
|
||||||
#include "UIRenderer.h"
|
#include "UIRenderer.h"
|
||||||
#include "configuration.h"
|
|
||||||
#include "gps/GeoCoord.h"
|
#include "gps/GeoCoord.h"
|
||||||
#include "gps/RTC.h" // for getTime() function
|
#include "gps/RTC.h" // for getTime() function
|
||||||
#include "graphics/ScreenFonts.h"
|
#include "graphics/ScreenFonts.h"
|
||||||
#include "graphics/SharedUIDisplay.h"
|
#include "graphics/SharedUIDisplay.h"
|
||||||
#include "graphics/images.h"
|
#include "graphics/images.h"
|
||||||
|
#include "meshUtils.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
// Forward declarations for functions defined in Screen.cpp
|
// Forward declarations for functions defined in Screen.cpp
|
||||||
@@ -72,23 +74,17 @@ const char *getSafeNodeName(meshtastic_NodeInfoLite *node)
|
|||||||
return nodeName;
|
return nodeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t sinceLastSeen(meshtastic_NodeInfoLite *node)
|
|
||||||
{
|
|
||||||
uint32_t now = getTime();
|
|
||||||
uint32_t last_seen = node->last_heard;
|
|
||||||
if (last_seen == 0 || now < last_seen) {
|
|
||||||
return UINT32_MAX;
|
|
||||||
}
|
|
||||||
return now - last_seen;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *getCurrentModeTitle(int screenWidth)
|
const char *getCurrentModeTitle(int screenWidth)
|
||||||
{
|
{
|
||||||
switch (currentMode) {
|
switch (currentMode) {
|
||||||
case MODE_LAST_HEARD:
|
case MODE_LAST_HEARD:
|
||||||
return "Node List";
|
return "Last Heard";
|
||||||
case MODE_HOP_SIGNAL:
|
case MODE_HOP_SIGNAL:
|
||||||
return (screenWidth > 128) ? "Hops/Signal" : "Hops/Sig";
|
#ifdef USE_EINK
|
||||||
|
return "Hops/Sig";
|
||||||
|
#else
|
||||||
|
return (isHighResolution) ? "Hops/Signal" : "Hops/Sig";
|
||||||
|
#endif
|
||||||
case MODE_DISTANCE:
|
case MODE_DISTANCE:
|
||||||
return "Distance";
|
return "Distance";
|
||||||
default:
|
default:
|
||||||
@@ -102,54 +98,15 @@ unsigned long getModeCycleIntervalMs()
|
|||||||
return 3000;
|
return 3000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate bearing between two lat/lon points
|
|
||||||
float calculateBearing(double lat1, double lon1, double lat2, double lon2)
|
|
||||||
{
|
|
||||||
double dLon = (lon2 - lon1) * DEG_TO_RAD;
|
|
||||||
double y = sin(dLon) * cos(lat2 * DEG_TO_RAD);
|
|
||||||
double x = cos(lat1 * DEG_TO_RAD) * sin(lat2 * DEG_TO_RAD) - sin(lat1 * DEG_TO_RAD) * cos(lat2 * DEG_TO_RAD) * cos(dLon);
|
|
||||||
double bearing = atan2(y, x) * RAD_TO_DEG;
|
|
||||||
return fmod(bearing + 360.0, 360.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int calculateMaxScroll(int totalEntries, int visibleRows)
|
int calculateMaxScroll(int totalEntries, int visibleRows)
|
||||||
{
|
{
|
||||||
return std::max(0, (totalEntries - 1) / (visibleRows * 2));
|
return std::max(0, (totalEntries - 1) / (visibleRows * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void retrieveAndSortNodes(std::vector<NodeEntry> &nodeList)
|
|
||||||
{
|
|
||||||
size_t numNodes = nodeDB->getNumMeshNodes();
|
|
||||||
for (size_t i = 0; i < numNodes; i++) {
|
|
||||||
meshtastic_NodeInfoLite *node = nodeDB->getMeshNodeByIndex(i);
|
|
||||||
if (!node || node->num == nodeDB->getNodeNum())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
NodeEntry entry;
|
|
||||||
entry.node = node;
|
|
||||||
entry.sortValue = sinceLastSeen(node);
|
|
||||||
|
|
||||||
nodeList.push_back(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort nodes: favorites first, then by last heard (most recent first)
|
|
||||||
std::sort(nodeList.begin(), nodeList.end(), [](const NodeEntry &a, const NodeEntry &b) {
|
|
||||||
bool aFav = a.node->is_favorite;
|
|
||||||
bool bFav = b.node->is_favorite;
|
|
||||||
if (aFav != bFav)
|
|
||||||
return aFav > bFav;
|
|
||||||
if (a.sortValue == 0 || a.sortValue == UINT32_MAX)
|
|
||||||
return false;
|
|
||||||
if (b.sortValue == 0 || b.sortValue == UINT32_MAX)
|
|
||||||
return true;
|
|
||||||
return a.sortValue < b.sortValue;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void drawColumnSeparator(OLEDDisplay *display, int16_t x, int16_t yStart, int16_t yEnd)
|
void drawColumnSeparator(OLEDDisplay *display, int16_t x, int16_t yStart, int16_t yEnd)
|
||||||
{
|
{
|
||||||
int columnWidth = display->getWidth() / 2;
|
int columnWidth = display->getWidth() / 2;
|
||||||
int separatorX = x + columnWidth - 1;
|
int separatorX = x + columnWidth - 2;
|
||||||
for (int y = yStart; y <= yEnd; y += 2) {
|
for (int y = yStart; y <= yEnd; y += 2) {
|
||||||
display->setPixel(separatorX, y);
|
display->setPixel(separatorX, y);
|
||||||
}
|
}
|
||||||
@@ -178,7 +135,7 @@ void drawScrollbar(OLEDDisplay *display, int visibleNodeRows, int totalEntries,
|
|||||||
void drawEntryLastHeard(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth)
|
void drawEntryLastHeard(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth)
|
||||||
{
|
{
|
||||||
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
||||||
int timeOffset = (SCREEN_WIDTH > 128) ? (isLeftCol ? 7 : 10) : (isLeftCol ? 3 : 7);
|
int timeOffset = (isHighResolution) ? (isLeftCol ? 7 : 10) : (isLeftCol ? 3 : 7);
|
||||||
|
|
||||||
const char *nodeName = getSafeNodeName(node);
|
const char *nodeName = getSafeNodeName(node);
|
||||||
|
|
||||||
@@ -199,9 +156,9 @@ void drawEntryLastHeard(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int
|
|||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawString(x + ((SCREEN_WIDTH > 128) ? 6 : 3), y, nodeName);
|
display->drawString(x + ((isHighResolution) ? 6 : 3), y, nodeName);
|
||||||
if (node->is_favorite) {
|
if (node->is_favorite) {
|
||||||
if (SCREEN_WIDTH > 128) {
|
if (isHighResolution) {
|
||||||
drawScaledXBitmap16x16(x, y + 6, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint, display);
|
drawScaledXBitmap16x16(x, y + 6, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint, display);
|
||||||
} else {
|
} else {
|
||||||
display->drawXbm(x, y + 5, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint);
|
display->drawXbm(x, y + 5, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint);
|
||||||
@@ -209,6 +166,8 @@ void drawEntryLastHeard(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
int rightEdge = x + columnWidth - timeOffset;
|
int rightEdge = x + columnWidth - timeOffset;
|
||||||
|
if (timeStr[strlen(timeStr) - 1] == 'm') // Fix the fact that our fonts don't line up well all the time
|
||||||
|
rightEdge -= 1;
|
||||||
int textWidth = display->getStringWidth(timeStr);
|
int textWidth = display->getStringWidth(timeStr);
|
||||||
display->drawString(rightEdge - textWidth, y, timeStr);
|
display->drawString(rightEdge - textWidth, y, timeStr);
|
||||||
}
|
}
|
||||||
@@ -218,8 +177,8 @@ void drawEntryHopSignal(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int
|
|||||||
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
||||||
|
|
||||||
int nameMaxWidth = columnWidth - 25;
|
int nameMaxWidth = columnWidth - 25;
|
||||||
int barsOffset = (SCREEN_WIDTH > 128) ? (isLeftCol ? 16 : 20) : (isLeftCol ? 15 : 19);
|
int barsOffset = (isHighResolution) ? (isLeftCol ? 20 : 24) : (isLeftCol ? 15 : 19);
|
||||||
int hopOffset = (SCREEN_WIDTH > 128) ? (isLeftCol ? 17 : 25) : (isLeftCol ? 13 : 17);
|
int hopOffset = (isHighResolution) ? (isLeftCol ? 21 : 29) : (isLeftCol ? 13 : 17);
|
||||||
|
|
||||||
int barsXOffset = columnWidth - barsOffset;
|
int barsXOffset = columnWidth - barsOffset;
|
||||||
|
|
||||||
@@ -228,9 +187,9 @@ void drawEntryHopSignal(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int
|
|||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
|
|
||||||
display->drawStringMaxWidth(x + ((SCREEN_WIDTH > 128) ? 6 : 3), y, nameMaxWidth, nodeName);
|
display->drawStringMaxWidth(x + ((isHighResolution) ? 6 : 3), y, nameMaxWidth, nodeName);
|
||||||
if (node->is_favorite) {
|
if (node->is_favorite) {
|
||||||
if (SCREEN_WIDTH > 128) {
|
if (isHighResolution) {
|
||||||
drawScaledXBitmap16x16(x, y + 6, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint, display);
|
drawScaledXBitmap16x16(x, y + 6, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint, display);
|
||||||
} else {
|
} else {
|
||||||
display->drawXbm(x, y + 5, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint);
|
display->drawXbm(x, y + 5, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint);
|
||||||
@@ -265,7 +224,7 @@ void drawEntryHopSignal(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int
|
|||||||
void drawNodeDistance(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth)
|
void drawNodeDistance(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16_t x, int16_t y, int columnWidth)
|
||||||
{
|
{
|
||||||
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
||||||
int nameMaxWidth = columnWidth - (SCREEN_WIDTH > 128 ? (isLeftCol ? 25 : 28) : (isLeftCol ? 20 : 22));
|
int nameMaxWidth = columnWidth - (isHighResolution ? (isLeftCol ? 25 : 28) : (isLeftCol ? 20 : 22));
|
||||||
|
|
||||||
const char *nodeName = getSafeNodeName(node);
|
const char *nodeName = getSafeNodeName(node);
|
||||||
char distStr[10] = "";
|
char distStr[10] = "";
|
||||||
@@ -320,9 +279,9 @@ void drawNodeDistance(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
|
|||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawStringMaxWidth(x + ((SCREEN_WIDTH > 128) ? 6 : 3), y, nameMaxWidth, nodeName);
|
display->drawStringMaxWidth(x + ((isHighResolution) ? 6 : 3), y, nameMaxWidth, nodeName);
|
||||||
if (node->is_favorite) {
|
if (node->is_favorite) {
|
||||||
if (SCREEN_WIDTH > 128) {
|
if (isHighResolution) {
|
||||||
drawScaledXBitmap16x16(x, y + 6, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint, display);
|
drawScaledXBitmap16x16(x, y + 6, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint, display);
|
||||||
} else {
|
} else {
|
||||||
display->drawXbm(x, y + 5, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint);
|
display->drawXbm(x, y + 5, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint);
|
||||||
@@ -330,8 +289,8 @@ void drawNodeDistance(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(distStr) > 0) {
|
if (strlen(distStr) > 0) {
|
||||||
int offset = (SCREEN_WIDTH > 128) ? (isLeftCol ? 7 : 10) // Offset for Wide Screens (Left Column:Right Column)
|
int offset = (isHighResolution) ? (isLeftCol ? 7 : 10) // Offset for Wide Screens (Left Column:Right Column)
|
||||||
: (isLeftCol ? 5 : 8); // Offset for Narrow Screens (Left Column:Right Column)
|
: (isLeftCol ? 4 : 7); // Offset for Narrow Screens (Left Column:Right Column)
|
||||||
int rightEdge = x + columnWidth - offset;
|
int rightEdge = x + columnWidth - offset;
|
||||||
int textWidth = display->getStringWidth(distStr);
|
int textWidth = display->getStringWidth(distStr);
|
||||||
display->drawString(rightEdge - textWidth, y, distStr);
|
display->drawString(rightEdge - textWidth, y, distStr);
|
||||||
@@ -360,15 +319,15 @@ void drawEntryCompass(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
|
|||||||
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
||||||
|
|
||||||
// Adjust max text width depending on column and screen width
|
// Adjust max text width depending on column and screen width
|
||||||
int nameMaxWidth = columnWidth - (SCREEN_WIDTH > 128 ? (isLeftCol ? 25 : 28) : (isLeftCol ? 20 : 22));
|
int nameMaxWidth = columnWidth - (isHighResolution ? (isLeftCol ? 25 : 28) : (isLeftCol ? 20 : 22));
|
||||||
|
|
||||||
const char *nodeName = getSafeNodeName(node);
|
const char *nodeName = getSafeNodeName(node);
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawStringMaxWidth(x + ((SCREEN_WIDTH > 128) ? 6 : 3), y, nameMaxWidth, nodeName);
|
display->drawStringMaxWidth(x + ((isHighResolution) ? 6 : 3), y, nameMaxWidth, nodeName);
|
||||||
if (node->is_favorite) {
|
if (node->is_favorite) {
|
||||||
if (SCREEN_WIDTH > 128) {
|
if (isHighResolution) {
|
||||||
drawScaledXBitmap16x16(x, y + 6, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint, display);
|
drawScaledXBitmap16x16(x, y + 6, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint, display);
|
||||||
} else {
|
} else {
|
||||||
display->drawXbm(x, y + 5, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint);
|
display->drawXbm(x, y + 5, smallbulletpoint_width, smallbulletpoint_height, smallbulletpoint);
|
||||||
@@ -383,19 +342,21 @@ void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
||||||
int arrowXOffset = (SCREEN_WIDTH > 128) ? (isLeftCol ? 22 : 24) : (isLeftCol ? 12 : 18);
|
int arrowXOffset = (isHighResolution) ? (isLeftCol ? 22 : 24) : (isLeftCol ? 12 : 18);
|
||||||
|
|
||||||
int centerX = x + columnWidth - arrowXOffset;
|
int centerX = x + columnWidth - arrowXOffset;
|
||||||
int centerY = y + FONT_HEIGHT_SMALL / 2;
|
int centerY = y + FONT_HEIGHT_SMALL / 2;
|
||||||
|
|
||||||
double nodeLat = node->position.latitude_i * 1e-7;
|
double nodeLat = node->position.latitude_i * 1e-7;
|
||||||
double nodeLon = node->position.longitude_i * 1e-7;
|
double nodeLon = node->position.longitude_i * 1e-7;
|
||||||
float bearingToNode = calculateBearing(userLat, userLon, nodeLat, nodeLon);
|
float bearing = GeoCoord::bearing(userLat, userLon, nodeLat, nodeLon);
|
||||||
|
float bearingToNode = RAD_TO_DEG * bearing;
|
||||||
float relativeBearing = fmod((bearingToNode - myHeading + 360), 360);
|
float relativeBearing = fmod((bearingToNode - myHeading + 360), 360);
|
||||||
float angle = relativeBearing * DEG_TO_RAD;
|
float angle = relativeBearing * DEG_TO_RAD;
|
||||||
|
|
||||||
// Shrink size by 2px
|
// Shrink size by 2px
|
||||||
int size = FONT_HEIGHT_SMALL - 5;
|
int size = FONT_HEIGHT_SMALL - 5;
|
||||||
|
CompassRenderer::drawArrowToNode(display, centerX, centerY, size, relativeBearing);
|
||||||
|
/*
|
||||||
float halfSize = size / 2.0;
|
float halfSize = size / 2.0;
|
||||||
|
|
||||||
// Point of the arrow
|
// Point of the arrow
|
||||||
@@ -420,6 +381,7 @@ void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
|
|||||||
// Draw the chevron-style arrowhead
|
// Draw the chevron-style arrowhead
|
||||||
display->fillTriangle(tipX, tipY, leftX, leftY, notchX, notchY);
|
display->fillTriangle(tipX, tipY, leftX, leftY, notchX, notchY);
|
||||||
display->fillTriangle(tipX, tipY, notchX, notchY, rightX, rightY);
|
display->fillTriangle(tipX, tipY, notchX, notchY, rightX, rightY);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================
|
// =============================
|
||||||
@@ -437,42 +399,21 @@ void drawNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t
|
|||||||
display->clear();
|
display->clear();
|
||||||
|
|
||||||
// Draw the battery/time header
|
// Draw the battery/time header
|
||||||
graphics::drawCommonHeader(display, x, y);
|
graphics::drawCommonHeader(display, x, y, title);
|
||||||
|
|
||||||
// Draw the centered title within the header
|
|
||||||
const int highlightHeight = COMMON_HEADER_HEIGHT;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
|
|
||||||
display->setFont(FONT_SMALL);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED)
|
|
||||||
display->setColor(BLACK);
|
|
||||||
|
|
||||||
display->drawString(centerX, textY, title);
|
|
||||||
if (config.display.heading_bold)
|
|
||||||
display->drawString(centerX + 1, textY, title);
|
|
||||||
|
|
||||||
display->setColor(WHITE);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
|
|
||||||
// Space below header
|
// Space below header
|
||||||
y += COMMON_HEADER_HEIGHT;
|
y += COMMON_HEADER_HEIGHT;
|
||||||
|
|
||||||
// Fetch and display sorted node list
|
int totalEntries = nodeDB->getNumMeshNodes();
|
||||||
std::vector<NodeEntry> nodeList;
|
|
||||||
retrieveAndSortNodes(nodeList);
|
|
||||||
|
|
||||||
int totalEntries = nodeList.size();
|
|
||||||
int totalRowsAvailable = (display->getHeight() - y) / rowYOffset;
|
int totalRowsAvailable = (display->getHeight() - y) / rowYOffset;
|
||||||
#ifdef USE_EINK
|
|
||||||
totalRowsAvailable -= 1;
|
|
||||||
#endif
|
|
||||||
int visibleNodeRows = totalRowsAvailable;
|
int visibleNodeRows = totalRowsAvailable;
|
||||||
int totalColumns = 2;
|
int totalColumns = 2;
|
||||||
|
|
||||||
int startIndex = scrollIndex * visibleNodeRows * totalColumns;
|
int startIndex = scrollIndex * visibleNodeRows * totalColumns;
|
||||||
|
if (nodeDB->getMeshNodeByIndex(startIndex)->num == nodeDB->getNodeNum()) {
|
||||||
|
startIndex++; // skip own node
|
||||||
|
}
|
||||||
int endIndex = std::min(startIndex + visibleNodeRows * totalColumns, totalEntries);
|
int endIndex = std::min(startIndex + visibleNodeRows * totalColumns, totalEntries);
|
||||||
|
|
||||||
int yOffset = 0;
|
int yOffset = 0;
|
||||||
@@ -484,10 +425,10 @@ void drawNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t
|
|||||||
for (int i = startIndex; i < endIndex; ++i) {
|
for (int i = startIndex; i < endIndex; ++i) {
|
||||||
int xPos = x + (col * columnWidth);
|
int xPos = x + (col * columnWidth);
|
||||||
int yPos = y + yOffset;
|
int yPos = y + yOffset;
|
||||||
renderer(display, nodeList[i].node, xPos, yPos, columnWidth);
|
renderer(display, nodeDB->getMeshNodeByIndex(i), xPos, yPos, columnWidth);
|
||||||
|
|
||||||
if (extras) {
|
if (extras) {
|
||||||
extras(display, nodeList[i].node, xPos, yPos, columnWidth, heading, lat, lon);
|
extras(display, nodeDB->getMeshNodeByIndex(i), xPos, yPos, columnWidth, heading, lat, lon);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastNodeY = std::max(lastNodeY, yPos + FONT_HEIGHT_SMALL);
|
lastNodeY = std::max(lastNodeY, yPos + FONT_HEIGHT_SMALL);
|
||||||
@@ -551,13 +492,18 @@ void drawDynamicNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state,
|
|||||||
#ifdef USE_EINK
|
#ifdef USE_EINK
|
||||||
void drawLastHeardScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
void drawLastHeardScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
const char *title = "Node List";
|
const char *title = "Last Heard";
|
||||||
drawNodeListScreen(display, state, x, y, title, drawEntryLastHeard);
|
drawNodeListScreen(display, state, x, y, title, drawEntryLastHeard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawHopSignalScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
void drawHopSignalScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_EINK
|
||||||
|
const char *title = "Hops/Sig";
|
||||||
|
#else
|
||||||
|
|
||||||
const char *title = "Hops/Signal";
|
const char *title = "Hops/Signal";
|
||||||
|
#endif
|
||||||
drawNodeListScreen(display, state, x, y, title, drawEntryHopSignal);
|
drawNodeListScreen(display, state, x, y, title, drawEntryHopSignal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,285 +518,27 @@ void drawNodeListWithCompasses(OLEDDisplay *display, OLEDDisplayUiState *state,
|
|||||||
{
|
{
|
||||||
float heading = 0;
|
float heading = 0;
|
||||||
bool validHeading = false;
|
bool validHeading = false;
|
||||||
double lat = 0;
|
auto ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());
|
||||||
double lon = 0;
|
double lat = DegD(ourNode->position.latitude_i);
|
||||||
|
double lon = DegD(ourNode->position.longitude_i);
|
||||||
|
|
||||||
|
if (!screen->ignoreCompass) {
|
||||||
#if HAS_GPS
|
#if HAS_GPS
|
||||||
if (screen->hasHeading()) {
|
if (screen->hasHeading()) {
|
||||||
heading = screen->getHeading(); // degrees
|
heading = screen->getHeading(); // degrees
|
||||||
validHeading = true;
|
validHeading = true;
|
||||||
} else {
|
} else {
|
||||||
heading = screen->estimatedHeading(lat, lon);
|
heading = screen->estimatedHeading(lat, lon);
|
||||||
validHeading = !isnan(heading);
|
validHeading = !isnan(heading);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!validHeading)
|
if (!validHeading)
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
drawNodeListScreen(display, state, x, y, "Bearings", drawEntryCompass, drawCompassArrow, heading, lat, lon);
|
drawNodeListScreen(display, state, x, y, "Bearings", drawEntryCompass, drawCompassArrow, heading, lat, lon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
|
||||||
{
|
|
||||||
// Cache favorite nodes for the current frame only, to save computation
|
|
||||||
static std::vector<meshtastic_NodeInfoLite *> favoritedNodes;
|
|
||||||
static int prevFrame = -1;
|
|
||||||
|
|
||||||
// Only rebuild favorites list if we're on a new frame
|
|
||||||
if (state->currentFrame != prevFrame) {
|
|
||||||
prevFrame = state->currentFrame;
|
|
||||||
favoritedNodes.clear();
|
|
||||||
size_t total = nodeDB->getNumMeshNodes();
|
|
||||||
for (size_t i = 0; i < total; i++) {
|
|
||||||
meshtastic_NodeInfoLite *n = nodeDB->getMeshNodeByIndex(i);
|
|
||||||
// Skip nulls and ourself
|
|
||||||
if (!n || n->num == nodeDB->getNodeNum())
|
|
||||||
continue;
|
|
||||||
if (n->is_favorite)
|
|
||||||
favoritedNodes.push_back(n);
|
|
||||||
}
|
|
||||||
// Keep a stable, consistent display order
|
|
||||||
std::sort(favoritedNodes.begin(), favoritedNodes.end(),
|
|
||||||
[](meshtastic_NodeInfoLite *a, meshtastic_NodeInfoLite *b) { return a->num < b->num; });
|
|
||||||
}
|
|
||||||
if (favoritedNodes.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Only display if index is valid
|
|
||||||
int nodeIndex = state->currentFrame - (screen->frameCount - favoritedNodes.size());
|
|
||||||
if (nodeIndex < 0 || nodeIndex >= (int)favoritedNodes.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
meshtastic_NodeInfoLite *node = favoritedNodes[nodeIndex];
|
|
||||||
if (!node || node->num == nodeDB->getNodeNum() || !node->is_favorite)
|
|
||||||
return;
|
|
||||||
|
|
||||||
display->clear();
|
|
||||||
|
|
||||||
// Draw battery/time/mail header (common across screens)
|
|
||||||
graphics::drawCommonHeader(display, x, y);
|
|
||||||
|
|
||||||
// Draw the short node name centered at the top, with bold shadow if set
|
|
||||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
const char *shortName = (node->has_user && haveGlyphs(node->user.short_name)) ? node->user.short_name : "Node";
|
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED)
|
|
||||||
display->setColor(BLACK);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->setFont(FONT_SMALL);
|
|
||||||
display->drawString(centerX, textY, shortName);
|
|
||||||
if (config.display.heading_bold)
|
|
||||||
display->drawString(centerX + 1, textY, shortName);
|
|
||||||
|
|
||||||
display->setColor(WHITE);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
display->setFont(FONT_SMALL);
|
|
||||||
|
|
||||||
// Dynamic row stacking with predefined Y positions
|
|
||||||
const int yPositions[5] = {moreCompactFirstLine, moreCompactSecondLine, moreCompactThirdLine, moreCompactFourthLine,
|
|
||||||
moreCompactFifthLine};
|
|
||||||
int line = 0;
|
|
||||||
|
|
||||||
// 1. Long Name (always try to show first)
|
|
||||||
const char *username = (node->has_user && node->user.long_name[0]) ? node->user.long_name : nullptr;
|
|
||||||
if (username && line < 5) {
|
|
||||||
display->drawString(x, yPositions[line++], username);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Signal and Hops (combined on one line, if available)
|
|
||||||
char signalHopsStr[32] = "";
|
|
||||||
bool haveSignal = false;
|
|
||||||
int percentSignal = clamp((int)((node->snr + 10) * 5), 0, 100);
|
|
||||||
const char *signalLabel = " Sig";
|
|
||||||
|
|
||||||
// If SNR looks reasonable, show signal
|
|
||||||
if ((int)((node->snr + 10) * 5) >= 0 && node->snr > -100) {
|
|
||||||
snprintf(signalHopsStr, sizeof(signalHopsStr), "%s: %d%%", signalLabel, percentSignal);
|
|
||||||
haveSignal = true;
|
|
||||||
}
|
|
||||||
// If hops is valid (>0), show right after signal
|
|
||||||
if (node->hops_away > 0) {
|
|
||||||
size_t len = strlen(signalHopsStr);
|
|
||||||
if (haveSignal) {
|
|
||||||
snprintf(signalHopsStr + len, sizeof(signalHopsStr) - len, " [%d %s]", node->hops_away,
|
|
||||||
(node->hops_away == 1 ? "Hop" : "Hops"));
|
|
||||||
} else {
|
|
||||||
snprintf(signalHopsStr, sizeof(signalHopsStr), "[%d %s]", node->hops_away, (node->hops_away == 1 ? "Hop" : "Hops"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (signalHopsStr[0] && line < 5) {
|
|
||||||
display->drawString(x, yPositions[line++], signalHopsStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Heard (last seen, skip if node never seen)
|
|
||||||
char seenStr[20] = "";
|
|
||||||
uint32_t seconds = sinceLastSeen(node);
|
|
||||||
if (seconds != 0 && seconds != UINT32_MAX) {
|
|
||||||
uint32_t minutes = seconds / 60, hours = minutes / 60, days = hours / 24;
|
|
||||||
snprintf(seenStr, sizeof(seenStr), (days > 365 ? " Heard: ?" : " Heard: %d%c ago"),
|
|
||||||
(days ? days
|
|
||||||
: hours ? hours
|
|
||||||
: minutes),
|
|
||||||
(days ? 'd'
|
|
||||||
: hours ? 'h'
|
|
||||||
: 'm'));
|
|
||||||
}
|
|
||||||
if (seenStr[0] && line < 5) {
|
|
||||||
display->drawString(x, yPositions[line++], seenStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Uptime (only show if metric is present)
|
|
||||||
char uptimeStr[32] = "";
|
|
||||||
if (node->has_device_metrics && node->device_metrics.has_uptime_seconds) {
|
|
||||||
uint32_t uptime = node->device_metrics.uptime_seconds;
|
|
||||||
uint32_t days = uptime / 86400;
|
|
||||||
uint32_t hours = (uptime % 86400) / 3600;
|
|
||||||
uint32_t mins = (uptime % 3600) / 60;
|
|
||||||
|
|
||||||
if (days > 0) {
|
|
||||||
snprintf(uptimeStr, sizeof(uptimeStr), " Uptime: %dd %dh", days, hours);
|
|
||||||
} else if (hours > 0) {
|
|
||||||
snprintf(uptimeStr, sizeof(uptimeStr), " Uptime: %dh %dm", hours, mins);
|
|
||||||
} else {
|
|
||||||
snprintf(uptimeStr, sizeof(uptimeStr), " Uptime: %dm", mins);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (uptimeStr[0] && line < 5) {
|
|
||||||
display->drawString(x, yPositions[line++], uptimeStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. Distance (only if both nodes have GPS position)
|
|
||||||
meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());
|
|
||||||
char distStr[24] = "";
|
|
||||||
bool haveDistance = false;
|
|
||||||
|
|
||||||
if (nodeDB->hasValidPosition(ourNode) && nodeDB->hasValidPosition(node)) {
|
|
||||||
double lat1 = ourNode->position.latitude_i * 1e-7;
|
|
||||||
double lon1 = ourNode->position.longitude_i * 1e-7;
|
|
||||||
double lat2 = node->position.latitude_i * 1e-7;
|
|
||||||
double lon2 = node->position.longitude_i * 1e-7;
|
|
||||||
|
|
||||||
double earthRadiusKm = 6371.0;
|
|
||||||
double dLat = (lat2 - lat1) * DEG_TO_RAD;
|
|
||||||
double dLon = (lon2 - lon1) * DEG_TO_RAD;
|
|
||||||
|
|
||||||
double a =
|
|
||||||
sin(dLat / 2) * sin(dLat / 2) + cos(lat1 * DEG_TO_RAD) * cos(lat2 * DEG_TO_RAD) * sin(dLon / 2) * sin(dLon / 2);
|
|
||||||
double c = 2 * atan2(sqrt(a), sqrt(1 - a));
|
|
||||||
double distanceKm = earthRadiusKm * c;
|
|
||||||
|
|
||||||
// Format distance appropriately
|
|
||||||
if (distanceKm < 1.0) {
|
|
||||||
double miles = distanceKm * 0.621371;
|
|
||||||
if (miles < 0.1) {
|
|
||||||
int feet = (int)(miles * 5280);
|
|
||||||
if (feet > 0 && feet < 1000) {
|
|
||||||
snprintf(distStr, sizeof(distStr), " Distance: %dft", feet);
|
|
||||||
haveDistance = true;
|
|
||||||
} else if (feet >= 1000) {
|
|
||||||
snprintf(distStr, sizeof(distStr), " Distance: ¼mi");
|
|
||||||
haveDistance = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int roundedMiles = (int)(miles + 0.5);
|
|
||||||
if (roundedMiles > 0 && roundedMiles < 1000) {
|
|
||||||
snprintf(distStr, sizeof(distStr), " Distance: %dmi", roundedMiles);
|
|
||||||
haveDistance = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int km = (int)(distanceKm + 0.5);
|
|
||||||
if (km > 0 && km < 1000) {
|
|
||||||
snprintf(distStr, sizeof(distStr), " Distance: %dkm", km);
|
|
||||||
haveDistance = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Only display if we actually have a value!
|
|
||||||
if (haveDistance && distStr[0] && line < 5) {
|
|
||||||
display->drawString(x, yPositions[line++], distStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compass rendering for different screen orientations
|
|
||||||
if (SCREEN_WIDTH > SCREEN_HEIGHT) {
|
|
||||||
// Landscape: side-aligned compass
|
|
||||||
bool showCompass = false;
|
|
||||||
if (ourNode && (nodeDB->hasValidPosition(ourNode) || screen->hasHeading()) && nodeDB->hasValidPosition(node)) {
|
|
||||||
showCompass = true;
|
|
||||||
}
|
|
||||||
if (showCompass) {
|
|
||||||
const int16_t topY = compactFirstLine;
|
|
||||||
const int16_t bottomY = SCREEN_HEIGHT - (FONT_HEIGHT_SMALL - 1);
|
|
||||||
const int16_t usableHeight = bottomY - topY - 5;
|
|
||||||
int16_t compassRadius = usableHeight / 2;
|
|
||||||
if (compassRadius < 8)
|
|
||||||
compassRadius = 8;
|
|
||||||
const int16_t compassDiam = compassRadius * 2;
|
|
||||||
const int16_t compassX = x + SCREEN_WIDTH - compassRadius - 8;
|
|
||||||
const int16_t compassY = topY + (usableHeight / 2) + ((FONT_HEIGHT_SMALL - 1) / 2) + 2;
|
|
||||||
|
|
||||||
const auto &op = ourNode->position;
|
|
||||||
float myHeading = screen->hasHeading() ? screen->getHeading() * PI / 180
|
|
||||||
: screen->estimatedHeading(DegD(op.latitude_i), DegD(op.longitude_i));
|
|
||||||
CompassRenderer::drawCompassNorth(display, compassX, compassY, myHeading);
|
|
||||||
|
|
||||||
const auto &p = node->position;
|
|
||||||
float bearing = GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i));
|
|
||||||
if (!config.display.compass_north_top)
|
|
||||||
bearing -= myHeading;
|
|
||||||
CompassRenderer::drawNodeHeading(display, compassX, compassY, compassDiam, bearing);
|
|
||||||
|
|
||||||
display->drawCircle(compassX, compassY, compassRadius);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Portrait: bottom-centered compass
|
|
||||||
bool showCompass = false;
|
|
||||||
if (ourNode && (nodeDB->hasValidPosition(ourNode) || screen->hasHeading()) && nodeDB->hasValidPosition(node)) {
|
|
||||||
showCompass = true;
|
|
||||||
}
|
|
||||||
if (showCompass) {
|
|
||||||
int yBelowContent = (line > 0 && line <= 5) ? (yPositions[line - 1] + FONT_HEIGHT_SMALL + 2) : moreCompactFirstLine;
|
|
||||||
|
|
||||||
const int margin = 4;
|
|
||||||
#if defined(USE_EINK)
|
|
||||||
const int iconSize = (SCREEN_WIDTH > 128) ? 16 : 8;
|
|
||||||
const int navBarHeight = iconSize + 6;
|
|
||||||
#else
|
|
||||||
const int navBarHeight = 0;
|
|
||||||
#endif
|
|
||||||
int availableHeight = SCREEN_HEIGHT - yBelowContent - navBarHeight - margin;
|
|
||||||
|
|
||||||
if (availableHeight < FONT_HEIGHT_SMALL * 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int compassRadius = availableHeight / 2;
|
|
||||||
if (compassRadius < 8)
|
|
||||||
compassRadius = 8;
|
|
||||||
if (compassRadius * 2 > SCREEN_WIDTH - 16)
|
|
||||||
compassRadius = (SCREEN_WIDTH - 16) / 2;
|
|
||||||
|
|
||||||
int compassX = x + SCREEN_WIDTH / 2;
|
|
||||||
int compassY = yBelowContent + availableHeight / 2;
|
|
||||||
|
|
||||||
const auto &op = ourNode->position;
|
|
||||||
float myHeading = screen->hasHeading() ? screen->getHeading() * PI / 180
|
|
||||||
: screen->estimatedHeading(DegD(op.latitude_i), DegD(op.longitude_i));
|
|
||||||
CompassRenderer::drawCompassNorth(display, compassX, compassY, myHeading);
|
|
||||||
|
|
||||||
const auto &p = node->position;
|
|
||||||
float bearing = GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i));
|
|
||||||
if (!config.display.compass_north_top)
|
|
||||||
bearing -= myHeading;
|
|
||||||
CompassRenderer::drawNodeHeading(display, compassX, compassY, compassRadius * 2, bearing);
|
|
||||||
|
|
||||||
display->drawCircle(compassX, compassY, compassRadius);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Draw a series of fields in a column, wrapping to multiple columns if needed
|
/// Draw a series of fields in a column, wrapping to multiple columns if needed
|
||||||
void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields)
|
void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields)
|
||||||
{
|
{
|
||||||
@@ -876,3 +564,4 @@ void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields
|
|||||||
|
|
||||||
} // namespace NodeListRenderer
|
} // namespace NodeListRenderer
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
#endif
|
||||||
@@ -23,12 +23,6 @@ namespace NodeListRenderer
|
|||||||
typedef void (*EntryRenderer)(OLEDDisplay *, meshtastic_NodeInfoLite *, int16_t, int16_t, int);
|
typedef void (*EntryRenderer)(OLEDDisplay *, meshtastic_NodeInfoLite *, int16_t, int16_t, int);
|
||||||
typedef void (*NodeExtrasRenderer)(OLEDDisplay *, meshtastic_NodeInfoLite *, int16_t, int16_t, int, float, double, double);
|
typedef void (*NodeExtrasRenderer)(OLEDDisplay *, meshtastic_NodeInfoLite *, int16_t, int16_t, int, float, double, double);
|
||||||
|
|
||||||
// Node entry structure
|
|
||||||
struct NodeEntry {
|
|
||||||
meshtastic_NodeInfoLite *node;
|
|
||||||
uint32_t sortValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Node list mode enumeration
|
// Node list mode enumeration
|
||||||
enum NodeListMode { MODE_LAST_HEARD = 0, MODE_HOP_SIGNAL = 1, MODE_DISTANCE = 2, MODE_COUNT = 3 };
|
enum NodeListMode { MODE_LAST_HEARD = 0, MODE_HOP_SIGNAL = 1, MODE_DISTANCE = 2, MODE_COUNT = 3 };
|
||||||
|
|
||||||
@@ -54,13 +48,10 @@ void drawHopSignalScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||||||
void drawDistanceScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
void drawDistanceScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
void drawDynamicNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
void drawDynamicNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
void drawNodeListWithCompasses(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
void drawNodeListWithCompasses(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
|
||||||
|
|
||||||
// Utility functions
|
// Utility functions
|
||||||
const char *getCurrentModeTitle(int screenWidth);
|
const char *getCurrentModeTitle(int screenWidth);
|
||||||
void retrieveAndSortNodes(std::vector<NodeEntry> &nodeList);
|
|
||||||
const char *getSafeNodeName(meshtastic_NodeInfoLite *node);
|
const char *getSafeNodeName(meshtastic_NodeInfoLite *node);
|
||||||
uint32_t sinceLastSeen(meshtastic_NodeInfoLite *node);
|
|
||||||
void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields);
|
void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields);
|
||||||
|
|
||||||
// Bitmap drawing function
|
// Bitmap drawing function
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#include "NotificationRenderer.h"
|
#include "configuration.h"
|
||||||
|
#if HAS_SCREEN
|
||||||
|
|
||||||
#include "DisplayFormatters.h"
|
#include "DisplayFormatters.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "configuration.h"
|
#include "NotificationRenderer.h"
|
||||||
#include "graphics/Screen.h"
|
|
||||||
#include "graphics/ScreenFonts.h"
|
#include "graphics/ScreenFonts.h"
|
||||||
#include "graphics/SharedUIDisplay.h"
|
#include "graphics/SharedUIDisplay.h"
|
||||||
#include "graphics/images.h"
|
#include "graphics/images.h"
|
||||||
@@ -25,8 +26,14 @@ extern bool hasUnreadMessage;
|
|||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace NotificationRenderer
|
char NotificationRenderer::inEvent = INPUT_BROKER_NONE;
|
||||||
{
|
int8_t NotificationRenderer::curSelected = 0;
|
||||||
|
char NotificationRenderer::alertBannerMessage[256] = {0};
|
||||||
|
uint32_t NotificationRenderer::alertBannerUntil = 0; // 0 is a special case meaning forever
|
||||||
|
uint8_t NotificationRenderer::alertBannerOptions = 0; // last x lines are seelctable options
|
||||||
|
const char **NotificationRenderer::optionsArrayPtr = nullptr;
|
||||||
|
std::function<void(int)> NotificationRenderer::alertBannerCallback = NULL;
|
||||||
|
bool NotificationRenderer::pauseBanner = false;
|
||||||
|
|
||||||
// Used on boot when a certificate is being created
|
// Used on boot when a certificate is being created
|
||||||
void NotificationRenderer::drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
void NotificationRenderer::drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
@@ -48,109 +55,195 @@ void NotificationRenderer::drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiStat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used when booting without a region set
|
|
||||||
void NotificationRenderer::drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
|
||||||
{
|
|
||||||
display->setFont(FONT_SMALL);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->drawString(64 + x, y, "//\\ E S H T /\\ S T / C");
|
|
||||||
display->drawString(64 + x, y + FONT_HEIGHT_SMALL, getDeviceName());
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
|
|
||||||
if ((millis() / 10000) % 2) {
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 2 - 3, "Set the region using the");
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 3 - 3, "Meshtastic Android, iOS,");
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 4 - 3, "Web or CLI clients.");
|
|
||||||
} else {
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 2 - 3, "Visit meshtastic.org");
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 3 - 3, "for more information.");
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 4 - 3, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
|
||||||
yield();
|
|
||||||
esp_task_wdt_reset();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *state)
|
void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *state)
|
||||||
{
|
{
|
||||||
// Exit if no message is active or duration has passed
|
if (!isOverlayBannerShowing() || pauseBanner)
|
||||||
if (strlen(alertBannerMessage) == 0 || (alertBannerUntil != 0 && millis() > alertBannerUntil))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// === Layout Configuration ===
|
// === Layout Configuration ===
|
||||||
constexpr uint16_t padding = 5; // Padding around text inside the box
|
constexpr uint16_t hPadding = 5;
|
||||||
constexpr uint8_t lineSpacing = 1; // Extra space between lines
|
constexpr uint16_t vPadding = 2;
|
||||||
|
constexpr uint8_t lineSpacing = 1;
|
||||||
|
|
||||||
// Search the message to determine if we need the bell added
|
|
||||||
bool needs_bell = (strstr(alertBannerMessage, "Alert Received") != nullptr);
|
bool needs_bell = (strstr(alertBannerMessage, "Alert Received") != nullptr);
|
||||||
|
|
||||||
// Setup font and alignment
|
// Setup font and alignment
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT); // We will manually center per line
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
// === Split the message into lines (supports multi-line banners) ===
|
constexpr int MAX_LINES = 5;
|
||||||
const int MAX_LINES = 10;
|
uint16_t optionWidths[alertBannerOptions] = {0};
|
||||||
char lines[MAX_LINES][256];
|
|
||||||
int lineCount = 0;
|
|
||||||
|
|
||||||
// Create a working copy of the message to tokenize
|
|
||||||
char messageCopy[256];
|
|
||||||
strncpy(messageCopy, alertBannerMessage, sizeof(messageCopy) - 1);
|
|
||||||
messageCopy[sizeof(messageCopy) - 1] = '\0';
|
|
||||||
|
|
||||||
char *line = strtok(messageCopy, "\n");
|
|
||||||
while (line != nullptr && lineCount < MAX_LINES) {
|
|
||||||
strncpy(lines[lineCount], line, sizeof(lines[lineCount]) - 1);
|
|
||||||
lines[lineCount][sizeof(lines[lineCount]) - 1] = '\0';
|
|
||||||
lineCount++;
|
|
||||||
line = strtok(nullptr, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// === Measure text dimensions ===
|
|
||||||
uint16_t minWidth = (SCREEN_WIDTH > 128) ? 106 : 78;
|
|
||||||
uint16_t maxWidth = 0;
|
uint16_t maxWidth = 0;
|
||||||
uint16_t lineWidths[MAX_LINES];
|
uint16_t arrowsWidth = display->getStringWidth("> <", 4, true);
|
||||||
for (int i = 0; i < lineCount; i++) {
|
uint16_t lineWidths[MAX_LINES] = {0};
|
||||||
uint16_t w = display->getStringWidth(lines[i], strlen(lines[i]), true);
|
uint16_t lineLengths[MAX_LINES] = {0};
|
||||||
lineWidths[i] = w;
|
char *lineStarts[MAX_LINES + 1];
|
||||||
if (w > maxWidth)
|
uint16_t lineCount = 0;
|
||||||
maxWidth = w;
|
char lineBuffer[40] = {0};
|
||||||
|
|
||||||
|
// Parse lines
|
||||||
|
char *alertEnd = alertBannerMessage + strnlen(alertBannerMessage, sizeof(alertBannerMessage));
|
||||||
|
lineStarts[lineCount] = alertBannerMessage;
|
||||||
|
|
||||||
|
while ((lineCount < MAX_LINES) && (lineStarts[lineCount] < alertEnd)) {
|
||||||
|
lineStarts[lineCount + 1] = std::find(lineStarts[lineCount], alertEnd, '\n');
|
||||||
|
lineLengths[lineCount] = lineStarts[lineCount + 1] - lineStarts[lineCount];
|
||||||
|
if (lineStarts[lineCount + 1][0] == '\n')
|
||||||
|
lineStarts[lineCount + 1] += 1;
|
||||||
|
lineWidths[lineCount] = display->getStringWidth(lineStarts[lineCount], lineLengths[lineCount], true);
|
||||||
|
if (lineWidths[lineCount] > maxWidth)
|
||||||
|
maxWidth = lineWidths[lineCount];
|
||||||
|
lineCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t boxWidth = padding * 2 + maxWidth;
|
// Measure option widths
|
||||||
if (needs_bell && boxWidth < minWidth)
|
for (int i = 0; i < alertBannerOptions; i++) {
|
||||||
boxWidth += (SCREEN_WIDTH > 128) ? 26 : 20;
|
optionWidths[i] = display->getStringWidth(optionsArrayPtr[i], strlen(optionsArrayPtr[i]), true);
|
||||||
|
if (optionWidths[i] > maxWidth)
|
||||||
|
maxWidth = optionWidths[i];
|
||||||
|
if (optionWidths[i] + arrowsWidth > maxWidth)
|
||||||
|
maxWidth = optionWidths[i] + arrowsWidth;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t boxHeight = padding * 2 + lineCount * FONT_HEIGHT_SMALL + (lineCount - 1) * lineSpacing;
|
// Handle input
|
||||||
|
if (alertBannerOptions > 0) {
|
||||||
|
if (inEvent == INPUT_BROKER_UP || inEvent == INPUT_BROKER_ALT_PRESS) {
|
||||||
|
curSelected--;
|
||||||
|
} else if (inEvent == INPUT_BROKER_DOWN || inEvent == INPUT_BROKER_USER_PRESS) {
|
||||||
|
curSelected++;
|
||||||
|
} else if (inEvent == INPUT_BROKER_SELECT) {
|
||||||
|
alertBannerCallback(curSelected);
|
||||||
|
alertBannerMessage[0] = '\0';
|
||||||
|
} else if ((inEvent == INPUT_BROKER_CANCEL || inEvent == INPUT_BROKER_ALT_LONG) && alertBannerUntil != 0) {
|
||||||
|
alertBannerMessage[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curSelected == -1)
|
||||||
|
curSelected = alertBannerOptions - 1;
|
||||||
|
if (curSelected == alertBannerOptions)
|
||||||
|
curSelected = 0;
|
||||||
|
} else {
|
||||||
|
if (inEvent == INPUT_BROKER_SELECT || inEvent == INPUT_BROKER_ALT_LONG || inEvent == INPUT_BROKER_CANCEL) {
|
||||||
|
alertBannerMessage[0] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inEvent = INPUT_BROKER_NONE;
|
||||||
|
if (alertBannerMessage[0] == '\0')
|
||||||
|
return;
|
||||||
|
|
||||||
|
// === Box Size Calculation ===
|
||||||
|
uint16_t boxWidth = hPadding * 2 + maxWidth;
|
||||||
|
if (needs_bell) {
|
||||||
|
if (isHighResolution && boxWidth <= 150)
|
||||||
|
boxWidth += 26;
|
||||||
|
if (!isHighResolution && boxWidth <= 100)
|
||||||
|
boxWidth += 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t totalLines = lineCount + alertBannerOptions;
|
||||||
|
uint16_t screenHeight = display->height();
|
||||||
|
uint8_t effectiveLineHeight = FONT_HEIGHT_SMALL - 3;
|
||||||
|
uint8_t visibleTotalLines = std::min<uint8_t>(totalLines, (screenHeight - vPadding * 2) / effectiveLineHeight);
|
||||||
|
uint16_t contentHeight = visibleTotalLines * effectiveLineHeight;
|
||||||
|
uint16_t boxHeight = contentHeight + vPadding * 2;
|
||||||
|
|
||||||
int16_t boxLeft = (display->width() / 2) - (boxWidth / 2);
|
int16_t boxLeft = (display->width() / 2) - (boxWidth / 2);
|
||||||
int16_t boxTop = (display->height() / 2) - (boxHeight / 2);
|
int16_t boxTop = (display->height() / 2) - (boxHeight / 2);
|
||||||
|
|
||||||
// === Draw background box ===
|
// === Draw Box ===
|
||||||
display->setColor(BLACK);
|
display->setColor(BLACK);
|
||||||
display->fillRect(boxLeft - 1, boxTop - 1, boxWidth + 2, boxHeight + 2); // Slightly oversized box
|
display->fillRect(boxLeft - 1, boxTop - 1, boxWidth + 2, boxHeight + 2);
|
||||||
|
display->fillRect(boxLeft, boxTop - 2, boxWidth, 1);
|
||||||
|
display->fillRect(boxLeft, boxTop + boxHeight + 1, boxWidth, 1);
|
||||||
|
display->fillRect(boxLeft - 2, boxTop, 1, boxHeight);
|
||||||
|
display->fillRect(boxLeft + boxWidth + 1, boxTop, 1, boxHeight);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->drawRect(boxLeft, boxTop, boxWidth, boxHeight);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(boxLeft, boxTop, 1, 1);
|
||||||
|
display->fillRect(boxLeft + boxWidth - 1, boxTop, 1, 1);
|
||||||
|
display->fillRect(boxLeft, boxTop + boxHeight - 1, 1, 1);
|
||||||
|
display->fillRect(boxLeft + boxWidth - 1, boxTop + boxHeight - 1, 1, 1);
|
||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
display->drawRect(boxLeft, boxTop, boxWidth, boxHeight); // Border
|
|
||||||
|
|
||||||
// === Draw each line centered in the box ===
|
// === Draw Content ===
|
||||||
int16_t lineY = boxTop + padding;
|
int16_t lineY = boxTop + vPadding;
|
||||||
for (int i = 0; i < lineCount; i++) {
|
uint8_t linesShown = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < lineCount && linesShown < visibleTotalLines; i++, linesShown++) {
|
||||||
|
strncpy(lineBuffer, lineStarts[i], 40);
|
||||||
|
lineBuffer[lineLengths[i] > 39 ? 39 : lineLengths[i]] = '\0';
|
||||||
|
|
||||||
int16_t textX = boxLeft + (boxWidth - lineWidths[i]) / 2;
|
int16_t textX = boxLeft + (boxWidth - lineWidths[i]) / 2;
|
||||||
uint16_t line_width = display->getStringWidth(lines[i], strlen(lines[i]), true);
|
|
||||||
|
|
||||||
if (needs_bell && i == 0) {
|
if (needs_bell && i == 0) {
|
||||||
int bellY = lineY + (FONT_HEIGHT_SMALL - 8) / 2;
|
int bellY = lineY + (FONT_HEIGHT_SMALL - 8) / 2;
|
||||||
display->drawXbm(textX - 10, bellY, 8, 8, bell_alert);
|
display->drawXbm(textX - 10, bellY, 8, 8, bell_alert);
|
||||||
display->drawXbm(textX + line_width + 2, bellY, 8, 8, bell_alert);
|
display->drawXbm(textX + lineWidths[i] + 2, bellY, 8, 8, bell_alert);
|
||||||
}
|
}
|
||||||
|
|
||||||
display->drawString(textX, lineY, lines[i]);
|
// Determine if this is a pop-up or a pick list
|
||||||
if (SCREEN_WIDTH > 128)
|
if (alertBannerOptions > 0) {
|
||||||
display->drawString(textX + 1, lineY, lines[i]); // Faux bold
|
// Pick List
|
||||||
|
display->setColor(WHITE);
|
||||||
|
int background_yOffset = 1;
|
||||||
|
// Determine if we have low hanging characters
|
||||||
|
if (strchr(lineBuffer, 'p') || strchr(lineBuffer, 'g') || strchr(lineBuffer, 'y') || strchr(lineBuffer, 'j')) {
|
||||||
|
background_yOffset = -1;
|
||||||
|
}
|
||||||
|
display->fillRect(boxLeft, boxTop + 1, boxWidth, effectiveLineHeight - background_yOffset);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
int yOffset = 3;
|
||||||
|
display->drawString(textX, lineY - yOffset, lineBuffer);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
lineY += (effectiveLineHeight - 2 - background_yOffset);
|
||||||
|
} else {
|
||||||
|
// Pop-up
|
||||||
|
display->drawString(textX, lineY - 2, lineBuffer);
|
||||||
|
lineY += (effectiveLineHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lineY += FONT_HEIGHT_SMALL + lineSpacing;
|
uint8_t firstOptionToShow = 0;
|
||||||
|
if (alertBannerOptions > 0) {
|
||||||
|
if (curSelected > 1 && alertBannerOptions > visibleTotalLines - lineCount)
|
||||||
|
firstOptionToShow = curSelected - 1;
|
||||||
|
else
|
||||||
|
firstOptionToShow = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = firstOptionToShow; i < alertBannerOptions && linesShown < visibleTotalLines; i++, linesShown++) {
|
||||||
|
if (i == curSelected) {
|
||||||
|
strncpy(lineBuffer, "> ", 3);
|
||||||
|
strncpy(lineBuffer + 2, optionsArrayPtr[i], 36);
|
||||||
|
strncpy(lineBuffer + strlen(optionsArrayPtr[i]) + 2, " <", 3);
|
||||||
|
lineBuffer[39] = '\0';
|
||||||
|
} else {
|
||||||
|
strncpy(lineBuffer, optionsArrayPtr[i], 40);
|
||||||
|
lineBuffer[39] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t textX = boxLeft + (boxWidth - optionWidths[i] - (i == curSelected ? arrowsWidth : 0)) / 2;
|
||||||
|
display->drawString(textX, lineY, lineBuffer);
|
||||||
|
lineY += effectiveLineHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Scroll Bar (Thicker, inside box, not over title) ===
|
||||||
|
if (totalLines > visibleTotalLines) {
|
||||||
|
const uint8_t scrollBarWidth = 5;
|
||||||
|
const uint8_t scrollPadding = 2;
|
||||||
|
|
||||||
|
int16_t scrollBarX = boxLeft + boxWidth - scrollBarWidth - 2;
|
||||||
|
int16_t scrollBarY = boxTop + vPadding + effectiveLineHeight; // start after title line
|
||||||
|
uint16_t scrollBarHeight = boxHeight - vPadding * 2 - effectiveLineHeight;
|
||||||
|
|
||||||
|
float ratio = (float)visibleTotalLines / totalLines;
|
||||||
|
uint16_t indicatorHeight = std::max((int)(scrollBarHeight * ratio), 4);
|
||||||
|
float scrollRatio = (float)(firstOptionToShow + linesShown - visibleTotalLines) / (totalLines - visibleTotalLines);
|
||||||
|
uint16_t indicatorY = scrollBarY + scrollRatio * (scrollBarHeight - indicatorHeight);
|
||||||
|
|
||||||
|
display->drawRect(scrollBarX, scrollBarY, scrollBarWidth, scrollBarHeight);
|
||||||
|
display->fillRect(scrollBarX + 1, indicatorY, scrollBarWidth - 2, indicatorHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,6 +273,10 @@ void NotificationRenderer::drawFrameFirmware(OLEDDisplay *display, OLEDDisplayUi
|
|||||||
"Please be patient and do not power off.");
|
"Please be patient and do not power off.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace NotificationRenderer
|
bool NotificationRenderer::isOverlayBannerShowing()
|
||||||
|
{
|
||||||
|
return strlen(alertBannerMessage) > 0 && (alertBannerUntil == 0 || millis() <= alertBannerUntil);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
#endif
|
||||||
@@ -6,19 +6,24 @@
|
|||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace NotificationRenderer
|
|
||||||
{
|
|
||||||
|
|
||||||
class NotificationRenderer
|
class NotificationRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static char inEvent;
|
||||||
|
static int8_t curSelected;
|
||||||
|
static char alertBannerMessage[256];
|
||||||
|
static uint32_t alertBannerUntil; // 0 is a special case meaning forever
|
||||||
|
static const char **optionsArrayPtr;
|
||||||
|
static uint8_t alertBannerOptions; // last x lines are seelctable options
|
||||||
|
static std::function<void(int)> alertBannerCallback;
|
||||||
|
|
||||||
|
static bool pauseBanner;
|
||||||
|
|
||||||
static void drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *state);
|
static void drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisplayUiState *state);
|
||||||
static void drawCriticalFaultFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
static void drawCriticalFaultFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
static void drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
static void drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
static void drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
|
||||||
static void drawFrameFirmware(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
static void drawFrameFirmware(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
|
static bool isOverlayBannerShowing();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace NotificationRenderer
|
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -28,65 +28,61 @@ class Screen;
|
|||||||
* Contains utility functions for drawing common UI elements, overlays,
|
* Contains utility functions for drawing common UI elements, overlays,
|
||||||
* battery indicators, and other shared graphical components.
|
* battery indicators, and other shared graphical components.
|
||||||
*/
|
*/
|
||||||
namespace UIRenderer
|
class UIRenderer
|
||||||
{
|
{
|
||||||
// Common UI elements
|
public:
|
||||||
void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y);
|
// Common UI elements
|
||||||
void drawBattery(OLEDDisplay *display, int16_t x, int16_t y, uint8_t *imgBuffer, const meshtastic::PowerStatus *powerStatus);
|
static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::NodeStatus *nodeStatus,
|
||||||
void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::NodeStatus *nodeStatus, int node_offset = 0,
|
int node_offset = 0, bool show_total = true, String additional_words = "");
|
||||||
bool show_total = true, String additional_words = "");
|
|
||||||
|
|
||||||
// GPS status functions
|
// GPS status functions
|
||||||
void drawGps(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gpsStatus);
|
static void drawGps(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gpsStatus);
|
||||||
void drawGpsCoordinates(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gpsStatus);
|
static void drawGpsCoordinates(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gpsStatus);
|
||||||
void drawGpsAltitude(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gpsStatus);
|
static void drawGpsAltitude(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gpsStatus);
|
||||||
void drawGpsPowerStatus(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gpsStatus);
|
static void drawGpsPowerStatus(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gpsStatus);
|
||||||
|
|
||||||
// Layout and utility functions
|
// Layout and utility functions
|
||||||
void drawScrollbar(OLEDDisplay *display, int visibleItems, int totalItems, int scrollIndex, int x, int startY);
|
static void drawScrollbar(OLEDDisplay *display, int visibleItems, int totalItems, int scrollIndex, int x, int startY);
|
||||||
|
|
||||||
// Overlay and special screens
|
// Overlay and special screens
|
||||||
void drawFrameText(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y, const char *text);
|
static void drawFrameText(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y, const char *text);
|
||||||
|
|
||||||
// Function overlay for showing mute/buzzer modifiers etc.
|
// Navigation bar overlay
|
||||||
void drawFunctionOverlay(OLEDDisplay *display, OLEDDisplayUiState *state);
|
static void drawNavigationBar(OLEDDisplay *display, OLEDDisplayUiState *state);
|
||||||
|
|
||||||
// Navigation bar overlay
|
static void drawNodeInfo(OLEDDisplay *display, const OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
void drawNavigationBar(OLEDDisplay *display, OLEDDisplayUiState *state);
|
|
||||||
|
|
||||||
void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
static void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
|
|
||||||
void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
// Icon and screen drawing functions
|
||||||
|
static void drawIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
|
|
||||||
// Icon and screen drawing functions
|
// Compass and location screen
|
||||||
void drawIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
static void drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
|
|
||||||
// Compass and location screen
|
static NodeNum currentFavoriteNodeNum;
|
||||||
void drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
|
||||||
|
|
||||||
// OEM screens
|
// OEM screens
|
||||||
#ifdef USERPREFS_OEM_TEXT
|
#ifdef USERPREFS_OEM_TEXT
|
||||||
void drawOEMIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
static void drawOEMIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
void drawOEMBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
static void drawOEMBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_EINK
|
#ifdef USE_EINK
|
||||||
/// Used on eink displays while in deep sleep
|
/// Used on eink displays while in deep sleep
|
||||||
void drawDeepSleepFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
static void drawDeepSleepFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
||||||
|
|
||||||
/// Used on eink displays when screen updates are paused
|
/// Used on eink displays when screen updates are paused
|
||||||
void drawScreensaverOverlay(OLEDDisplay *display, OLEDDisplayUiState *state);
|
static void drawScreensaverOverlay(OLEDDisplay *display, OLEDDisplayUiState *state);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Time and date utilities
|
static std::string drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds);
|
||||||
void getTimeAgoStr(uint32_t agoSecs, char *timeStr, uint8_t maxLength);
|
static int formatDateTime(char *buffer, size_t bufferSize, uint32_t rtc_sec, OLEDDisplay *display, bool showTime);
|
||||||
std::string drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds);
|
|
||||||
int formatDateTime(char *buffer, size_t bufferSize, uint32_t rtc_sec, OLEDDisplay *display, bool showTime);
|
|
||||||
|
|
||||||
// Message filtering
|
// Message filtering
|
||||||
bool shouldDrawMessage(const meshtastic_MeshPacket *packet);
|
static bool shouldDrawMessage(const meshtastic_MeshPacket *packet);
|
||||||
// Check if the display can render a string (detect special chars; emoji)
|
// Check if the display can render a string (detect special chars; emoji)
|
||||||
bool haveGlyphs(const char *str);
|
static bool haveGlyphs(const char *str);
|
||||||
} // namespace UIRenderer
|
}; // namespace UIRenderer
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ const uint8_t SATELLITE_IMAGE[] PROGMEM = {0x00, 0x08, 0x00, 0x1C, 0x00, 0x0E, 0
|
|||||||
0xF8, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xC8, 0x01, 0x9C, 0x54,
|
0xF8, 0x00, 0xF0, 0x01, 0xE0, 0x03, 0xC8, 0x01, 0x9C, 0x54,
|
||||||
0x0E, 0x52, 0x07, 0x48, 0x02, 0x26, 0x00, 0x10, 0x00, 0x0E};
|
0x0E, 0x52, 0x07, 0x48, 0x02, 0x26, 0x00, 0x10, 0x00, 0x0E};
|
||||||
|
|
||||||
const uint8_t imgSatellite[] PROGMEM = {0x70, 0x71, 0x22, 0xFA, 0xFA, 0x22, 0x71, 0x70};
|
#define imgSatellite_width 8
|
||||||
|
#define imgSatellite_height 8
|
||||||
|
const uint8_t imgSatellite[] PROGMEM = {
|
||||||
|
0b00000000, 0b00000000, 0b00000000, 0b00011000, 0b11011011, 0b11111111, 0b11011011, 0b00011000,
|
||||||
|
};
|
||||||
|
|
||||||
const uint8_t imgUSB[] PROGMEM = {0x60, 0x60, 0x30, 0x18, 0x18, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x24, 0x24, 0x24, 0x3C};
|
const uint8_t imgUSB[] PROGMEM = {0x60, 0x60, 0x30, 0x18, 0x18, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x24, 0x24, 0x24, 0x3C};
|
||||||
const uint8_t imgPower[] PROGMEM = {0x40, 0x40, 0x40, 0x58, 0x48, 0x08, 0x08, 0x08,
|
const uint8_t imgPower[] PROGMEM = {0x40, 0x40, 0x40, 0x58, 0x48, 0x08, 0x08, 0x08,
|
||||||
0x1C, 0x22, 0x22, 0x41, 0x7F, 0x22, 0x22, 0x22};
|
0x1C, 0x22, 0x22, 0x41, 0x7F, 0x22, 0x22, 0x22};
|
||||||
@@ -14,11 +19,9 @@ const uint8_t imgUser[] PROGMEM = {0x3C, 0x42, 0x99, 0xA5, 0xA5, 0x99, 0x42, 0x3
|
|||||||
const uint8_t imgPositionEmpty[] PROGMEM = {0x20, 0x30, 0x28, 0x24, 0x42, 0xFF};
|
const uint8_t imgPositionEmpty[] PROGMEM = {0x20, 0x30, 0x28, 0x24, 0x42, 0xFF};
|
||||||
const uint8_t imgPositionSolid[] PROGMEM = {0x20, 0x30, 0x38, 0x3C, 0x7E, 0xFF};
|
const uint8_t imgPositionSolid[] PROGMEM = {0x20, 0x30, 0x38, 0x3C, 0x7E, 0xFF};
|
||||||
|
|
||||||
#if defined(DISPLAY_CLOCK_FRAME)
|
|
||||||
const uint8_t bluetoothConnectedIcon[36] PROGMEM = {0xfe, 0x01, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0xe3, 0x1f,
|
const uint8_t bluetoothConnectedIcon[36] PROGMEM = {0xfe, 0x01, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0xe3, 0x1f,
|
||||||
0xf3, 0x3f, 0x33, 0x30, 0x33, 0x33, 0x33, 0x33, 0x03, 0x33, 0xff, 0x33,
|
0xf3, 0x3f, 0x33, 0x30, 0x33, 0x33, 0x33, 0x33, 0x03, 0x33, 0xff, 0x33,
|
||||||
0xfe, 0x31, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0x3f, 0xe0, 0x1f};
|
0xfe, 0x31, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0x3f, 0xe0, 0x1f};
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
||||||
defined(ST7789_CS) || defined(USE_ST7789) || defined(HX8357_CS) || defined(ILI9488_CS) || ARCH_PORTDUINO) && \
|
defined(ST7789_CS) || defined(USE_ST7789) || defined(HX8357_CS) || defined(ILI9488_CS) || ARCH_PORTDUINO) && \
|
||||||
@@ -39,25 +42,21 @@ const uint8_t imgSF[] PROGMEM = {0xd2, 0xb7, 0xad, 0xbb, 0x92, 0x01, 0xfd, 0xfd,
|
|||||||
|
|
||||||
// === Horizontal battery ===
|
// === Horizontal battery ===
|
||||||
// Basic battery design and all related pieces
|
// Basic battery design and all related pieces
|
||||||
const unsigned char batteryBitmap_h[] PROGMEM = {
|
const unsigned char batteryBitmap_h_bottom[] PROGMEM = {
|
||||||
0b11111110, 0b00000000, 0b11110000, 0b00000111, 0b00000001, 0b00000000, 0b00000000, 0b00001000, 0b00000001, 0b00000000,
|
0b00011110, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000001,
|
||||||
0b00000000, 0b00001000, 0b00000001, 0b00000000, 0b00000000, 0b00001000, 0b00000001, 0b00000000, 0b00000000, 0b00001000,
|
0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000,
|
||||||
0b00000001, 0b00000000, 0b00000000, 0b00011000, 0b00000001, 0b00000000, 0b00000000, 0b00011000, 0b00000001, 0b00000000,
|
0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00000001, 0b00000000, 0b00011110, 0b00000000};
|
||||||
0b00000000, 0b00011000, 0b00000001, 0b00000000, 0b00000000, 0b00011000, 0b00000001, 0b00000000, 0b00000000, 0b00011000,
|
|
||||||
0b00000001, 0b00000000, 0b00000000, 0b00001000, 0b00000001, 0b00000000, 0b00000000, 0b00001000, 0b00000001, 0b00000000,
|
|
||||||
0b00000000, 0b00001000, 0b00000001, 0b00000000, 0b00000000, 0b00001000, 0b11111110, 0b00000000, 0b11110000, 0b00000111};
|
|
||||||
|
|
||||||
// This is the left and right bars for the fill in
|
const unsigned char batteryBitmap_h_top[] PROGMEM = {
|
||||||
const unsigned char batteryBitmap_sidegaps_h[] PROGMEM = {
|
0b00111100, 0b00000000, 0b01000000, 0b00000000, 0b01000000, 0b00000000, 0b01000000, 0b00000000, 0b01000000,
|
||||||
0b11111111, 0b00001111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
|
0b00000000, 0b11000000, 0b00000000, 0b11000000, 0b00000000, 0b11000000, 0b00000000, 0b01000000, 0b00000000,
|
||||||
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
|
0b01000000, 0b00000000, 0b01000000, 0b00000000, 0b01000000, 0b00000000, 0b00111100, 0b00000000};
|
||||||
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b00001111};
|
|
||||||
|
|
||||||
// Lightning Bolt
|
// Lightning Bolt
|
||||||
const unsigned char lightning_bolt_h[] PROGMEM = {
|
const unsigned char lightning_bolt_h[] PROGMEM = {
|
||||||
0b11110000, 0b00000000, 0b11110000, 0b00000000, 0b01110000, 0b00000000, 0b00111000, 0b00000000, 0b00111100,
|
0b00000000, 0b00000000, 0b00100000, 0b00000000, 0b00110000, 0b00000000, 0b00111000, 0b00000000, 0b00111100,
|
||||||
0b00000000, 0b11111100, 0b00000000, 0b01111110, 0b00000000, 0b00111000, 0b00000000, 0b00110000, 0b00000000,
|
0b00000000, 0b00011110, 0b00000000, 0b11111111, 0b00000000, 0b01111000, 0b00000000, 0b00111100, 0b00000000,
|
||||||
0b00010000, 0b00000000, 0b00010000, 0b00000000, 0b00001000, 0b00000000, 0b00001000, 0b00000000};
|
0b00011100, 0b00000000, 0b00001100, 0b00000000, 0b00000100, 0b00000000, 0b00000000, 0b00000000};
|
||||||
|
|
||||||
// === Vertical battery ===
|
// === Vertical battery ===
|
||||||
// Basic battery design and all related pieces
|
// Basic battery design and all related pieces
|
||||||
@@ -82,13 +81,13 @@ static const unsigned char mail[] PROGMEM = {
|
|||||||
|
|
||||||
// 📬 Mail / Message
|
// 📬 Mail / Message
|
||||||
const uint8_t icon_mail[] PROGMEM = {
|
const uint8_t icon_mail[] PROGMEM = {
|
||||||
0b00000000, // (padding)
|
|
||||||
0b11111111, // ████████ top border
|
0b11111111, // ████████ top border
|
||||||
0b10000001, // █ █ sides
|
0b10000001, // █ █ sides
|
||||||
0b11000011, // ██ ██ diagonal
|
0b11000011, // ██ ██ diagonal
|
||||||
0b10100101, // █ █ █ █ inner M
|
0b10100101, // █ █ █ █ inner M
|
||||||
0b10011001, // █ ██ █ inner M
|
0b10011001, // █ ██ █ inner M
|
||||||
0b10000001, // █ █ sides
|
0b10000001, // █ █ sides
|
||||||
|
0b10000001, // █ █ sides
|
||||||
0b11111111 // ████████ bottom
|
0b11111111 // ████████ bottom
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -274,5 +273,16 @@ const uint8_t bluetoothdisabled[] PROGMEM = {0b11101100, 0b01010100, 0b01001100,
|
|||||||
const uint8_t smallbulletpoint[] PROGMEM = {0b00000011, 0b00000011, 0b00000000, 0b00000000,
|
const uint8_t smallbulletpoint[] PROGMEM = {0b00000011, 0b00000011, 0b00000000, 0b00000000,
|
||||||
0b00000000, 0b00000000, 0b00000000, 0b00000000};
|
0b00000000, 0b00000000, 0b00000000, 0b00000000};
|
||||||
|
|
||||||
|
// Digital Clock
|
||||||
|
#define digital_icon_clock_width 8
|
||||||
|
#define digital_icon_clock_height 8
|
||||||
|
const uint8_t digital_icon_clock[] PROGMEM = {0b00111100, 0b01000010, 0b10000101, 0b10101001,
|
||||||
|
0b10010001, 0b10000001, 0b01000010, 0b00111100};
|
||||||
|
// Analog Clock
|
||||||
|
#define analog_icon_clock_width 8
|
||||||
|
#define analog_icon_clock_height 8
|
||||||
|
const uint8_t analog_icon_clock[] PROGMEM = {0b11111111, 0b01000010, 0b00100100, 0b00011000,
|
||||||
|
0b00100100, 0b01000010, 0b01000010, 0b11111111};
|
||||||
|
|
||||||
#include "img/icon.xbm"
|
#include "img/icon.xbm"
|
||||||
static_assert(sizeof(icon_bits) >= 0, "Silence unused variable warning");
|
static_assert(sizeof(icon_bits) >= 0, "Silence unused variable warning");
|
||||||
@@ -5,7 +5,7 @@ E-Ink display driver
|
|||||||
- Manufacturer: DKE
|
- Manufacturer: DKE
|
||||||
- Size: 2.13 inch
|
- Size: 2.13 inch
|
||||||
- Resolution: 122px x 250px
|
- Resolution: 122px x 250px
|
||||||
- Flex connector marking: FPC-7528B
|
- Flex connector marking (not a unique identifier): FPC-7528B
|
||||||
|
|
||||||
Note: this is from an older generation of DKE panels, which still used Solomon Systech controller ICs.
|
Note: this is from an older generation of DKE panels, which still used Solomon Systech controller ICs.
|
||||||
DKE's website suggests that the latest DEPG0213BN displays may use Fitipower controllers instead.
|
DKE's website suggests that the latest DEPG0213BN displays may use Fitipower controllers instead.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ E-Ink display driver
|
|||||||
- Manufacturer: DKE
|
- Manufacturer: DKE
|
||||||
- Size: 2.9 inch
|
- Size: 2.9 inch
|
||||||
- Resolution: 128px x 296px
|
- Resolution: 128px x 296px
|
||||||
- Flex connector marking: FPC-7519 rev.b
|
- Flex connector marking (not a unique identifier): FPC-7519 rev.b
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,9 @@ void GDEY0154D67::configScanning()
|
|||||||
{
|
{
|
||||||
// "Driver output control"
|
// "Driver output control"
|
||||||
sendCommand(0x01);
|
sendCommand(0x01);
|
||||||
sendData(0xC7);
|
sendData(0xC7); // Scan until gate 199 (200px vertical res.)
|
||||||
sendData(0x00);
|
sendData(0x00);
|
||||||
sendData(0x00);
|
sendData(0x00);
|
||||||
|
|
||||||
// To-do: delete this method?
|
|
||||||
// Values set here might be redundant: C7, 00, 00 seems to be default
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specify which information is used to control the sequence of voltages applied to move the pixels
|
// Specify which information is used to control the sequence of voltages applied to move the pixels
|
||||||
@@ -52,10 +49,10 @@ void GDEY0154D67::detachFromUpdate()
|
|||||||
{
|
{
|
||||||
switch (updateType) {
|
switch (updateType) {
|
||||||
case FAST:
|
case FAST:
|
||||||
return beginPolling(50, 500); // At least 500ms for fast refresh
|
return beginPolling(50, 300); // At least 300ms for fast refresh
|
||||||
case FULL:
|
case FULL:
|
||||||
default:
|
default:
|
||||||
return beginPolling(100, 2000); // At least 2 seconds for full refresh
|
return beginPolling(100, 1500); // At least 1.5 seconds for full refresh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
@@ -5,7 +5,7 @@ E-Ink display driver
|
|||||||
- Manufacturer: Goodisplay
|
- Manufacturer: Goodisplay
|
||||||
- Size: 1.54 inch
|
- Size: 1.54 inch
|
||||||
- Resolution: 200px x 200px
|
- Resolution: 200px x 200px
|
||||||
- Flex connector marking: FPC-B001
|
- Flex connector marking (not a unique identifier): FPC-B001
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -31,9 +31,9 @@ class GDEY0154D67 : public SSD16XX
|
|||||||
GDEY0154D67() : SSD16XX(width, height, supported) {}
|
GDEY0154D67() : SSD16XX(width, height, supported) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void configScanning() override;
|
void configScanning() override;
|
||||||
virtual void configWaveform() override;
|
void configWaveform() override;
|
||||||
virtual void configUpdateSequence() override;
|
void configUpdateSequence() override;
|
||||||
void detachFromUpdate() override;
|
void detachFromUpdate() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ void GDEY0213B74::configScanning()
|
|||||||
sendData(0xF9);
|
sendData(0xF9);
|
||||||
sendData(0x00);
|
sendData(0x00);
|
||||||
sendData(0x00);
|
sendData(0x00);
|
||||||
|
|
||||||
// To-do: delete this method?
|
|
||||||
// Values set here might be redundant: F9, 00, 00 seems to be default
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specify which information is used to control the sequence of voltages applied to move the pixels
|
// Specify which information is used to control the sequence of voltages applied to move the pixels
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ E-Ink display driver
|
|||||||
- Manufacturer: Goodisplay
|
- Manufacturer: Goodisplay
|
||||||
- Size: 2.13 inch
|
- Size: 2.13 inch
|
||||||
- Resolution: 250px x 122px
|
- Resolution: 250px x 122px
|
||||||
- Flex connector marking: FPC-A002
|
- Flex connector marking (not a unique identifier):
|
||||||
|
- FPC-A002
|
||||||
|
- FPC-A005 20.06.15 TRX
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
61
src/graphics/niche/Drivers/EInk/HINK_E0213A289.cpp
Normal file
61
src/graphics/niche/Drivers/EInk/HINK_E0213A289.cpp
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#include "./HINK_E0213A289.h"
|
||||||
|
|
||||||
|
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
|
|
||||||
|
using namespace NicheGraphics::Drivers;
|
||||||
|
|
||||||
|
// Map the display controller IC's output to the connected panel
|
||||||
|
void HINK_E0213A289::configScanning()
|
||||||
|
{
|
||||||
|
// "Driver output control"
|
||||||
|
// Scan gates from 0 to 249 (vertical resolution 250px)
|
||||||
|
sendCommand(0x01);
|
||||||
|
sendData(0xF9); // Maximum gate # (249, bits 0-7)
|
||||||
|
sendData(0x00); // Maximum gate # (bit 8)
|
||||||
|
sendData(0x00); // (Do not invert scanning order)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specify which information is used to control the sequence of voltages applied to move the pixels
|
||||||
|
// - For this display, configUpdateSequence() specifies that a suitable LUT will be loaded from
|
||||||
|
// the controller IC's OTP memory, when the update procedure begins.
|
||||||
|
void HINK_E0213A289::configWaveform()
|
||||||
|
{
|
||||||
|
sendCommand(0x3C); // Border waveform:
|
||||||
|
sendData(0x05); // Screen border should follow LUT1 waveform (actively drive pixels white)
|
||||||
|
|
||||||
|
sendCommand(0x18); // Temperature sensor:
|
||||||
|
sendData(0x80); // Use internal temperature sensor to select an appropriate refresh waveform
|
||||||
|
}
|
||||||
|
|
||||||
|
// Describes the sequence of events performed by the displays controller IC during a refresh
|
||||||
|
// Includes "power up", "load settings from memory", "update the pixels", etc
|
||||||
|
void HINK_E0213A289::configUpdateSequence()
|
||||||
|
{
|
||||||
|
switch (updateType) {
|
||||||
|
case FAST:
|
||||||
|
sendCommand(0x22); // Set "update sequence"
|
||||||
|
sendData(0xFF); // Will load LUT from OTP memory, Display mode 2 "differential refresh"
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FULL:
|
||||||
|
default:
|
||||||
|
sendCommand(0x22); // Set "update sequence"
|
||||||
|
sendData(0xF7); // Will load LUT from OTP memory
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once the refresh operation has been started,
|
||||||
|
// begin periodically polling the display to check for completion, using the normal Meshtastic threading code
|
||||||
|
// Only used when refresh is "async"
|
||||||
|
void HINK_E0213A289::detachFromUpdate()
|
||||||
|
{
|
||||||
|
switch (updateType) {
|
||||||
|
case FAST:
|
||||||
|
return beginPolling(50, 500); // At least 500ms for fast refresh
|
||||||
|
case FULL:
|
||||||
|
default:
|
||||||
|
return beginPolling(100, 1000); // At least 1 second for full refresh (quick; display only blinks pixels once)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
44
src/graphics/niche/Drivers/EInk/HINK_E0213A289.h
Normal file
44
src/graphics/niche/Drivers/EInk/HINK_E0213A289.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
E-Ink display driver
|
||||||
|
- HINK_E0213A289
|
||||||
|
- Manufacturer: Holitech
|
||||||
|
- Size: 2.13 inch
|
||||||
|
- Resolution: 122px x 250px
|
||||||
|
- Flex connector label (not a unique identifier): FPC-7528B
|
||||||
|
|
||||||
|
Note: as of Feb. 2025, these panels are used for "WeActStudio 2.13in B&W" display modules
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
|
|
||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
|
#include "./SSD16XX.h"
|
||||||
|
|
||||||
|
namespace NicheGraphics::Drivers
|
||||||
|
{
|
||||||
|
class HINK_E0213A289 : public SSD16XX
|
||||||
|
{
|
||||||
|
// Display properties
|
||||||
|
private:
|
||||||
|
static constexpr uint32_t width = 122;
|
||||||
|
static constexpr uint32_t height = 250;
|
||||||
|
static constexpr UpdateTypes supported = (UpdateTypes)(FULL | FAST);
|
||||||
|
|
||||||
|
public:
|
||||||
|
HINK_E0213A289() : SSD16XX(width, height, supported, 1) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void configScanning() override;
|
||||||
|
void configWaveform() override;
|
||||||
|
void configUpdateSequence() override;
|
||||||
|
void detachFromUpdate() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace NicheGraphics::Drivers
|
||||||
|
|
||||||
|
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
@@ -5,7 +5,7 @@ E-Ink display driver
|
|||||||
- Manufacturer: Holitech
|
- Manufacturer: Holitech
|
||||||
- Size: 4.2 inch
|
- Size: 4.2 inch
|
||||||
- Resolution: 400px x 300px
|
- Resolution: 400px x 300px
|
||||||
- Flex connector marking: HINK-E042A07-FPC-A1
|
- Flex connector marking (not a unique identifier): HINK-E042A07-FPC-A1
|
||||||
- Silver sticker with QR code, marked: HE042A87
|
- Silver sticker with QR code, marked: HE042A87
|
||||||
|
|
||||||
Note: as of Feb. 2025, these panels are used for "WeActStudio 4.2in B&W" display modules
|
Note: as of Feb. 2025, these panels are used for "WeActStudio 4.2in B&W" display modules
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ E-Ink display driver
|
|||||||
- Manufacturer: WISEVAST
|
- Manufacturer: WISEVAST
|
||||||
- Size: 2.13 inch
|
- Size: 2.13 inch
|
||||||
- Resolution: 122px x 255px
|
- Resolution: 122px x 255px
|
||||||
- Flex connector marking: Soldering connector, no connector is needed
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ E-Ink display driver
|
|||||||
- Manufacturer: Wisevast
|
- Manufacturer: Wisevast
|
||||||
- Size: 2.13 inch
|
- Size: 2.13 inch
|
||||||
- Resolution: 122px x 250px
|
- Resolution: 122px x 250px
|
||||||
- Flex connector marking: HINK-E0213A162-FPC-A0 (Hidden, printed on back-side)
|
- Flex connector marking (not a unique identifier): HINK-E0213A162-FPC-A0 (Hidden, printed on back-side)
|
||||||
|
|
||||||
Note: this display uses an uncommon controller IC, Fitipower JD79656.
|
Note: this display uses an uncommon controller IC, Fitipower JD79656.
|
||||||
It is implemented as a "one-off", directly inheriting the EInk base class, unlike SSD16XX displays.
|
It is implemented as a "one-off", directly inheriting the EInk base class, unlike SSD16XX displays.
|
||||||
|
|||||||
59
src/graphics/niche/Drivers/EInk/ZJY128296_029EAAMFGN.cpp
Normal file
59
src/graphics/niche/Drivers/EInk/ZJY128296_029EAAMFGN.cpp
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#include "./ZJY128296_029EAAMFGN.h"
|
||||||
|
|
||||||
|
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
|
|
||||||
|
using namespace NicheGraphics::Drivers;
|
||||||
|
|
||||||
|
// Map the display controller IC's output to the connected panel
|
||||||
|
void ZJY128296_029EAAMFGN::configScanning()
|
||||||
|
{
|
||||||
|
// "Driver output control"
|
||||||
|
// Scan gates from 0 to 295 (vertical resolution 296px)
|
||||||
|
sendCommand(0x01);
|
||||||
|
sendData(0x27); // Number of gates (295, bits 0-7)
|
||||||
|
sendData(0x01); // Number of gates (295, bit 8)
|
||||||
|
sendData(0x00); // (Do not invert scanning order)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specify which information is used to control the sequence of voltages applied to move the pixels
|
||||||
|
// - For this display, configUpdateSequence() specifies that a suitable LUT will be loaded from
|
||||||
|
// the controller IC's OTP memory, when the update procedure begins.
|
||||||
|
void ZJY128296_029EAAMFGN::configWaveform()
|
||||||
|
{
|
||||||
|
sendCommand(0x3C); // Border waveform:
|
||||||
|
sendData(0x05); // Screen border should follow LUT1 waveform (actively drive pixels white)
|
||||||
|
|
||||||
|
sendCommand(0x18); // Temperature sensor:
|
||||||
|
sendData(0x80); // Use internal temperature sensor to select an appropriate refresh waveform
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZJY128296_029EAAMFGN::configUpdateSequence()
|
||||||
|
{
|
||||||
|
switch (updateType) {
|
||||||
|
case FAST:
|
||||||
|
sendCommand(0x22); // Set "update sequence"
|
||||||
|
sendData(0xFF); // Will load LUT from OTP memory, Display mode 2 "differential refresh"
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FULL:
|
||||||
|
default:
|
||||||
|
sendCommand(0x22); // Set "update sequence"
|
||||||
|
sendData(0xF7); // Will load LUT from OTP memory
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once the refresh operation has been started,
|
||||||
|
// begin periodically polling the display to check for completion, using the normal Meshtastic threading code
|
||||||
|
// Only used when refresh is "async"
|
||||||
|
void ZJY128296_029EAAMFGN::detachFromUpdate()
|
||||||
|
{
|
||||||
|
switch (updateType) {
|
||||||
|
case FAST:
|
||||||
|
return beginPolling(50, 300); // At least 300ms for fast refresh
|
||||||
|
case FULL:
|
||||||
|
default:
|
||||||
|
return beginPolling(100, 2000); // At least 2 seconds for full refresh
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
44
src/graphics/niche/Drivers/EInk/ZJY128296_029EAAMFGN.h
Normal file
44
src/graphics/niche/Drivers/EInk/ZJY128296_029EAAMFGN.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
E-Ink display driver
|
||||||
|
- ZJY128296-029EAAMFGN
|
||||||
|
- Manufacturer: Zhongjingyuan
|
||||||
|
- Size: 2.9 inch
|
||||||
|
- Resolution: 128px x 296px
|
||||||
|
- Flex connector label (not a unique identifier): FPC-A005 20.06.15 TRX
|
||||||
|
|
||||||
|
Note: as of Feb. 2025, these panels are used for "WeActStudio 2.9in B&W" display modules
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
|
|
||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
|
#include "./SSD16XX.h"
|
||||||
|
|
||||||
|
namespace NicheGraphics::Drivers
|
||||||
|
{
|
||||||
|
class ZJY128296_029EAAMFGN : public SSD16XX
|
||||||
|
{
|
||||||
|
// Display properties
|
||||||
|
private:
|
||||||
|
static constexpr uint32_t width = 128;
|
||||||
|
static constexpr uint32_t height = 296;
|
||||||
|
static constexpr UpdateTypes supported = (UpdateTypes)(FULL | FAST);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ZJY128296_029EAAMFGN() : SSD16XX(width, height, supported) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void configScanning() override;
|
||||||
|
void configWaveform() override;
|
||||||
|
void configUpdateSequence() override;
|
||||||
|
void detachFromUpdate() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace NicheGraphics::Drivers
|
||||||
|
|
||||||
|
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
32
src/graphics/niche/Drivers/EInk/ZJY200200_0154DAAMFGN.h
Normal file
32
src/graphics/niche/Drivers/EInk/ZJY200200_0154DAAMFGN.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
E-Ink display driver
|
||||||
|
- ZJY200200-0154DAAMFGN
|
||||||
|
- Manufacturer: Zhongjingyuan
|
||||||
|
- Size: 1.54 inch
|
||||||
|
- Resolution: 200px x 200px
|
||||||
|
- Flex connector marking: FPC-B001
|
||||||
|
|
||||||
|
Note: as of Feb. 2025, these panels are used for "WeActStudio 1.54in B&W" display modules
|
||||||
|
|
||||||
|
This *is* a distinct panel, however the driver is currently identical to GDEY0154D67
|
||||||
|
We recognize it as separate now, to avoid breaking any custom builds if the drivers do need to diverge in future.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
|
|
||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
|
#include "./GDEY0154D67.h"
|
||||||
|
|
||||||
|
namespace NicheGraphics::Drivers
|
||||||
|
{
|
||||||
|
|
||||||
|
typedef GDEY0154D67 ZJY200200_0154DAAMFGN;
|
||||||
|
|
||||||
|
} // namespace NicheGraphics::Drivers
|
||||||
|
|
||||||
|
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||||
@@ -19,6 +19,8 @@ namespace NicheGraphics::InkHUD
|
|||||||
enum MenuAction {
|
enum MenuAction {
|
||||||
NO_ACTION,
|
NO_ACTION,
|
||||||
SEND_PING,
|
SEND_PING,
|
||||||
|
STORE_CANNEDMESSAGE_SELECTION,
|
||||||
|
SEND_CANNEDMESSAGE,
|
||||||
SHUTDOWN,
|
SHUTDOWN,
|
||||||
NEXT_TILE,
|
NEXT_TILE,
|
||||||
TOGGLE_BACKLIGHT,
|
TOGGLE_BACKLIGHT,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
|
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
|
#include "Router.h"
|
||||||
#include "airtime.h"
|
#include "airtime.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
@@ -31,6 +32,12 @@ InkHUD::MenuApplet::MenuApplet() : concurrency::OSThread("MenuApplet")
|
|||||||
if (settings->optionalMenuItems.backlight) {
|
if (settings->optionalMenuItems.backlight) {
|
||||||
backlight = Drivers::LatchingBacklight::getInstance();
|
backlight = Drivers::LatchingBacklight::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize the Canned Message store
|
||||||
|
// This is a shared nicheGraphics component
|
||||||
|
// - handles loading & parsing the canned messages
|
||||||
|
// - handles setting / getting of canned messages via apps (Client API Admin Messages)
|
||||||
|
cm.store = CannedMessageStore::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InkHUD::MenuApplet::onForeground()
|
void InkHUD::MenuApplet::onForeground()
|
||||||
@@ -65,6 +72,10 @@ void InkHUD::MenuApplet::onForeground()
|
|||||||
|
|
||||||
void InkHUD::MenuApplet::onBackground()
|
void InkHUD::MenuApplet::onBackground()
|
||||||
{
|
{
|
||||||
|
// Discard any data we generated while selecting a canned message
|
||||||
|
// Frees heap mem
|
||||||
|
freeCannedMessageResources();
|
||||||
|
|
||||||
// If device has a backlight which isn't controlled by aux button:
|
// If device has a backlight which isn't controlled by aux button:
|
||||||
// Item in options submenu allows keeping backlight on after menu is closed
|
// Item in options submenu allows keeping backlight on after menu is closed
|
||||||
// If this item is deselected we will turn backlight off again, now that menu is closing
|
// If this item is deselected we will turn backlight off again, now that menu is closing
|
||||||
@@ -153,6 +164,16 @@ void InkHUD::MenuApplet::execute(MenuItem item)
|
|||||||
inkhud->forceUpdate(Drivers::EInk::UpdateTypes::FULL);
|
inkhud->forceUpdate(Drivers::EInk::UpdateTypes::FULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case STORE_CANNEDMESSAGE_SELECTION:
|
||||||
|
cm.selectedMessageItem = &cm.messageItems.at(cursor - 1); // Minus one: offset for the initial "Send Ping" entry
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SEND_CANNEDMESSAGE:
|
||||||
|
cm.selectedRecipientItem = &cm.recipientItems.at(cursor);
|
||||||
|
sendText(cm.selectedRecipientItem->dest, cm.selectedRecipientItem->channelIndex, cm.selectedMessageItem->rawText.c_str());
|
||||||
|
inkhud->forceUpdate(Drivers::EInk::UpdateTypes::FULL); // Next refresh should be FULL. Lots of button pressing to get here
|
||||||
|
break;
|
||||||
|
|
||||||
case ROTATE:
|
case ROTATE:
|
||||||
inkhud->rotate();
|
inkhud->rotate();
|
||||||
break;
|
break;
|
||||||
@@ -260,9 +281,11 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SEND:
|
case SEND:
|
||||||
items.push_back(MenuItem("Ping", MenuAction::SEND_PING, MenuPage::EXIT));
|
populateSendPage();
|
||||||
// Todo: canned messages
|
break;
|
||||||
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
|
||||||
|
case CANNEDMESSAGE_RECIPIENT:
|
||||||
|
populateRecipientPage();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPTIONS:
|
case OPTIONS:
|
||||||
@@ -497,6 +520,8 @@ void InkHUD::MenuApplet::populateAutoshowPage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create MenuItem entries to select our definition of "Recent"
|
||||||
|
// Controls how long data will remain in any "Recents" flavored applets
|
||||||
void InkHUD::MenuApplet::populateRecentsPage()
|
void InkHUD::MenuApplet::populateRecentsPage()
|
||||||
{
|
{
|
||||||
// How many values are shown for use to choose from
|
// How many values are shown for use to choose from
|
||||||
@@ -510,6 +535,112 @@ void InkHUD::MenuApplet::populateRecentsPage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MenuItem entries for the "send" page
|
||||||
|
// Dynamically creates menu items based on available canned messages
|
||||||
|
void InkHUD::MenuApplet::populateSendPage()
|
||||||
|
{
|
||||||
|
// Position / NodeInfo packet
|
||||||
|
items.push_back(MenuItem("Ping", MenuAction::SEND_PING, MenuPage::EXIT));
|
||||||
|
|
||||||
|
// One menu item for each canned message
|
||||||
|
uint8_t count = cm.store->size();
|
||||||
|
for (uint8_t i = 0; i < count; i++) {
|
||||||
|
// Gather the information for this item
|
||||||
|
CannedMessages::MessageItem messageItem;
|
||||||
|
messageItem.rawText = cm.store->at(i);
|
||||||
|
messageItem.label = parse(messageItem.rawText);
|
||||||
|
|
||||||
|
// Store the item (until the menu closes)
|
||||||
|
cm.messageItems.push_back(messageItem);
|
||||||
|
|
||||||
|
// Create a menu item
|
||||||
|
const char *itemText = cm.messageItems.back().label.c_str();
|
||||||
|
items.push_back(MenuItem(itemText, MenuAction::STORE_CANNEDMESSAGE_SELECTION, MenuPage::CANNEDMESSAGE_RECIPIENT));
|
||||||
|
}
|
||||||
|
|
||||||
|
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dynamically create MenuItem entries for possible canned message destinations
|
||||||
|
// All available channels are shown
|
||||||
|
// Favorite nodes are shown, provided we don't have an *excessive* amount
|
||||||
|
void InkHUD::MenuApplet::populateRecipientPage()
|
||||||
|
{
|
||||||
|
// Create recipient data (and menu items) for any channels
|
||||||
|
// --------------------------------------------------------
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < MAX_NUM_CHANNELS; i++) {
|
||||||
|
// Get the channel, and check if it's enabled
|
||||||
|
meshtastic_Channel &channel = channels.getByIndex(i);
|
||||||
|
if (!channel.has_settings || channel.role == meshtastic_Channel_Role_DISABLED)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
CannedMessages::RecipientItem r;
|
||||||
|
|
||||||
|
// Set index
|
||||||
|
r.channelIndex = channel.index;
|
||||||
|
|
||||||
|
// Set a label for the menu item
|
||||||
|
r.label = "Ch " + to_string(i) + ": ";
|
||||||
|
if (channel.role == meshtastic_Channel_Role_PRIMARY)
|
||||||
|
r.label += "Primary";
|
||||||
|
else
|
||||||
|
r.label += parse(channel.settings.name);
|
||||||
|
|
||||||
|
// Add to the list of recipients
|
||||||
|
cm.recipientItems.push_back(r);
|
||||||
|
|
||||||
|
// Add a menu item for this recipient
|
||||||
|
const char *itemText = cm.recipientItems.back().label.c_str();
|
||||||
|
items.push_back(MenuItem(itemText, SEND_CANNEDMESSAGE, MenuPage::EXIT));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create recipient data (and menu items) for favorite nodes
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
uint32_t nodeCount = nodeDB->getNumMeshNodes();
|
||||||
|
uint32_t favoriteCount = 0;
|
||||||
|
|
||||||
|
// Count favorites
|
||||||
|
for (uint32_t i = 0; i < nodeCount; i++) {
|
||||||
|
if (nodeDB->getMeshNodeByIndex(i)->is_favorite)
|
||||||
|
favoriteCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only add favorites if the number is reasonable
|
||||||
|
// Don't want some monstrous list that takes 100 clicks to reach exit
|
||||||
|
if (favoriteCount < 20) {
|
||||||
|
for (uint32_t i = 0; i < nodeCount; i++) {
|
||||||
|
meshtastic_NodeInfoLite *node = nodeDB->getMeshNodeByIndex(i);
|
||||||
|
|
||||||
|
// Skip node if not a favorite
|
||||||
|
if (!node->is_favorite)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
CannedMessages::RecipientItem r;
|
||||||
|
|
||||||
|
r.dest = node->num;
|
||||||
|
r.channelIndex = nodeDB->getMeshNodeChannel(node->num); // Channel index only relevant if encrypted DM not possible(?)
|
||||||
|
|
||||||
|
// Set a label for the menu item
|
||||||
|
r.label = "DM: ";
|
||||||
|
if (node->has_user)
|
||||||
|
r.label += parse(node->user.long_name);
|
||||||
|
else
|
||||||
|
r.label += hexifyNodeNum(node->num); // Unsure if it's possible to favorite a node without NodeInfo?
|
||||||
|
|
||||||
|
// Add to the list of recipients
|
||||||
|
cm.recipientItems.push_back(r);
|
||||||
|
|
||||||
|
// Add a menu item for this recipient
|
||||||
|
const char *itemText = cm.recipientItems.back().label.c_str();
|
||||||
|
items.push_back(MenuItem(itemText, SEND_CANNEDMESSAGE, MenuPage::EXIT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||||
|
}
|
||||||
|
|
||||||
// Renders the panel shown at the top of the root menu.
|
// Renders the panel shown at the top of the root menu.
|
||||||
// Displays the clock, and several other pieces of instantaneous system info,
|
// Displays the clock, and several other pieces of instantaneous system info,
|
||||||
// which we'd prefer not to have displayed in a normal applet, as they update too frequently.
|
// which we'd prefer not to have displayed in a normal applet, as they update too frequently.
|
||||||
@@ -619,4 +750,37 @@ uint16_t InkHUD::MenuApplet::getSystemInfoPanelHeight()
|
|||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send a text message to the mesh
|
||||||
|
// Used to send our canned messages
|
||||||
|
void InkHUD::MenuApplet::sendText(NodeNum dest, ChannelIndex channel, const char *message)
|
||||||
|
{
|
||||||
|
meshtastic_MeshPacket *p = router->allocForSending();
|
||||||
|
p->decoded.portnum = meshtastic_PortNum_TEXT_MESSAGE_APP;
|
||||||
|
p->to = dest;
|
||||||
|
p->channel = channel;
|
||||||
|
p->want_ack = true;
|
||||||
|
p->decoded.payload.size = strlen(message);
|
||||||
|
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);
|
||||||
|
|
||||||
|
// Tack on a bell character if requested
|
||||||
|
if (moduleConfig.canned_message.send_bell && p->decoded.payload.size < meshtastic_Constants_DATA_PAYLOAD_LEN) {
|
||||||
|
p->decoded.payload.bytes[p->decoded.payload.size] = 7; // Bell character
|
||||||
|
p->decoded.payload.bytes[p->decoded.payload.size + 1] = '\0'; // Append Null Terminator
|
||||||
|
p->decoded.payload.size++;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_INFO("Send message id=%d, dest=%x, msg=%.*s", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
|
||||||
|
|
||||||
|
service->sendToMesh(p, RX_SRC_LOCAL, true); // Send to mesh, cc to phone
|
||||||
|
}
|
||||||
|
|
||||||
|
// Free up any heap mmemory we'd used while selecting / sending canned messages
|
||||||
|
void InkHUD::MenuApplet::freeCannedMessageResources()
|
||||||
|
{
|
||||||
|
cm.selectedMessageItem = nullptr;
|
||||||
|
cm.selectedRecipientItem = nullptr;
|
||||||
|
cm.messageItems.clear();
|
||||||
|
cm.recipientItems.clear();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -6,10 +6,12 @@
|
|||||||
#include "graphics/niche/InkHUD/InkHUD.h"
|
#include "graphics/niche/InkHUD/InkHUD.h"
|
||||||
#include "graphics/niche/InkHUD/Persistence.h"
|
#include "graphics/niche/InkHUD/Persistence.h"
|
||||||
#include "graphics/niche/InkHUD/SystemApplet.h"
|
#include "graphics/niche/InkHUD/SystemApplet.h"
|
||||||
|
#include "graphics/niche/Utils/CannedMessageStore.h"
|
||||||
|
|
||||||
#include "./MenuItem.h"
|
#include "./MenuItem.h"
|
||||||
#include "./MenuPage.h"
|
#include "./MenuPage.h"
|
||||||
|
|
||||||
|
#include "Channels.h"
|
||||||
#include "concurrency/OSThread.h"
|
#include "concurrency/OSThread.h"
|
||||||
|
|
||||||
namespace NicheGraphics::InkHUD
|
namespace NicheGraphics::InkHUD
|
||||||
@@ -36,12 +38,18 @@ class MenuApplet : public SystemApplet, public concurrency::OSThread
|
|||||||
|
|
||||||
void execute(MenuItem item); // Perform the MenuAction associated with a MenuItem, if any
|
void execute(MenuItem item); // Perform the MenuAction associated with a MenuItem, if any
|
||||||
void showPage(MenuPage page); // Load and display a MenuPage
|
void showPage(MenuPage page); // Load and display a MenuPage
|
||||||
|
|
||||||
|
void populateSendPage(); // Dynamically create MenuItems including canned messages
|
||||||
|
void populateRecipientPage(); // Dynamically create a page of possible destinations for a canned message
|
||||||
void populateAppletPage(); // Dynamically create MenuItems for toggling loaded applets
|
void populateAppletPage(); // Dynamically create MenuItems for toggling loaded applets
|
||||||
void populateAutoshowPage(); // Dynamically create MenuItems for selecting which applets can autoshow
|
void populateAutoshowPage(); // Dynamically create MenuItems for selecting which applets can autoshow
|
||||||
void populateRecentsPage(); // Create menu items: a choice of values for settings.recentlyActiveSeconds
|
void populateRecentsPage(); // Create menu items: a choice of values for settings.recentlyActiveSeconds
|
||||||
|
|
||||||
uint16_t getSystemInfoPanelHeight();
|
uint16_t getSystemInfoPanelHeight();
|
||||||
void drawSystemInfoPanel(int16_t left, int16_t top, uint16_t width,
|
void drawSystemInfoPanel(int16_t left, int16_t top, uint16_t width,
|
||||||
uint16_t *height = nullptr); // Info panel at top of root menu
|
uint16_t *height = nullptr); // Info panel at top of root menu
|
||||||
|
void sendText(NodeNum dest, ChannelIndex channel, const char *message); // Send a text message to mesh
|
||||||
|
void freeCannedMessageResources(); // Clear MenuApplet's canned message processing data
|
||||||
|
|
||||||
MenuPage currentPage = MenuPage::ROOT;
|
MenuPage currentPage = MenuPage::ROOT;
|
||||||
uint8_t cursor = 0; // Which menu item is currently highlighted
|
uint8_t cursor = 0; // Which menu item is currently highlighted
|
||||||
@@ -51,6 +59,37 @@ class MenuApplet : public SystemApplet, public concurrency::OSThread
|
|||||||
|
|
||||||
std::vector<MenuItem> items; // MenuItems for the current page. Filled by ShowPage
|
std::vector<MenuItem> items; // MenuItems for the current page. Filled by ShowPage
|
||||||
|
|
||||||
|
// Data for selecting and sending canned messages via the menu
|
||||||
|
// Placed into a sub-class for organization only
|
||||||
|
class CannedMessages
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Share NicheGraphics component
|
||||||
|
// Handles loading, getting, setting
|
||||||
|
CannedMessageStore *store;
|
||||||
|
|
||||||
|
// One canned message
|
||||||
|
// Links the menu item to the true message text
|
||||||
|
struct MessageItem {
|
||||||
|
std::string label; // Shown in menu. Prefixed, and UTF-8 chars parsed
|
||||||
|
std::string rawText; // The message which will be sent, if this item is selected
|
||||||
|
} *selectedMessageItem;
|
||||||
|
|
||||||
|
// One possible destination for a canned message
|
||||||
|
// Links the menu item to the intended recipient
|
||||||
|
// May represent either broadcast or DM
|
||||||
|
struct RecipientItem {
|
||||||
|
std::string label; // Shown in menu
|
||||||
|
NodeNum dest = NODENUM_BROADCAST;
|
||||||
|
uint8_t channelIndex = 0;
|
||||||
|
} *selectedRecipientItem;
|
||||||
|
|
||||||
|
// These lists are generated when the menu page is populated
|
||||||
|
// Cleared onBackground (when MenuApplet closes)
|
||||||
|
std::vector<MessageItem> messageItems;
|
||||||
|
std::vector<RecipientItem> recipientItems;
|
||||||
|
} cm;
|
||||||
|
|
||||||
Applet *borrowedTileOwner = nullptr; // Which applet we have temporarily replaced while displaying menu
|
Applet *borrowedTileOwner = nullptr; // Which applet we have temporarily replaced while displaying menu
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace NicheGraphics::InkHUD
|
|||||||
enum MenuPage : uint8_t {
|
enum MenuPage : uint8_t {
|
||||||
ROOT, // Initial menu page
|
ROOT, // Initial menu page
|
||||||
SEND,
|
SEND,
|
||||||
|
CANNEDMESSAGE_RECIPIENT, // Select destination for a canned message
|
||||||
OPTIONS,
|
OPTIONS,
|
||||||
APPLETS,
|
APPLETS,
|
||||||
AUTOSHOW,
|
AUTOSHOW,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user