mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-20 17:52:35 +00:00
Compare commits
112 Commits
multicast-
...
v2.6.5.fc3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc3d9f2a15 | ||
|
|
69f938ea98 | ||
|
|
ec298199ee | ||
|
|
0d800b7a22 | ||
|
|
1b1d4625aa | ||
|
|
fb2010552f | ||
|
|
c94dd1e331 | ||
|
|
cfc2a96a45 | ||
|
|
c0dab4a672 | ||
|
|
12d1305618 | ||
|
|
a084073cc1 | ||
|
|
e2933bcb5b | ||
|
|
606abfc116 | ||
|
|
860e8eca5a | ||
|
|
5a9d70b445 | ||
|
|
2125c03974 | ||
|
|
56eb0c08b2 | ||
|
|
1b33189fe6 | ||
|
|
25237a15ff | ||
|
|
0110275494 | ||
|
|
4dfba50304 | ||
|
|
7494106170 | ||
|
|
0665802823 | ||
|
|
1017f6af35 | ||
|
|
11bafae287 | ||
|
|
31130fd49e | ||
|
|
594cb0cc1e | ||
|
|
ef18a9b5b5 | ||
|
|
67fddcc214 | ||
|
|
f6ed10f329 | ||
|
|
644849126c | ||
|
|
ea4ce8d827 | ||
|
|
128c347c64 | ||
|
|
ae88759059 | ||
|
|
2c01fad798 | ||
|
|
a5efbfccd7 | ||
|
|
886bffe8f3 | ||
|
|
39408fd3b1 | ||
|
|
3314b00fcc | ||
|
|
72db671e00 | ||
|
|
bd2d2981c9 | ||
|
|
da26ff5b95 | ||
|
|
f626f02005 | ||
|
|
f18f60cd0b | ||
|
|
850d21dcb9 | ||
|
|
e08177ba98 | ||
|
|
b52c355f2f | ||
|
|
e79d4492e8 | ||
|
|
95523a9659 | ||
|
|
32d91ed859 | ||
|
|
a93d779ec0 | ||
|
|
38c8c20a2b | ||
|
|
b89355ffa6 | ||
|
|
8a4a0cc932 | ||
|
|
cbcdc3ed00 | ||
|
|
d663d44647 | ||
|
|
3148e7277d | ||
|
|
7df327664e | ||
|
|
a902776e57 | ||
|
|
ea9485657e | ||
|
|
0491c890d7 | ||
|
|
4a3991a8c6 | ||
|
|
c602bfecbd | ||
|
|
6c7c0770f9 | ||
|
|
89cde1a8e6 | ||
|
|
02237f5ac6 | ||
|
|
4a12b4eb32 | ||
|
|
a2387c79ee | ||
|
|
d7504921fb | ||
|
|
4e1030ef9c | ||
|
|
1e41c994b3 | ||
|
|
4590ef2e7b | ||
|
|
769f0623be | ||
|
|
52527b24a7 | ||
|
|
6c17694b64 | ||
|
|
640e731ad2 | ||
|
|
ba81a8ad87 | ||
|
|
83d8e3cb09 | ||
|
|
6429eca5e4 | ||
|
|
13101c1bab | ||
|
|
d28af68b5a | ||
|
|
53a7afff41 | ||
|
|
eb375d8e62 | ||
|
|
33f2b7144f | ||
|
|
e5f8218d34 | ||
|
|
0ddb507055 | ||
|
|
3afe84c4f4 | ||
|
|
e9d8a3d7f9 | ||
|
|
e722a97987 | ||
|
|
daa4186d65 | ||
|
|
1ee800e901 | ||
|
|
cf7f0f9d08 | ||
|
|
1e4a0134e6 | ||
|
|
0951fdd49b | ||
|
|
848a3ed6a1 | ||
|
|
fd7a1f2ccb | ||
|
|
5acaf8f897 | ||
|
|
cff93adb5e | ||
|
|
e4d3ec1f59 | ||
|
|
ae27aaaf43 | ||
|
|
31c0e8fa2c | ||
|
|
0d95b1afcc | ||
|
|
46235f6f8b | ||
|
|
d1068fd1e4 | ||
|
|
f41afb14b1 | ||
|
|
f8ad02aab3 | ||
|
|
077759e15d | ||
|
|
22aa2d7582 | ||
|
|
6673cb9292 | ||
|
|
8efc9702d3 | ||
|
|
2876eec7ed | ||
|
|
9cc13e628a |
@@ -29,6 +29,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
gpg \
|
||||
gnupg2 \
|
||||
libusb-1.0-0-dev \
|
||||
libuv1-dev \
|
||||
libi2c-dev \
|
||||
libxcb-xkb-dev \
|
||||
libxkbcommon-dev \
|
||||
|
||||
9
.github/ISSUE_TEMPLATE/Bug Report.yml
vendored
9
.github/ISSUE_TEMPLATE/Bug Report.yml
vendored
@@ -72,6 +72,15 @@ body:
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: checkboxes
|
||||
id: mui
|
||||
attributes:
|
||||
label: Is this bug report about any UI component firmware like InkHUD or Meshtatic UI (MUI)?
|
||||
options:
|
||||
- label: Meshtastic UI aka MUI colorTFT
|
||||
- label: InkHUD ePaper
|
||||
- label: OLED slide UI on any display
|
||||
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
|
||||
9
.github/actions/build-variant/action.yml
vendored
9
.github/actions/build-variant/action.yml
vendored
@@ -43,6 +43,13 @@ runs:
|
||||
id: base
|
||||
uses: ./.github/actions/setup-base
|
||||
|
||||
- name: Get web ui version
|
||||
if: inputs.include-web-ui == 'true'
|
||||
id: webver
|
||||
shell: bash
|
||||
run: |
|
||||
echo "ver=$(cat bin/web.version)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Pull web ui
|
||||
if: inputs.include-web-ui == 'true'
|
||||
uses: dsaltares/fetch-gh-release-asset@master
|
||||
@@ -51,7 +58,7 @@ runs:
|
||||
file: build.tar
|
||||
target: build.tar
|
||||
token: ${{ inputs.github_token }}
|
||||
version: tags/v2.5.3
|
||||
version: tags/v${{ steps.webver.outputs.ver }}
|
||||
|
||||
- name: Unpack web ui
|
||||
if: inputs.include-web-ui == 'true'
|
||||
|
||||
2
.github/actions/setup-native/action.yml
vendored
2
.github/actions/setup-native/action.yml
vendored
@@ -11,4 +11,4 @@ runs:
|
||||
- name: Install libs needed for native build
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get install -y libbluetooth-dev libgpiod-dev libyaml-cpp-dev openssl libssl-dev libulfius-dev liborcania-dev libusb-1.0-0-dev libi2c-dev
|
||||
sudo apt-get install -y libbluetooth-dev libgpiod-dev libyaml-cpp-dev openssl libssl-dev libulfius-dev liborcania-dev libusb-1.0-0-dev libi2c-dev libuv1-dev
|
||||
|
||||
18
.github/pull_request_template.md
vendored
18
.github/pull_request_template.md
vendored
@@ -1,7 +1,6 @@
|
||||
## 🙏 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) ❌
|
||||
|
||||
## Thank you for sending in a pull request, here's some tips to get started!
|
||||
|
||||
- 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
|
||||
is appreciated." This will allow other devs to potentially save you time by not accidentially duplicating work etc...
|
||||
@@ -12,4 +11,17 @@
|
||||
- If your PR fixes a bug, mention "fixes #bugnum" somewhere in your pull request description.
|
||||
- If your other co-developers have comments on your PR please tweak as needed.
|
||||
- Please also enable "Allow edits by maintainers".
|
||||
- Please do not submit untested code.
|
||||
- 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
|
||||
|
||||
|
||||
## 🤝 Attestations
|
||||
- [ ] 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:
|
||||
- [ ] Heltec (Lora32) V3
|
||||
- [ ] LilyGo T-Deck
|
||||
- [ ] LilyGo T-Beam
|
||||
- [ ] RAK WisBlock 4631
|
||||
- [ ] Seeed Studio T-1000E tracker card
|
||||
- [ ] Other (please specify below)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
version: 0.1
|
||||
cli:
|
||||
version: 1.22.11
|
||||
version: 1.22.12
|
||||
plugins:
|
||||
sources:
|
||||
- id: trunk
|
||||
@@ -9,26 +9,25 @@ plugins:
|
||||
lint:
|
||||
enabled:
|
||||
- prettier@3.5.3
|
||||
- trufflehog@3.88.17
|
||||
- yamllint@1.36.0
|
||||
- trufflehog@3.88.23
|
||||
- yamllint@1.37.0
|
||||
- bandit@1.8.3
|
||||
- checkov@3.2.386
|
||||
- terrascan@1.19.9
|
||||
- trivy@0.60.0
|
||||
- trivy@0.61.0
|
||||
- taplo@0.9.3
|
||||
- ruff@0.10.0
|
||||
- ruff@0.11.4
|
||||
- isort@6.0.1
|
||||
- markdownlint@0.44.0
|
||||
- oxipng@9.1.4
|
||||
- svgo@3.3.2
|
||||
- actionlint@1.7.7
|
||||
- flake8@7.1.2
|
||||
- flake8@7.2.0
|
||||
- hadolint@2.12.1-beta
|
||||
- shfmt@3.6.0
|
||||
- shellcheck@0.10.0
|
||||
- black@25.1.0
|
||||
- git-diff-check
|
||||
- gitleaks@8.24.0
|
||||
- gitleaks@8.24.2
|
||||
- clang-format@16.0.3
|
||||
ignore:
|
||||
- linters: [ALL]
|
||||
|
||||
17
Dockerfile
17
Dockerfile
@@ -12,8 +12,8 @@ ENV TZ=Etc/UTC
|
||||
# Install Dependencies
|
||||
ENV PIP_ROOT_USER_ACTION=ignore
|
||||
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||
wget g++ zip git ca-certificates \
|
||||
libgpiod-dev libyaml-cpp-dev libbluetooth-dev libi2c-dev \
|
||||
curl wget g++ zip git ca-certificates \
|
||||
libgpiod-dev libyaml-cpp-dev libbluetooth-dev libi2c-dev libuv1-dev \
|
||||
libusb-1.0-0-dev libulfius-dev liborcania-dev libssl-dev pkg-config \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
|
||||
&& pip install --no-cache-dir -U platformio \
|
||||
@@ -27,6 +27,12 @@ COPY . /tmp/firmware
|
||||
RUN bash ./bin/build-native.sh && \
|
||||
cp "/tmp/firmware/release/meshtasticd_linux_$(uname -m)" "/tmp/firmware/release/meshtasticd"
|
||||
|
||||
# Fetch web assets
|
||||
RUN curl -L "https://github.com/meshtastic/web/releases/download/v$(cat /tmp/firmware/bin/web.version)/build.tar" -o /tmp/web.tar \
|
||||
&& mkdir -p /tmp/web \
|
||||
&& tar -xf /tmp/web.tar -C /tmp/web/ \
|
||||
&& gzip -dr /tmp/web \
|
||||
&& rm /tmp/web.tar
|
||||
|
||||
##### PRODUCTION BUILD #############
|
||||
|
||||
@@ -38,7 +44,7 @@ ENV TZ=Etc/UTC
|
||||
USER root
|
||||
|
||||
RUN apt-get update && apt-get --no-install-recommends -y install \
|
||||
libc-bin libc6 libgpiod2 libyaml-cpp0.7 libi2c0 libulfius2.7 libusb-1.0-0-dev liborcania2.3 libssl3 \
|
||||
libc-bin libc6 libgpiod2 libyaml-cpp0.7 libi2c0 libuv1 libusb-1.0-0-dev liborcania2.3 libulfius2.7 libssl3 \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
|
||||
&& mkdir -p /var/lib/meshtasticd \
|
||||
&& mkdir -p /etc/meshtasticd/config.d \
|
||||
@@ -46,6 +52,7 @@ RUN apt-get update && apt-get --no-install-recommends -y install \
|
||||
|
||||
# Fetch compiled binary from the builder
|
||||
COPY --from=builder /tmp/firmware/release/meshtasticd /usr/sbin/
|
||||
COPY --from=builder /tmp/web /usr/share/meshtasticd/
|
||||
# Copy config templates
|
||||
COPY ./bin/config.d /etc/meshtasticd/available.d
|
||||
|
||||
@@ -54,7 +61,9 @@ VOLUME /var/lib/meshtasticd
|
||||
|
||||
# Expose Meshtastic TCP API port from the host
|
||||
EXPOSE 4403
|
||||
# Expose Meshtastic Web UI port from the host
|
||||
EXPOSE 443
|
||||
|
||||
CMD [ "sh", "-cx", "meshtasticd -d /var/lib/meshtasticd" ]
|
||||
|
||||
HEALTHCHECK NONE
|
||||
HEALTHCHECK NONE
|
||||
|
||||
@@ -9,7 +9,7 @@ FROM python:3.13-alpine3.21 AS builder
|
||||
ENV PIP_ROOT_USER_ACTION=ignore
|
||||
RUN apk --no-cache add \
|
||||
bash g++ libstdc++-dev linux-headers zip git ca-certificates libgpiod-dev yaml-cpp-dev bluez-dev \
|
||||
libusb-dev i2c-tools-dev openssl-dev pkgconf argp-standalone \
|
||||
libusb-dev i2c-tools-dev libuv-dev openssl-dev pkgconf argp-standalone \
|
||||
&& rm -rf /var/cache/apk/* \
|
||||
&& pip install --no-cache-dir -U platformio \
|
||||
&& mkdir /tmp/firmware
|
||||
@@ -32,7 +32,7 @@ FROM alpine:3.21
|
||||
USER root
|
||||
|
||||
RUN apk --no-cache add \
|
||||
libstdc++ libgpiod yaml-cpp libusb i2c-tools \
|
||||
libstdc++ libgpiod yaml-cpp libusb i2c-tools libuv \
|
||||
&& rm -rf /var/cache/apk/* \
|
||||
&& mkdir -p /var/lib/meshtasticd \
|
||||
&& mkdir -p /etc/meshtasticd/config.d \
|
||||
|
||||
@@ -45,11 +45,11 @@ lib_deps =
|
||||
${networking_base.lib_deps}
|
||||
${environmental_base.lib_deps}
|
||||
${radiolib_base.lib_deps}
|
||||
https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2
|
||||
https://github.com/meshtastic/esp32_https_server/archive/23665b3adc080a311dcbb586ed5941b5f94d6ea2.zip
|
||||
h2zero/NimBLE-Arduino@^1.4.3
|
||||
https://github.com/dbinfrago/libpax.git#3cdc0371c375676a97967547f4065607d4c53fd1
|
||||
https://github.com/dbinfrago/libpax/archive/3cdc0371c375676a97967547f4065607d4c53fd1.zip
|
||||
lewisxhe/XPowersLib@^0.2.7
|
||||
https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f
|
||||
https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip
|
||||
rweather/Crypto@^0.4.0
|
||||
|
||||
lib_ignore =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[esp32c6_base]
|
||||
extends = esp32_base
|
||||
platform = https://github.com/Jason2866/platform-espressif32.git#22faa566df8c789000f8136cd8d0aca49617af55
|
||||
platform = https://github.com/Jason2866/platform-espressif32/archive/22faa566df8c789000f8136cd8d0aca49617af55.zip
|
||||
build_flags =
|
||||
${arduino_base.build_flags}
|
||||
-Wall
|
||||
@@ -25,7 +25,7 @@ lib_deps =
|
||||
${environmental_base.lib_deps}
|
||||
${radiolib_base.lib_deps}
|
||||
lewisxhe/XPowersLib@^0.2.7
|
||||
https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f
|
||||
https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip
|
||||
rweather/Crypto@^0.4.0
|
||||
|
||||
build_src_filter =
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
[nrf52_base]
|
||||
; Instead of the standard nordicnrf52 platform, we use our fork which has our added variant files
|
||||
platform = platformio/nordicnrf52@^10.7.0
|
||||
platform = platformio/nordicnrf52@^10.8.0
|
||||
extends = arduino_base
|
||||
platform_packages =
|
||||
; our custom Git version until they merge our PR
|
||||
platformio/framework-arduinoadafruitnrf52 @ https://github.com/meshtastic/Adafruit_nRF52_Arduino.git#e13f5820002a4fb2a5e6754b42ace185277e5adf
|
||||
platformio/framework-arduinoadafruitnrf52 @ https://github.com/meshtastic/Adafruit_nRF52_Arduino#e13f5820002a4fb2a5e6754b42ace185277e5adf
|
||||
platformio/toolchain-gccarmnoneeabi@~1.90301.0
|
||||
|
||||
build_type = debug
|
||||
@@ -17,7 +17,6 @@ build_flags =
|
||||
-DLFS_NO_ASSERT ; Disable LFS assertions , see https://github.com/meshtastic/firmware/pull/3818
|
||||
-DMESHTASTIC_EXCLUDE_AUDIO=1
|
||||
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
|
||||
-DMAX_NUM_NODES=80
|
||||
|
||||
build_src_filter =
|
||||
${arduino_base.build_src_filter} -<platform/esp32/> -<platform/stm32wl> -<nimble/> -<mesh/wifi/> -<mesh/api/> -<mesh/http/> -<modules/esp32> -<platform/rp2xx0> -<mesh/eth/> -<mesh/raspihttp>
|
||||
|
||||
@@ -6,7 +6,7 @@ build_flags = ${nrf52_base.build_flags}
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
${environmental_base.lib_deps}
|
||||
https://github.com/Kongduino/Adafruit_nRFCrypto.git#e31a8825ea3300b163a0a3c1ddd5de34e10e1371
|
||||
https://github.com/Kongduino/Adafruit_nRFCrypto/archive/e31a8825ea3300b163a0a3c1ddd5de34e10e1371.zip
|
||||
|
||||
; Common NRF52 debugging settings follow. See the Meshtastic developer docs for how to connect SWD debugging probes to your board.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
; The Portduino based 'native' environment. Currently supported on Linux targets with real LoRa hardware (or simulated).
|
||||
[portduino_base]
|
||||
platform = https://github.com/meshtastic/platform-native.git#562d189828f09fbf4c4093b3c0104bae9d8e9ff9
|
||||
platform = https://github.com/meshtastic/platform-native/archive/c5bd469ab9b5a6966321e09557b27d906961da63.zip
|
||||
framework = arduino
|
||||
|
||||
build_src_filter =
|
||||
@@ -26,7 +26,7 @@ lib_deps =
|
||||
${radiolib_base.lib_deps}
|
||||
rweather/Crypto@^0.4.0
|
||||
lovyan03/LovyanGFX@^1.2.0
|
||||
https://github.com/pine64/libch341-spi-userspace#a9b17e3452f7fb747000d9b4ad4409155b39f6ef
|
||||
https://github.com/pine64/libch341-spi-userspace/archive/a9b17e3452f7fb747000d9b4ad4409155b39f6ef.zip
|
||||
|
||||
build_flags =
|
||||
${arduino_base.build_flags}
|
||||
@@ -34,10 +34,12 @@ build_flags =
|
||||
-Isrc/platform/portduino
|
||||
-DRADIOLIB_EEPROM_UNSUPPORTED
|
||||
-DPORTDUINO_LINUX_HARDWARE
|
||||
-DHAS_UDP_MULTICAST
|
||||
-lpthread
|
||||
-lstdc++fs
|
||||
-lbluetooth
|
||||
-lgpiod
|
||||
-lyaml-cpp
|
||||
-li2c
|
||||
-luv
|
||||
-std=c++17
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
; Common settings for rp2040 Processor based targets
|
||||
[rp2040_base]
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi.git#76ecf3c7e9dd4503af0331154c4ca1cddc4b03e5 ; For arduino-pico >= 4.4.3
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi#76ecf3c7e9dd4503af0331154c4ca1cddc4b03e5 ; For arduino-pico >= 4.4.3
|
||||
extends = arduino_base
|
||||
platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#4.4.3
|
||||
platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico#4.4.3
|
||||
|
||||
board_build.core = earlephilhower
|
||||
board_build.filesystem_size = 0.5m
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
; Common settings for rp2040 Processor based targets
|
||||
[rp2350_base]
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi.git#76ecf3c7e9dd4503af0331154c4ca1cddc4b03e5 ; For arduino-pico >= 4.4.3
|
||||
platform = https://github.com/maxgerhardt/platform-raspberrypi#76ecf3c7e9dd4503af0331154c4ca1cddc4b03e5 ; For arduino-pico >= 4.4.3
|
||||
extends = arduino_base
|
||||
platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#4.4.3
|
||||
platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico#4.4.3
|
||||
|
||||
board_build.core = earlephilhower
|
||||
board_build.filesystem_size = 0.5m
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
[stm32_base]
|
||||
extends = arduino_base
|
||||
platform = platformio/ststm32
|
||||
platform_packages = platformio/framework-arduinoststm32@^4.20900.0
|
||||
platform = ststm32
|
||||
platform_packages = platformio/framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/2.10.1.zip
|
||||
extra_scripts =
|
||||
${env.extra_scripts}
|
||||
post:extra_scripts/extra_stm32.py
|
||||
|
||||
build_type = release
|
||||
|
||||
;board_build.flash_offset = 0x08000000
|
||||
|
||||
build_flags =
|
||||
build_flags =
|
||||
${arduino_base.build_flags}
|
||||
-flto
|
||||
-Isrc/platform/stm32wl -g
|
||||
@@ -18,27 +19,24 @@ build_flags =
|
||||
-DMESHTASTIC_EXCLUDE_SCREEN
|
||||
-DMESHTASTIC_EXCLUDE_MQTT
|
||||
-DMESHTASTIC_EXCLUDE_BLUETOOTH
|
||||
-DMESHTASTIC_EXCLUDE_PKI
|
||||
-DMESHTASTIC_EXCLUDE_GPS
|
||||
; -DVECT_TAB_OFFSET=0x08000000
|
||||
-DconfigUSE_CMSIS_RTOS_V2=1
|
||||
; -DSPI_MODE_0=SPI_MODE0
|
||||
;-DDEBUG_MUTE
|
||||
-fmerge-all-constants
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
|
||||
build_src_filter =
|
||||
|
||||
build_src_filter =
|
||||
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<mesh/api/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mesh/eth/> -<input> -<buzz> -<modules/RemoteHardwareModule.cpp> -<platform/nrf52> -<platform/portduino> -<platform/rp2xx0> -<mesh/raspihttp>
|
||||
|
||||
board_upload.offset_address = 0x08000000
|
||||
upload_protocol = stlink
|
||||
debug_tool = stlink
|
||||
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
charlesbaynham/OSFS@^1.2.3
|
||||
jgromes/RadioLib@7.0.2
|
||||
https://github.com/caveman99/Crypto.git#f61ae26a53f7a2d0ba5511625b8bf8eff3a35d5e
|
||||
${radiolib_base.lib_deps}
|
||||
https://github.com/caveman99/Crypto/archive/eae9c768054118a9399690f8af202853d1ae8516.zip
|
||||
|
||||
lib_ignore =
|
||||
mathertel/OneButton@2.6.1
|
||||
Wire
|
||||
Wire
|
||||
|
||||
@@ -6,6 +6,12 @@
|
||||
### Including the "Module:" line!
|
||||
---
|
||||
Lora:
|
||||
# Default to auto-detecting the module type
|
||||
# This will be overridden by configs from config.d
|
||||
Module: auto
|
||||
|
||||
# # Uncomment to enable Simulation mode, or use --sim
|
||||
# Module: sim
|
||||
|
||||
# Module: sx1262 # Waveshare SX1302 LISTEN ONLY AT THIS TIME!
|
||||
# CS: 7
|
||||
@@ -191,5 +197,6 @@ General:
|
||||
MaxNodes: 200
|
||||
MaxMessageQueue: 100
|
||||
ConfigDirectory: /etc/meshtasticd/config.d/
|
||||
AvailableDirectory: /etc/meshtasticd/available.d/
|
||||
# MACAddress: AA:BB:CC:DD:EE:FF
|
||||
# MACAddressSource: eth0
|
||||
# MACAddressSource: eth0
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Module: RF95 # Adafruit RFM9x
|
||||
# Reset: 25
|
||||
# CS: 7
|
||||
# IRQ: 22
|
||||
# Busy: 23
|
||||
6
bin/config.d/lora-Adafruit-RFM9x.yaml
Normal file
6
bin/config.d/lora-Adafruit-RFM9x.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
Lora:
|
||||
Module: RF95 # Adafruit RFM9x
|
||||
Reset: 25
|
||||
CS: 7
|
||||
IRQ: 22
|
||||
# Busy: 23
|
||||
@@ -1,3 +1,5 @@
|
||||
# MeshAdv-Pi E22-900M30S
|
||||
# https://github.com/chrismyers2000/MeshAdv-Pi-Hat
|
||||
Lora:
|
||||
Module: sx1262
|
||||
CS: 21
|
||||
@@ -9,4 +11,4 @@ Lora:
|
||||
DIO3_TCXO_VOLTAGE: true
|
||||
# Only for E22-900M33S:
|
||||
# Limit the output power to 8 dBm
|
||||
# SX126X_MAX_POWER: 8
|
||||
# SX126X_MAX_POWER: 8
|
||||
|
||||
11
bin/config.d/lora-MeshAdv-Mini-900M22S.yaml
Normal file
11
bin/config.d/lora-MeshAdv-Mini-900M22S.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
# MeshAdv Mini E22-900M22S
|
||||
# https://github.com/chrismyers2000/MeshAdv-Mini
|
||||
Lora:
|
||||
Module: sx1262 # Ebyte E22-900M22S
|
||||
CS: 8
|
||||
IRQ: 16
|
||||
Busy: 20
|
||||
Reset: 24
|
||||
TXen: 13
|
||||
DIO2_AS_RF_SWITCH: true
|
||||
DIO3_TCXO_VOLTAGE: true
|
||||
17
bin/config.d/lora-usb-meshtoad-e22.yaml
Normal file
17
bin/config.d/lora-usb-meshtoad-e22.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
Lora:
|
||||
Module: sx1262
|
||||
CS: 0
|
||||
IRQ: 6
|
||||
Reset: 2
|
||||
Busy: 4
|
||||
RXen: 1
|
||||
DIO2_AS_RF_SWITCH: true
|
||||
DIO3_TCXO_VOLTAGE: true
|
||||
spidev: ch341
|
||||
USB_PID: 0x5512
|
||||
USB_VID: 0x1A86
|
||||
# Optional: Reduce power to 10 dBm to
|
||||
# avoid over-drawing the USB port
|
||||
# SX126X_MAX_POWER: 10
|
||||
# Optional: Set the serial number for multi-radio support
|
||||
# USB_Serialnum: 13374201
|
||||
@@ -7,12 +7,19 @@ SET "DEBUG=0"
|
||||
SET "PYTHON="
|
||||
SET "WEB_APP=0"
|
||||
SET "TFT_BUILD=0"
|
||||
SET "TFT8=0"
|
||||
SET "TFT16=0"
|
||||
SET "BIGDB8=0"
|
||||
SET "BIGDB16=0"
|
||||
SET "ESPTOOL_BAUD=115200"
|
||||
SET "ESPTOOL_CMD="
|
||||
SET "LOGCOUNTER=0"
|
||||
|
||||
@REM FIXME: Determine mcu from PlatformIO variant, this is unmaintainable.
|
||||
SET "S3=s3 v3 t-deck wireless-paper wireless-tracker station-g2 unphone"
|
||||
SET "C3=esp32c3"
|
||||
@REM FIXME: Determine flash size from PlatformIO variant, this is unmaintainable.
|
||||
SET "BIGDB_8MB=picomputer-s3 unphone seeed-sensecap-indicator crowpanel-esp32s3 heltec_capsule_sensor_v3 heltec-v3 heltec-vision-master-e213 heltec-vision-master-e290 heltec-vision-master-t190 heltec-wireless-paper heltec-wireless-tracker heltec-wsl-v3 icarus seeed-xiao-s3 tbeam-s3-core t-watch-s3 tracksenger"
|
||||
SET "BIGDB_16MB=t-deck mesh-tab t-energy-s3 dreamcatcher ESP32-S3-Pico m5stack-cores3 station-g2 t-eth-elite"
|
||||
|
||||
GOTO getopts
|
||||
:help
|
||||
ECHO Flash image file to device, but first erasing and writing system information.
|
||||
@@ -34,7 +41,7 @@ ECHO Example: %SCRIPT_NAME% -f firmware-unphone-2.6.0.0b106d4.bin -p COM11 --web
|
||||
GOTO eof
|
||||
|
||||
:version
|
||||
ECHO %SCRIPT_NAME% [Version 2.6.0]
|
||||
ECHO %SCRIPT_NAME% [Version 2.6.1]
|
||||
ECHO Meshtastic
|
||||
GOTO eof
|
||||
|
||||
@@ -106,7 +113,7 @@ IF NOT "__%PYTHON%__"=="____" (
|
||||
|
||||
CALL :LOG_MESSAGE DEBUG "Checking esptool command !ESPTOOL_CMD!..."
|
||||
!ESPTOOL_CMD! >nul 2>&1
|
||||
IF %ERRORLEVEL% GTR 2 (
|
||||
IF %ERRORLEVEL% GEQ 2 (
|
||||
@REM esptool exits with code 1 if help is displayed.
|
||||
CALL :LOG_MESSAGE ERROR "esptool not found: !ESPTOOL_CMD!"
|
||||
EXIT /B 1
|
||||
@@ -121,6 +128,7 @@ CALL :LOG_MESSAGE DEBUG "Using esptool command: !ESPTOOL_CMD!"
|
||||
IF "__!ESPTOOL_PORT!__" == "____" (
|
||||
CALL :LOG_MESSAGE WARN "Using esptool port: UNSET."
|
||||
) ELSE (
|
||||
SET "ESPTOOL_CMD=!ESPTOOL_CMD! --port !ESPTOOL_PORT!"
|
||||
CALL :LOG_MESSAGE INFO "Using esptool port: !ESPTOOL_PORT!."
|
||||
)
|
||||
CALL :LOG_MESSAGE INFO "Using esptool baud: !ESPTOOL_BAUD!."
|
||||
@@ -133,44 +141,36 @@ IF NOT "!FILENAME:-tft-=!"=="!FILENAME!" (
|
||||
CALL :LOG_MESSAGE ERROR "Cannot enable WebUI (--web) and MUI." & GOTO eof
|
||||
)
|
||||
SET "TFT_BUILD=1"
|
||||
GOTO tft
|
||||
) ELSE (
|
||||
CALL :LOG_MESSAGE DEBUG "We are NOT working with a *-tft-* file. !FILENAME!"
|
||||
GOTO no_tft
|
||||
)
|
||||
|
||||
:tft
|
||||
SET "TFT8MB=picomputer-s3 unphone seeed-sensecap-indicator"
|
||||
FOR %%a IN (%TFT8MB%) DO (
|
||||
FOR %%a IN (%BIGDB_8MB%) DO (
|
||||
IF NOT "!FILENAME:%%a=!"=="!FILENAME!" (
|
||||
@REM We are working with any of %TFT8MB%.
|
||||
SET "TFT8=1"
|
||||
GOTO end_loop_tft8mb
|
||||
@REM We are working with any of %BIGDB_8MB%.
|
||||
SET "BIGDB8=1"
|
||||
GOTO end_loop_bigdb_8mb
|
||||
)
|
||||
)
|
||||
:end_loop_tft8mb
|
||||
:end_loop_bigdb_8mb
|
||||
|
||||
SET "TFT16MB=t-deck"
|
||||
FOR %%a IN (%TFT16MB%) DO (
|
||||
FOR %%a IN (%BIGDB_16MB%) DO (
|
||||
IF NOT "!FILENAME:%%a=!"=="!FILENAME!" (
|
||||
@REM We are working with any of %TFT16MB%.
|
||||
SET "TFT16=1"
|
||||
GOTO end_loop_tft16mb
|
||||
@REM We are working with any of %BIGDB_16MB%.
|
||||
SET "BIGDB16=1"
|
||||
GOTO end_loop_bigdb_16mb
|
||||
)
|
||||
)
|
||||
:end_loop_tft16mb
|
||||
:end_loop_bigdb_16mb
|
||||
|
||||
IF %TFT8% EQU 1 CALL :LOG_MESSAGE INFO "tft and MUI 8mb selected."
|
||||
IF %TFT16% EQU 1 CALL :LOG_MESSAGE INFO "tft and MUI 16mb selected."
|
||||
|
||||
:no_tft
|
||||
IF %BIGDB8% EQU 1 CALL :LOG_MESSAGE INFO "BigDB 8mb partition selected."
|
||||
IF %BIGDB16% EQU 1 CALL :LOG_MESSAGE INFO "BigDB 16mb partition selected."
|
||||
|
||||
@REM Extract BASENAME from %FILENAME% for later use.
|
||||
SET "BASENAME=!FILENAME:firmware-=!"
|
||||
CALL :LOG_MESSAGE DEBUG "Computed firmware basename: !BASENAME!"
|
||||
|
||||
@REM Account for S3 and C3 board's different OTA partition.
|
||||
SET "S3=s3 v3 t-deck wireless-paper wireless-tracker station-g2 unphone"
|
||||
FOR %%a IN (%S3%) DO (
|
||||
IF NOT "!FILENAME:%%a=!"=="!FILENAME!" (
|
||||
@REM We are working with any of %S3%.
|
||||
@@ -179,7 +179,6 @@ FOR %%a IN (%S3%) DO (
|
||||
)
|
||||
)
|
||||
|
||||
SET "C3=esp32c3"
|
||||
FOR %%a IN (%C3%) DO (
|
||||
IF NOT "!FILENAME:%%a=!"=="!FILENAME!" (
|
||||
@REM We are working with any of %C3%.
|
||||
@@ -208,14 +207,14 @@ CALL :LOG_MESSAGE DEBUG "Set SPIFFS_FILENAME to: !SPIFFS_FILENAME!"
|
||||
SET "OTA_OFFSET=0x260000"
|
||||
SET "SPIFFS_OFFSET=0x300000"
|
||||
|
||||
@REM Offsets for MUI 8mb.
|
||||
IF %TFT8% EQU 1 IF %TFT_BUILD% EQU 1 (
|
||||
@REM Offsets for BigDB 8mb.
|
||||
IF %BIGDB8% EQU 1 (
|
||||
SET "OTA_OFFSET=0x340000"
|
||||
SET "SPIFFS_OFFSET=0x670000"
|
||||
)
|
||||
|
||||
@REM Offsets for MUI 16mb.
|
||||
IF %TFT16% EQU 1 IF %TFT_BUILD% EQU 1 (
|
||||
@REM Offsets for BigDB 16mb.
|
||||
IF %BIGDB16% EQU 1 (
|
||||
SET "OTA_OFFSET=0x650000"
|
||||
SET "SPIFFS_OFFSET=0xc90000"
|
||||
)
|
||||
|
||||
@@ -2,9 +2,48 @@
|
||||
|
||||
PYTHON=${PYTHON:-$(which python3 python | head -n 1)}
|
||||
WEB_APP=false
|
||||
TFT8=false
|
||||
TFT16=false
|
||||
TFT_BUILD=false
|
||||
MCU=""
|
||||
|
||||
# Variant groups
|
||||
BIGDB_8MB=(
|
||||
"picomputer-s3"
|
||||
"unphone"
|
||||
"seeed-sensecap-indicator"
|
||||
"crowpanel-esp32s3"
|
||||
"heltec_capsule_sensor_v3"
|
||||
"heltec-v3"
|
||||
"heltec-vision-master-e213"
|
||||
"heltec-vision-master-e290"
|
||||
"heltec-vision-master-t190"
|
||||
"heltec-wireless-paper"
|
||||
"heltec-wireless-tracker"
|
||||
"heltec-wsl-v3"
|
||||
"icarus"
|
||||
"seeed-xiao-s3"
|
||||
"tbeam-s3-core"
|
||||
"t-watch-s3"
|
||||
"tracksenger"
|
||||
)
|
||||
BIGDB_16MB=(
|
||||
"t-deck"
|
||||
"mesh-tab"
|
||||
"t-energy-s3"
|
||||
"dreamcatcher"
|
||||
"ESP32-S3-Pico"
|
||||
"m5stack-cores3"
|
||||
"station-g2"
|
||||
"t-eth-elite"
|
||||
)
|
||||
S3_VARIANTS=(
|
||||
"s3"
|
||||
"-v3"
|
||||
"t-deck"
|
||||
"wireless-paper"
|
||||
"wireless-tracker"
|
||||
"station-g2"
|
||||
"unphone"
|
||||
)
|
||||
|
||||
# Determine the correct esptool command to use
|
||||
if "$PYTHON" -m esptool version >/dev/null 2>&1; then
|
||||
@@ -42,8 +81,8 @@ while [ $# -gt 0 ]; do
|
||||
exit 0
|
||||
;;
|
||||
-p)
|
||||
ESPTOOL_PORT="$2"
|
||||
shift # Shift past the option argument
|
||||
ESPTOOL_CMD="$ESPTOOL_CMD --port $2"
|
||||
shift
|
||||
;;
|
||||
-P)
|
||||
PYTHON="$2"
|
||||
@@ -78,21 +117,13 @@ if [[ $FILENAME != firmware-* ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if FILENAME contains "-tft-" and set target partitionScheme accordingly.
|
||||
# Check if FILENAME contains "-tft-" and prevent web/mui comingling.
|
||||
if [[ ${FILENAME//-tft-/} != "$FILENAME" ]]; then
|
||||
TFT_BUILD=true
|
||||
if [[ $WEB_APP == true ]] && [[ $TFT_BUILD == true ]]; then
|
||||
echo "Cannot enable WebUI (--web) and MUI."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $FILENAME == *"picomputer-s3"* || $FILENAME == *"unphone"* || $FILENAME == *"seeed-sensecap-indicator"* ]]; then
|
||||
TFT8=true
|
||||
fi
|
||||
|
||||
if [[ $FILENAME == *"t-deck"* ]]; then
|
||||
TFT16=true
|
||||
fi
|
||||
fi
|
||||
|
||||
# Extract BASENAME from %FILENAME% for later use.
|
||||
@@ -105,20 +136,31 @@ if [ -f "${FILENAME}" ] && [ -n "${FILENAME##*"update"*}" ]; then
|
||||
# Default OTA Offset
|
||||
OTA_OFFSET=0x260000
|
||||
|
||||
# littlefs* offset for MUI 8mb and OTA OFFSET.
|
||||
if [ "$TFT8" = true ] && [ "$TFT_BUILD" = true ]; then
|
||||
OFFSET=0x670000
|
||||
OTA_OFFSET=0x340000
|
||||
fi
|
||||
# littlefs* offset for BigDB 8mb and OTA OFFSET.
|
||||
for variant in "${BIGDB_8MB[@]}"; do
|
||||
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
||||
OFFSET=0x670000
|
||||
OTA_OFFSET=0x340000
|
||||
fi
|
||||
done
|
||||
|
||||
# littlefs* offset for MUI 16mb and OTA OFFSET.
|
||||
if [ "$TFT16" = true ] && [ "$TFT_BUILD" = true ]; then
|
||||
OFFSET=0xc90000
|
||||
OTA_OFFSET=0x650000
|
||||
fi
|
||||
# littlefs* offset for BigDB 16mb and OTA OFFSET.
|
||||
for variant in "${BIGDB_16MB[@]}"; do
|
||||
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
||||
OFFSET=0xc90000
|
||||
OTA_OFFSET=0x650000
|
||||
fi
|
||||
done
|
||||
|
||||
# Account for S3 board's different OTA partition
|
||||
if [ -n "${FILENAME##*"s3"*}" ] && [ -n "${FILENAME##*"-v3"*}" ] && [ -n "${FILENAME##*"t-deck"*}" ] && [ -n "${FILENAME##*"wireless-paper"*}" ] && [ -n "${FILENAME##*"wireless-tracker"*}" ] && [ -n "${FILENAME##*"station-g2"*}" ] && [ -n "${FILENAME##*"unphone"*}" ]; then
|
||||
# FIXME: Use PlatformIO info to determine MCU type, this is unmaintainable
|
||||
for variant in "${S3_VARIANTS[@]}"; do
|
||||
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
||||
MCU="esp32s3"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$MCU" != "esp32s3" ]; then
|
||||
if [ -n "${FILENAME##*"esp32c3"*}" ]; then
|
||||
OTAFILE=bleota.bin
|
||||
else
|
||||
|
||||
@@ -16,7 +16,7 @@ ECHO.
|
||||
ECHO Usage: %SCRIPT_NAME% -f filename [-p PORT] [-P python]
|
||||
ECHO.
|
||||
ECHO Options:
|
||||
ECHO -f filename The .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)
|
||||
ECHO The file must be located in this current directory.
|
||||
ECHO -p PORT Set the environment variable for ESPTOOL_PORT.
|
||||
ECHO If not set, ESPTOOL iterates all ports (Dangerous).
|
||||
@@ -28,7 +28,7 @@ ECHO Example: %SCRIPT_NAME% -f firmware-t-deck-tft-2.6.0.0b106d4-update.bin -p C
|
||||
GOTO eof
|
||||
|
||||
:version
|
||||
ECHO %SCRIPT_NAME% [Version 2.6.0]
|
||||
ECHO %SCRIPT_NAME% [Version 2.6.1]
|
||||
ECHO Meshtastic
|
||||
GOTO eof
|
||||
|
||||
@@ -53,6 +53,7 @@ IF "__!FILENAME!__"=="____" (
|
||||
CALL :LOG_MESSAGE DEBUG "Missing -f filename input."
|
||||
GOTO help
|
||||
) ELSE (
|
||||
CALL :LOG_MESSAGE DEBUG "Filename: !FILENAME!"
|
||||
IF NOT "__!FILENAME: =!__"=="__!FILENAME!__" (
|
||||
CALL :LOG_MESSAGE ERROR "Filename containing spaces are not supported."
|
||||
GOTO help
|
||||
@@ -62,7 +63,6 @@ IF "__!FILENAME!__"=="____" (
|
||||
SET "FILENAME=!FILENAME:./=!"
|
||||
)
|
||||
|
||||
CALL :LOG_MESSAGE DEBUG "Filename: !FILENAME!"
|
||||
CALL :LOG_MESSAGE DEBUG "Checking if !FILENAME! exists..."
|
||||
IF NOT EXIST !FILENAME! (
|
||||
CALL :LOG_MESSAGE ERROR "File does not exist: !FILENAME!. Terminating."
|
||||
@@ -71,7 +71,7 @@ IF NOT EXIST !FILENAME! (
|
||||
|
||||
IF "!FILENAME:update=!"=="!FILENAME!" (
|
||||
CALL :LOG_MESSAGE DEBUG "We are NOT working with a *update* file. !FILENAME!"
|
||||
CALL :LOG_MESSAGE INFO "Use script device-install.bat to flash update !FILENAME!."
|
||||
CALL :LOG_MESSAGE INFO "Use script device-install.bat to flash !FILENAME!."
|
||||
GOTO eof
|
||||
) ELSE (
|
||||
CALL :LOG_MESSAGE DEBUG "We are working with a *update* file. !FILENAME!"
|
||||
@@ -95,7 +95,7 @@ IF NOT "__%PYTHON%__"=="____" (
|
||||
|
||||
CALL :LOG_MESSAGE DEBUG "Checking esptool command !ESPTOOL_CMD!..."
|
||||
!ESPTOOL_CMD! >nul 2>&1
|
||||
IF %ERRORLEVEL% GTR 2 (
|
||||
IF %ERRORLEVEL% GEQ 2 (
|
||||
@REM esptool exits with code 1 if help is displayed.
|
||||
CALL :LOG_MESSAGE ERROR "esptool not found: !ESPTOOL_CMD!"
|
||||
EXIT /B 1
|
||||
@@ -110,6 +110,7 @@ CALL :LOG_MESSAGE DEBUG "Using esptool command: !ESPTOOL_CMD!"
|
||||
IF "__!ESPTOOL_PORT!__" == "____" (
|
||||
CALL :LOG_MESSAGE WARN "Using esptool port: UNSET."
|
||||
) ELSE (
|
||||
SET "ESPTOOL_CMD=!ESPTOOL_CMD! --port !ESPTOOL_PORT!"
|
||||
CALL :LOG_MESSAGE INFO "Using esptool port: !ESPTOOL_PORT!."
|
||||
)
|
||||
CALL :LOG_MESSAGE INFO "Using esptool baud: !ESPTOOL_BAUD!."
|
||||
|
||||
@@ -35,8 +35,8 @@ while getopts ":hp:P:f:" opt; do
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
p) export ESPTOOL_PORT=${OPTARG}
|
||||
;;
|
||||
p) ESPTOOL_CMD="$ESPTOOL_CMD --port ${OPTARG}"
|
||||
;;
|
||||
P) PYTHON=${OPTARG}
|
||||
;;
|
||||
f) FILENAME=${OPTARG}
|
||||
|
||||
@@ -83,7 +83,7 @@ if platform.name == "espressif32":
|
||||
|
||||
if platform.name == "nordicnrf52":
|
||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.hex",
|
||||
env.VerboseAction(f"{sys.executable} ./bin/uf2conv.py $BUILD_DIR/firmware.hex -c -f 0xADA52840 -o $BUILD_DIR/firmware.uf2",
|
||||
env.VerboseAction(f"\"{sys.executable}\" ./bin/uf2conv.py $BUILD_DIR/firmware.hex -c -f 0xADA52840 -o $BUILD_DIR/firmware.uf2",
|
||||
"Generating UF2 file"))
|
||||
|
||||
Import("projenv")
|
||||
|
||||
@@ -2,6 +2,10 @@ function meshtastic_version {
|
||||
meshtastic_version=$(python3 bin/buildinfo.py short)
|
||||
echo -n "$meshtastic_version"
|
||||
}
|
||||
function web_version {
|
||||
web_version=$(cat bin/web.version)
|
||||
echo -n "$web_version"
|
||||
}
|
||||
function git_commits_num {
|
||||
total_commits=$(git rev-list --all --count)
|
||||
echo -n "$total_commits"
|
||||
|
||||
1
bin/web.version
Normal file
1
bin/web.version
Normal file
@@ -0,0 +1 @@
|
||||
2.6.0
|
||||
53
boards/ThinkNode-M1.json
Normal file
53
boards/ThinkNode-M1.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "nrf52840_s140_v6.ld"
|
||||
},
|
||||
"core": "nRF5",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DARDUINO_NRF52840_TTGO_EINK -DNRF52840_XXAA",
|
||||
"f_cpu": "64000000L",
|
||||
"hwids": [
|
||||
["0x239A", "0x4405"],
|
||||
["0x239A", "0x0029"],
|
||||
["0x239A", "0x002A"]
|
||||
],
|
||||
"usb_product": "elecrow_eink",
|
||||
"mcu": "nrf52840",
|
||||
"variant": "ELECROW-ThinkNode-M1",
|
||||
"variants_dir": "variants",
|
||||
"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",
|
||||
"onboard_tools": ["jlink"],
|
||||
"svd_path": "nrf52840.svd",
|
||||
"openocd_target": "nrf52840-mdk-rs"
|
||||
},
|
||||
"frameworks": ["arduino"],
|
||||
"name": "elecrow eink",
|
||||
"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": "FIXME",
|
||||
"vendor": "ELECROW"
|
||||
}
|
||||
@@ -2,7 +2,8 @@
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32s3_out.ld",
|
||||
"partitions": "default_8MB.csv"
|
||||
"partitions": "default_8MB.csv",
|
||||
"memory_type": "qio_opi"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
@@ -15,6 +16,7 @@
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"psram_type": "opi",
|
||||
"hwids": [
|
||||
["0x303A", "0x1001"],
|
||||
["0x303A", "0x0002"]
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32s3_out.ld",
|
||||
"partitions": "default_8MB.csv"
|
||||
"partitions": "default_8MB.csv",
|
||||
"memory_type": "qio_opi"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
@@ -15,6 +16,7 @@
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"psram_type": "opi",
|
||||
"hwids": [
|
||||
["0x303A", "0x1001"],
|
||||
["0x303A", "0x0002"]
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32s3_out.ld",
|
||||
"partitions": "default_8MB.csv"
|
||||
"partitions": "default_8MB.csv",
|
||||
"memory_type": "qio_opi"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
@@ -15,6 +16,7 @@
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"psram_type": "opi",
|
||||
"hwids": [
|
||||
["0x303A", "0x1001"],
|
||||
["0x303A", "0x0002"]
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"f_boot": "120000000L",
|
||||
"boot": "qio",
|
||||
"flash_mode": "qio",
|
||||
"psram_type": "opi",
|
||||
"hwids": [["0x1A86", "0x7523"]],
|
||||
"mcu": "esp32s3",
|
||||
"variant": "esp32s3"
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"psram_type": "opi",
|
||||
"hwids": [["0x2886", "0x0059"]],
|
||||
"mcu": "esp32s3",
|
||||
"variant": "seeed-xiao-s3"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"psram_type": "opi",
|
||||
"hwids": [
|
||||
["0x303A", "0x1001"],
|
||||
["0x303A", "0x0002"]
|
||||
@@ -23,7 +24,7 @@
|
||||
"mcu": "esp32s3",
|
||||
"variant": "t-watch-s3"
|
||||
},
|
||||
"connectivity": ["wifi"],
|
||||
"connectivity": ["wifi", "bluetooth"],
|
||||
"debug": {
|
||||
"openocd_target": "esp32s3.cfg"
|
||||
},
|
||||
|
||||
5
debian/ci_pack_sdeb.sh
vendored
5
debian/ci_pack_sdeb.sh
vendored
@@ -10,8 +10,9 @@ platformio pkg install -e native -t platformio/tool-scons@4.40502.0
|
||||
# Compress `pio` directory to prevent dh_clean from sanitizing it
|
||||
tar -cf pio.tar pio/
|
||||
rm -rf pio
|
||||
# Download the latest meshtastic/web release build.tar to `web.tar`
|
||||
curl -L https://github.com/meshtastic/web/releases/latest/download/build.tar -o web.tar
|
||||
# Download the meshtastic/web release build.tar to `web.tar`
|
||||
web_ver=$(cat bin/web.version)
|
||||
curl -L "https://github.com/meshtastic/web/releases/download/v$web_ver/build.tar" -o web.tar
|
||||
|
||||
package=$(dpkg-parsechangelog --show-field Source)
|
||||
|
||||
|
||||
1
debian/control
vendored
1
debian/control
vendored
@@ -17,6 +17,7 @@ Build-Depends: debhelper-compat (= 13),
|
||||
libbluetooth-dev,
|
||||
libusb-1.0-0-dev,
|
||||
libi2c-dev,
|
||||
libuv1-dev,
|
||||
openssl,
|
||||
libssl-dev,
|
||||
libulfius-dev,
|
||||
|
||||
22
extra_scripts/extra_stm32.py
Executable file
22
extra_scripts/extra_stm32.py
Executable file
@@ -0,0 +1,22 @@
|
||||
# trunk-ignore-all(ruff/F821)
|
||||
# trunk-ignore-all(flake8/F821): For SConstruct imports
|
||||
|
||||
Import("env")
|
||||
# Custom HEX from ELF
|
||||
env.AddPostAction(
|
||||
"$BUILD_DIR/${PROGNAME}.elf",
|
||||
env.VerboseAction(
|
||||
" ".join(
|
||||
[
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"ihex",
|
||||
"-R",
|
||||
".eeprom",
|
||||
"$BUILD_DIR/${PROGNAME}.elf",
|
||||
"$BUILD_DIR/${PROGNAME}.hex",
|
||||
]
|
||||
),
|
||||
"Building $BUILD_DIR/${PROGNAME}.hex",
|
||||
),
|
||||
)
|
||||
@@ -21,7 +21,7 @@ Summary: Meshtastic daemon for communicating with Meshtastic devices
|
||||
License: GPL-3.0
|
||||
URL: https://github.com/meshtastic/firmware
|
||||
Source0: {{{ git_dir_pack }}}
|
||||
Source1: https://github.com/meshtastic/web/releases/latest/download/build.tar
|
||||
Source1: https://github.com/meshtastic/web/releases/download/v{{{ web_version }}}/build.tar
|
||||
|
||||
BuildRequires: systemd-rpm-macros
|
||||
BuildRequires: python3-devel
|
||||
@@ -36,6 +36,7 @@ BuildRequires: pkgconfig(libgpiod)
|
||||
BuildRequires: pkgconfig(bluez)
|
||||
BuildRequires: pkgconfig(libusb-1.0)
|
||||
BuildRequires: libi2c-devel
|
||||
BuildRequires: pkgconfig(libuv)
|
||||
# Web components:
|
||||
BuildRequires: pkgconfig(openssl)
|
||||
BuildRequires: pkgconfig(liborcania)
|
||||
|
||||
@@ -56,11 +56,11 @@ build_flags = -Wno-missing-field-initializers
|
||||
monitor_speed = 115200
|
||||
monitor_filters = direct
|
||||
lib_deps =
|
||||
https://github.com/meshtastic/esp8266-oled-ssd1306.git#e16cee124fe26490cb14880c679321ad8ac89c95
|
||||
https://github.com/meshtastic/esp8266-oled-ssd1306/archive/0119501e9983bd894830b02f545c377ee08d66fe.zip
|
||||
mathertel/OneButton@2.6.1
|
||||
https://github.com/meshtastic/arduino-fsm.git#7db3702bf0cfe97b783d6c72595e3f38e0b19159
|
||||
https://github.com/meshtastic/TinyGPSPlus.git#71a82db35f3b973440044c476d4bcdc673b104f4
|
||||
https://github.com/meshtastic/ArduinoThread.git#7c3ee9e1951551b949763b1f5280f8db1fa4068d
|
||||
https://github.com/meshtastic/arduino-fsm/archive/7db3702bf0cfe97b783d6c72595e3f38e0b19159.zip
|
||||
https://github.com/meshtastic/TinyGPSPlus/archive/71a82db35f3b973440044c476d4bcdc673b104f4.zip
|
||||
https://github.com/meshtastic/ArduinoThread/archive/7c3ee9e1951551b949763b1f5280f8db1fa4068d.zip
|
||||
nanopb/Nanopb@0.4.91
|
||||
erriez/ErriezCRC32@1.0.1
|
||||
|
||||
@@ -94,18 +94,18 @@ lib_deps =
|
||||
|
||||
[device-ui_base]
|
||||
lib_deps =
|
||||
https://github.com/meshtastic/device-ui.git#74e739ed4532ca10393df9fc89ae5a22f0bab2b1
|
||||
https://github.com/meshtastic/device-ui/archive/56ef8db7eb4dda44dc0c1ec5828044debbbc6d33.zip
|
||||
|
||||
; Common libs for environmental measurements in telemetry module
|
||||
; (not included in native / portduino)
|
||||
[environmental_base]
|
||||
lib_deps =
|
||||
adafruit/Adafruit BusIO@1.16.2
|
||||
adafruit/Adafruit Unified Sensor@1.1.14
|
||||
adafruit/Adafruit BusIO@1.17.0
|
||||
adafruit/Adafruit Unified Sensor@1.1.15
|
||||
adafruit/Adafruit BMP280 Library@2.6.8
|
||||
adafruit/Adafruit BMP085 Library@1.2.4
|
||||
adafruit/Adafruit BME280 Library@2.2.4
|
||||
adafruit/Adafruit BMP3XX Library@2.1.5
|
||||
adafruit/Adafruit BMP3XX Library@2.1.6
|
||||
adafruit/Adafruit DPS310@1.1.5
|
||||
adafruit/Adafruit MCP9808 Library@2.0.2
|
||||
adafruit/Adafruit INA260 Library@1.5.2
|
||||
@@ -114,27 +114,27 @@ lib_deps =
|
||||
adafruit/Adafruit SHTC3 Library@1.0.1
|
||||
adafruit/Adafruit LPS2X@2.0.6
|
||||
adafruit/Adafruit SHT31 Library@2.2.2
|
||||
adafruit/Adafruit PM25 AQI Sensor@1.1.1
|
||||
adafruit/Adafruit PM25 AQI Sensor@1.2.0
|
||||
adafruit/Adafruit MPU6050@2.2.6
|
||||
adafruit/Adafruit LIS3DH@1.3.0
|
||||
adafruit/Adafruit AHTX0@2.0.5
|
||||
adafruit/Adafruit LSM6DS@4.7.3
|
||||
adafruit/Adafruit LSM6DS@4.7.4
|
||||
adafruit/Adafruit VEML7700 Library@2.1.6
|
||||
adafruit/Adafruit SHT4x Library@1.0.5
|
||||
adafruit/Adafruit TSL2591 Library@1.4.5
|
||||
sparkfun/SparkFun Qwiic Scale NAU7802 Arduino Library@1.0.6
|
||||
sparkfun/SparkFun 9DoF IMU Breakout - ICM 20948 - Arduino Library@1.2.13
|
||||
sparkfun/SparkFun 9DoF IMU Breakout - ICM 20948 - Arduino Library@1.3.0
|
||||
ClosedCube OPT3001@1.1.2
|
||||
emotibit/EmotiBit MLX90632@1.0.8
|
||||
adafruit/Adafruit MLX90614 Library@2.1.5
|
||||
https://github.com/boschsensortec/Bosch-BSEC2-Library#v1.7.2502
|
||||
https://github.com/boschsensortec/Bosch-BSEC2-Library/archive/v1.7.2502.zip
|
||||
boschsensortec/BME68x Sensor Library@1.1.40407
|
||||
https://github.com/KodinLanewave/INA3221@1.0.1
|
||||
https://github.com/KodinLanewave/INA3221/archive/1.0.1.zip
|
||||
mprograms/QMC5883LCompass@1.2.3
|
||||
dfrobot/DFRobot_RTU@1.0.3
|
||||
https://github.com/meshtastic/DFRobot_LarkWeatherStation#4de3a9cadef0f6a5220a8a906cf9775b02b0040d
|
||||
https://github.com/DFRobot/DFRobot_RainfallSensor#38fea5e02b40a5430be6dab39a99a6f6347d667e
|
||||
robtillaart/INA226@0.6.0
|
||||
https://github.com/meshtastic/DFRobot_LarkWeatherStation/archive/4de3a9cadef0f6a5220a8a906cf9775b02b0040d.zip
|
||||
https://github.com/DFRobot/DFRobot_RainfallSensor/archive/38fea5e02b40a5430be6dab39a99a6f6347d667e.zip
|
||||
robtillaart/INA226@0.6.4
|
||||
|
||||
; Health Sensor Libraries
|
||||
sparkfun/SparkFun MAX3010x Pulse and Proximity Sensor Library@1.1.2
|
||||
|
||||
Submodule protobufs updated: 14ec205865...5a5ab103d2
@@ -6,6 +6,11 @@
|
||||
NCP5623 rgb;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_LP5562
|
||||
#include <graphics/NomadStarLED.h>
|
||||
LP5562 rgbw;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_NEOPIXEL
|
||||
#include <graphics/NeoPixel.h>
|
||||
Adafruit_NeoPixel pixels(NEOPIXEL_COUNT, NEOPIXEL_DATA, NEOPIXEL_TYPE);
|
||||
@@ -26,7 +31,7 @@ class AmbientLightingThread : public concurrency::OSThread
|
||||
notifyDeepSleepObserver.observe(¬ifyDeepSleep); // Let us know when shutdown() is issued.
|
||||
|
||||
// Enables Ambient Lighting by default if conditions are meet.
|
||||
#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE)
|
||||
#ifdef HAS_RGB_LED
|
||||
#ifdef ENABLE_AMBIENTLIGHTING
|
||||
moduleConfig.ambient_lighting.led_state = true;
|
||||
#endif
|
||||
@@ -39,7 +44,7 @@ class AmbientLightingThread : public concurrency::OSThread
|
||||
// moduleConfig.ambient_lighting.green = (myNodeInfo.my_node_num & 0x00FF00) >> 8;
|
||||
// moduleConfig.ambient_lighting.blue = myNodeInfo.my_node_num & 0x0000FF;
|
||||
|
||||
#ifdef HAS_NCP5623
|
||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
||||
_type = type;
|
||||
if (_type == ScanI2C::DeviceType::NONE) {
|
||||
LOG_DEBUG("AmbientLighting Disable due to no RGB leds found on I2C bus");
|
||||
@@ -47,17 +52,21 @@ class AmbientLightingThread : public concurrency::OSThread
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE)
|
||||
#ifdef HAS_RGB_LED
|
||||
if (!moduleConfig.ambient_lighting.led_state) {
|
||||
LOG_DEBUG("AmbientLighting Disable due to moduleConfig.ambient_lighting.led_state OFF");
|
||||
disable();
|
||||
return;
|
||||
}
|
||||
LOG_DEBUG("AmbientLighting init");
|
||||
#ifdef HAS_NCP5623
|
||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
||||
if (_type == ScanI2C::NCP5623) {
|
||||
rgb.begin();
|
||||
#endif
|
||||
#ifdef HAS_LP5562
|
||||
} else if (_type == ScanI2C::LP5562) {
|
||||
rgbw.begin();
|
||||
#endif
|
||||
#ifdef RGBLED_RED
|
||||
pinMode(RGBLED_RED, OUTPUT);
|
||||
pinMode(RGBLED_GREEN, OUTPUT);
|
||||
@@ -70,7 +79,7 @@ class AmbientLightingThread : public concurrency::OSThread
|
||||
#endif
|
||||
setLighting();
|
||||
#endif
|
||||
#ifdef HAS_NCP5623
|
||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -78,13 +87,13 @@ class AmbientLightingThread : public concurrency::OSThread
|
||||
protected:
|
||||
int32_t runOnce() override
|
||||
{
|
||||
#if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE)
|
||||
#ifdef HAS_NCP5623
|
||||
if (_type == ScanI2C::NCP5623 && moduleConfig.ambient_lighting.led_state) {
|
||||
#ifdef HAS_RGB_LED
|
||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
||||
if ((_type == ScanI2C::NCP5623 || _type == ScanI2C::LP5562) && moduleConfig.ambient_lighting.led_state) {
|
||||
#endif
|
||||
setLighting();
|
||||
return 30000; // 30 seconds to reset from any animations that may have been running from Ext. Notification
|
||||
#ifdef HAS_NCP5623
|
||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -108,6 +117,14 @@ class AmbientLightingThread : public concurrency::OSThread
|
||||
rgb.setBlue(0);
|
||||
LOG_INFO("OFF: NCP5623 Ambient lighting");
|
||||
#endif
|
||||
#ifdef HAS_LP5562
|
||||
rgbw.setCurrent(0);
|
||||
rgbw.setRed(0);
|
||||
rgbw.setGreen(0);
|
||||
rgbw.setBlue(0);
|
||||
rgbw.setWhite(0);
|
||||
LOG_INFO("OFF: LP5562 Ambient lighting");
|
||||
#endif
|
||||
#ifdef HAS_NEOPIXEL
|
||||
pixels.clear();
|
||||
pixels.show();
|
||||
@@ -141,6 +158,14 @@ class AmbientLightingThread : public concurrency::OSThread
|
||||
LOG_DEBUG("Init NCP5623 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);
|
||||
#endif
|
||||
#ifdef HAS_LP5562
|
||||
rgbw.setCurrent(moduleConfig.ambient_lighting.current);
|
||||
rgbw.setRed(moduleConfig.ambient_lighting.red);
|
||||
rgbw.setGreen(moduleConfig.ambient_lighting.green);
|
||||
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,
|
||||
moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green, moduleConfig.ambient_lighting.blue);
|
||||
#endif
|
||||
#ifdef HAS_NEOPIXEL
|
||||
pixels.fill(pixels.Color(moduleConfig.ambient_lighting.red, moduleConfig.ambient_lighting.green,
|
||||
moduleConfig.ambient_lighting.blue),
|
||||
|
||||
@@ -41,10 +41,8 @@ class AudioThread : public concurrency::OSThread
|
||||
delete i2sRtttl;
|
||||
i2sRtttl = nullptr;
|
||||
}
|
||||
if (rtttlFile != nullptr) {
|
||||
delete rtttlFile;
|
||||
rtttlFile = nullptr;
|
||||
}
|
||||
delete rtttlFile;
|
||||
rtttlFile = nullptr;
|
||||
|
||||
setCPUFast(false);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ ButtonThread::ButtonThread() : OSThread("Button")
|
||||
#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)
|
||||
#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);
|
||||
@@ -73,23 +73,28 @@ ButtonThread::ButtonThread() : OSThread("Button")
|
||||
userButton.setDebounceMs(1);
|
||||
userButton.attachDoubleClick(userButtonDoublePressed);
|
||||
userButton.attachMultiClick(userButtonMultiPressed, this); // Reference to instance: get click count from non-static OneButton
|
||||
#ifndef T_DECK // T-Deck immediately wakes up after shutdown, so disable this function
|
||||
#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
|
||||
userButtonAlt = OneButton(BUTTON_PIN_ALT, true, true);
|
||||
#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(userButtonPressed);
|
||||
userButtonAlt.attachClick(userButtonPressedScreen);
|
||||
userButtonAlt.setClickMs(BUTTON_CLICK_MS);
|
||||
userButtonAlt.setPressMs(BUTTON_LONGPRESS_MS);
|
||||
userButtonAlt.setDebounceMs(1);
|
||||
userButtonAlt.attachDoubleClick(userButtonDoublePressed);
|
||||
userButtonAlt.attachLongPressStart(userButtonPressedLongStart);
|
||||
userButtonAlt.attachLongPressStop(userButtonPressedLongStop);
|
||||
#endif
|
||||
@@ -111,6 +116,49 @@ ButtonThread::ButtonThread() : OSThread("Button")
|
||||
#endif
|
||||
}
|
||||
|
||||
void ButtonThread::switchPage()
|
||||
{
|
||||
#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
|
||||
@@ -141,49 +189,48 @@ int32_t ButtonThread::runOnce()
|
||||
// If a nag notification is running, stop it and prevent other actions
|
||||
if (moduleConfig.external_notification.enabled && (externalNotificationModule->nagCycleCutoff != UINT32_MAX)) {
|
||||
externalNotificationModule->stopNow();
|
||||
return 50;
|
||||
break;
|
||||
}
|
||||
#ifdef BUTTON_PIN
|
||||
#if !defined(USERPREFS_BUTTON_PIN)
|
||||
if (((config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN) !=
|
||||
#ifdef ELECROW_ThinkNode_M1
|
||||
sendAdHocPosition();
|
||||
break;
|
||||
#endif
|
||||
#if defined(USERPREFS_BUTTON_PIN)
|
||||
if (((config.device.button_gpio ? config.device.button_gpio : USERPREFS_BUTTON_PIN) !=
|
||||
#endif
|
||||
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(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);
|
||||
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!");
|
||||
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
|
||||
}
|
||||
#ifdef ELECROW_ThinkNode_M1
|
||||
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
||||
break;
|
||||
#endif
|
||||
sendAdHocPosition();
|
||||
break;
|
||||
}
|
||||
|
||||
case BUTTON_EVENT_MULTI_PRESSED: {
|
||||
LOG_BUTTON("Mulitipress! %hux", multipressClickCount);
|
||||
switch (multipressClickCount) {
|
||||
#if HAS_GPS
|
||||
#if HAS_GPS && !defined(ELECROW_ThinkNode_M1)
|
||||
// 3 clicks: toggle GPS
|
||||
case 3:
|
||||
if (!config.device.disable_triple_click && (gps != nullptr)) {
|
||||
@@ -192,8 +239,17 @@ int32_t ButtonThread::runOnce()
|
||||
screen->forceDisplay(true); // Force a new UI frame, then force an EInk update
|
||||
}
|
||||
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) // i.e. T-Echo
|
||||
|
||||
#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);
|
||||
@@ -293,8 +349,12 @@ void ButtonThread::attachButtonInterrupts()
|
||||
#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);
|
||||
|
||||
@@ -24,6 +24,7 @@ class ButtonThread : public concurrency::OSThread
|
||||
enum ButtonEventType {
|
||||
BUTTON_EVENT_NONE,
|
||||
BUTTON_EVENT_PRESSED,
|
||||
BUTTON_EVENT_PRESSED_SCREEN,
|
||||
BUTTON_EVENT_DOUBLE_PRESSED,
|
||||
BUTTON_EVENT_MULTI_PRESSED,
|
||||
BUTTON_EVENT_LONG_PRESSED,
|
||||
@@ -36,13 +37,15 @@ class ButtonThread : public concurrency::OSThread
|
||||
void attachButtonInterrupts();
|
||||
void detachButtonInterrupts();
|
||||
void storeClickCount();
|
||||
bool isBuzzing() { return buzzer_flag; }
|
||||
void setScreenFlag(bool flag) { screen_flag = flag; }
|
||||
bool getScreenFlag() { return screen_flag; }
|
||||
|
||||
// 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
|
||||
@@ -64,14 +67,20 @@ class ButtonThread : public concurrency::OSThread
|
||||
|
||||
// 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();
|
||||
|
||||
@@ -27,9 +27,6 @@ const char *DisplayFormatters::getModemPresetDisplayName(meshtastic_Config_LoRaC
|
||||
case meshtastic_Config_LoRaConfig_ModemPreset_LONG_MODERATE:
|
||||
return useShortName ? "LongM" : "LongMod";
|
||||
break;
|
||||
case meshtastic_Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
|
||||
return useShortName ? "VeryL" : "VLongSlow";
|
||||
break;
|
||||
default:
|
||||
return useShortName ? "Custom" : "Invalid";
|
||||
break;
|
||||
|
||||
@@ -29,30 +29,6 @@ SPIClass SPI1(HSPI);
|
||||
|
||||
#endif // HAS_SDCARD
|
||||
|
||||
#if defined(ARCH_STM32WL)
|
||||
|
||||
uint16_t OSFS::startOfEEPROM = 1;
|
||||
uint16_t OSFS::endOfEEPROM = 2048;
|
||||
|
||||
// 3) How do I read from the medium?
|
||||
void OSFS::readNBytes(uint16_t address, unsigned int num, byte *output)
|
||||
{
|
||||
for (uint16_t i = address; i < address + num; i++) {
|
||||
*output = EEPROM.read(i);
|
||||
output++;
|
||||
}
|
||||
}
|
||||
|
||||
// 4) How to I write to the medium?
|
||||
void OSFS::writeNBytes(uint16_t address, unsigned int num, const byte *input)
|
||||
{
|
||||
for (uint16_t i = address; i < address + num; i++) {
|
||||
EEPROM.update(i, *input);
|
||||
input++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Copies a file from one location to another.
|
||||
*
|
||||
@@ -62,33 +38,7 @@ void OSFS::writeNBytes(uint16_t address, unsigned int num, const byte *input)
|
||||
*/
|
||||
bool copyFile(const char *from, const char *to)
|
||||
{
|
||||
#ifdef ARCH_STM32WL
|
||||
unsigned char cbuffer[2048];
|
||||
|
||||
// Var to hold the result of actions
|
||||
OSFS::result r;
|
||||
|
||||
r = OSFS::getFile(from, cbuffer);
|
||||
|
||||
if (r == notfound) {
|
||||
LOG_ERROR("Failed to open source file %s", from);
|
||||
return false;
|
||||
} else if (r == noerr) {
|
||||
r = OSFS::newFile(to, cbuffer, true);
|
||||
if (r == noerr) {
|
||||
return true;
|
||||
} else {
|
||||
LOG_ERROR("OSFS Error %d", r);
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
LOG_ERROR("OSFS Error %d", r);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
#elif defined(FSCom)
|
||||
#ifdef FSCom
|
||||
// take SPI Lock
|
||||
concurrency::LockGuard g(spiLock);
|
||||
unsigned char cbuffer[16];
|
||||
@@ -127,13 +77,7 @@ bool copyFile(const char *from, const char *to)
|
||||
*/
|
||||
bool renameFile(const char *pathFrom, const char *pathTo)
|
||||
{
|
||||
#ifdef ARCH_STM32WL
|
||||
if (copyFile(pathFrom, pathTo) && (OSFS::deleteFile(pathFrom) == OSFS::result::NO_ERROR)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
#elif defined(FSCom)
|
||||
#ifdef FSCom
|
||||
|
||||
#ifdef ARCH_ESP32
|
||||
// take SPI Lock
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_STM32WL)
|
||||
// STM32WL series 2 Kbytes (8 rows of 256 bytes)
|
||||
#include <EEPROM.h>
|
||||
#include <OSFS.h>
|
||||
|
||||
// Useful consts
|
||||
const OSFS::result noerr = OSFS::result::NO_ERROR;
|
||||
const OSFS::result notfound = OSFS::result::FILE_NOT_FOUND;
|
||||
// STM32WL
|
||||
#include "LittleFS.h"
|
||||
#define FSCom InternalFS
|
||||
#define FSBegin() FSCom.begin()
|
||||
using namespace STM32_LittleFS_Namespace;
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_RP2040)
|
||||
|
||||
@@ -380,6 +380,20 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
||||
// if we have a integrated device with a battery, we can assume that the battery is always connected
|
||||
#ifdef BATTERY_IMMUTABLE
|
||||
virtual bool isBatteryConnect() override { return true; }
|
||||
#elif defined(ADC_V)
|
||||
virtual bool isBatteryConnect() override
|
||||
{
|
||||
int lastReading = digitalRead(ADC_V);
|
||||
// 判断值是否变化
|
||||
for (int i = 2; i < 500; i++) {
|
||||
int reading = digitalRead(ADC_V);
|
||||
if (reading != lastReading) {
|
||||
return false; // 有变化,USB供电, 没接电池
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
virtual bool isBatteryConnect() override { return getBatteryPercent() != -1; }
|
||||
#endif
|
||||
@@ -391,7 +405,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
||||
virtual bool isVbusIn() override
|
||||
{
|
||||
#ifdef EXT_PWR_DETECT
|
||||
#ifdef HELTEC_CAPSULE_SENSOR_V3
|
||||
#if defined(HELTEC_CAPSULE_SENSOR_V3) || defined(HELTEC_SENSOR_HUB)
|
||||
// if external powered that pin will be pulled down
|
||||
if (digitalRead(EXT_PWR_DETECT) == LOW) {
|
||||
return true;
|
||||
@@ -541,7 +555,7 @@ Power::Power() : OSThread("Power")
|
||||
bool Power::analogInit()
|
||||
{
|
||||
#ifdef EXT_PWR_DETECT
|
||||
#ifdef HELTEC_CAPSULE_SENSOR_V3
|
||||
#if defined(HELTEC_CAPSULE_SENSOR_V3) || defined(HELTEC_SENSOR_HUB)
|
||||
pinMode(EXT_PWR_DETECT, INPUT_PULLUP);
|
||||
#else
|
||||
pinMode(EXT_PWR_DETECT, INPUT);
|
||||
@@ -668,12 +682,12 @@ void Power::readPowerStatus()
|
||||
int8_t batteryChargePercent = -1;
|
||||
OptionalBool usbPowered = OptUnknown;
|
||||
OptionalBool hasBattery = OptUnknown; // These must be static because NRF_APM code doesn't run every time
|
||||
OptionalBool isCharging = OptUnknown;
|
||||
OptionalBool isChargingNow = OptUnknown;
|
||||
|
||||
if (batteryLevel) {
|
||||
hasBattery = batteryLevel->isBatteryConnect() ? OptTrue : OptFalse;
|
||||
usbPowered = batteryLevel->isVbusIn() ? OptTrue : OptFalse;
|
||||
isCharging = batteryLevel->isCharging() ? OptTrue : OptFalse;
|
||||
isChargingNow = batteryLevel->isCharging() ? OptTrue : OptFalse;
|
||||
if (hasBattery) {
|
||||
batteryVoltageMv = batteryLevel->getBattVoltage();
|
||||
// If the AXP192 returns a valid battery percentage, use it
|
||||
@@ -702,15 +716,15 @@ void Power::readPowerStatus()
|
||||
|
||||
// If changed to DISCONNECTED
|
||||
if (nrf_usb_state == NRFX_POWER_USB_STATE_DISCONNECTED)
|
||||
isCharging = usbPowered = OptFalse;
|
||||
isChargingNow = usbPowered = OptFalse;
|
||||
// If changed to CONNECTED / READY
|
||||
else
|
||||
isCharging = usbPowered = OptTrue;
|
||||
isChargingNow = usbPowered = OptTrue;
|
||||
|
||||
#endif
|
||||
|
||||
// Notify any status instances that are observing us
|
||||
const PowerStatus powerStatus2 = PowerStatus(hasBattery, usbPowered, isCharging, batteryVoltageMv, batteryChargePercent);
|
||||
const PowerStatus powerStatus2 = PowerStatus(hasBattery, usbPowered, isChargingNow, batteryVoltageMv, batteryChargePercent);
|
||||
LOG_DEBUG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d", powerStatus2.getHasUSB(), powerStatus2.getIsCharging(),
|
||||
powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
|
||||
newStatus.notifyObservers(&powerStatus2);
|
||||
@@ -756,6 +770,7 @@ void Power::readPowerStatus()
|
||||
// If we have a battery at all and it is less than 0%, force deep sleep if we have more than 10 low readings in
|
||||
// a row. NOTE: min LiIon/LiPo voltage is 2.0 to 2.5V, current OCV min is set to 3100 that is large enough.
|
||||
//
|
||||
|
||||
if (batteryLevel && powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) {
|
||||
if (batteryLevel->getBattVoltage() < OCV[NUM_OCV_POINTS - 1]) {
|
||||
low_voltage_counter++;
|
||||
|
||||
@@ -30,8 +30,11 @@ struct ToneDuration {
|
||||
#define NOTE_B3 247
|
||||
#define NOTE_CS4 277
|
||||
|
||||
const int DURATION_1_8 = 125; // 1/8 note
|
||||
const int DURATION_1_4 = 250; // 1/4 note
|
||||
const int DURATION_1_8 = 125; // 1/8 note
|
||||
const int DURATION_1_4 = 250; // 1/4 note
|
||||
const int DURATION_1_2 = 500; // 1/2 note
|
||||
const int DURATION_3_4 = 750; // 1/4 note
|
||||
const int DURATION_1_1 = 1000; // 1/1 note
|
||||
|
||||
void playTones(const ToneDuration *tone_durations, int size)
|
||||
{
|
||||
@@ -55,6 +58,12 @@ void playBeep()
|
||||
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||
}
|
||||
|
||||
void playLongBeep()
|
||||
{
|
||||
ToneDuration melody[] = {{NOTE_B3, DURATION_1_1}};
|
||||
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||
}
|
||||
|
||||
void playGPSEnableBeep()
|
||||
{
|
||||
ToneDuration melody[] = {{NOTE_C3, DURATION_1_8}, {NOTE_FS3, DURATION_1_4}, {NOTE_CS4, DURATION_1_4}};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
void playBeep();
|
||||
void playLongBeep();
|
||||
void playStartMelody();
|
||||
void playShutdownMelody();
|
||||
void playGPSEnableBeep();
|
||||
|
||||
@@ -152,6 +152,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define MLX90614_ADDR_DEF 0x5A
|
||||
#define CGRADSENS_ADDR 0x66
|
||||
#define LTR390UV_ADDR 0x53
|
||||
#define XPOWERS_AXP192_AXP2101_ADDRESS 0x34 // same adress as TCA8418
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// ACCELEROMETER
|
||||
@@ -170,6 +171,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// LED
|
||||
// -----------------------------------------------------------------------------
|
||||
#define NCP5623_ADDR 0x38
|
||||
#define LP5562_ADDR 0x30
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Security
|
||||
@@ -295,6 +297,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#error HW_VENDOR must be defined
|
||||
#endif
|
||||
|
||||
// Support multiple RGB LED configuration
|
||||
#if defined(HAS_NCP5623) || defined(HAS_LP5562) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE)
|
||||
#define HAS_RGB_LED
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Global switches to turn off features for a minimized build
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -31,8 +31,8 @@ ScanI2C::FoundDevice ScanI2C::firstRTC() const
|
||||
|
||||
ScanI2C::FoundDevice ScanI2C::firstKeyboard() const
|
||||
{
|
||||
ScanI2C::DeviceType types[] = {CARDKB, TDECKKB, BBQ10KB, RAK14004, MPR121KB};
|
||||
return firstOfOrNONE(5, types);
|
||||
ScanI2C::DeviceType types[] = {CARDKB, TDECKKB, BBQ10KB, RAK14004, MPR121KB, TCA8418KB};
|
||||
return firstOfOrNONE(6, types);
|
||||
}
|
||||
|
||||
ScanI2C::FoundDevice ScanI2C::firstAccelerometer() const
|
||||
@@ -41,6 +41,12 @@ ScanI2C::FoundDevice ScanI2C::firstAccelerometer() const
|
||||
return firstOfOrNONE(8, types);
|
||||
}
|
||||
|
||||
ScanI2C::FoundDevice ScanI2C::firstRGBLED() const
|
||||
{
|
||||
ScanI2C::DeviceType types[] = {NCP5623, LP5562};
|
||||
return firstOfOrNONE(2, types);
|
||||
}
|
||||
|
||||
ScanI2C::FoundDevice ScanI2C::find(ScanI2C::DeviceType) const
|
||||
{
|
||||
return DEVICE_NONE;
|
||||
|
||||
@@ -18,7 +18,7 @@ class ScanI2C
|
||||
TDECKKB,
|
||||
BBQ10KB,
|
||||
RAK14004,
|
||||
PMU_AXP192_AXP2101,
|
||||
PMU_AXP192_AXP2101, // has the same adress as the TCA8418KB
|
||||
BME_680,
|
||||
BME_280,
|
||||
BMP_280,
|
||||
@@ -49,6 +49,7 @@ class ScanI2C
|
||||
VEML7700,
|
||||
RCWL9620,
|
||||
NCP5623,
|
||||
LP5562,
|
||||
TSL2591,
|
||||
OPT3001,
|
||||
MLX90632,
|
||||
@@ -69,6 +70,7 @@ class ScanI2C
|
||||
DFROBOT_RAIN,
|
||||
DPS310,
|
||||
LTR390UV,
|
||||
TCA8418KB,
|
||||
} DeviceType;
|
||||
|
||||
// typedef uint8_t DeviceAddress;
|
||||
@@ -121,6 +123,8 @@ class ScanI2C
|
||||
|
||||
FoundDevice firstAccelerometer() const;
|
||||
|
||||
FoundDevice firstRGBLED() const;
|
||||
|
||||
virtual FoundDevice find(DeviceType) const;
|
||||
|
||||
virtual bool exists(DeviceType) const;
|
||||
|
||||
@@ -10,11 +10,6 @@
|
||||
#include "meshUtils.h" // vformat
|
||||
#endif
|
||||
|
||||
// AXP192 and AXP2101 have the same device address, we just need to identify it in Power.cpp
|
||||
#ifndef XPOWERS_AXP192_AXP2101_ADDRESS
|
||||
#define XPOWERS_AXP192_AXP2101_ADDRESS 0x34
|
||||
#endif
|
||||
|
||||
bool in_array(uint8_t *array, int size, uint8_t lookfor)
|
||||
{
|
||||
int i;
|
||||
@@ -218,9 +213,20 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
#ifdef HAS_NCP5623
|
||||
SCAN_SIMPLE_CASE(NCP5623_ADDR, NCP5623, "NCP5623", (uint8_t)addr.address);
|
||||
#endif
|
||||
#ifdef HAS_PMU
|
||||
SCAN_SIMPLE_CASE(XPOWERS_AXP192_AXP2101_ADDRESS, PMU_AXP192_AXP2101, "AXP192/AXP2101", (uint8_t)addr.address)
|
||||
#ifdef HAS_LP5562
|
||||
SCAN_SIMPLE_CASE(LP5562_ADDR, LP5562, "LP5562", (uint8_t)addr.address);
|
||||
#endif
|
||||
case XPOWERS_AXP192_AXP2101_ADDRESS:
|
||||
// Do we have the axp2101/192 or the TCA8418
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x90), 1);
|
||||
if (registerValue == 0x0) {
|
||||
logFoundDevice("TCA8418", (uint8_t)addr.address);
|
||||
type = TCA8418KB;
|
||||
} else {
|
||||
logFoundDevice("AXP192/AXP2101", (uint8_t)addr.address);
|
||||
type = PMU_AXP192_AXP2101;
|
||||
}
|
||||
break;
|
||||
case BME_ADDR:
|
||||
case BME_ADDR_ALTERNATE:
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xD0), 1); // GET_ID
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "RTC.h"
|
||||
#include "Throttle.h"
|
||||
#include "buzz.h"
|
||||
#include "concurrency/Periodic.h"
|
||||
#include "meshUtils.h"
|
||||
|
||||
#include "main.h" // pmu_found
|
||||
@@ -89,6 +90,45 @@ static const char *getGPSPowerStateString(GPSPowerState state)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PIN_GPS_SWITCH
|
||||
// If we have a hardware switch, define a periodic watcher outside of the GPS runOnce thread, since this can be sleeping
|
||||
// idefinitely
|
||||
|
||||
int lastState = LOW;
|
||||
bool firstrun = true;
|
||||
|
||||
static int32_t gpsSwitch()
|
||||
{
|
||||
if (gps) {
|
||||
int currentState = digitalRead(PIN_GPS_SWITCH);
|
||||
|
||||
// if the switch is set to zero, disable the GPS Thread
|
||||
if (firstrun)
|
||||
if (currentState == LOW)
|
||||
lastState = HIGH;
|
||||
|
||||
if (currentState != lastState) {
|
||||
if (currentState == LOW) {
|
||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_DISABLED;
|
||||
if (!firstrun)
|
||||
playGPSDisableBeep();
|
||||
gps->disable();
|
||||
} else {
|
||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
||||
if (!firstrun)
|
||||
playGPSEnableBeep();
|
||||
gps->enable();
|
||||
}
|
||||
lastState = currentState;
|
||||
}
|
||||
firstrun = false;
|
||||
}
|
||||
return 1000;
|
||||
}
|
||||
|
||||
static concurrency::Periodic *gpsPeriodic;
|
||||
#endif
|
||||
|
||||
static void UBXChecksum(uint8_t *message, size_t length)
|
||||
{
|
||||
uint8_t CK_A = 0, CK_B = 0;
|
||||
@@ -981,15 +1021,16 @@ void GPS::down()
|
||||
setPowerState(GPS_IDLE);
|
||||
|
||||
else {
|
||||
// Check whether the GPS hardware is capable of GPS_SOFTSLEEP
|
||||
// If not, fallback to GPS_HARDSLEEP instead
|
||||
// Check whether the GPS hardware is capable of GPS_SOFTSLEEP
|
||||
// If not, fallback to GPS_HARDSLEEP instead
|
||||
#ifdef PIN_GPS_STANDBY // L76B, L76K and clones have a standby pin
|
||||
bool softsleepSupported = true;
|
||||
#else
|
||||
bool softsleepSupported = false;
|
||||
#endif
|
||||
// U-blox is supported via PMREQ
|
||||
if (IS_ONE_OF(gnssModel, GNSS_MODEL_UBLOX6, GNSS_MODEL_UBLOX7, GNSS_MODEL_UBLOX8, GNSS_MODEL_UBLOX9, GNSS_MODEL_UBLOX10))
|
||||
softsleepSupported = true;
|
||||
#ifdef PIN_GPS_STANDBY // L76B, L76K and clones have a standby pin
|
||||
softsleepSupported = true;
|
||||
#endif
|
||||
|
||||
if (softsleepSupported) {
|
||||
// How long does gps_update_interval need to be, for GPS_HARDSLEEP to become more efficient than
|
||||
@@ -1200,12 +1241,13 @@ GnssModel_t GPS::probe(int serialSpeed)
|
||||
PROBE_SIMPLE("LC86", "$PQTMVERNO*58", "$PQTMVERNO,LC86", GNSS_MODEL_AG3352, 500);
|
||||
PROBE_SIMPLE("L76K", "$PCAS06,0*1B", "$GPTXT,01,01,02,SW=", GNSS_MODEL_MTK, 500);
|
||||
|
||||
// Close all NMEA sentences, valid for L76B MTK platform (Waveshare Pico GPS)
|
||||
// Close all NMEA sentences, valid for MTK3333 and MTK3339 platforms
|
||||
_serial_gps->write("$PMTK514,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*2E\r\n");
|
||||
delay(20);
|
||||
std::vector<ChipInfo> mtk = {{"L76B", "Quectel-L76B", GNSS_MODEL_MTK_L76B},
|
||||
{"PA1616S", "1616S", GNSS_MODEL_MTK_PA1616S},
|
||||
{"LS20031", "MC-1513", GNSS_MODEL_LS20031}};
|
||||
{"LS20031", "MC-1513", GNSS_MODEL_MTK_L76B},
|
||||
{"L96", "Quectel-L96", GNSS_MODEL_MTK_L76B}};
|
||||
PROBE_FAMILY("MTK Family", "$PMTK605*31", mtk, 500);
|
||||
|
||||
uint8_t cfg_rate[] = {0xB5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00};
|
||||
@@ -1388,6 +1430,12 @@ GPS *GPS::createGps()
|
||||
pinMode(PIN_GPS_PPS, INPUT);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_GPS_SWITCH
|
||||
// toggle GPS via external GPIO switch
|
||||
pinMode(PIN_GPS_SWITCH, INPUT);
|
||||
gpsPeriodic = new concurrency::Periodic("GPSSwitch", gpsSwitch);
|
||||
#endif
|
||||
|
||||
// Currently disabled per issue #525 (TinyGPS++ crash bug)
|
||||
// when fixed upstream, can be un-disabled to enable 3D FixType and PDOP
|
||||
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
|
||||
|
||||
@@ -224,7 +224,7 @@ static const uint8_t _message_GSA[] = {
|
||||
0x00, // Rate for DDC
|
||||
0x00, // Rate for UART1
|
||||
0x00, // Rate for UART2
|
||||
0x00, // Rate for USB usefull for native linux
|
||||
0x00, // Rate for USB useful for native linux
|
||||
0x00, // Rate for SPI
|
||||
0x00 // Reserved
|
||||
};
|
||||
@@ -258,7 +258,7 @@ static const uint8_t _message_RMC[] = {
|
||||
0x00, // Rate for DDC
|
||||
0x01, // Rate for UART1
|
||||
0x00, // Rate for UART2
|
||||
0x01, // Rate for USB usefull for native linux
|
||||
0x01, // Rate for USB useful for native linux
|
||||
0x00, // Rate for SPI
|
||||
0x00 // Reserved
|
||||
};
|
||||
@@ -269,7 +269,7 @@ static const uint8_t _message_GGA[] = {
|
||||
0x00, // Rate for DDC
|
||||
0x01, // Rate for UART1
|
||||
0x00, // Rate for UART2
|
||||
0x01, // Rate for USB, usefull for native linux
|
||||
0x01, // Rate for USB, useful for native linux
|
||||
0x00, // Rate for SPI
|
||||
0x00 // Reserved
|
||||
};
|
||||
|
||||
@@ -128,16 +128,25 @@ bool EInkDisplay::connect()
|
||||
#ifdef PIN_EINK_EN
|
||||
// backlight power, HIGH is backlight on, LOW is off
|
||||
pinMode(PIN_EINK_EN, OUTPUT);
|
||||
#ifdef ELECROW_ThinkNode_M1
|
||||
// ThinkNode M1 has a hardware dimmable backlight. Start enabled
|
||||
digitalWrite(PIN_EINK_EN, HIGH);
|
||||
#else
|
||||
digitalWrite(PIN_EINK_EN, LOW);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(TTGO_T_ECHO)
|
||||
#if defined(TTGO_T_ECHO) || defined(ELECROW_ThinkNode_M1)
|
||||
{
|
||||
auto lowLevel = new EINK_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY, SPI1);
|
||||
|
||||
adafruitDisplay = new GxEPD2_BW<EINK_DISPLAY_MODEL, EINK_DISPLAY_MODEL::HEIGHT>(*lowLevel);
|
||||
adafruitDisplay->init();
|
||||
#ifdef ELECROW_ThinkNode_M1
|
||||
adafruitDisplay->setRotation(4);
|
||||
#else
|
||||
adafruitDisplay->setRotation(3);
|
||||
#endif
|
||||
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||
}
|
||||
#elif defined(MESHLINK)
|
||||
@@ -166,7 +175,8 @@ bool EInkDisplay::connect()
|
||||
}
|
||||
|
||||
#elif defined(HELTEC_WIRELESS_PAPER_V1_0) || defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_VISION_MASTER_E213) || \
|
||||
defined(HELTEC_VISION_MASTER_E290) || defined(TLORA_T3S3_EPAPER) || defined(CROWPANEL_ESP32S3_5_EPAPER)
|
||||
defined(HELTEC_VISION_MASTER_E290) || defined(TLORA_T3S3_EPAPER) || defined(CROWPANEL_ESP32S3_5_EPAPER) || \
|
||||
defined(CROWPANEL_ESP32S3_4_EPAPER) || defined(CROWPANEL_ESP32S3_2_EPAPER)
|
||||
{
|
||||
// Start HSPI
|
||||
hspi = new SPIClass(HSPI);
|
||||
@@ -182,7 +192,7 @@ bool EInkDisplay::connect()
|
||||
// Init GxEPD2
|
||||
adafruitDisplay->init();
|
||||
adafruitDisplay->setRotation(3);
|
||||
#if defined(CROWPANEL_ESP32S3_5_EPAPER)
|
||||
#if defined(CROWPANEL_ESP32S3_5_EPAPER) || defined(CROWPANEL_ESP32S3_4_EPAPER)
|
||||
adafruitDisplay->setRotation(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ class EInkDisplay : public OLEDDisplay
|
||||
|
||||
// If display uses HSPI
|
||||
#if defined(HELTEC_WIRELESS_PAPER) || defined(HELTEC_WIRELESS_PAPER_V1_0) || defined(HELTEC_VISION_MASTER_E213) || \
|
||||
defined(HELTEC_VISION_MASTER_E290) || defined(TLORA_T3S3_EPAPER) || defined(CROWPANEL_ESP32S3_5_EPAPER)
|
||||
defined(HELTEC_VISION_MASTER_E290) || defined(TLORA_T3S3_EPAPER) || defined(CROWPANEL_ESP32S3_5_EPAPER) || \
|
||||
defined(CROWPANEL_ESP32S3_4_EPAPER) || defined(CROWPANEL_ESP32S3_2_EPAPER)
|
||||
SPIClass *hspi = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
5
src/graphics/NomadStarLED.h
Normal file
5
src/graphics/NomadStarLED.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#ifdef HAS_LP5562
|
||||
#include <LP5562.h>
|
||||
extern LP5562 rgbw;
|
||||
|
||||
#endif
|
||||
@@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#if !MESHTASTIC_EXCLUDE_GPS
|
||||
#include "GPS.h"
|
||||
#endif
|
||||
#include "ButtonThread.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "error.h"
|
||||
@@ -1606,6 +1607,7 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
|
||||
if (on != screenOn) {
|
||||
if (on) {
|
||||
LOG_INFO("Turn on screen");
|
||||
buttonThread->setScreenFlag(true);
|
||||
powerMon->setState(meshtastic_PowerMon_State_Screen_On);
|
||||
#ifdef T_WATCH_S3
|
||||
PMU->enablePowerOutput(XPOWERS_ALDO2);
|
||||
@@ -1641,6 +1643,12 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
|
||||
setScreensaverFrames(einkScreensaver);
|
||||
#endif
|
||||
LOG_INFO("Turn off screen");
|
||||
buttonThread->setScreenFlag(false);
|
||||
#ifdef ELECROW_ThinkNode_M1
|
||||
if (digitalRead(PIN_EINK_EN) == HIGH) {
|
||||
digitalWrite(PIN_EINK_EN, LOW);
|
||||
}
|
||||
#endif
|
||||
dispdev->displayOff();
|
||||
#ifdef USE_ST7789
|
||||
SPI1.end();
|
||||
@@ -2664,14 +2672,19 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
||||
// minutes %= 60;
|
||||
// hours %= 24;
|
||||
|
||||
// Show uptime as days, hours, minutes OR seconds
|
||||
std::string uptime = screen->drawTimeDelta(days, hours, minutes, seconds);
|
||||
|
||||
// Line 1 (Still)
|
||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(uptime.c_str()), y, uptime.c_str());
|
||||
if (config.display.heading_bold)
|
||||
display->drawString(x - 1 + SCREEN_WIDTH - display->getStringWidth(uptime.c_str()), y, uptime.c_str());
|
||||
|
||||
display->setColor(WHITE);
|
||||
|
||||
// Setup string to assemble analogClock string
|
||||
std::string analogClock = "";
|
||||
|
||||
// Show uptime as days, hours, minutes OR seconds
|
||||
std::string uptime = screen->drawTimeDelta(days, hours, minutes, seconds);
|
||||
|
||||
uint32_t rtc_sec = getValidTime(RTCQuality::RTCQualityDevice, true); // Display local timezone
|
||||
if (rtc_sec > 0) {
|
||||
long hms = rtc_sec % SEC_PER_DAY;
|
||||
@@ -2704,9 +2717,6 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
||||
analogClock += timebuf;
|
||||
}
|
||||
|
||||
// Line 1
|
||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(uptime.c_str()), y, uptime.c_str());
|
||||
|
||||
// Line 2
|
||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, analogClock.c_str());
|
||||
|
||||
@@ -2728,7 +2738,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
||||
drawGPSpowerstat(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
||||
}
|
||||
#endif
|
||||
/* 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
|
||||
if (heartbeat)
|
||||
display->setPixel(0, 0);
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
#include "graphics/fonts/OLEDDisplayFontsCS.h"
|
||||
#endif
|
||||
|
||||
#ifdef CROWPANEL_ESP32S3_5_EPAPER
|
||||
#include "graphics/fonts/EinkDisplayFonts.h"
|
||||
#endif
|
||||
|
||||
#ifdef OLED_PL
|
||||
#define FONT_SMALL_LOCAL ArialMT_Plain_10_PL
|
||||
#else
|
||||
@@ -74,13 +78,12 @@
|
||||
#endif
|
||||
|
||||
#if defined(CROWPANEL_ESP32S3_5_EPAPER)
|
||||
#include "graphics/fonts/EinkDisplayFonts.h"
|
||||
#undef FONT_SMALL
|
||||
#undef FONT_MEDIUM
|
||||
#undef FONT_LARGE
|
||||
#define FONT_SMALL FONT_LARGE_LOCAL // Height: 30
|
||||
#define FONT_MEDIUM FONT_LARGE_LOCAL // Height: 30
|
||||
#define FONT_LARGE FONT_LARGE_LOCAL // Height: 30
|
||||
#define FONT_SMALL Monospaced_plain_30
|
||||
#define FONT_MEDIUM Monospaced_plain_30
|
||||
#define FONT_LARGE Monospaced_plain_30
|
||||
#endif
|
||||
|
||||
#define _fontHeight(font) ((font)[1] + 1) // height is position 1
|
||||
|
||||
@@ -6,7 +6,7 @@ using namespace NicheGraphics::Drivers;
|
||||
|
||||
// Separate from EInk::begin method, as derived class constructors can probably supply these parameters as constants
|
||||
EInk::EInk(uint16_t width, uint16_t height, UpdateTypes supported)
|
||||
: concurrency::OSThread("E-Ink Driver"), width(width), height(height), supportedUpdateTypes(supported)
|
||||
: concurrency::OSThread("EInkDriver"), width(width), height(height), supportedUpdateTypes(supported)
|
||||
{
|
||||
OSThread::disable();
|
||||
}
|
||||
@@ -31,8 +31,8 @@ bool EInk::supports(UpdateTypes type)
|
||||
void EInk::beginPolling(uint32_t interval, uint32_t expectedDuration)
|
||||
{
|
||||
updateRunning = true;
|
||||
updateBegunAt = millis();
|
||||
pollingInterval = interval;
|
||||
pollingBegunAt = millis();
|
||||
|
||||
// To minimize load, we can choose to delay polling for a few seconds, if we know roughly how long the update will take
|
||||
// By default, expectedDuration is 0, and we'll start polling immediately
|
||||
@@ -45,10 +45,26 @@ void EInk::beginPolling(uint32_t interval, uint32_t expectedDuration)
|
||||
// This is what allows us to update the display asynchronously
|
||||
int32_t EInk::runOnce()
|
||||
{
|
||||
// Check for polling timeout
|
||||
// Manually set at 10 seconds, in case some big task holds up the firmware's cooperative multitasking
|
||||
if (millis() - pollingBegunAt > 10000)
|
||||
failed = true;
|
||||
|
||||
// Handle failure
|
||||
// - polling timeout
|
||||
// - other error (derived classes)
|
||||
if (failed) {
|
||||
LOG_WARN("Display update failed. Check wiring & power supply.");
|
||||
updateRunning = false;
|
||||
failed = false;
|
||||
return disable();
|
||||
}
|
||||
|
||||
// If update not yet done
|
||||
if (!isUpdateDone())
|
||||
return pollingInterval; // Poll again in a few ms
|
||||
|
||||
// If update done:
|
||||
// If update done
|
||||
finalizeUpdate(); // Any post-update code: power down panel hardware, hibernate, etc
|
||||
updateRunning = false; // Change what we report via EInk::busy()
|
||||
return disable(); // Stop polling
|
||||
|
||||
@@ -24,7 +24,7 @@ class EInk : private concurrency::OSThread
|
||||
enum UpdateTypes : uint8_t {
|
||||
UNSPECIFIED = 0,
|
||||
FULL = 1 << 0,
|
||||
FAST = 1 << 1,
|
||||
FAST = 1 << 1, // "Partial Refresh"
|
||||
};
|
||||
|
||||
EInk(uint16_t width, uint16_t height, UpdateTypes supported);
|
||||
@@ -41,14 +41,15 @@ class EInk : private concurrency::OSThread
|
||||
void beginPolling(uint32_t interval, uint32_t expectedDuration); // Begin checking repeatedly if update finished
|
||||
virtual bool isUpdateDone() = 0; // Check once if update finished
|
||||
virtual void finalizeUpdate() {} // Run any post-update code
|
||||
bool failed = false; // If an error occurred during update
|
||||
|
||||
private:
|
||||
int32_t runOnce() override; // Repeated checking if update finished
|
||||
|
||||
const UpdateTypes supportedUpdateTypes; // Capabilities of a derived display class
|
||||
bool updateRunning = false; // see EInk::busy()
|
||||
uint32_t updateBegunAt = 0; // For initial pause before polling for update completion
|
||||
uint32_t pollingInterval = 0; // How often to check if update complete (ms)
|
||||
uint32_t pollingBegunAt = 0; // To timeout during polling
|
||||
};
|
||||
|
||||
} // namespace NicheGraphics::Drivers
|
||||
|
||||
58
src/graphics/niche/Drivers/EInk/HINK_E042A87.cpp
Normal file
58
src/graphics/niche/Drivers/EInk/HINK_E042A87.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "./HINK_E042A87.h"
|
||||
|
||||
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||
|
||||
using namespace NicheGraphics::Drivers;
|
||||
|
||||
// Load settings about how the pixels are moved from old state to new state during a refresh
|
||||
// - manually specified,
|
||||
// - or with stored values from displays OTP memory
|
||||
void HINK_E042A87::configWaveform()
|
||||
{
|
||||
sendCommand(0x3C); // Border waveform:
|
||||
sendData(0x01); // Follow LUT for VSH1
|
||||
|
||||
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_E042A87::configUpdateSequence()
|
||||
{
|
||||
switch (updateType) {
|
||||
case FAST:
|
||||
sendCommand(0x21); // Use both "old" and "new" image memory (differential)
|
||||
sendData(0x00);
|
||||
sendData(0x00);
|
||||
|
||||
sendCommand(0x22); // Set "update sequence"
|
||||
sendData(0xFF); // Differential, load waveform from OTP
|
||||
break;
|
||||
|
||||
case FULL:
|
||||
default:
|
||||
sendCommand(0x21); // Bypass "old" image memory (non-differential)
|
||||
sendData(0x40);
|
||||
sendData(0x00);
|
||||
|
||||
sendCommand(0x22); // Set "update sequence":
|
||||
sendData(0xF7); // Non-differential, load waveform from OTP
|
||||
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_E042A87::detachFromUpdate()
|
||||
{
|
||||
switch (updateType) {
|
||||
case FAST:
|
||||
return beginPolling(50, 1000); // At least 1 second, then check every 50ms
|
||||
case FULL:
|
||||
default:
|
||||
return beginPolling(100, 3500); // At least 3.5 seconds, then check every 100ms
|
||||
}
|
||||
}
|
||||
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||
43
src/graphics/niche/Drivers/EInk/HINK_E042A87.h
Normal file
43
src/graphics/niche/Drivers/EInk/HINK_E042A87.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
|
||||
E-Ink display driver
|
||||
- HINK-E042A87
|
||||
- Manufacturer: Holitech
|
||||
- Size: 4.2 inch
|
||||
- Resolution: 400px x 300px
|
||||
- Flex connector marking: HINK-E042A07-FPC-A1
|
||||
- Silver sticker with QR code, marked: HE042A87
|
||||
|
||||
Note: as of Feb. 2025, these panels are used for "WeActStudio 4.2in B&W" display modules
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
#include "./SSD16XX.h"
|
||||
|
||||
namespace NicheGraphics::Drivers
|
||||
{
|
||||
class HINK_E042A87 : public SSD16XX
|
||||
{
|
||||
// Display properties
|
||||
private:
|
||||
static constexpr uint32_t width = 400;
|
||||
static constexpr uint32_t height = 300;
|
||||
static constexpr UpdateTypes supported = (UpdateTypes)(FULL | FAST);
|
||||
|
||||
public:
|
||||
HINK_E042A87() : SSD16XX(width, height, supported) {}
|
||||
|
||||
protected:
|
||||
void configWaveform() override;
|
||||
void configUpdateSequence() override;
|
||||
void detachFromUpdate() override;
|
||||
};
|
||||
|
||||
} // namespace NicheGraphics::Drivers
|
||||
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
||||
@@ -28,6 +28,17 @@ void setupNicheGraphics()
|
||||
}
|
||||
```
|
||||
|
||||
- [Methods](#methods)
|
||||
- [`update(uint8_t *imageData, UpdateTypes type)`](#updateuint8_t-imagedata-updatetypes-type)
|
||||
- [`await()`](#await)
|
||||
- [`supports(UpdateTypes type)`](#supportsupdatetypes-type)
|
||||
- [`busy()`](#busy)
|
||||
- [`width()`](#width)
|
||||
- [`height()`](#height)
|
||||
- [Supporting New Displays](#supporting-new-displays)
|
||||
- [Controller IC](#controller-ic)
|
||||
- [Finding Information](#finding-information)
|
||||
|
||||
## Methods
|
||||
|
||||
### `update(uint8_t *imageData, UpdateTypes type)`
|
||||
@@ -37,7 +48,7 @@ Update the image on the display
|
||||
- _`imageData`_ to draw to the display.
|
||||
- _`type`_ which type of update to perform.
|
||||
- `FULL`
|
||||
- `FAST`
|
||||
- `FAST` (partial refresh)
|
||||
- (Other custom types may be possible)
|
||||
|
||||
The imageData is a 1-bit image. X-Pixels are 8-per byte, with the MSB being the leftmost pixel. This was not an InkHUD design decision; it is the raw format accepted by the E-Ink display controllers ICs.
|
||||
@@ -83,3 +94,39 @@ Width of the display, in pixels. Note: most displays are portrait. Your UI will
|
||||
### `height()`
|
||||
|
||||
Height of the display, in pixels. Note: most displays are portrait. Your UI will need to implement rotation in software.
|
||||
|
||||
## Supporting New Displays
|
||||
|
||||
_This topic is not covered in depth, but these notes may be helpful._
|
||||
|
||||
The `InkHUD::Drivers::EInk` class contains only the mechanism for implementing an E-Ink driver on-top of Meshtastic's `OSThread`. A driver for a specific display needs to extend this class.
|
||||
|
||||
### Controller IC
|
||||
|
||||
If your display uses a controller IC from Solomon Systech, you can probably extend the existing `Drivers::SSD16XX` class, making only minor modifications.
|
||||
|
||||
At this stage, displays using controller ICS from other manufacturers (UltraChip, Fitipower, etc) need to manually implemented. See `Drivers::LCMEN2R13EFC1` for an example.
|
||||
|
||||
Generic base classes for manufacturers other than Solomon Systech might be added here in future.
|
||||
|
||||
### Finding Information
|
||||
|
||||
#### Flex-Connector Labels
|
||||
|
||||
The orange flex-connector attached to E-Ink displays is often printed with an identifying label. This is not a _totally_ unique identifier, but does give a very strong clue as to the true model of the display, which can be used to search out further information.
|
||||
|
||||
#### Datasheets
|
||||
|
||||
The manufacturer of a DIY display module may publish a datasheet. These are often incomplete, but might reveal the true model of the display, or the controller IC.
|
||||
|
||||
If you can determine the true model name of the display, you can likely find a more complete datasheet on the display manufacturer's website. This will often provide a "typical operating sequence"; a general overview of the code used to drive the display
|
||||
|
||||
#### Example Code
|
||||
|
||||
The manufacturer of a DIY module may publish example code. You may have more luck finding example code published by the display manufacturer themselves, if you can determine the true model of the panel. These examples are a very valuable reference.
|
||||
|
||||
#### Other E-Ink drivers
|
||||
|
||||
Libraries like ZinggJM's GxEPD2 can be valuable sources of information, although your panel may not be _specifically_ supported, and only _compatible_ with a driver there, so some caution is advised.
|
||||
|
||||
The display selection file in GxEPD2's Hello World example is also a useful resource for matching "flex connector labels" with display models, but the flex connector label is _not_ a unique identifier, so this is only another clue.
|
||||
|
||||
@@ -37,11 +37,26 @@ void SSD16XX::begin(SPIClass *spi, uint8_t pin_dc, uint8_t pin_cs, uint8_t pin_b
|
||||
reset();
|
||||
}
|
||||
|
||||
void SSD16XX::wait()
|
||||
// Poll the displays busy pin until an operation is complete
|
||||
// Timeout and set fail flag if something went wrong and the display got stuck
|
||||
void SSD16XX::wait(uint32_t timeout)
|
||||
{
|
||||
// Don't bother waiting if part of the update sequence failed
|
||||
// In that situation, we're now just failing-through the process, until we can try again with next update.
|
||||
if (failed)
|
||||
return;
|
||||
|
||||
uint32_t startMs = millis();
|
||||
|
||||
// Busy when HIGH
|
||||
while (digitalRead(pin_busy) == HIGH)
|
||||
while (digitalRead(pin_busy) == HIGH) {
|
||||
// Check for timeout
|
||||
if (millis() - startMs > timeout) {
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
||||
void SSD16XX::reset()
|
||||
@@ -50,8 +65,9 @@ void SSD16XX::reset()
|
||||
if (pin_rst != 0xFF) {
|
||||
pinMode(pin_rst, OUTPUT);
|
||||
digitalWrite(pin_rst, LOW);
|
||||
delay(50);
|
||||
pinMode(pin_rst, INPUT_PULLUP);
|
||||
delay(10);
|
||||
digitalWrite(pin_rst, HIGH);
|
||||
delay(10);
|
||||
wait();
|
||||
}
|
||||
|
||||
@@ -61,6 +77,11 @@ void SSD16XX::reset()
|
||||
|
||||
void SSD16XX::sendCommand(const uint8_t command)
|
||||
{
|
||||
// Abort if part of the update sequence failed
|
||||
// This will unlock again once we have failed-through the entire process
|
||||
if (failed)
|
||||
return;
|
||||
|
||||
spi->beginTransaction(spiSettings);
|
||||
digitalWrite(pin_dc, LOW); // DC pin low indicates command
|
||||
digitalWrite(pin_cs, LOW);
|
||||
@@ -77,6 +98,11 @@ void SSD16XX::sendData(uint8_t data)
|
||||
|
||||
void SSD16XX::sendData(const uint8_t *data, uint32_t size)
|
||||
{
|
||||
// Abort if part of the update sequence failed
|
||||
// This will unlock again once we have failed-through the entire process
|
||||
if (failed)
|
||||
return;
|
||||
|
||||
spi->beginTransaction(spiSettings);
|
||||
digitalWrite(pin_dc, HIGH); // DC pin HIGH indicates data, instead of command
|
||||
digitalWrite(pin_cs, LOW);
|
||||
|
||||
@@ -27,7 +27,7 @@ class SSD16XX : public EInk
|
||||
virtual void update(uint8_t *imageData, UpdateTypes type) override;
|
||||
|
||||
protected:
|
||||
virtual void wait();
|
||||
virtual void wait(uint32_t timeout = 1000);
|
||||
virtual void reset();
|
||||
virtual void sendCommand(const uint8_t command);
|
||||
virtual void sendData(const uint8_t data);
|
||||
|
||||
@@ -582,9 +582,12 @@ std::string InkHUD::Applet::getTimeString(uint32_t epochSeconds)
|
||||
uint32_t hour = hms / SEC_PER_HOUR;
|
||||
uint32_t min = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
|
||||
|
||||
// Format the clock string
|
||||
// Format the clock string, either 12 hour or 24 hour
|
||||
char clockStr[11];
|
||||
sprintf(clockStr, "%u:%02u %s", (hour % 12 == 0 ? 12 : hour % 12), min, hour > 11 ? "PM" : "AM");
|
||||
if (config.display.use_12h_clock)
|
||||
sprintf(clockStr, "%u:%02u %s", (hour % 12 == 0 ? 12 : hour % 12), min, hour > 11 ? "PM" : "AM");
|
||||
else
|
||||
sprintf(clockStr, "%02u:%02u", hour, min);
|
||||
|
||||
return clockStr;
|
||||
}
|
||||
@@ -799,7 +802,7 @@ uint16_t InkHUD::Applet::getLogoHeight(uint16_t limitWidth, uint16_t limitHeight
|
||||
// // \\
|
||||
|
||||
*/
|
||||
void InkHUD::Applet::drawLogo(int16_t centerX, int16_t centerY, uint16_t width, uint16_t height)
|
||||
void InkHUD::Applet::drawLogo(int16_t centerX, int16_t centerY, uint16_t width, uint16_t height, Color color)
|
||||
{
|
||||
struct Point {
|
||||
int x;
|
||||
@@ -905,24 +908,24 @@ void InkHUD::Applet::drawLogo(int16_t centerX, int16_t centerY, uint16_t width,
|
||||
Point aq2{a2.x - fromPath.x, a2.y - fromPath.y};
|
||||
Point aq3{a2.x + fromPath.x, a2.y + fromPath.y};
|
||||
Point aq4{a1.x + fromPath.x, a1.y + fromPath.y};
|
||||
fillTriangle(aq1.x, aq1.y, aq2.x, aq2.y, aq3.x, aq3.y, BLACK);
|
||||
fillTriangle(aq1.x, aq1.y, aq3.x, aq3.y, aq4.x, aq4.y, BLACK);
|
||||
fillTriangle(aq1.x, aq1.y, aq2.x, aq2.y, aq3.x, aq3.y, color);
|
||||
fillTriangle(aq1.x, aq1.y, aq3.x, aq3.y, aq4.x, aq4.y, color);
|
||||
|
||||
// Make the path thick: path b becomes quad b
|
||||
Point bq1{b1.x - fromPath.x, b1.y - fromPath.y};
|
||||
Point bq2{b2.x - fromPath.x, b2.y - fromPath.y};
|
||||
Point bq3{b2.x + fromPath.x, b2.y + fromPath.y};
|
||||
Point bq4{b1.x + fromPath.x, b1.y + fromPath.y};
|
||||
fillTriangle(bq1.x, bq1.y, bq2.x, bq2.y, bq3.x, bq3.y, BLACK);
|
||||
fillTriangle(bq1.x, bq1.y, bq3.x, bq3.y, bq4.x, bq4.y, BLACK);
|
||||
fillTriangle(bq1.x, bq1.y, bq2.x, bq2.y, bq3.x, bq3.y, color);
|
||||
fillTriangle(bq1.x, bq1.y, bq3.x, bq3.y, bq4.x, bq4.y, color);
|
||||
|
||||
// Make the path thick: path c becomes quad c
|
||||
Point cq1{c1.x - fromPath.x, c1.y + fromPath.y};
|
||||
Point cq2{c2.x - fromPath.x, c2.y + fromPath.y};
|
||||
Point cq3{c2.x + fromPath.x, c2.y - fromPath.y};
|
||||
Point cq4{c1.x + fromPath.x, c1.y - fromPath.y};
|
||||
fillTriangle(cq1.x, cq1.y, cq2.x, cq2.y, cq3.x, cq3.y, BLACK);
|
||||
fillTriangle(cq1.x, cq1.y, cq3.x, cq3.y, cq4.x, cq4.y, BLACK);
|
||||
fillTriangle(cq1.x, cq1.y, cq2.x, cq2.y, cq3.x, cq3.y, color);
|
||||
fillTriangle(cq1.x, cq1.y, cq3.x, cq3.y, cq4.x, cq4.y, color);
|
||||
|
||||
// Radius the intersection of quad b and quad c
|
||||
/*
|
||||
@@ -941,7 +944,7 @@ void InkHUD::Applet::drawLogo(int16_t centerX, int16_t centerY, uint16_t width,
|
||||
// The radius for the cap *should* be the same as logoTh, but it's not, due to accumulated rounding
|
||||
// We get better results just re-deriving it
|
||||
int16_t capRad = sqrt(pow(fromPath.x, 2) + pow(fromPath.y, 2));
|
||||
fillCircle(b2.x, b2.y, capRad, BLACK);
|
||||
fillCircle(b2.x, b2.y, capRad, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,8 @@ class Applet : public GFX
|
||||
static constexpr float LOGO_ASPECT_RATIO = 1.9; // Width:Height for drawing the Meshtastic logo
|
||||
uint16_t getLogoWidth(uint16_t limitWidth, uint16_t limitHeight); // Size Meshtastic logo to fit within region
|
||||
uint16_t getLogoHeight(uint16_t limitWidth, uint16_t limitHeight); // Size Meshtastic logo to fit within region
|
||||
void drawLogo(int16_t centerX, int16_t centerY, uint16_t width, uint16_t height); // Draw the meshtastic logo
|
||||
void drawLogo(int16_t centerX, int16_t centerY, uint16_t width, uint16_t height,
|
||||
Color color = BLACK); // Draw the Meshtastic logo
|
||||
|
||||
std::string hexifyNodeNum(NodeNum num); // Style as !0123abdc
|
||||
SignalStrength getSignalStrength(float snr, float rssi); // Interpret SNR and RSSI, as an easy to understand value
|
||||
|
||||
@@ -8,7 +8,7 @@ using namespace NicheGraphics;
|
||||
// Our basic example doesn't do anything useful. It just passively prints some text.
|
||||
void InkHUD::BasicExampleApplet::onRender()
|
||||
{
|
||||
print("Hello, World!");
|
||||
printAt(0, 0, "Hello, World!");
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
using namespace NicheGraphics;
|
||||
|
||||
// We configured MeshModule API to call this method when we receive a new text message
|
||||
// We configured the Module API to call this method when we receive a new text message
|
||||
ProcessMessage InkHUD::NewMsgExampleApplet::handleReceived(const meshtastic_MeshPacket &mp)
|
||||
{
|
||||
|
||||
// Abort if applet fully deactivated
|
||||
// Don't waste time: we wouldn't be rendered anyway
|
||||
if (!isActive())
|
||||
return ProcessMessage::CONTINUE;
|
||||
|
||||
@@ -25,7 +26,7 @@ ProcessMessage InkHUD::NewMsgExampleApplet::handleReceived(const meshtastic_Mesh
|
||||
requestUpdate();
|
||||
}
|
||||
|
||||
// Tell MeshModule API to continue informing other firmware components about this message
|
||||
// Tell Module API to continue informing other firmware components about this message
|
||||
// We're not the only component which is interested in new text messages
|
||||
return ProcessMessage::CONTINUE;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,15 @@ void InkHUD::LogoApplet::onRender()
|
||||
int16_t logoCX = X(0.5);
|
||||
int16_t logoCY = Y(0.5 - 0.05);
|
||||
|
||||
drawLogo(logoCX, logoCY, logoW, logoH);
|
||||
// Invert colors if black-on-white
|
||||
// Used during shutdown, to resport display health
|
||||
// Todo: handle this in InkHUD::Renderer instead
|
||||
if (inverted) {
|
||||
fillScreen(BLACK);
|
||||
setTextColor(WHITE);
|
||||
}
|
||||
|
||||
drawLogo(logoCX, logoCY, logoW, logoH, inverted ? WHITE : BLACK);
|
||||
|
||||
if (!textLeft.empty()) {
|
||||
setFont(fontSmall);
|
||||
@@ -74,13 +82,45 @@ void InkHUD::LogoApplet::onBackground()
|
||||
// Begin displaying the screen which is shown at shutdown
|
||||
void InkHUD::LogoApplet::onShutdown()
|
||||
{
|
||||
bringToForeground();
|
||||
|
||||
textLeft = "";
|
||||
textRight = "";
|
||||
textTitle = "Shutting Down...";
|
||||
fontTitle = fontSmall;
|
||||
|
||||
// Draw a shutting down screen, twice.
|
||||
// Once white on black, once black on white.
|
||||
// Intention is to restore display health.
|
||||
|
||||
inverted = true;
|
||||
inkhud->forceUpdate(Drivers::EInk::FULL, false);
|
||||
delay(1000); // Cooldown. Back to back updates aren't great for health.
|
||||
inverted = false;
|
||||
inkhud->forceUpdate(Drivers::EInk::FULL, false);
|
||||
delay(1000); // Cooldown
|
||||
|
||||
// Prepare for the powered-off screen now
|
||||
// We can change these values because the initial "shutting down" screen has already rendered at this point
|
||||
textLeft = "";
|
||||
textRight = "";
|
||||
textTitle = owner.short_name;
|
||||
fontTitle = fontLarge;
|
||||
|
||||
// This is then drawn by InkHUD::Events::onShutdown, with a blocking FULL update, after InkHUD's flash write is complete
|
||||
}
|
||||
|
||||
void InkHUD::LogoApplet::onReboot()
|
||||
{
|
||||
bringToForeground();
|
||||
// This is then drawn by InkHUD::Events::onShutdown, with a blocking FULL update
|
||||
|
||||
textLeft = "";
|
||||
textRight = "";
|
||||
textTitle = "Rebooting...";
|
||||
fontTitle = fontSmall;
|
||||
|
||||
inkhud->forceUpdate(Drivers::EInk::FULL, false);
|
||||
// Perform the update right now, waiting here until complete
|
||||
}
|
||||
|
||||
int32_t InkHUD::LogoApplet::runOnce()
|
||||
|
||||
@@ -25,6 +25,7 @@ class LogoApplet : public SystemApplet, public concurrency::OSThread
|
||||
void onForeground() override;
|
||||
void onBackground() override;
|
||||
void onShutdown() override;
|
||||
void onReboot() override;
|
||||
|
||||
protected:
|
||||
int32_t runOnce() override;
|
||||
@@ -33,6 +34,7 @@ class LogoApplet : public SystemApplet, public concurrency::OSThread
|
||||
std::string textRight;
|
||||
std::string textTitle;
|
||||
AppletFont fontTitle;
|
||||
bool inverted = false; // Invert colors. Used during shutdown, to restore display health.
|
||||
};
|
||||
|
||||
} // namespace NicheGraphics::InkHUD
|
||||
|
||||
@@ -18,19 +18,20 @@ namespace NicheGraphics::InkHUD
|
||||
|
||||
enum MenuAction {
|
||||
NO_ACTION,
|
||||
SEND_NODEINFO,
|
||||
SEND_POSITION,
|
||||
SEND_PING,
|
||||
SHUTDOWN,
|
||||
NEXT_TILE,
|
||||
TOGGLE_BACKLIGHT,
|
||||
TOGGLE_GPS,
|
||||
ENABLE_BLUETOOTH,
|
||||
TOGGLE_APPLET,
|
||||
ACTIVATE_APPLETS, // Todo: remove? Possible redundant, handled by TOGGLE_APPLET?
|
||||
TOGGLE_AUTOSHOW_APPLET,
|
||||
SET_RECENTS,
|
||||
ROTATE,
|
||||
LAYOUT,
|
||||
TOGGLE_BATTERY_ICON,
|
||||
TOGGLE_NOTIFICATIONS,
|
||||
TOGGLE_BACKLIGHT,
|
||||
TOGGLE_12H_CLOCK,
|
||||
};
|
||||
|
||||
} // namespace NicheGraphics::InkHUD
|
||||
|
||||
@@ -4,9 +4,15 @@
|
||||
|
||||
#include "RTC.h"
|
||||
|
||||
#include "MeshService.h"
|
||||
#include "airtime.h"
|
||||
#include "main.h"
|
||||
#include "power.h"
|
||||
|
||||
#if !MESHTASTIC_EXCLUDE_GPS
|
||||
#include "GPS.h"
|
||||
#endif
|
||||
|
||||
using namespace NicheGraphics;
|
||||
|
||||
static constexpr uint8_t MENU_TIMEOUT_SEC = 60; // How many seconds before menu auto-closes
|
||||
@@ -27,8 +33,6 @@ InkHUD::MenuApplet::MenuApplet() : concurrency::OSThread("MenuApplet")
|
||||
}
|
||||
}
|
||||
|
||||
void InkHUD::MenuApplet::onActivate() {}
|
||||
|
||||
void InkHUD::MenuApplet::onForeground()
|
||||
{
|
||||
// We do need this before we render, but we can optimize by just calculating it once now
|
||||
@@ -141,6 +145,14 @@ void InkHUD::MenuApplet::execute(MenuItem item)
|
||||
inkhud->nextTile();
|
||||
break;
|
||||
|
||||
case SEND_PING:
|
||||
service->refreshLocalMeshNode();
|
||||
service->trySendPosition(NODENUM_BROADCAST, true);
|
||||
|
||||
// Force the next refresh to use FULL, to protect the display, as some users will probably spam this button
|
||||
inkhud->forceUpdate(Drivers::EInk::UpdateTypes::FULL);
|
||||
break;
|
||||
|
||||
case ROTATE:
|
||||
inkhud->rotate();
|
||||
break;
|
||||
@@ -161,12 +173,6 @@ void InkHUD::MenuApplet::execute(MenuItem item)
|
||||
case TOGGLE_APPLET:
|
||||
settings->userApplets.active[cursor] = !settings->userApplets.active[cursor];
|
||||
inkhud->updateAppletSelection();
|
||||
// requestUpdate(Drivers::EInk::UpdateTypes::FULL); // Select FULL, seeing how this action doesn't auto exit
|
||||
break;
|
||||
|
||||
case ACTIVATE_APPLETS:
|
||||
// Todo: remove this action? Already handled by TOGGLE_APPLET?
|
||||
inkhud->updateAppletSelection();
|
||||
break;
|
||||
|
||||
case TOGGLE_AUTOSHOW_APPLET:
|
||||
@@ -205,6 +211,25 @@ void InkHUD::MenuApplet::execute(MenuItem item)
|
||||
backlight->latch();
|
||||
break;
|
||||
|
||||
case TOGGLE_12H_CLOCK:
|
||||
config.display.use_12h_clock = !config.display.use_12h_clock;
|
||||
nodeDB->saveToDisk(SEGMENT_CONFIG);
|
||||
break;
|
||||
|
||||
case TOGGLE_GPS:
|
||||
gps->toggleGpsMode();
|
||||
nodeDB->saveToDisk(SEGMENT_CONFIG);
|
||||
break;
|
||||
|
||||
case ENABLE_BLUETOOTH:
|
||||
// This helps users recover from a bad wifi config
|
||||
LOG_INFO("Enabling Bluetooth");
|
||||
config.network.wifi_enabled = false;
|
||||
config.bluetooth.enabled = true;
|
||||
nodeDB->saveToDisk();
|
||||
rebootAtMsec = millis() + 2000;
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_WARN("Action not implemented");
|
||||
}
|
||||
@@ -226,7 +251,7 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
||||
if (settings->optionalMenuItems.nextTile && settings->userTiles.count > 1)
|
||||
items.push_back(MenuItem("Next Tile", MenuAction::NEXT_TILE, MenuPage::ROOT)); // Only if multiple applets shown
|
||||
|
||||
// items.push_back(MenuItem("Send", MenuPage::SEND)); // TODO
|
||||
items.push_back(MenuItem("Send", MenuPage::SEND));
|
||||
items.push_back(MenuItem("Options", MenuPage::OPTIONS));
|
||||
// items.push_back(MenuItem("Display Off", MenuPage::EXIT)); // TODO
|
||||
items.push_back(MenuItem("Save & Shut Down", MenuAction::SHUTDOWN));
|
||||
@@ -234,21 +259,28 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
||||
break;
|
||||
|
||||
case SEND:
|
||||
items.push_back(MenuItem("Send Message", MenuPage::EXIT));
|
||||
items.push_back(MenuItem("Send NodeInfo", MenuAction::SEND_NODEINFO));
|
||||
items.push_back(MenuItem("Send Position", MenuAction::SEND_POSITION));
|
||||
items.push_back(MenuItem("Ping", MenuAction::SEND_PING, MenuPage::EXIT));
|
||||
// Todo: canned messages
|
||||
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||
break;
|
||||
|
||||
case OPTIONS:
|
||||
// Optional: backlight
|
||||
if (settings->optionalMenuItems.backlight) {
|
||||
assert(backlight);
|
||||
if (settings->optionalMenuItems.backlight)
|
||||
items.push_back(MenuItem(backlight->isLatched() ? "Backlight Off" : "Keep Backlight On", // Label
|
||||
MenuAction::TOGGLE_BACKLIGHT, // Action
|
||||
MenuPage::EXIT // Exit once complete
|
||||
));
|
||||
}
|
||||
|
||||
// Optional: GPS
|
||||
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_DISABLED)
|
||||
items.push_back(MenuItem("Enable GPS", MenuAction::TOGGLE_GPS, MenuPage::EXIT));
|
||||
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED)
|
||||
items.push_back(MenuItem("Disable GPS", MenuAction::TOGGLE_GPS, MenuPage::EXIT));
|
||||
|
||||
// Optional: Enable Bluetooth, in case of lost wifi connection
|
||||
if (!config.bluetooth.enabled || config.network.wifi_enabled)
|
||||
items.push_back(MenuItem("Enable Bluetooth", MenuAction::ENABLE_BLUETOOTH, MenuPage::EXIT));
|
||||
|
||||
items.push_back(MenuItem("Applets", MenuPage::APPLETS));
|
||||
items.push_back(MenuItem("Auto-show", MenuPage::AUTOSHOW));
|
||||
@@ -260,26 +292,14 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
||||
&settings->optionalFeatures.notifications));
|
||||
items.push_back(MenuItem("Battery Icon", MenuAction::TOGGLE_BATTERY_ICON, MenuPage::OPTIONS,
|
||||
&settings->optionalFeatures.batteryIcon));
|
||||
|
||||
// TODO - GPS and Wifi switches
|
||||
/*
|
||||
// Optional: has GPS
|
||||
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_DISABLED)
|
||||
items.push_back(MenuItem("Enable GPS", MenuPage::EXIT)); // TODO
|
||||
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED)
|
||||
items.push_back(MenuItem("Disable GPS", MenuPage::EXIT)); // TODO
|
||||
|
||||
// Optional: using wifi
|
||||
if (!config.bluetooth.enabled)
|
||||
items.push_back(MenuItem("Enable Bluetooth", MenuPage::EXIT)); // TODO: escape hatch if wifi configured wrong
|
||||
*/
|
||||
|
||||
items.push_back(
|
||||
MenuItem("12-Hour Clock", MenuAction::TOGGLE_12H_CLOCK, MenuPage::OPTIONS, &config.display.use_12h_clock));
|
||||
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||
break;
|
||||
|
||||
case APPLETS:
|
||||
populateAppletPage();
|
||||
items.push_back(MenuItem("Exit", MenuAction::ACTIVATE_APPLETS));
|
||||
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||
break;
|
||||
|
||||
case AUTOSHOW:
|
||||
@@ -293,7 +313,6 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
||||
|
||||
case EXIT:
|
||||
sendToBackground(); // Menu applet dismissed, allow normal behavior to resume
|
||||
// requestUpdate(Drivers::EInk::UpdateTypes::FULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -378,11 +397,14 @@ void InkHUD::MenuApplet::onRender()
|
||||
// Center-line for the text
|
||||
int16_t center = itemT + (itemH / 2);
|
||||
|
||||
// Box, if currently selected
|
||||
if (cursorShown && i == cursor)
|
||||
drawRect(itemL, itemT, itemW, itemH, BLACK);
|
||||
|
||||
// Item's text
|
||||
printAt(itemL + X(padding), center, item.label, LEFT, MIDDLE);
|
||||
|
||||
// Testing only: circle instead of check box
|
||||
// Checkbox, if relevant
|
||||
if (item.checkState) {
|
||||
const uint16_t cbWH = fontSmall.lineHeight(); // Checkbox: width / height
|
||||
const int16_t cbL = itemR - X(padding) - cbWH; // Checkbox: left
|
||||
|
||||
@@ -21,7 +21,6 @@ class MenuApplet : public SystemApplet, public concurrency::OSThread
|
||||
{
|
||||
public:
|
||||
MenuApplet();
|
||||
void onActivate() override;
|
||||
void onForeground() override;
|
||||
void onBackground() override;
|
||||
void onButtonShortPress() override;
|
||||
|
||||
@@ -207,8 +207,6 @@ void InkHUD::TipsApplet::onBackground()
|
||||
inkhud->forceUpdate(EInk::UpdateTypes::FULL);
|
||||
}
|
||||
|
||||
void InkHUD::TipsApplet::onActivate() {}
|
||||
|
||||
// While our SystemApplet::handleInput flag is true
|
||||
void InkHUD::TipsApplet::onButtonShortPress()
|
||||
{
|
||||
|
||||
@@ -33,7 +33,6 @@ class TipsApplet : public SystemApplet
|
||||
TipsApplet();
|
||||
|
||||
void onRender() override;
|
||||
void onActivate() override;
|
||||
void onForeground() override;
|
||||
void onBackground() override;
|
||||
void onButtonShortPress() override;
|
||||
|
||||
@@ -70,6 +70,9 @@ void InkHUD::Events::onButtonLong()
|
||||
// Returns 0 to signal that we agree to sleep now
|
||||
int InkHUD::Events::beforeDeepSleep(void *unused)
|
||||
{
|
||||
// If a previous display update is in progress, wait for it to complete.
|
||||
inkhud->awaitUpdate();
|
||||
|
||||
// Notify all applets that we're shutting down
|
||||
for (Applet *ua : inkhud->userApplets) {
|
||||
ua->onDeactivate();
|
||||
@@ -87,9 +90,12 @@ int InkHUD::Events::beforeDeepSleep(void *unused)
|
||||
inkhud->persistence->saveSettings();
|
||||
inkhud->persistence->saveLatestMessage();
|
||||
|
||||
// LogoApplet::onShutdown will have requested an update, to draw the shutdown screen
|
||||
// Draw that now, and wait here until the update is complete
|
||||
// LogoApplet::onShutdown attempted to heal the display by drawing a "shutting down" screen twice,
|
||||
// then prepared a final powered-off screen for us, which shows device shortname.
|
||||
// We're updating to show that one now.
|
||||
|
||||
inkhud->forceUpdate(Drivers::EInk::UpdateTypes::FULL, false);
|
||||
delay(1000); // Cooldown, before potentially yanking display power
|
||||
|
||||
return 0; // We agree: deep sleep now
|
||||
}
|
||||
@@ -106,16 +112,16 @@ int InkHUD::Events::beforeReboot(void *unused)
|
||||
a->onDeactivate();
|
||||
a->onShutdown();
|
||||
}
|
||||
for (Applet *sa : inkhud->systemApplets) {
|
||||
for (SystemApplet *sa : inkhud->systemApplets) {
|
||||
// Note: no onDeactivate. System applets are always active.
|
||||
sa->onShutdown();
|
||||
sa->onReboot();
|
||||
}
|
||||
|
||||
inkhud->persistence->saveSettings();
|
||||
inkhud->persistence->saveLatestMessage();
|
||||
|
||||
// Note: no forceUpdate call here
|
||||
// Because OSThread will not be given another chance to run before reboot, this means that no display update will occur
|
||||
// We don't have any final screen to draw, although LogoApplet::onReboot did already display a "rebooting" screen
|
||||
|
||||
return 0; // No special status to report. Ignored anyway by this Observable
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class Persistence
|
||||
// Rotation of the display
|
||||
// Multiples of 90 degrees clockwise
|
||||
// Most commonly: rotation is 0 when flex connector is oriented below display
|
||||
uint8_t rotation = 1;
|
||||
uint8_t rotation = 0;
|
||||
|
||||
// How long do we consider another node to be "active"?
|
||||
// Used when applets want to filter for "active nodes" only
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# InkHUD
|
||||
|
||||
A heads-up-display for E-Ink devices, intended to supplement a connected phone / client. Implemented as a "NicheGraphics" UI.
|
||||
|
||||
Supported devices (as of 1st Feb. 2025):
|
||||
|
||||
- Heltec Vision Master E213
|
||||
- Heltec Vision Master E290
|
||||
- Heltec Wireless Paper V1.1
|
||||
- LILYGO T-Echo
|
||||
|
||||
More to follow
|
||||
@@ -26,6 +26,8 @@ class SystemApplet : public Applet
|
||||
bool lockRendering = false; // - prevent other applets from being rendered during an update
|
||||
bool lockRequests = false; // - prevent other applets from triggering display updates
|
||||
|
||||
virtual void onReboot() { onShutdown(); } // - handle reboot specially
|
||||
|
||||
// Other system applets may take precedence over our own system applet though
|
||||
// The order an applet is passed to WindowManager::addSystemApplet determines this hierarchy (added earlier = higher rank)
|
||||
|
||||
|
||||
640
src/graphics/niche/InkHUD/docs/README.md
Normal file
640
src/graphics/niche/InkHUD/docs/README.md
Normal file
@@ -0,0 +1,640 @@
|
||||
# InkHUD
|
||||
|
||||
This document is intended as a reference for maintainers. A haphazard collection of notes which _might_ be helpful.
|
||||
|
||||
<img src="disclaimer.jpg" width="250" alt="self deprecating meme" />
|
||||
|
||||
---
|
||||
|
||||
- [Purpose](#purpose)
|
||||
- [Design Principles](#design-principles)
|
||||
- [Self-Contained](#self-contained)
|
||||
- [Static](#static)
|
||||
- [Non-interactive](#non-interactive)
|
||||
- [Customizable](#customizable)
|
||||
- [Event-Driven Rendering](#event-driven-rendering)
|
||||
- [No `#ifdef` spaghetti](#no-ifdef-spaghetti)
|
||||
- [The Implementation](#the-implementation)
|
||||
- [The Rendering Process](#the-rendering-process)
|
||||
- [Concepts](#concepts)
|
||||
- [NicheGraphics Framework](#nichegraphics-framework)
|
||||
- [NicheGraphics E-Ink Drivers](#nichegraphics-e-ink-drivers)
|
||||
- [InkHUD Applets](#inkhud-applets)
|
||||
- [Adding a Variant](#adding-a-variant)
|
||||
- [platformio.ini](#platformioini)
|
||||
- [nicheGraphics.h](#nichegraphicsh)
|
||||
- [Class Notes](#class-notes)
|
||||
- [`InkHUD::InkHUD`](#inkhudinkhud)
|
||||
- [`InkHUD::Persistence`](#inkhudpersistence)
|
||||
- [`InkHUD::Persistence::Settings`](#inkhudpersistencesettings)
|
||||
- [`InkHUD::Persistence::LatestMessage`](#inkhudpersistencelatestmessage)
|
||||
- [`InkHUD::WindowManager`](#inkhudwindowmanager)
|
||||
- [`InkHUD::Renderer`](#inkhudrenderer)
|
||||
- [`InkHUD::Renderer::DisplayHealth`](#inkhudrendererdisplayhealth)
|
||||
- [`InkHUD::Events`](#inkhudevents)
|
||||
- [`InkHUD::Applet`](#inkhudapplet)
|
||||
- [`InkHUD::SystemApplet`](#inkhudsystemapplet)
|
||||
- [`InkHUD::Tile`](#inkhudtile)
|
||||
- [`InkHUD::AppletFont`](#inkhudappletfont)
|
||||
|
||||
## Purpose
|
||||
|
||||
InkHUD is a minimal UI for E-Ink devices. It displays the user's choice of info, as statically as possible, to minimize the amount of display refreshing.
|
||||
|
||||
It is intended to supplement a connected client app.
|
||||
|
||||
## Design Principles
|
||||
|
||||
### Self-Contained
|
||||
|
||||
- Keep InkHUD code within `/src/graphics/niche/InkHUD`.
|
||||
- Place reusable components within `/src/graphics/niche`, for other UIs to take advantage of.
|
||||
- Interact with the firmware code using the **Module API**, **Observables**, and other similarly non-intrusive hooks.
|
||||
|
||||
### Static
|
||||
|
||||
Information should be displayed as statically as possible. Unnecessary updates should be avoided.
|
||||
|
||||
As as example, fixed timestamps are used instead of `X seconds ago` labels, as these need to be constantly updated to remain current.
|
||||
|
||||
### Non-interactive
|
||||
|
||||
InkHUD aims to be a "heads up display". The intention is for the user to glance at the display. The intention is _not_ for the user to frequently interact with the display.
|
||||
|
||||
Some interactivity is tolerated as a means to an end: the display _should_ be customizable, but this should be minimized as much as possible.
|
||||
|
||||
_Edit: there's significant demand for keyboard support, so some sort of free-text feature will need to be added eventually, although it does go against the original design principles._
|
||||
|
||||
### Customizable
|
||||
|
||||
The user should be given the choice to decide which information they would like to receive, and how they would like to receive it.
|
||||
|
||||
### Event-Driven Rendering
|
||||
|
||||
The display image does not update "automatically". Individual applets are responsible for deciding when they have new information to show, and then requesting a display update.
|
||||
|
||||
### No `#ifdef` spaghetti
|
||||
|
||||
**Don't** use preprocessor macros for device-specific configuration. This should be achieved with config methods, in [`nicheGraphics.h`](#nichegraphicsh).
|
||||
|
||||
**Do** use preprocessor macros to guard all files
|
||||
|
||||
- `#ifdef MESHTASTIC_INCLUDE_INKHUD` for InkHUD files
|
||||
- `#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS` for reusable components (drivers, etc)
|
||||
|
||||
## The Implementation
|
||||
|
||||
- Variant's platformio.ini file extends `inkhud` (defined in InkHUD/PlatformioConfig.ini)
|
||||
- original screen class suppressed: `MESHTASTIC_EXCLUDE_SCREEN`
|
||||
- ButtonThread suppressed: `HAS_BUTTON=0`
|
||||
- NicheGraphics components included: `MESHTASTIC_INCLUDE_NICHE_GRAPHICS`
|
||||
- InkHUD components included: `MESHTASTIC_INCLUDE_INKHUD`
|
||||
- `main.cpp`
|
||||
- includes `nicheGraphics.h` (from variant folder)
|
||||
- calls `setupNicheGraphics`, (from nicheGraphics.h)
|
||||
- `nicheGraphics.h`
|
||||
- includes InkHUD components
|
||||
- includes shared NicheGraphics components
|
||||
- `setupNicheGraphics`
|
||||
- configures and connects components
|
||||
- `inkhud->begin`
|
||||
|
||||
## The Rendering Process
|
||||
|
||||
(animated diagram)
|
||||
|
||||
<img src="rendering.gif" alt="animated process diagram of InkHUD rendering" height="480"/>
|
||||
|
||||
An overview:
|
||||
|
||||
- A component calls `requestUpdate` (applets only) or `InkHUD::forceUpdate`
|
||||
- `Renderer` schedules a render cycle for the next loop(), using `Renderer::runOnce`
|
||||
- `Renderer` determines whether the update request is valid
|
||||
- `Renderer` asks relevant applets to render
|
||||
- Applet dimensions are updated (by Applet's `Tile`)
|
||||
- Applets generate pixel output, and pass this to their `Tile`
|
||||
- Tiles shift these "relative" pixels to their true region, for multiplexing
|
||||
- Tiles pass the pixels to `Renderer`
|
||||
- `Renderer` applies any global display rotation to the pixels
|
||||
- `Renderer` combines the pixels into the finished image
|
||||
- The finished image is passed to the display driver, starting the physical update process
|
||||
|
||||
## Concepts
|
||||
|
||||
### NicheGraphics Framework
|
||||
|
||||
InkHUD is implemented as a _NicheGraphics_ UI.
|
||||
|
||||
Intended as a pattern / philosophy for implementing self-contained UIs, to suit various niche devices, which are best served by their own custom user interface.
|
||||
|
||||
Hypothetical examples: E-Ink, 1602 LCDs, tiny OLEDs, smart watches, etc
|
||||
|
||||
A NicheGraphics UI:
|
||||
|
||||
- Is self-contained
|
||||
- Makes use of the loose collection of resources (drivers, input methods, etc) gathered in the `/src/graphics/niche` folder.
|
||||
- Implements a `setupNicheGraphics()` method.
|
||||
|
||||
### NicheGraphics E-Ink Drivers
|
||||
|
||||
InkHUD uses a set of custom E-Ink drivers. These are not based on GxEPD2, or any other code base. They are written directly on-top of the Meshtastic firmware, to make use of the OSThread class for asynchronous display updates.
|
||||
|
||||
Interacting with the drivers is straightforward. InkHUD generates a frame of 1-bit image data. This image data is passed to the driver, along with the type of refresh to use (FULL or FAST).
|
||||
|
||||
`driver->update(uint8_t* buffer, EInk::UpdateTypes::FULL)`
|
||||
|
||||
For more information, see the documentation in `src/graphics/niche/Drivers/EInk`
|
||||
|
||||
### InkHUD Applets
|
||||
|
||||
An InkHUD applet is a class which generates a screen of info for the display.
|
||||
|
||||
Consider: `DMApplet.h` (displays most recent direct message) and `RecentsList.h` (displays a list of recently heard nodes)
|
||||
|
||||
- Applets are modular: they are easy to write, and easy to implement. Users select which applets they want, using the menu.
|
||||
- Applets use responsive design. They should scale for different screens / layouts / fonts.
|
||||
- Applets decide when to update. They use the Module API, Observers, etc, to retrieve information, and request a display update when they have something interesting to show.
|
||||
|
||||
See `src/graphics/niche/InkHUD/Applets/Examples` for example code.
|
||||
|
||||
#### Writing an Applet
|
||||
|
||||
Your new applet class will inherit `InkHUD::Applet`.
|
||||
|
||||
```cpp
|
||||
class BasicExampleApplet : public Applet
|
||||
{
|
||||
public:
|
||||
// You must have an onRender() method
|
||||
// All drawing happens here
|
||||
|
||||
void onRender() override;
|
||||
};
|
||||
```
|
||||
|
||||
The `onRender` method is called when the display image is redrawn. This can happen at any time, so be ready!
|
||||
|
||||
```cpp
|
||||
// All drawing happens here
|
||||
// Our basic example doesn't do anything useful. It just passively prints some text.
|
||||
void InkHUD::BasicExampleApplet::onRender()
|
||||
{
|
||||
printAt(0, 0, "Hello, world!");
|
||||
}
|
||||
```
|
||||
|
||||
Your applet will need to scale automatically, to suit a variety of screens / layouts / fonts. Make sure you draw relative to applet's size.
|
||||
|
||||
| edge | coordinate | shorthand |
|
||||
| ------ | ---------- | --------- |
|
||||
| left | 0 | `X(0.0)` |
|
||||
| top | 0 | `Y(0.0)` |
|
||||
| right | `width()` | `X(1.0)` |
|
||||
| bottom | `height()` | `Y(1.0)` |
|
||||
|
||||
The same principles apply for drawing text. Methods like `AppletFont::lineHeight` and `getTextWidth` are useful here.
|
||||
|
||||
```cpp
|
||||
std::string line1 = "Line 1";
|
||||
printAt(0, Y(0.5), line1);
|
||||
drawRect(0, Y(0.5), getTextWidth(line1), fontSmall.lineHeight(), BLACK);
|
||||
```
|
||||
|
||||
Your applet will only be redrawn when _something_ requests a display update. Your applet is welcome to request a display update, when it determines that it has new info to display, by calling `requestUpdate`.
|
||||
|
||||
Exactly how you determine this, depends on what your applet actually does. Here's a code snippet from one of the example applets. The applet is requesting an update when a new message is received.
|
||||
|
||||
```cpp
|
||||
// We configured the Module API to call this method when we receive a new text message
|
||||
ProcessMessage InkHUD::NewMsgExampleApplet::handleReceived(const meshtastic_MeshPacket &mp)
|
||||
{
|
||||
|
||||
// Abort if applet fully deactivated
|
||||
// Don't waste time: we wouldn't be rendered anyway
|
||||
if (!isActive())
|
||||
return ProcessMessage::CONTINUE;
|
||||
|
||||
// Check that this is an incoming message
|
||||
// Outgoing messages (sent by us) will also call handleReceived
|
||||
|
||||
if (!isFromUs(&mp)) {
|
||||
// Store the sender's nodenum
|
||||
// We need to keep this information, so we can re-use it anytime render() is called
|
||||
haveMessage = true;
|
||||
fromWho = mp.from;
|
||||
|
||||
// Tell InkHUD that we have something new to show on the screen
|
||||
requestUpdate();
|
||||
}
|
||||
|
||||
// Tell Module API to continue informing other firmware components about this message
|
||||
// We're not the only component which is interested in new text messages
|
||||
return ProcessMessage::CONTINUE;
|
||||
}
|
||||
```
|
||||
|
||||
#### Implementing an Applet
|
||||
|
||||
Incorporating your new applet into InkHUD is easy.
|
||||
|
||||
In a variant's `nicheGraphics.h`:
|
||||
|
||||
- `#include` your applet
|
||||
- `inkhud->addApplet("My Applet", new InkHUD::MyApplet);`
|
||||
|
||||
You will need to add these lines to any variants which will use your applet.
|
||||
|
||||
#### Applet Bases
|
||||
|
||||
If you need to create several similar applets, it might make sense to create a reusable base class. Several of these already exist in `src/graphics/niche/InkHUD/Applets/Bases`, but use these with caution, as they may be modified in future.
|
||||
|
||||
#### System Applets
|
||||
|
||||
So far, we have been talking about "user applets". We also recognize a separate category of "system applets". These handle things like the menu, and the boot screen. These often need special handling, and need to be implemented manually.
|
||||
|
||||
## Adding a Variant
|
||||
|
||||
In `/variants/<YOUR_VARIANT>/`:
|
||||
|
||||
### platformio.ini
|
||||
|
||||
Extend `inkhud`, then combine with any other platformio config your hardware variant requires.
|
||||
|
||||
_(Example shows only config required by InkHUD. This is not a complete `env` definition.)_
|
||||
|
||||
```ini
|
||||
[env:YOUR_VARIANT-inkhud]
|
||||
extends = esp32s3_base, inkhud ; or nrf52840_base, etc
|
||||
|
||||
build_src_filter =
|
||||
${esp32_base.build_src_filter}
|
||||
${inkhud.build_src_filter}
|
||||
|
||||
build_flags =
|
||||
${esp32s3_base.build_flags}
|
||||
${inkhud.build_flags}
|
||||
|
||||
lib_deps =
|
||||
${inkhud.lib_deps} ; InkHUD libs first, so we get GFXRoot instead of AdafruitGFX
|
||||
${esp32s3_base.lib_deps}
|
||||
```
|
||||
|
||||
### nicheGraphics.h
|
||||
|
||||
⚠ Wrap this file in `#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS`
|
||||
|
||||
`nicheGraphics.h` should be placed in the same folder as your variant's `platformio.ini`. If this is not possible, modify `build_src_filter`.
|
||||
|
||||
`nicheGraphics.h` should contain a `setupNicheGraphics` method, which creates and configures the various components for InkHUD.
|
||||
|
||||
- Display
|
||||
- Start SPI
|
||||
- Create display driver
|
||||
- InkHUD
|
||||
- Create InkHUD instance
|
||||
- Set E-Ink fast refresh limit (`setDisplayResilience`)
|
||||
- Set fonts
|
||||
- Set default user-settings
|
||||
- Select applets to build (`addApplet`)
|
||||
- Start InkHUD
|
||||
- Buttons
|
||||
- Setup `TwoButton` driver (user button, optional "auxiliary" button)
|
||||
- Connect to InkHUD handlers (use lambdas)
|
||||
|
||||
For well commented examples, see:
|
||||
|
||||
- `variants/heltec_vision_master_e290/nicheGraphics.h` (ESP32)
|
||||
- `variants/t-echo/nicheGraphics.h` (NRF52)
|
||||
|
||||
## Class Notes
|
||||
|
||||
### `InkHUD::InkHUD`
|
||||
|
||||
_`src/graphics/niche/InkHUD/InkHUD.h`_
|
||||
|
||||
- singleton
|
||||
- mediator between other InkHUD components
|
||||
|
||||
#### `getInstance()`
|
||||
|
||||
Gets access to the class.
|
||||
First `getInstance` call instantiates the class, and the subclasses:
|
||||
|
||||
- `InkHUD::Persistence`
|
||||
- `InkHUD::WindowManager`
|
||||
- `InkHUD::Renderer`
|
||||
- `InkHUD::Events`
|
||||
|
||||
For convenience, many InkHUD components call this on `begin`, and store it as `InkHUD* inkhud`.
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::Persistence`
|
||||
|
||||
_`src/graphics/niche/InkHUD/Persistence.h`_
|
||||
|
||||
Stores InkHUD data in flash
|
||||
|
||||
- settings
|
||||
- most recent text message received (both for broadcast and DM)
|
||||
|
||||
In rare cases, applets may store their own specific data separately (e.g. `ThreadedMessageApplet`)
|
||||
|
||||
Data saved only on shutdown / reboot. Not saved if power is removed unexpectedly.
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::Persistence::Settings`
|
||||
|
||||
_`src/graphics/niche/InkHUD/Persistence.h`_
|
||||
|
||||
Settings which relate to InkHUD. Mostly user's customization, but some values record the UI's state (e.g. `tips.safeShutdownSeen`)
|
||||
|
||||
- stored using `FlashData.h` (a shared Niche Graphics tool)
|
||||
- not encoded as protobufs
|
||||
- serialized directly as bytes of struct
|
||||
|
||||
#### Defaults
|
||||
|
||||
Global default values are set when the struct is defined (Persistence.h).
|
||||
Per-variant defaults are set by modifying the values of the settings instance during `setupNicheGraphics()`, before `inkhud->begin` is called.
|
||||
|
||||
```cpp
|
||||
inkhud->persistence->settings.userTiles.count = 2;
|
||||
inkhud->persistence->settings.userTiles.maxCount = 4;
|
||||
inkhud->persistence->settings.rotation = 3;
|
||||
```
|
||||
|
||||
By modifying the values at this point, they will be used if we fail to load previous settings from flash (not yet saved, old version, etc)
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::Persistence::LatestMessage`
|
||||
|
||||
_`src/graphics/niche/InkHUD/Persistence.h`_
|
||||
|
||||
Most recently received text message
|
||||
|
||||
- most recent DM
|
||||
- most recent broadcast
|
||||
|
||||
Collected here, so various user applets don't all have to store their own copy of this info.
|
||||
|
||||
We are unable to use `devicestate.rx_text_message` for this purpose, because:
|
||||
|
||||
- it is cleared by an outgoing text message
|
||||
- we want to store both a recent broadcast and a recent DM
|
||||
|
||||
#### Saving / Loading
|
||||
|
||||
_A bit of a hack.._
|
||||
Stored to flash using `InkHUD::MessageStore`, which is really intended for storing a thread of messages (see `ThreadedMessageApplet`). Used because it stores strings more efficiently than `FlashData.h`.
|
||||
|
||||
The hack is:
|
||||
|
||||
- If most recent message was a DM, we only store the DM.
|
||||
- If most recent message was a broadcast, we store both a DM and a broadcast. The DM may be 0-length string.
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::WindowManager`
|
||||
|
||||
_`src/graphics/niche/InkHUD/WindowManager.h`_
|
||||
|
||||
Manages which applets are shown, and their size / position (by manipulating the "tiles")
|
||||
|
||||
- owns the `Tile` instances
|
||||
- creates and destroys tiles; sets size and position:
|
||||
- at startup
|
||||
- at runtime, when config changes (layout, rotation, etc)
|
||||
- activates (or deactivates) applets
|
||||
- cycling through applets (e.g. on button press)
|
||||
|
||||
The window manager doesn't process pixels; that is handled by the `InkHUD::Tile` objects.
|
||||
|
||||
Note: Some of the methods (incl. `changeLayout`, `changeActivatedApplets`) don't trigger changes themselves. They should be called _after_ the relevant values in `inkhud->persistence->settings` have been modified.
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::Renderer`
|
||||
|
||||
_`src/graphics/niche/InkHUD/Renderer.h`_
|
||||
|
||||
Get pixel output from applets (via a tile), combine, and pass to the driver.
|
||||
|
||||
- triggered by `requestUpdate` or `forceUpdate`
|
||||
- not run immediately: allows multiple applets to share one render cycle
|
||||
- calls `Applet::onRender` for relevant applets
|
||||
- applies global rotation
|
||||
- passes finalized image to driver
|
||||
|
||||
`requestUpdate` is for applets (user or system). Renderer will honor the request if the applet is visible. `forceUpdate` can be used anywhere, but not from user applets, please.
|
||||
|
||||
#### Asynchronous updates
|
||||
|
||||
`requestUpdate` and `forceUpdate` do not block code execution. They schedule rendering for "ASAP", using `Renderer::runOnce`. Renderer then gets pixel output from relevant applets, and hands the assembled image to the driver. Driver's update process is also asynchronous. If the driver is busy when `requestUpdate` or `forceUpdate` is called, another rendering will run as soon as possible. This is handled by `Renderer::runOnce`
|
||||
|
||||
#### Blocking updates
|
||||
|
||||
If needed, call `forceUpdate` with the optional argument `async=false` to wait while an update runs (> 1 second). Additionally, the `awaitUpdate` method can be used to block until any previous update has completed. An example usage of this is waiting to draw the shutdown screen.
|
||||
|
||||
#### Global rotation
|
||||
|
||||
The exact size / position / rotation of InkHUD applets is configurable by the user. To achieve this, applets draw pixels between 0,0 and `Applet::width()`, `Applet::height()`
|
||||
|
||||
- **Scaling**: Applet's `width()` and `height()` are set by `Tile` before rendering starts
|
||||
- **Translation**: `Tile` shifts applet pixels up/down/left/right
|
||||
- **Rotation**: `Renderer` rotates all pixels it receives, before placing them into the final image buffer
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::Renderer::DisplayHealth`
|
||||
|
||||
_`src/graphics/niche/InkHUD/DisplayHealth.h`_
|
||||
|
||||
Responsible for maintaining display health, by optimizing the ratio of FAST vs FULL refreshes
|
||||
|
||||
- count number of FAST vs FULL refreshes (debt)
|
||||
- suggest either FAST or FULL type
|
||||
- periodically FULL refresh the display unprovoked, if needed
|
||||
|
||||
#### Background Info
|
||||
|
||||
When the image on an E-Ink display is updated, different procedures can be used to move the pixels to their new states. We have defined two procedures: `FAST` and `FULL`.
|
||||
|
||||
A `FAST` update moves pixels directly from their old position, to their new position. This is aesthetically pleasing, and quick, _but_ it is challenging for the display hardware. If used excessively, pixels can build up residual charge, which negatively impacts the display's lifespan and image quality.
|
||||
|
||||
A `FULL` update first moves all pixels between black and white, before letting them eventually settle at their final position. This causes an unpleasant flashing of the display image, but is best for the display health and image quality.
|
||||
|
||||
Most displays readily tolerate `FAST` updates, so long as a `FULL` update is occasionally performed. How often this `FULL` update is required depends on the display model.
|
||||
|
||||
#### Debt
|
||||
|
||||
`InkHUD::DisplayHealth` records how many `FAST` refreshes have occurred since the previous `FULL` refresh.
|
||||
|
||||
This is referred to as the "full refresh debt".
|
||||
|
||||
If an update of a specific type (`FULL` / `FAST`) is requested / forced, this will be granted.
|
||||
|
||||
If an update is requested / forced _without_ a specified type (`UpdateTypes::UNSPECIFIED`), `DisplayHealth` will select either `FAST` or `FULL`, in an attempt to maintain a target ratio of fast to full updates.
|
||||
|
||||
This target is set by `InkHUD::setDisplayResilience`, when setting up in `nichegraphics.h`
|
||||
|
||||
If an _excessive_ amount of `FAST` refreshes are performed back-to-back, `DisplayHealth` will begin artificially inflating the full refresh debt. This will cause the next few `UNSPECIFIED` updates to _all_ be performed as `FULL`, while the debt is paid down.
|
||||
|
||||
This system of "full refresh debt" allows us to increase perceived responsiveness by tolerating additional strain on the display during periods of user interaction, and attempting to "repair the damage" later, once user interaction ceases.
|
||||
|
||||
#### Maintenance
|
||||
|
||||
The system of "full refresh debt" assumes that the display will perform many updates of `UNSPECIFIED` type between periods of user interaction. Depending on the amount of mesh traffic / applet selection, this may not be the case.
|
||||
|
||||
If debt is particularly high, and no updates are taking place organically, `DisplayHealth` will begin infrequently performing `FULL` updates, purely to pay down the full refresh debt.
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::Events`
|
||||
|
||||
Handles events which impact the InkHUD system generally (e.g. shutdown, button press).
|
||||
|
||||
Applets themselves do also listen separately for various events, but for the purpose of gathering information which they would like to display.
|
||||
|
||||
#### Buttons
|
||||
|
||||
Button input is sometimes handled by a system applet. `InkHUD::Events` determines whether the button should be handled by a specific system applet, or should instead trigger a default behavior
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::Applet`
|
||||
|
||||
A base class for applets. An applet is one "program", which may show info on the display.
|
||||
|
||||
To oversimplify, all of the InkHUD code "under the hood" only exists to support applets. Applets are what actually shows useful information to the user. This base class exposes the functionality needed to write an applet.
|
||||
|
||||
#### Drawing Methods
|
||||
|
||||
`Applet` implements most AdafruitGFX drawing methods. Exception is the text handling. `printAt`, `printWrapped`, and `printThick` should be used instead. These are intended to be more convenient, but they also implement the character substitution system which powers the foreign alphabet support.
|
||||
|
||||
`Applet` also adds methods for drawing several design elements which are re-used commonly though-out InkHUD.
|
||||
|
||||
#### InkHUD Events
|
||||
|
||||
Applets undergo a number of state changes: activated / deactivated by user, brought to foreground / hidden to background by user button press, etc. The `Applet` class provides a set of virtual methods, which an applet can override to appropriately handle these events.
|
||||
|
||||
The `onRender` virtual method is one example. This is called when an applet is rendered, and should execute all drawing code. An applet _must_ implement this method.
|
||||
|
||||
#### Responsive Design
|
||||
|
||||
An applet's size will vary depending on the screen size, and the user's layout (multiplexing). Immediately before `onRender` is called, an applet's dimensions are updated, so that `width()` and `height()` will give the required size. The applet should draw its graphical elements relative to these values. The methods `X(float)` and `Y(float)` are also provided for convenience.
|
||||
|
||||
| edge | coordinate | shorthand |
|
||||
| ------ | ---------- | --------- |
|
||||
| left | 0 | `X(0.0)` |
|
||||
| top | 0 | `Y(0.0)` |
|
||||
| right | `width()` | `X(1.0)` |
|
||||
| bottom | `height()` | `Y(1.0)` |
|
||||
|
||||
The same principles apply for drawing text. Methods like `AppletFont::lineHeight` and `getTextWidth` are useful here.
|
||||
|
||||
Applets should always draw relative to their top left corner, at _x=0, y=0._ The applet's pixels are automatically moved to the correct position on-screen by an InkHUD::Tile.
|
||||
|
||||
#### User Applets
|
||||
|
||||
User applets are the "normal" applets, each one displaying a specific set of information to the user. They can be activated / deactivated at run-time using the on-screen menu. Examples include `DMApplet.h` and `PositionsApplet.h`. User applets are not expected to interact with lower layers of the InkHUD code.
|
||||
|
||||
Users applets are instantiated in a variant's `setupNicheGraphics` method, and passed to `InkHUD::addApplet`. Their class should not be mentioned elsewhere, so that its code can be stripped away during compilation if a variant does not implement the specific applet. Internal processing of user applets treats them all as the generic `Applet` type only.
|
||||
|
||||
#### Activated / Deactivated
|
||||
|
||||
User applets can be activated or deactivated. This changes at run-time: the user selects which applets should be active using the on-screen menu. An applet should not process data while it is deactivated. It can unobserve any observables, ignore `handleReceived` calls, etc.
|
||||
|
||||
An applet can implement the virtual `onActivate` and `onDeactivate` methods to handle this change in state. It can check this state internally by calling `isActive`.
|
||||
|
||||
System applets cannot be deactivated.
|
||||
|
||||
#### Foreground / Background
|
||||
|
||||
An activated applet can either be _foreground_ or _background_. A foreground applet is one which will be rendered to a tile when the screen updates. A background applet will not be drawn. The applet cycling which takes place when the user button is pressed is implemented using foreground / background.
|
||||
|
||||
Regardless of whether it is foreground or background, an activated applet should continue to collect / process data, and request update when it has new info to display. This is because of the _autoshow_ mechanic, which might bring a background applet to foreground in order to display its data. If an applet remains background, its update requests will be safely ignored.
|
||||
|
||||
#### Autoshow
|
||||
|
||||
Autoshow is a feature which allows the user to select which applets (if any) they would like to be shown automatically. If autoshow is enabled for an applet, it will be brought to foreground when it has new information to display. The user grants this privilege on a per-applet basis, using the on-screen menu. If an event causes an applet to be autoshown, NotificationApplet should not be shown for the same event.
|
||||
|
||||
An applet needs to decide when it has information worthy of autoshowing. It signals this by calling `requestAutoshow`, in addition to the usual `requestUpdate` call.
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::SystemApplet`
|
||||
|
||||
_System applets_ are applets with special roles, which require special handling. Examples include `BatteryIconApplet.h` and `LogoApplet.h`. These are manually implemented, one-by-one, in `WindowManager.h`.
|
||||
|
||||
This class is a slight extension of `Applet`. It adds extra flags for some special features which are restricted to system applets: exclusive use of the display, and the handling of user input. Having a separate system applet class also allows us to make it clear within the code when system applets are being handled, rather than user applets
|
||||
|
||||
We store reference to these as a `vector<SystemApplets*>`. This parallels how we treat user applets, and makes rendering convenient.
|
||||
Because system applets do have unique roles, there are times when we will need to interact with a specific applet. Rather than keeping an extra set of references, we access them from the `vector<SystemApplet*>`. Use `InkHUD::getSystemApplet` to access the applet by its `Applet::name` value, and then typecast.
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::Tile`
|
||||
|
||||
A tile represents a region of the display. A tile controls the size and position of an applet.
|
||||
|
||||
For an applet to render, it must be assigned to a tile. When an applet is assigned to a tile, the two become linked. The applet is aware of the tile; the tile is aware of the applet. Applets cannot share a tile; assigning a different applet will remove any existing link.
|
||||
|
||||
Before an applet renders, its width and height are set to the dimensions of the tile. During `onRender`, an applet's drawing methods generate pixels between _x=0, y=0_ and _x=Applet::width(), y=Applet::height()_. These pixels are passed to its tile's `Tile::handleAppletPixel` method. The tile then applies x and y offset, "translating" these pixels to the tile's region of the display. These translated pixels are then passed on to the `InkHUD::Renderer`.
|
||||
|
||||

|
||||
|
||||
#### User Tiles
|
||||
|
||||
_User applets_ are the "normal" applets. They can be activated / deactivated at run-time using the on-screen menu. User applets are rendered to one of the **user tiles**.
|
||||
|
||||
The user can customize the "layout", using the on-screen menu. Depending on their selected layout, a certain number of _user tiles_ are created. These tiles are automatically positioned and sized so that they fill the entire screen.
|
||||
|
||||
Often, a user will have enabled more applets than they have tiles. Pressing the user-button will cycle through these applets. The old applet is sent to _background_, the new applet is brought to _foreground_. When a user applet is brought to foreground, it becomes assigned to a user tile (the focused tile). When it renders, its size will be set by this tile, and its pixels will be translated to this tile's region. The user applet which was sent to background loses its assignment; it no longer has an assigned tile.
|
||||
|
||||
#### Focused Tile
|
||||
|
||||
The focused tile is one of the user tiles. This is tile whose applet will change when the user button is pressed. This also the tile where the menu will appear on longpress. The focused tile is identified by its index in `vector<Tile*> userTiles`.
|
||||
|
||||
#### Highlighting
|
||||
|
||||
In addition to the user button, some devices have a second "auxiliary button". The function of this button can vary from device to device, but it is sometimes used to focus a different tile. When this happens, the newly focused tile is temporarily "highlighted", by drawing it with a border. This border is automatically removed after several seconds. As drawing code may only be executed by applets, this highlighting is a collaborative effort between a `Tile` and an `Applet`: performed in `Applet::render`, after the virtual `onRender` method has already run.
|
||||
|
||||
Highlighting is only used when `nextTile` is fired by an aux button. It does not occur if performed via the on-screen menu.
|
||||
|
||||
#### System Tiles
|
||||
|
||||
_System applets_ are applets with special roles, which require special handling. Examples include `BatteryIconApplet.h` and `LogoApplet.h`. _Mostly_, these applets do not render to user tiles. Instead, they are given their own unique tile, which is positioned / dimensioned manually. The only reference we keep to these special tiles is stored within the linked system applet. They can be accessed with `Applet::getTile`.
|
||||
|
||||
---
|
||||
|
||||
### `InkHUD::AppletFont`
|
||||
|
||||
Wrapper which extends the functionality of an AdafruitGFX font.
|
||||
|
||||
#### Dimension Info
|
||||
|
||||
The AppletFont class pre-calculates some info about a font's dimensions, which is useful for design (`AppletFont::lineHeight`), and is used to power InkHUD's custom text handling.
|
||||
|
||||
The default AdafruitGFX text handling places characters "upon a line", as if hand-written on a sheet of ruled paper. `InkHUD::AppletFont` measures the character set of the font, so that we instead draw fixed-height lines of text, positioned by the bounding box, with optional horizontal and vertical alignment.
|
||||
|
||||

|
||||
|
||||
The height of this box is `AppletFont::lineHeight`, which is the height of the tallest character in the font. This gives us a fixed-height for text, which is much tighter than with AdafruitGFX's default line spacing.
|
||||
|
||||
#### UTF-8 Substitutions
|
||||
|
||||
To enable non-English text, the `AppletFont` class includes a mechanism to detect specific UTF-8 characters, and replace them with alternative glyphs from the AdafruitGFX font. This can be used to remap characters for a custom font, or to offer a suitable ASCII replacement.
|
||||
|
||||
```cpp
|
||||
// With a custom font
|
||||
// ї is ASCII 0xBF, in Windows-1251 encoding
|
||||
addSubstitution("ї", "\xBF");
|
||||
|
||||
// Substitution (with a default font)
|
||||
addSubstitution("ö", "oe");
|
||||
```
|
||||
|
||||
These substitutions should be performed in a variant's `setupNicheGraphics` method. For convenience, some common ASCII encodings have ready-to-go sets of substitutions you can apply, for example `AppletFont::addSubstitutionsWin1251`
|
||||
BIN
src/graphics/niche/InkHUD/docs/appletfont.png
Normal file
BIN
src/graphics/niche/InkHUD/docs/appletfont.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
BIN
src/graphics/niche/InkHUD/docs/disclaimer.jpg
Normal file
BIN
src/graphics/niche/InkHUD/docs/disclaimer.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
src/graphics/niche/InkHUD/docs/rendering.gif
Normal file
BIN
src/graphics/niche/InkHUD/docs/rendering.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
BIN
src/graphics/niche/InkHUD/docs/tile_translation.png
Normal file
BIN
src/graphics/niche/InkHUD/docs/tile_translation.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "./TwoButton.h"
|
||||
|
||||
#include "NodeDB.h" // For the helper function TwoButton::getUserButtonPin
|
||||
#include "PowerFSM.h"
|
||||
#include "sleep.h"
|
||||
|
||||
@@ -57,14 +58,47 @@ void TwoButton::stop()
|
||||
detachInterrupt(buttons[1].pin);
|
||||
}
|
||||
|
||||
// Attempt to resolve a GPIO pin for the user button, honoring userPrefs.jsonc and device settings
|
||||
// This helper method isn't used by the TweButton class itself, it could be moved elsewhere.
|
||||
// Intention is to pass this value to TwoButton::setWiring in the setupNicheGraphics method.
|
||||
uint8_t TwoButton::getUserButtonPin()
|
||||
{
|
||||
uint8_t pin = 0xFF; // Unset
|
||||
|
||||
// Use default pin for variant, if no better source
|
||||
#ifdef BUTTON_PIN
|
||||
pin = BUTTON_PIN;
|
||||
#endif
|
||||
|
||||
// From userPrefs.jsonc, if set
|
||||
#ifdef USERPREFS_BUTTON_PIN
|
||||
pin = USERPREFS_BUTTON_PIN;
|
||||
#endif
|
||||
|
||||
// From user's override in device settings, if set
|
||||
if (config.device.button_gpio)
|
||||
pin = config.device.button_gpio;
|
||||
|
||||
return pin;
|
||||
}
|
||||
|
||||
// Configures the wiring and logic of either button
|
||||
// Called when outlining your NicheGraphics implementation, in variant/nicheGraphics.cpp
|
||||
void TwoButton::setWiring(uint8_t whichButton, uint8_t pin, bool internalPullup)
|
||||
{
|
||||
// Prevent the same GPIO being assigned to multiple buttons
|
||||
// Allows an edge case when the user remaps hardware buttons using device settings, due to a broken user button
|
||||
for (uint8_t i = 0; i < whichButton; i++) {
|
||||
if (buttons[i].pin == pin) {
|
||||
LOG_WARN("Attempted reuse of GPIO %d. Ignoring assignment whichButton=%d", pin, whichButton);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
assert(whichButton < 2);
|
||||
buttons[whichButton].pin = pin;
|
||||
buttons[whichButton].activeLogic = LOW;
|
||||
buttons[whichButton].mode = internalPullup ? INPUT_PULLUP : INPUT; // fix me
|
||||
buttons[whichButton].activeLogic = LOW; // Unimplemented
|
||||
buttons[whichButton].mode = internalPullup ? INPUT_PULLUP : INPUT;
|
||||
|
||||
pinMode(buttons[whichButton].pin, buttons[whichButton].mode);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ class TwoButton : protected concurrency::OSThread
|
||||
public:
|
||||
typedef std::function<void()> Callback;
|
||||
|
||||
static uint8_t getUserButtonPin(); // Resolve the GPIO, considering the various possible source of definition
|
||||
|
||||
static TwoButton *getInstance(); // Create or get the singleton instance
|
||||
void start(); // Start handling button input
|
||||
void stop(); // Stop handling button input (disconnect ISRs for sleep)
|
||||
@@ -62,7 +64,7 @@ class TwoButton : protected concurrency::OSThread
|
||||
public:
|
||||
// Per-button config
|
||||
uint8_t pin = 0xFF; // 0xFF: unset
|
||||
bool activeLogic = LOW; // Active LOW by default. Todo: remove, unused
|
||||
bool activeLogic = LOW; // Active LOW by default. Currently unimplemented.
|
||||
uint8_t mode = INPUT; // Whether to use internal pull up / pull down resistors
|
||||
uint32_t debounceLength = 50; // Minimum length for shortpress, in ms
|
||||
uint32_t longpressLength = 500; // How long after button down to fire longpress, in ms
|
||||
|
||||
@@ -119,7 +119,7 @@ void tftSetup(void)
|
||||
#ifdef ARCH_ESP32
|
||||
tftSleepObserver.observe(¬ifyLightSleep);
|
||||
endSleepObserver.observe(¬ifyLightSleepEnd);
|
||||
xTaskCreatePinnedToCore(tft_task_handler, "tft", 8192, NULL, 1, NULL, 0);
|
||||
xTaskCreatePinnedToCore(tft_task_handler, "tft", 10240, NULL, 1, NULL, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
561
src/input/TCA8418Keyboard.cpp
Normal file
561
src/input/TCA8418Keyboard.cpp
Normal file
@@ -0,0 +1,561 @@
|
||||
// Based on the MPR121 Keyboard and Adafruit TCA8418 library
|
||||
|
||||
#include "TCA8418Keyboard.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// REGISTERS
|
||||
// #define _TCA8418_REG_RESERVED 0x00
|
||||
#define _TCA8418_REG_CFG 0x01 // Configuration register
|
||||
#define _TCA8418_REG_INT_STAT 0x02 // Interrupt status
|
||||
#define _TCA8418_REG_KEY_LCK_EC 0x03 // Key lock and event counter
|
||||
#define _TCA8418_REG_KEY_EVENT_A 0x04 // Key event register A
|
||||
#define _TCA8418_REG_KEY_EVENT_B 0x05 // Key event register B
|
||||
#define _TCA8418_REG_KEY_EVENT_C 0x06 // Key event register C
|
||||
#define _TCA8418_REG_KEY_EVENT_D 0x07 // Key event register D
|
||||
#define _TCA8418_REG_KEY_EVENT_E 0x08 // Key event register E
|
||||
#define _TCA8418_REG_KEY_EVENT_F 0x09 // Key event register F
|
||||
#define _TCA8418_REG_KEY_EVENT_G 0x0A // Key event register G
|
||||
#define _TCA8418_REG_KEY_EVENT_H 0x0B // Key event register H
|
||||
#define _TCA8418_REG_KEY_EVENT_I 0x0C // Key event register I
|
||||
#define _TCA8418_REG_KEY_EVENT_J 0x0D // Key event register J
|
||||
#define _TCA8418_REG_KP_LCK_TIMER 0x0E // Keypad lock1 to lock2 timer
|
||||
#define _TCA8418_REG_UNLOCK_1 0x0F // Unlock register 1
|
||||
#define _TCA8418_REG_UNLOCK_2 0x10 // Unlock register 2
|
||||
#define _TCA8418_REG_GPIO_INT_STAT_1 0x11 // GPIO interrupt status 1
|
||||
#define _TCA8418_REG_GPIO_INT_STAT_2 0x12 // GPIO interrupt status 2
|
||||
#define _TCA8418_REG_GPIO_INT_STAT_3 0x13 // GPIO interrupt status 3
|
||||
#define _TCA8418_REG_GPIO_DAT_STAT_1 0x14 // GPIO data status 1
|
||||
#define _TCA8418_REG_GPIO_DAT_STAT_2 0x15 // GPIO data status 2
|
||||
#define _TCA8418_REG_GPIO_DAT_STAT_3 0x16 // GPIO data status 3
|
||||
#define _TCA8418_REG_GPIO_DAT_OUT_1 0x17 // GPIO data out 1
|
||||
#define _TCA8418_REG_GPIO_DAT_OUT_2 0x18 // GPIO data out 2
|
||||
#define _TCA8418_REG_GPIO_DAT_OUT_3 0x19 // GPIO data out 3
|
||||
#define _TCA8418_REG_GPIO_INT_EN_1 0x1A // GPIO interrupt enable 1
|
||||
#define _TCA8418_REG_GPIO_INT_EN_2 0x1B // GPIO interrupt enable 2
|
||||
#define _TCA8418_REG_GPIO_INT_EN_3 0x1C // GPIO interrupt enable 3
|
||||
#define _TCA8418_REG_KP_GPIO_1 0x1D // Keypad/GPIO select 1
|
||||
#define _TCA8418_REG_KP_GPIO_2 0x1E // Keypad/GPIO select 2
|
||||
#define _TCA8418_REG_KP_GPIO_3 0x1F // Keypad/GPIO select 3
|
||||
#define _TCA8418_REG_GPI_EM_1 0x20 // GPI event mode 1
|
||||
#define _TCA8418_REG_GPI_EM_2 0x21 // GPI event mode 2
|
||||
#define _TCA8418_REG_GPI_EM_3 0x22 // GPI event mode 3
|
||||
#define _TCA8418_REG_GPIO_DIR_1 0x23 // GPIO data direction 1
|
||||
#define _TCA8418_REG_GPIO_DIR_2 0x24 // GPIO data direction 2
|
||||
#define _TCA8418_REG_GPIO_DIR_3 0x25 // GPIO data direction 3
|
||||
#define _TCA8418_REG_GPIO_INT_LVL_1 0x26 // GPIO edge/level detect 1
|
||||
#define _TCA8418_REG_GPIO_INT_LVL_2 0x27 // GPIO edge/level detect 2
|
||||
#define _TCA8418_REG_GPIO_INT_LVL_3 0x28 // GPIO edge/level detect 3
|
||||
#define _TCA8418_REG_DEBOUNCE_DIS_1 0x29 // Debounce disable 1
|
||||
#define _TCA8418_REG_DEBOUNCE_DIS_2 0x2A // Debounce disable 2
|
||||
#define _TCA8418_REG_DEBOUNCE_DIS_3 0x2B // Debounce disable 3
|
||||
#define _TCA8418_REG_GPIO_PULL_1 0x2C // GPIO pull-up disable 1
|
||||
#define _TCA8418_REG_GPIO_PULL_2 0x2D // GPIO pull-up disable 2
|
||||
#define _TCA8418_REG_GPIO_PULL_3 0x2E // GPIO pull-up disable 3
|
||||
// #define _TCA8418_REG_RESERVED 0x2F
|
||||
|
||||
// FIELDS CONFIG REGISTER 1
|
||||
#define _TCA8418_REG_CFG_AI 0x80 // Auto-increment for read/write
|
||||
#define _TCA8418_REG_CFG_GPI_E_CGF 0x40 // Event mode config
|
||||
#define _TCA8418_REG_CFG_OVR_FLOW_M 0x20 // Overflow mode enable
|
||||
#define _TCA8418_REG_CFG_INT_CFG 0x10 // Interrupt config
|
||||
#define _TCA8418_REG_CFG_OVR_FLOW_IEN 0x08 // Overflow interrupt enable
|
||||
#define _TCA8418_REG_CFG_K_LCK_IEN 0x04 // Keypad lock interrupt enable
|
||||
#define _TCA8418_REG_CFG_GPI_IEN 0x02 // GPI interrupt enable
|
||||
#define _TCA8418_REG_CFG_KE_IEN 0x01 // Key events interrupt enable
|
||||
|
||||
// FIELDS INT_STAT REGISTER 2
|
||||
#define _TCA8418_REG_STAT_CAD_INT 0x10 // Ctrl-alt-del seq status
|
||||
#define _TCA8418_REG_STAT_OVR_FLOW_INT 0x08 // Overflow interrupt status
|
||||
#define _TCA8418_REG_STAT_K_LCK_INT 0x04 // Key lock interrupt status
|
||||
#define _TCA8418_REG_STAT_GPI_INT 0x02 // GPI interrupt status
|
||||
#define _TCA8418_REG_STAT_K_INT 0x01 // Key events interrupt status
|
||||
|
||||
// FIELDS KEY_LCK_EC REGISTER 3
|
||||
#define _TCA8418_REG_LCK_EC_K_LCK_EN 0x40 // Key lock enable
|
||||
#define _TCA8418_REG_LCK_EC_LCK_2 0x20 // Keypad lock status 2
|
||||
#define _TCA8418_REG_LCK_EC_LCK_1 0x10 // Keypad lock status 1
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_3 0x08 // Key event count bit 3
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_2 0x04 // Key event count bit 2
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_1 0x02 // Key event count bit 1
|
||||
#define _TCA8418_REG_LCK_EC_KLEC_0 0x01 // Key event count bit 0
|
||||
|
||||
// Pin IDs for matrix rows/columns
|
||||
enum {
|
||||
_TCA8418_ROW0, // Pin ID for row 0
|
||||
_TCA8418_ROW1, // Pin ID for row 1
|
||||
_TCA8418_ROW2, // Pin ID for row 2
|
||||
_TCA8418_ROW3, // Pin ID for row 3
|
||||
_TCA8418_ROW4, // Pin ID for row 4
|
||||
_TCA8418_ROW5, // Pin ID for row 5
|
||||
_TCA8418_ROW6, // Pin ID for row 6
|
||||
_TCA8418_ROW7, // Pin ID for row 7
|
||||
_TCA8418_COL0, // Pin ID for column 0
|
||||
_TCA8418_COL1, // Pin ID for column 1
|
||||
_TCA8418_COL2, // Pin ID for column 2
|
||||
_TCA8418_COL3, // Pin ID for column 3
|
||||
_TCA8418_COL4, // Pin ID for column 4
|
||||
_TCA8418_COL5, // Pin ID for column 5
|
||||
_TCA8418_COL6, // Pin ID for column 6
|
||||
_TCA8418_COL7, // Pin ID for column 7
|
||||
_TCA8418_COL8, // Pin ID for column 8
|
||||
_TCA8418_COL9 // Pin ID for column 9
|
||||
};
|
||||
|
||||
#define _TCA8418_COLS 3
|
||||
#define _TCA8418_ROWS 4
|
||||
#define _TCA8418_NUM_KEYS 12
|
||||
|
||||
uint8_t TCA8418TapMod[_TCA8418_NUM_KEYS] = {13, 7, 7, 7, 7, 7,
|
||||
9, 7, 9, 2, 2, 2}; // Num chars per key, Modulus for rotating through characters
|
||||
|
||||
unsigned char TCA8418TapMap[_TCA8418_NUM_KEYS][13] = {
|
||||
{'1', '.', ',', '?', '!', ':', ';', '-', '_', '\\', '/', '(', ')'}, // 1
|
||||
{'2', 'a', 'b', 'c', 'A', 'B', 'C'}, // 2
|
||||
{'3', 'd', 'e', 'f', 'D', 'E', 'F'}, // 3
|
||||
{'4', 'g', 'h', 'i', 'G', 'H', 'I'}, // 4
|
||||
{'5', 'j', 'k', 'l', 'J', 'K', 'L'}, // 5
|
||||
{'6', 'm', 'n', 'o', 'M', 'N', 'O'}, // 6
|
||||
{'7', 'p', 'q', 'r', 's', 'P', 'Q', 'R', 'S'}, // 7
|
||||
{'8', 't', 'u', 'v', 'T', 'U', 'V'}, // 8
|
||||
{'9', 'w', 'x', 'y', 'z', 'W', 'X', 'Y', 'Z'}, // 9
|
||||
{'*', '+'}, // *
|
||||
{'0', ' '}, // 0
|
||||
{'#', '@'}, // #
|
||||
};
|
||||
|
||||
unsigned char TCA8418LongPressMap[_TCA8418_NUM_KEYS] = {
|
||||
_TCA8418_ESC, // 1
|
||||
_TCA8418_UP, // 2
|
||||
_TCA8418_NONE, // 3
|
||||
_TCA8418_LEFT, // 4
|
||||
_TCA8418_NONE, // 5
|
||||
_TCA8418_RIGHT, // 6
|
||||
_TCA8418_NONE, // 7
|
||||
_TCA8418_DOWN, // 8
|
||||
_TCA8418_NONE, // 9
|
||||
_TCA8418_BSP, // *
|
||||
_TCA8418_NONE, // 0
|
||||
_TCA8418_NONE, // #
|
||||
};
|
||||
|
||||
#define _TCA8418_LONG_PRESS_THRESHOLD 2000
|
||||
#define _TCA8418_MULTI_TAP_THRESHOLD 750
|
||||
|
||||
TCA8418Keyboard::TCA8418Keyboard() : m_wire(nullptr), m_addr(0), readCallback(nullptr), writeCallback(nullptr)
|
||||
{
|
||||
state = Init;
|
||||
last_key = -1;
|
||||
next_key = -1;
|
||||
should_backspace = false;
|
||||
last_tap = 0L;
|
||||
char_idx = 0;
|
||||
tap_interval = 0;
|
||||
backlight_on = true;
|
||||
queue = "";
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::begin(uint8_t addr, TwoWire *wire)
|
||||
{
|
||||
m_addr = addr;
|
||||
m_wire = wire;
|
||||
|
||||
m_wire->begin();
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr)
|
||||
{
|
||||
m_addr = addr;
|
||||
m_wire = nullptr;
|
||||
writeCallback = w;
|
||||
readCallback = r;
|
||||
reset();
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::reset()
|
||||
{
|
||||
LOG_DEBUG("TCA8418 Reset");
|
||||
// GPIO
|
||||
// set default all GIO pins to INPUT
|
||||
writeRegister(_TCA8418_REG_GPIO_DIR_1, 0x00);
|
||||
writeRegister(_TCA8418_REG_GPIO_DIR_2, 0x00);
|
||||
// Set COL9 as GPIO output
|
||||
writeRegister(_TCA8418_REG_GPIO_DIR_3, 0x02);
|
||||
// Switch off keyboard backlight (COL9 = LOW)
|
||||
writeRegister(_TCA8418_REG_GPIO_DAT_OUT_3, 0x00);
|
||||
|
||||
// add all pins to key events
|
||||
writeRegister(_TCA8418_REG_GPI_EM_1, 0xFF);
|
||||
writeRegister(_TCA8418_REG_GPI_EM_2, 0xFF);
|
||||
writeRegister(_TCA8418_REG_GPI_EM_3, 0xFF);
|
||||
|
||||
// set all pins to FALLING interrupts
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_LVL_1, 0x00);
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_LVL_2, 0x00);
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_LVL_3, 0x00);
|
||||
|
||||
// add all pins to interrupts
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_EN_1, 0xFF);
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_EN_2, 0xFF);
|
||||
writeRegister(_TCA8418_REG_GPIO_INT_EN_3, 0xFF);
|
||||
|
||||
// Set keyboard matrix size
|
||||
matrix(_TCA8418_ROWS, _TCA8418_COLS);
|
||||
enableDebounce();
|
||||
flush();
|
||||
state = Idle;
|
||||
}
|
||||
|
||||
bool TCA8418Keyboard::matrix(uint8_t rows, uint8_t columns)
|
||||
{
|
||||
if ((rows > 8) || (columns > 10))
|
||||
return false;
|
||||
|
||||
// Skip zero size matrix
|
||||
if ((rows != 0) && (columns != 0)) {
|
||||
// Setup the keypad matrix.
|
||||
uint8_t mask = 0x00;
|
||||
for (int r = 0; r < rows; r++) {
|
||||
mask <<= 1;
|
||||
mask |= 1;
|
||||
}
|
||||
writeRegister(_TCA8418_REG_KP_GPIO_1, mask);
|
||||
|
||||
mask = 0x00;
|
||||
for (int c = 0; c < columns && c < 8; c++) {
|
||||
mask <<= 1;
|
||||
mask |= 1;
|
||||
}
|
||||
writeRegister(_TCA8418_REG_KP_GPIO_2, mask);
|
||||
|
||||
if (columns > 8) {
|
||||
if (columns == 9)
|
||||
mask = 0x01;
|
||||
else
|
||||
mask = 0x03;
|
||||
writeRegister(_TCA8418_REG_KP_GPIO_3, mask);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t TCA8418Keyboard::keyCount() const
|
||||
{
|
||||
uint8_t eventCount = readRegister(_TCA8418_REG_KEY_LCK_EC);
|
||||
eventCount &= 0x0F; // lower 4 bits only
|
||||
return eventCount;
|
||||
}
|
||||
|
||||
bool TCA8418Keyboard::hasEvent()
|
||||
{
|
||||
return queue.length() > 0;
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::queueEvent(char next)
|
||||
{
|
||||
if (next == _TCA8418_NONE) {
|
||||
return;
|
||||
}
|
||||
queue.concat(next);
|
||||
}
|
||||
|
||||
char TCA8418Keyboard::dequeueEvent()
|
||||
{
|
||||
if (queue.length() < 1) {
|
||||
return _TCA8418_NONE;
|
||||
}
|
||||
char next = queue.charAt(0);
|
||||
queue.remove(0, 1);
|
||||
return next;
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::trigger()
|
||||
{
|
||||
if (keyCount() == 0) {
|
||||
return;
|
||||
}
|
||||
if (state != Init) {
|
||||
// Read the key register
|
||||
uint8_t k = readRegister(_TCA8418_REG_KEY_EVENT_A);
|
||||
uint8_t key = k & 0x7F;
|
||||
if (k & 0x80) {
|
||||
if (state == Idle)
|
||||
pressed(key);
|
||||
return;
|
||||
} else {
|
||||
if (state == Held) {
|
||||
released();
|
||||
}
|
||||
state = Idle;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::pressed(uint8_t key)
|
||||
{
|
||||
if (state == Init || state == Busy) {
|
||||
return;
|
||||
}
|
||||
uint8_t next_key = 0;
|
||||
int row = (key - 1) / 10;
|
||||
int col = (key - 1) % 10;
|
||||
|
||||
if (row >= _TCA8418_ROWS || col >= _TCA8418_COLS) {
|
||||
return; // Invalid key
|
||||
}
|
||||
|
||||
// Compute key index based on dynamic row/column
|
||||
next_key = row * _TCA8418_COLS + col;
|
||||
|
||||
// LOG_DEBUG("TCA8418: Key %u -> Next Key %u", key, next_key);
|
||||
|
||||
state = Held;
|
||||
uint32_t now = millis();
|
||||
tap_interval = now - last_tap;
|
||||
if (tap_interval < 0) {
|
||||
// Long running, millis has overflowed.
|
||||
last_tap = 0;
|
||||
state = Busy;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the key is the same as the last one or if the time interval has passed
|
||||
if (next_key != last_key || tap_interval > _TCA8418_MULTI_TAP_THRESHOLD) {
|
||||
char_idx = 0; // Reset char index if new key or long press
|
||||
should_backspace = false; // dont backspace on new key
|
||||
} else {
|
||||
char_idx += 1; // Cycle through characters if same key pressed
|
||||
should_backspace = true; // allow backspace on same key
|
||||
}
|
||||
|
||||
// Store the current key as the last key
|
||||
last_key = next_key;
|
||||
last_tap = now;
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::released()
|
||||
{
|
||||
if (state != Held) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (last_key < 0 || last_key > _TCA8418_NUM_KEYS) { // reset to idle if last_key out of bounds
|
||||
last_key = -1;
|
||||
state = Idle;
|
||||
return;
|
||||
}
|
||||
uint32_t now = millis();
|
||||
int32_t held_interval = now - last_tap;
|
||||
last_tap = now;
|
||||
if (tap_interval < _TCA8418_MULTI_TAP_THRESHOLD && should_backspace) {
|
||||
queueEvent(_TCA8418_BSP);
|
||||
}
|
||||
if (held_interval > _TCA8418_LONG_PRESS_THRESHOLD) {
|
||||
queueEvent(TCA8418LongPressMap[last_key]);
|
||||
// LOG_DEBUG("Long Press Key: %i Map: %i", last_key, TCA8418LongPressMap[last_key]);
|
||||
} else {
|
||||
queueEvent(TCA8418TapMap[last_key][(char_idx % TCA8418TapMod[last_key])]);
|
||||
// LOG_DEBUG("Key Press: %i Index:%i if %i Map: %c", last_key, char_idx, TCA8418TapMod[last_key],
|
||||
// TCA8418TapMap[last_key][(char_idx % TCA8418TapMod[last_key])]);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t TCA8418Keyboard::flush()
|
||||
{
|
||||
// Flush key events
|
||||
uint8_t count = 0;
|
||||
while (readRegister(_TCA8418_REG_KEY_EVENT_A) != 0)
|
||||
count++;
|
||||
// Flush gpio events
|
||||
readRegister(_TCA8418_REG_GPIO_INT_STAT_1);
|
||||
readRegister(_TCA8418_REG_GPIO_INT_STAT_2);
|
||||
readRegister(_TCA8418_REG_GPIO_INT_STAT_3);
|
||||
// Clear INT_STAT register
|
||||
writeRegister(_TCA8418_REG_INT_STAT, 3);
|
||||
return count;
|
||||
}
|
||||
|
||||
uint8_t TCA8418Keyboard::digitalRead(uint8_t pinnum) const
|
||||
{
|
||||
if (pinnum > _TCA8418_COL9)
|
||||
return 0xFF;
|
||||
|
||||
uint8_t reg = _TCA8418_REG_GPIO_DAT_STAT_1 + pinnum / 8;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
// Level 0 = low other = high
|
||||
uint8_t value = readRegister(reg);
|
||||
if (value & mask)
|
||||
return HIGH;
|
||||
return LOW;
|
||||
}
|
||||
|
||||
bool TCA8418Keyboard::digitalWrite(uint8_t pinnum, uint8_t level)
|
||||
{
|
||||
if (pinnum > _TCA8418_COL9)
|
||||
return false;
|
||||
|
||||
uint8_t reg = _TCA8418_REG_GPIO_DAT_OUT_1 + pinnum / 8;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
// Level 0 = low other = high
|
||||
uint8_t value = readRegister(reg);
|
||||
if (level == LOW)
|
||||
value &= ~mask;
|
||||
else
|
||||
value |= mask;
|
||||
writeRegister(reg, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TCA8418Keyboard::pinMode(uint8_t pinnum, uint8_t mode)
|
||||
{
|
||||
if (pinnum > _TCA8418_COL9)
|
||||
return false;
|
||||
|
||||
uint8_t idx = pinnum / 8;
|
||||
uint8_t reg = _TCA8418_REG_GPIO_DIR_1 + idx;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
// Mode 0 = input 1 = output
|
||||
uint8_t value = readRegister(reg);
|
||||
if (mode == OUTPUT)
|
||||
value |= mask;
|
||||
else
|
||||
value &= ~mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
// Pullup 0 = enabled 1 = disabled
|
||||
reg = _TCA8418_REG_GPIO_PULL_1 + idx;
|
||||
value = readRegister(reg);
|
||||
if (mode == INPUT_PULLUP)
|
||||
value &= ~mask;
|
||||
else
|
||||
value |= mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TCA8418Keyboard::pinIRQMode(uint8_t pinnum, uint8_t mode)
|
||||
{
|
||||
if (pinnum > _TCA8418_COL9)
|
||||
return false;
|
||||
if ((mode != RISING) && (mode != FALLING))
|
||||
return false;
|
||||
|
||||
// Mode 0 = falling 1 = rising
|
||||
uint8_t idx = pinnum / 8;
|
||||
uint8_t reg = _TCA8418_REG_GPIO_INT_LVL_1 + idx;
|
||||
uint8_t mask = (1 << (pinnum % 8));
|
||||
|
||||
uint8_t value = readRegister(reg);
|
||||
if (mode == RISING)
|
||||
value |= mask;
|
||||
else
|
||||
value &= ~mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
// Enable interrupt
|
||||
reg = _TCA8418_REG_GPIO_INT_EN_1 + idx;
|
||||
value = readRegister(reg);
|
||||
value |= mask;
|
||||
writeRegister(reg, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::enableInterrupts()
|
||||
{
|
||||
uint8_t value = readRegister(_TCA8418_REG_CFG);
|
||||
value |= (_TCA8418_REG_CFG_GPI_IEN | _TCA8418_REG_CFG_KE_IEN);
|
||||
writeRegister(_TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418Keyboard::disableInterrupts()
|
||||
{
|
||||
uint8_t value = readRegister(_TCA8418_REG_CFG);
|
||||
value &= ~(_TCA8418_REG_CFG_GPI_IEN | _TCA8418_REG_CFG_KE_IEN);
|
||||
writeRegister(_TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418Keyboard::enableMatrixOverflow()
|
||||
{
|
||||
uint8_t value = readRegister(_TCA8418_REG_CFG);
|
||||
value |= _TCA8418_REG_CFG_OVR_FLOW_M;
|
||||
writeRegister(_TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418Keyboard::disableMatrixOverflow()
|
||||
{
|
||||
uint8_t value = readRegister(_TCA8418_REG_CFG);
|
||||
value &= ~_TCA8418_REG_CFG_OVR_FLOW_M;
|
||||
writeRegister(_TCA8418_REG_CFG, value);
|
||||
};
|
||||
|
||||
void TCA8418Keyboard::enableDebounce()
|
||||
{
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_1, 0x00);
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_2, 0x00);
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_3, 0x00);
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::disableDebounce()
|
||||
{
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_1, 0xFF);
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_2, 0xFF);
|
||||
writeRegister(_TCA8418_REG_DEBOUNCE_DIS_3, 0xFF);
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::setBacklight(bool on)
|
||||
{
|
||||
if (on) {
|
||||
digitalWrite(_TCA8418_COL9, HIGH);
|
||||
} else {
|
||||
digitalWrite(_TCA8418_COL9, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t TCA8418Keyboard::readRegister(uint8_t reg) const
|
||||
{
|
||||
if (m_wire) {
|
||||
m_wire->beginTransmission(m_addr);
|
||||
m_wire->write(reg);
|
||||
m_wire->endTransmission();
|
||||
|
||||
m_wire->requestFrom(m_addr, (uint8_t)1);
|
||||
if (m_wire->available() < 1)
|
||||
return 0;
|
||||
|
||||
return m_wire->read();
|
||||
}
|
||||
if (readCallback) {
|
||||
uint8_t data;
|
||||
readCallback(m_addr, reg, &data, 1);
|
||||
return data;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TCA8418Keyboard::writeRegister(uint8_t reg, uint8_t value)
|
||||
{
|
||||
uint8_t data[2];
|
||||
data[0] = reg;
|
||||
data[1] = value;
|
||||
|
||||
if (m_wire) {
|
||||
m_wire->beginTransmission(m_addr);
|
||||
m_wire->write(data, sizeof(uint8_t) * 2);
|
||||
m_wire->endTransmission();
|
||||
}
|
||||
if (writeCallback) {
|
||||
writeCallback(m_addr, data[0], &(data[1]), 1);
|
||||
}
|
||||
}
|
||||
83
src/input/TCA8418Keyboard.h
Normal file
83
src/input/TCA8418Keyboard.h
Normal file
@@ -0,0 +1,83 @@
|
||||
// Based on the MPR121 Keyboard and Adafruit TCA8418 library
|
||||
#include "configuration.h"
|
||||
#include <Wire.h>
|
||||
|
||||
#define _TCA8418_NONE 0x00
|
||||
#define _TCA8418_REBOOT 0x90
|
||||
#define _TCA8418_LEFT 0xb4
|
||||
#define _TCA8418_UP 0xb5
|
||||
#define _TCA8418_DOWN 0xb6
|
||||
#define _TCA8418_RIGHT 0xb7
|
||||
#define _TCA8418_ESC 0x1b
|
||||
#define _TCA8418_BSP 0x08
|
||||
#define _TCA8418_SELECT 0x0d
|
||||
|
||||
class TCA8418Keyboard
|
||||
{
|
||||
public:
|
||||
typedef uint8_t (*i2c_com_fptr_t)(uint8_t dev_addr, uint8_t reg_addr, uint8_t *data, uint8_t len);
|
||||
|
||||
enum KeyState { Init = 0, Idle, Held, Busy };
|
||||
|
||||
KeyState state;
|
||||
int8_t last_key;
|
||||
int8_t next_key;
|
||||
bool should_backspace;
|
||||
uint32_t last_tap;
|
||||
uint8_t char_idx;
|
||||
int32_t tap_interval;
|
||||
bool backlight_on;
|
||||
|
||||
String queue;
|
||||
|
||||
TCA8418Keyboard();
|
||||
|
||||
void begin(uint8_t addr = XPOWERS_AXP192_AXP2101_ADDRESS, TwoWire *wire = &Wire);
|
||||
void begin(i2c_com_fptr_t r, i2c_com_fptr_t w, uint8_t addr = XPOWERS_AXP192_AXP2101_ADDRESS);
|
||||
|
||||
void reset(void);
|
||||
// Configure the size of the keypad.
|
||||
// All other rows and columns are set as inputs.
|
||||
bool matrix(uint8_t rows, uint8_t columns);
|
||||
|
||||
// Flush all events in the FIFO buffer + GPIO events.
|
||||
uint8_t flush(void);
|
||||
|
||||
// Key events available in the internal FIFO buffer.
|
||||
uint8_t keyCount(void) const;
|
||||
|
||||
void trigger(void);
|
||||
void pressed(uint8_t key);
|
||||
void released(void);
|
||||
bool hasEvent(void);
|
||||
char dequeueEvent(void);
|
||||
void queueEvent(char);
|
||||
|
||||
uint8_t digitalRead(uint8_t pinnum) const;
|
||||
bool digitalWrite(uint8_t pinnum, uint8_t level);
|
||||
bool pinMode(uint8_t pinnum, uint8_t mode);
|
||||
bool pinIRQMode(uint8_t pinnum, uint8_t mode); // MODE FALLING or RISING
|
||||
|
||||
// enable / disable interrupts for matrix and GPI pins
|
||||
void enableInterrupts();
|
||||
void disableInterrupts();
|
||||
|
||||
// ignore key events when FIFO buffer is full or not.
|
||||
void enableMatrixOverflow();
|
||||
void disableMatrixOverflow();
|
||||
|
||||
// debounce keys.
|
||||
void enableDebounce();
|
||||
void disableDebounce();
|
||||
|
||||
void setBacklight(bool on);
|
||||
|
||||
uint8_t readRegister(uint8_t reg) const;
|
||||
void writeRegister(uint8_t reg, uint8_t value);
|
||||
|
||||
private:
|
||||
TwoWire *m_wire;
|
||||
uint8_t m_addr;
|
||||
i2c_com_fptr_t readCallback;
|
||||
i2c_com_fptr_t writeCallback;
|
||||
};
|
||||
@@ -12,8 +12,8 @@ void CardKbI2cImpl::init()
|
||||
#if !MESHTASTIC_EXCLUDE_I2C && !defined(ARCH_PORTDUINO) && !defined(I2C_NO_RESCAN)
|
||||
if (cardkb_found.address == 0x00) {
|
||||
LOG_DEBUG("Rescan for I2C keyboard");
|
||||
uint8_t i2caddr_scan[] = {CARDKB_ADDR, TDECK_KB_ADDR, BBQ10_KB_ADDR, MPR121_KB_ADDR};
|
||||
uint8_t i2caddr_asize = 4;
|
||||
uint8_t i2caddr_scan[] = {CARDKB_ADDR, TDECK_KB_ADDR, BBQ10_KB_ADDR, MPR121_KB_ADDR, XPOWERS_AXP192_AXP2101_ADDRESS};
|
||||
uint8_t i2caddr_asize = 5;
|
||||
auto i2cScanner = std::unique_ptr<ScanI2CTwoWire>(new ScanI2CTwoWire());
|
||||
|
||||
#if WIRE_INTERFACES_COUNT == 2
|
||||
@@ -43,6 +43,10 @@ void CardKbI2cImpl::init()
|
||||
// assign an arbitrary value to distinguish from other models
|
||||
kb_model = 0x37;
|
||||
break;
|
||||
case ScanI2C::DeviceType::TCA8418KB:
|
||||
// assign an arbitrary value to distinguish from other models
|
||||
kb_model = 0x84;
|
||||
break;
|
||||
default:
|
||||
// use this as default since it's also just zero
|
||||
LOG_WARN("kb_info.type is unknown(0x%02x), setting kb_model=0x00", kb_info.type);
|
||||
|
||||
@@ -43,6 +43,9 @@ int32_t KbI2cBase::runOnce()
|
||||
if (cardkb_found.address == MPR121_KB_ADDR) {
|
||||
MPRkeyboard.begin(MPR121_KB_ADDR, &Wire1);
|
||||
}
|
||||
if (cardkb_found.address == XPOWERS_AXP192_AXP2101_ADDRESS) {
|
||||
TCAKeyboard.begin(XPOWERS_AXP192_AXP2101_ADDRESS, &Wire1);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case ScanI2C::WIRE:
|
||||
@@ -55,6 +58,9 @@ int32_t KbI2cBase::runOnce()
|
||||
if (cardkb_found.address == MPR121_KB_ADDR) {
|
||||
MPRkeyboard.begin(MPR121_KB_ADDR, &Wire);
|
||||
}
|
||||
if (cardkb_found.address == XPOWERS_AXP192_AXP2101_ADDRESS) {
|
||||
TCAKeyboard.begin(XPOWERS_AXP192_AXP2101_ADDRESS, &Wire);
|
||||
}
|
||||
break;
|
||||
case ScanI2C::NO_I2C:
|
||||
default:
|
||||
@@ -226,6 +232,68 @@ int32_t KbI2cBase::runOnce()
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x84: { // Adafruit TCA8418
|
||||
TCAKeyboard.trigger();
|
||||
InputEvent e;
|
||||
while (TCAKeyboard.hasEvent()) {
|
||||
char nextEvent = TCAKeyboard.dequeueEvent();
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = 0x00;
|
||||
e.source = this->_originName;
|
||||
switch (nextEvent) {
|
||||
case _TCA8418_NONE:
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_REBOOT:
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = INPUT_BROKER_MSG_REBOOT;
|
||||
break;
|
||||
case _TCA8418_LEFT:
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_UP:
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_UP;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_DOWN:
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_DOWN;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_RIGHT:
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
case _TCA8418_BSP:
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_BACK;
|
||||
e.kbchar = 0x08;
|
||||
break;
|
||||
case _TCA8418_SELECT:
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
|
||||
e.kbchar = 0x0d;
|
||||
break;
|
||||
case _TCA8418_ESC:
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL;
|
||||
e.kbchar = 0x1b;
|
||||
break;
|
||||
default:
|
||||
if (nextEvent > 127) {
|
||||
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
e.kbchar = 0x00;
|
||||
break;
|
||||
}
|
||||
e.inputEvent = ANYKEY;
|
||||
e.kbchar = nextEvent;
|
||||
break;
|
||||
}
|
||||
if (e.inputEvent != meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE) {
|
||||
LOG_DEBUG("TCA8418 Notifying: %i Char: %c", e.inputEvent, e.kbchar);
|
||||
this->notifyObservers(&e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x02: {
|
||||
// RAK14004
|
||||
uint8_t rDataBuf[8] = {0};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "BBQ10Keyboard.h"
|
||||
#include "InputBroker.h"
|
||||
#include "MPR121Keyboard.h"
|
||||
#include "TCA8418Keyboard.h"
|
||||
#include "Wire.h"
|
||||
#include "concurrency/OSThread.h"
|
||||
|
||||
@@ -21,5 +22,6 @@ class KbI2cBase : public Observable<const InputEvent *>, public concurrency::OST
|
||||
|
||||
BBQ10Keyboard Q10keyboard;
|
||||
MPR121Keyboard MPRkeyboard;
|
||||
TCA8418Keyboard TCAKeyboard;
|
||||
bool is_sym = false;
|
||||
};
|
||||
120
src/main.cpp
120
src/main.cpp
@@ -212,6 +212,64 @@ const char *getDeviceName()
|
||||
return name;
|
||||
}
|
||||
|
||||
#if defined(ELECROW_ThinkNode_M1) || defined(ELECROW_ThinkNode_M2)
|
||||
static int32_t ledBlinkCount = 0;
|
||||
|
||||
static int32_t elecrowLedBlinker()
|
||||
{
|
||||
// are we in alert buzzer mode?
|
||||
#if HAS_BUTTON
|
||||
if (buttonThread->isBuzzing()) {
|
||||
// blink LED three times for 3 seconds, then 3 times for a second, with one second pause
|
||||
if (ledBlinkCount % 2) { // odd means LED OFF
|
||||
ledBlink.set(false);
|
||||
ledBlinkCount++;
|
||||
if (ledBlinkCount >= 12)
|
||||
ledBlinkCount = 0;
|
||||
noTone(PIN_BUZZER);
|
||||
return 1000;
|
||||
} else {
|
||||
if (ledBlinkCount < 6) {
|
||||
ledBlink.set(true);
|
||||
tone(PIN_BUZZER, 4000, 3000);
|
||||
ledBlinkCount++;
|
||||
return 3000;
|
||||
} else {
|
||||
ledBlink.set(true);
|
||||
tone(PIN_BUZZER, 4000, 1000);
|
||||
ledBlinkCount++;
|
||||
return 1000;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
ledBlinkCount = 0;
|
||||
if (config.device.led_heartbeat_disabled)
|
||||
return 1000;
|
||||
|
||||
static bool ledOn;
|
||||
// remain on when fully charged or discharging above 10%
|
||||
if ((powerStatus->getIsCharging() && powerStatus->getBatteryChargePercent() >= 100) ||
|
||||
(!powerStatus->getIsCharging() && powerStatus->getBatteryChargePercent() >= 10)) {
|
||||
ledOn = true;
|
||||
} else {
|
||||
ledOn ^= 1;
|
||||
}
|
||||
ledBlink.set(ledOn);
|
||||
// when charging, blink 0.5Hz square wave rate to indicate that
|
||||
if (powerStatus->getIsCharging()) {
|
||||
return 500;
|
||||
}
|
||||
// Blink rapidly when almost empty or if battery is not connected
|
||||
if ((!powerStatus->getIsCharging() && powerStatus->getBatteryChargePercent() < 10) || !powerStatus->getHasBattery()) {
|
||||
return 250;
|
||||
}
|
||||
#if HAS_BUTTON
|
||||
}
|
||||
#endif
|
||||
return 1000;
|
||||
}
|
||||
#else
|
||||
static int32_t ledBlinker()
|
||||
{
|
||||
// Still set up the blinking (heartbeat) interval but skip code path below, so LED will blink if
|
||||
@@ -227,6 +285,7 @@ static int32_t ledBlinker()
|
||||
// have a very sparse duty cycle of LED being on, unless charging, then blink 0.5Hz square wave rate to indicate that
|
||||
return powerStatus->getIsCharging() ? 1000 : (ledOn ? 1 : 1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t timeLastPowered = 0;
|
||||
|
||||
@@ -262,6 +321,22 @@ void printInfo()
|
||||
#ifndef PIO_UNIT_TESTING
|
||||
void setup()
|
||||
{
|
||||
|
||||
#if defined(PIN_POWER_EN)
|
||||
pinMode(PIN_POWER_EN, OUTPUT);
|
||||
digitalWrite(PIN_POWER_EN, HIGH);
|
||||
#endif
|
||||
|
||||
#ifdef LED_POWER
|
||||
pinMode(LED_POWER, OUTPUT);
|
||||
digitalWrite(LED_POWER, HIGH);
|
||||
#endif
|
||||
|
||||
#ifdef USER_LED
|
||||
pinMode(USER_LED, OUTPUT);
|
||||
digitalWrite(USER_LED, LOW);
|
||||
#endif
|
||||
|
||||
#if defined(T_DECK)
|
||||
// GPIO10 manages all peripheral power supplies
|
||||
// Turn on peripheral power immediately after MUC starts.
|
||||
@@ -325,13 +400,6 @@ void setup()
|
||||
|
||||
initDeepSleep();
|
||||
|
||||
// power on peripherals
|
||||
#if defined(PIN_POWER_EN)
|
||||
pinMode(PIN_POWER_EN, OUTPUT);
|
||||
digitalWrite(PIN_POWER_EN, HIGH);
|
||||
// digitalWrite(PIN_POWER_EN1, INPUT);
|
||||
#endif
|
||||
|
||||
#if defined(LORA_TCXO_GPIO)
|
||||
pinMode(LORA_TCXO_GPIO, OUTPUT);
|
||||
digitalWrite(LORA_TCXO_GPIO, HIGH);
|
||||
@@ -395,7 +463,12 @@ void setup()
|
||||
|
||||
OSThread::setup();
|
||||
|
||||
#if defined(ELECROW_ThinkNode_M1) || defined(ELECROW_ThinkNode_M2)
|
||||
// The ThinkNodes have their own blink logic
|
||||
ledPeriodic = new Periodic("Blink", elecrowLedBlinker);
|
||||
#else
|
||||
ledPeriodic = new Periodic("Blink", ledBlinker);
|
||||
#endif
|
||||
|
||||
fsInit();
|
||||
|
||||
@@ -568,6 +641,10 @@ void setup()
|
||||
// assign an arbitrary value to distinguish from other models
|
||||
kb_model = 0x37;
|
||||
break;
|
||||
case ScanI2C::DeviceType::TCA8418KB:
|
||||
// assign an arbitrary value to distinguish from other models
|
||||
kb_model = 0x84;
|
||||
break;
|
||||
default:
|
||||
// use this as default since it's also just zero
|
||||
LOG_WARN("kb_info.type is unknown(0x%02x), setting kb_model=0x00", kb_info.type);
|
||||
@@ -583,9 +660,9 @@ void setup()
|
||||
* "found".
|
||||
*/
|
||||
|
||||
// Only one supported RGB LED currently
|
||||
#ifdef HAS_NCP5623
|
||||
rgb_found = i2cScanner->find(ScanI2C::DeviceType::NCP5623);
|
||||
// Two supported RGB LED currently
|
||||
#ifdef HAS_RGB_LED
|
||||
rgb_found = i2cScanner->firstRGBLED();
|
||||
#endif
|
||||
|
||||
#ifdef HAS_TPS65233
|
||||
@@ -822,6 +899,13 @@ void setup()
|
||||
#ifdef HAS_UDP_MULTICAST
|
||||
LOG_DEBUG("Start multicast thread");
|
||||
udpThread = new UdpMulticastThread();
|
||||
#ifdef ARCH_PORTDUINO
|
||||
// FIXME: portduino does not ever call onNetworkConnected so call it here because I don't know what happen if I call
|
||||
// onNetworkConnected there
|
||||
if (config.network.enabled_protocols & meshtastic_Config_NetworkConfig_ProtocolFlags_UDP_BROADCAST) {
|
||||
udpThread->start();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
service = new MeshService();
|
||||
service->init();
|
||||
@@ -1244,10 +1328,23 @@ extern meshtastic_DeviceMetadata getDeviceMetadata()
|
||||
#ifndef ARCH_ESP32
|
||||
deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_PAXCOUNTER_CONFIG;
|
||||
#endif
|
||||
#if !defined(HAS_NCP5623) && !defined(RGBLED_RED) && !defined(HAS_NEOPIXEL) && !defined(UNPHONE) && !RAK_4631
|
||||
#if !defined(HAS_RGB_LED) && !RAK_4631
|
||||
deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_AMBIENTLIGHTING_CONFIG;
|
||||
#endif
|
||||
|
||||
// No bluetooth on these targets (yet):
|
||||
// Pico W / 2W may get it at some point
|
||||
// Portduino and ESP32-C6 are excluded because we don't have a working bluetooth stacks integrated yet.
|
||||
#if defined(ARCH_RP2040) || defined(ARCH_PORTDUINO) || defined(ARCH_STM32WL) || defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||
deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_BLUETOOTH_CONFIG;
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_NRF52) && !HAS_ETHERNET // nrf52 doesn't have network unless it's a RAK ethernet gateway currently
|
||||
deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_NETWORK_CONFIG; // No network on nRF52
|
||||
#elif defined(ARCH_RP2040) && !HAS_WIFI && !HAS_ETHERNET
|
||||
deviceMetadata.excluded_modules |= meshtastic_ExcludedModules_NETWORK_CONFIG; // No network on RP2040
|
||||
#endif
|
||||
|
||||
#if !(MESHTASTIC_EXCLUDE_PKI)
|
||||
deviceMetadata.hasPKC = true;
|
||||
#endif
|
||||
@@ -1296,5 +1393,4 @@ void loop()
|
||||
mainDelay.delay(delayMsec);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -347,7 +347,7 @@ bool Channels::anyMqttEnabled()
|
||||
{
|
||||
#if USERPREFS_EVENT_MODE
|
||||
// Don't publish messages on the public MQTT broker if we are in event mode
|
||||
if (mqtt && mqtt.isUsingDefaultServer()) {
|
||||
if (mqtt && mqtt->isUsingDefaultServer()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user