mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 22:22:05 +00:00
Merge branch 'master' of https://github.com/Nasimovy/meshtastic-firmware
This commit is contained in:
commit
f55e855887
9
.github/actions/build-variant/action.yml
vendored
9
.github/actions/build-variant/action.yml
vendored
@ -43,6 +43,13 @@ runs:
|
|||||||
id: base
|
id: base
|
||||||
uses: ./.github/actions/setup-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
|
- name: Pull web ui
|
||||||
if: inputs.include-web-ui == 'true'
|
if: inputs.include-web-ui == 'true'
|
||||||
uses: dsaltares/fetch-gh-release-asset@master
|
uses: dsaltares/fetch-gh-release-asset@master
|
||||||
@ -51,7 +58,7 @@ runs:
|
|||||||
file: build.tar
|
file: build.tar
|
||||||
target: build.tar
|
target: build.tar
|
||||||
token: ${{ inputs.github_token }}
|
token: ${{ inputs.github_token }}
|
||||||
version: tags/v2.5.3
|
version: tags/v${{ steps.webver.outputs.ver }}
|
||||||
|
|
||||||
- name: Unpack web ui
|
- name: Unpack web ui
|
||||||
if: inputs.include-web-ui == 'true'
|
if: inputs.include-web-ui == 'true'
|
||||||
|
@ -9,14 +9,14 @@ plugins:
|
|||||||
lint:
|
lint:
|
||||||
enabled:
|
enabled:
|
||||||
- prettier@3.5.3
|
- prettier@3.5.3
|
||||||
- trufflehog@3.88.20
|
- trufflehog@3.88.23
|
||||||
- yamllint@1.37.0
|
- yamllint@1.37.0
|
||||||
- bandit@1.8.3
|
- bandit@1.8.3
|
||||||
- checkov@3.2.396
|
- checkov@3.2.398
|
||||||
- terrascan@1.19.9
|
- terrascan@1.19.9
|
||||||
- trivy@0.61.0
|
- trivy@0.61.0
|
||||||
- taplo@0.9.3
|
- taplo@0.9.3
|
||||||
- ruff@0.11.2
|
- ruff@0.11.4
|
||||||
- isort@6.0.1
|
- isort@6.0.1
|
||||||
- markdownlint@0.44.0
|
- markdownlint@0.44.0
|
||||||
- oxipng@9.1.4
|
- oxipng@9.1.4
|
||||||
|
11
Dockerfile
11
Dockerfile
@ -12,7 +12,7 @@ ENV TZ=Etc/UTC
|
|||||||
# Install Dependencies
|
# Install Dependencies
|
||||||
ENV PIP_ROOT_USER_ACTION=ignore
|
ENV PIP_ROOT_USER_ACTION=ignore
|
||||||
RUN apt-get update && apt-get install --no-install-recommends -y \
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||||
wget g++ zip git ca-certificates \
|
curl wget g++ zip git ca-certificates \
|
||||||
libgpiod-dev libyaml-cpp-dev libbluetooth-dev libi2c-dev libuv1-dev \
|
libgpiod-dev libyaml-cpp-dev libbluetooth-dev libi2c-dev libuv1-dev \
|
||||||
libusb-1.0-0-dev libulfius-dev liborcania-dev libssl-dev pkg-config \
|
libusb-1.0-0-dev libulfius-dev liborcania-dev libssl-dev pkg-config \
|
||||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
|
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
|
||||||
@ -27,6 +27,12 @@ COPY . /tmp/firmware
|
|||||||
RUN bash ./bin/build-native.sh && \
|
RUN bash ./bin/build-native.sh && \
|
||||||
cp "/tmp/firmware/release/meshtasticd_linux_$(uname -m)" "/tmp/firmware/release/meshtasticd"
|
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 #############
|
##### PRODUCTION BUILD #############
|
||||||
|
|
||||||
@ -46,6 +52,7 @@ RUN apt-get update && apt-get --no-install-recommends -y install \
|
|||||||
|
|
||||||
# Fetch compiled binary from the builder
|
# Fetch compiled binary from the builder
|
||||||
COPY --from=builder /tmp/firmware/release/meshtasticd /usr/sbin/
|
COPY --from=builder /tmp/firmware/release/meshtasticd /usr/sbin/
|
||||||
|
COPY --from=builder /tmp/web /usr/share/meshtasticd/
|
||||||
# Copy config templates
|
# Copy config templates
|
||||||
COPY ./bin/config.d /etc/meshtasticd/available.d
|
COPY ./bin/config.d /etc/meshtasticd/available.d
|
||||||
|
|
||||||
@ -54,6 +61,8 @@ VOLUME /var/lib/meshtasticd
|
|||||||
|
|
||||||
# Expose Meshtastic TCP API port from the host
|
# Expose Meshtastic TCP API port from the host
|
||||||
EXPOSE 4403
|
EXPOSE 4403
|
||||||
|
# Expose Meshtastic Web UI port from the host
|
||||||
|
EXPOSE 443
|
||||||
|
|
||||||
CMD [ "sh", "-cx", "meshtasticd -d /var/lib/meshtasticd" ]
|
CMD [ "sh", "-cx", "meshtasticd -d /var/lib/meshtasticd" ]
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ if [ -f "${FILENAME}" ] && [ -n "${FILENAME##*"update"*}" ]; then
|
|||||||
|
|
||||||
# littlefs* offset for BigDB 8mb and OTA OFFSET.
|
# littlefs* offset for BigDB 8mb and OTA OFFSET.
|
||||||
for variant in "${BIGDB_8MB[@]}"; do
|
for variant in "${BIGDB_8MB[@]}"; do
|
||||||
if [ -n "${FILENAME##*"$variant"*}" ]; then
|
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
||||||
OFFSET=0x670000
|
OFFSET=0x670000
|
||||||
OTA_OFFSET=0x340000
|
OTA_OFFSET=0x340000
|
||||||
fi
|
fi
|
||||||
@ -146,7 +146,7 @@ if [ -f "${FILENAME}" ] && [ -n "${FILENAME##*"update"*}" ]; then
|
|||||||
|
|
||||||
# littlefs* offset for BigDB 16mb and OTA OFFSET.
|
# littlefs* offset for BigDB 16mb and OTA OFFSET.
|
||||||
for variant in "${BIGDB_16MB[@]}"; do
|
for variant in "${BIGDB_16MB[@]}"; do
|
||||||
if [ -n "${FILENAME##*"$variant"*}" ]; then
|
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
||||||
OFFSET=0xc90000
|
OFFSET=0xc90000
|
||||||
OTA_OFFSET=0x650000
|
OTA_OFFSET=0x650000
|
||||||
fi
|
fi
|
||||||
@ -155,7 +155,7 @@ if [ -f "${FILENAME}" ] && [ -n "${FILENAME##*"update"*}" ]; then
|
|||||||
# Account for S3 board's different OTA partition
|
# Account for S3 board's different OTA partition
|
||||||
# FIXME: Use PlatformIO info to determine MCU type, this is unmaintainable
|
# FIXME: Use PlatformIO info to determine MCU type, this is unmaintainable
|
||||||
for variant in "${S3_VARIANTS[@]}"; do
|
for variant in "${S3_VARIANTS[@]}"; do
|
||||||
if [ -n "${FILENAME##*"$variant"*}" ]; then
|
if [ -z "${FILENAME##*"$variant"*}" ]; then
|
||||||
MCU="esp32s3"
|
MCU="esp32s3"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -2,6 +2,10 @@ function meshtastic_version {
|
|||||||
meshtastic_version=$(python3 bin/buildinfo.py short)
|
meshtastic_version=$(python3 bin/buildinfo.py short)
|
||||||
echo -n "$meshtastic_version"
|
echo -n "$meshtastic_version"
|
||||||
}
|
}
|
||||||
|
function web_version {
|
||||||
|
web_version=$(cat bin/web.version)
|
||||||
|
echo -n "$web_version"
|
||||||
|
}
|
||||||
function git_commits_num {
|
function git_commits_num {
|
||||||
total_commits=$(git rev-list --all --count)
|
total_commits=$(git rev-list --all --count)
|
||||||
echo -n "$total_commits"
|
echo -n "$total_commits"
|
||||||
|
1
bin/web.version
Normal file
1
bin/web.version
Normal file
@ -0,0 +1 @@
|
|||||||
|
2.6.0
|
@ -2,7 +2,8 @@
|
|||||||
"build": {
|
"build": {
|
||||||
"arduino": {
|
"arduino": {
|
||||||
"ldscript": "esp32s3_out.ld",
|
"ldscript": "esp32s3_out.ld",
|
||||||
"partitions": "default_8MB.csv"
|
"partitions": "default_8MB.csv",
|
||||||
|
"memory_type": "qio_opi"
|
||||||
},
|
},
|
||||||
"core": "esp32",
|
"core": "esp32",
|
||||||
"extra_flags": [
|
"extra_flags": [
|
||||||
@ -15,6 +16,7 @@
|
|||||||
"f_cpu": "240000000L",
|
"f_cpu": "240000000L",
|
||||||
"f_flash": "80000000L",
|
"f_flash": "80000000L",
|
||||||
"flash_mode": "qio",
|
"flash_mode": "qio",
|
||||||
|
"psram_type": "opi",
|
||||||
"hwids": [
|
"hwids": [
|
||||||
["0x303A", "0x1001"],
|
["0x303A", "0x1001"],
|
||||||
["0x303A", "0x0002"]
|
["0x303A", "0x0002"]
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
"build": {
|
"build": {
|
||||||
"arduino": {
|
"arduino": {
|
||||||
"ldscript": "esp32s3_out.ld",
|
"ldscript": "esp32s3_out.ld",
|
||||||
"partitions": "default_8MB.csv"
|
"partitions": "default_8MB.csv",
|
||||||
|
"memory_type": "qio_opi"
|
||||||
},
|
},
|
||||||
"core": "esp32",
|
"core": "esp32",
|
||||||
"extra_flags": [
|
"extra_flags": [
|
||||||
@ -15,6 +16,7 @@
|
|||||||
"f_cpu": "240000000L",
|
"f_cpu": "240000000L",
|
||||||
"f_flash": "80000000L",
|
"f_flash": "80000000L",
|
||||||
"flash_mode": "qio",
|
"flash_mode": "qio",
|
||||||
|
"psram_type": "opi",
|
||||||
"hwids": [
|
"hwids": [
|
||||||
["0x303A", "0x1001"],
|
["0x303A", "0x1001"],
|
||||||
["0x303A", "0x0002"]
|
["0x303A", "0x0002"]
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
"build": {
|
"build": {
|
||||||
"arduino": {
|
"arduino": {
|
||||||
"ldscript": "esp32s3_out.ld",
|
"ldscript": "esp32s3_out.ld",
|
||||||
"partitions": "default_8MB.csv"
|
"partitions": "default_8MB.csv",
|
||||||
|
"memory_type": "qio_opi"
|
||||||
},
|
},
|
||||||
"core": "esp32",
|
"core": "esp32",
|
||||||
"extra_flags": [
|
"extra_flags": [
|
||||||
@ -15,6 +16,7 @@
|
|||||||
"f_cpu": "240000000L",
|
"f_cpu": "240000000L",
|
||||||
"f_flash": "80000000L",
|
"f_flash": "80000000L",
|
||||||
"flash_mode": "qio",
|
"flash_mode": "qio",
|
||||||
|
"psram_type": "opi",
|
||||||
"hwids": [
|
"hwids": [
|
||||||
["0x303A", "0x1001"],
|
["0x303A", "0x1001"],
|
||||||
["0x303A", "0x0002"]
|
["0x303A", "0x0002"]
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
"f_boot": "120000000L",
|
"f_boot": "120000000L",
|
||||||
"boot": "qio",
|
"boot": "qio",
|
||||||
"flash_mode": "qio",
|
"flash_mode": "qio",
|
||||||
|
"psram_type": "opi",
|
||||||
"hwids": [["0x1A86", "0x7523"]],
|
"hwids": [["0x1A86", "0x7523"]],
|
||||||
"mcu": "esp32s3",
|
"mcu": "esp32s3",
|
||||||
"variant": "esp32s3"
|
"variant": "esp32s3"
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"f_cpu": "240000000L",
|
"f_cpu": "240000000L",
|
||||||
"f_flash": "80000000L",
|
"f_flash": "80000000L",
|
||||||
"flash_mode": "qio",
|
"flash_mode": "qio",
|
||||||
|
"psram_type": "opi",
|
||||||
"hwids": [["0x2886", "0x0059"]],
|
"hwids": [["0x2886", "0x0059"]],
|
||||||
"mcu": "esp32s3",
|
"mcu": "esp32s3",
|
||||||
"variant": "seeed-xiao-s3"
|
"variant": "seeed-xiao-s3"
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"f_cpu": "240000000L",
|
"f_cpu": "240000000L",
|
||||||
"f_flash": "80000000L",
|
"f_flash": "80000000L",
|
||||||
"flash_mode": "qio",
|
"flash_mode": "qio",
|
||||||
|
"psram_type": "opi",
|
||||||
"hwids": [
|
"hwids": [
|
||||||
["0x303A", "0x1001"],
|
["0x303A", "0x1001"],
|
||||||
["0x303A", "0x0002"]
|
["0x303A", "0x0002"]
|
||||||
|
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
|
# Compress `pio` directory to prevent dh_clean from sanitizing it
|
||||||
tar -cf pio.tar pio/
|
tar -cf pio.tar pio/
|
||||||
rm -rf pio
|
rm -rf pio
|
||||||
# Download the latest meshtastic/web release build.tar to `web.tar`
|
# Download the meshtastic/web release build.tar to `web.tar`
|
||||||
curl -L https://github.com/meshtastic/web/releases/latest/download/build.tar -o 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)
|
package=$(dpkg-parsechangelog --show-field Source)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ Summary: Meshtastic daemon for communicating with Meshtastic devices
|
|||||||
License: GPL-3.0
|
License: GPL-3.0
|
||||||
URL: https://github.com/meshtastic/firmware
|
URL: https://github.com/meshtastic/firmware
|
||||||
Source0: {{{ git_dir_pack }}}
|
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: systemd-rpm-macros
|
||||||
BuildRequires: python3-devel
|
BuildRequires: python3-devel
|
||||||
|
@ -94,7 +94,7 @@ lib_deps =
|
|||||||
|
|
||||||
[device-ui_base]
|
[device-ui_base]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/meshtastic/device-ui/archive/99171e87a70452395b56cce713a951c1c2964370.zip
|
https://github.com/meshtastic/device-ui/archive/56ef8db7eb4dda44dc0c1ec5828044debbbc6d33.zip
|
||||||
|
|
||||||
; Common libs for environmental measurements in telemetry module
|
; Common libs for environmental measurements in telemetry module
|
||||||
; (not included in native / portduino)
|
; (not included in native / portduino)
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 13a3e5dcee25a2d2d4f1fbaba4c091c66d698ca5
|
Subproject commit 5a5ab103d2f6aa071fca29417475681a2cec5dcf
|
@ -116,46 +116,55 @@ ButtonThread::ButtonThread() : OSThread("Button")
|
|||||||
#endif
|
#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()
|
int32_t ButtonThread::runOnce()
|
||||||
{
|
{
|
||||||
// If the button is pressed we suppress CPU sleep until release
|
// If the button is pressed we suppress CPU sleep until release
|
||||||
canSleep = true; // Assume we should not keep the board awake
|
canSleep = true; // Assume we should not keep the board awake
|
||||||
|
|
||||||
#if defined(BUTTON_PIN) || defined(USERPREFS_BUTTON_PIN)
|
#if defined(BUTTON_PIN) || defined(USERPREFS_BUTTON_PIN)
|
||||||
// #if defined(ELECROW_ThinkNode_M1) || defined(ELECROW_ThinkNode_M2)
|
|
||||||
// buzzer_updata();
|
|
||||||
// if (buttonPressed) {
|
|
||||||
// buttonPressed = false; // 清除标志
|
|
||||||
// LOG_INFO("PIN_BUTTON2 pressed!"); // 串口打印信息
|
|
||||||
// // off_currentTime = millis();
|
|
||||||
// while (digitalRead(PIN_BUTTON2) == HIGH) {
|
|
||||||
// if (cont < 40) {
|
|
||||||
// // unsigned long currentTime = millis(); // 获取当前时间
|
|
||||||
// // if (currentTime - off_currentTime >= 1000) {
|
|
||||||
// cont++;
|
|
||||||
// // off_currentTime = currentTime;
|
|
||||||
// // }
|
|
||||||
// delay(100);
|
|
||||||
// } else {
|
|
||||||
|
|
||||||
// currentState = OFF;
|
|
||||||
// isBuzzing = false;
|
|
||||||
// cont = 0;
|
|
||||||
// BEEP_STATE = false;
|
|
||||||
// analogWrite(M2_buzzer, 0);
|
|
||||||
// pinMode(M2_buzzer, INPUT);
|
|
||||||
// screen->setOn(false);
|
|
||||||
// cont = 0;
|
|
||||||
// LOG_INFO("GGGGGGGGGGGGGGGGGGGGGGGGG");
|
|
||||||
// pinMode(1, OUTPUT);
|
|
||||||
// digitalWrite(1, LOW);
|
|
||||||
// pinMode(6, OUTPUT);
|
|
||||||
// digitalWrite(6, LOW);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #endif
|
|
||||||
userButton.tick();
|
userButton.tick();
|
||||||
canSleep &= userButton.isIdle();
|
canSleep &= userButton.isIdle();
|
||||||
#elif defined(ARCH_PORTDUINO)
|
#elif defined(ARCH_PORTDUINO)
|
||||||
@ -180,32 +189,27 @@ int32_t ButtonThread::runOnce()
|
|||||||
// If a nag notification is running, stop it and prevent other actions
|
// If a nag notification is running, stop it and prevent other actions
|
||||||
if (moduleConfig.external_notification.enabled && (externalNotificationModule->nagCycleCutoff != UINT32_MAX)) {
|
if (moduleConfig.external_notification.enabled && (externalNotificationModule->nagCycleCutoff != UINT32_MAX)) {
|
||||||
externalNotificationModule->stopNow();
|
externalNotificationModule->stopNow();
|
||||||
return 50;
|
break;
|
||||||
}
|
|
||||||
#ifdef BUTTON_PIN
|
|
||||||
#if !defined(USERPREFS_BUTTON_PIN)
|
|
||||||
if (((config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN) !=
|
|
||||||
#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);
|
|
||||||
}
|
}
|
||||||
|
#ifdef ELECROW_ThinkNode_M1
|
||||||
|
sendAdHocPosition();
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
switchPage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case BUTTON_EVENT_PRESSED_SCREEN: {
|
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
|
// turn screen on or off
|
||||||
screen_flag = !screen_flag;
|
screen_flag = !screen_flag;
|
||||||
if (screen)
|
if (screen)
|
||||||
@ -215,22 +219,18 @@ int32_t ButtonThread::runOnce()
|
|||||||
|
|
||||||
case BUTTON_EVENT_DOUBLE_PRESSED: {
|
case BUTTON_EVENT_DOUBLE_PRESSED: {
|
||||||
LOG_BUTTON("Double press!");
|
LOG_BUTTON("Double press!");
|
||||||
service->refreshLocalMeshNode();
|
#ifdef ELECROW_ThinkNode_M1
|
||||||
auto sentPosition = service->trySendPosition(NODENUM_BROADCAST, true);
|
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
||||||
if (screen) {
|
break;
|
||||||
if (sentPosition)
|
#endif
|
||||||
screen->print("Sent ad-hoc position\n");
|
sendAdHocPosition();
|
||||||
else
|
|
||||||
screen->print("Sent ad-hoc nodeinfo\n");
|
|
||||||
screen->forceDisplay(true); // Force a new UI frame, then force an EInk update
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case BUTTON_EVENT_MULTI_PRESSED: {
|
case BUTTON_EVENT_MULTI_PRESSED: {
|
||||||
LOG_BUTTON("Mulitipress! %hux", multipressClickCount);
|
LOG_BUTTON("Mulitipress! %hux", multipressClickCount);
|
||||||
switch (multipressClickCount) {
|
switch (multipressClickCount) {
|
||||||
#if HAS_GPS
|
#if HAS_GPS && !defined(ELECROW_ThinkNode_M1)
|
||||||
// 3 clicks: toggle GPS
|
// 3 clicks: toggle GPS
|
||||||
case 3:
|
case 3:
|
||||||
if (!config.device.disable_triple_click && (gps != nullptr)) {
|
if (!config.device.disable_triple_click && (gps != nullptr)) {
|
||||||
@ -239,17 +239,17 @@ int32_t ButtonThread::runOnce()
|
|||||||
screen->forceDisplay(true); // Force a new UI frame, then force an EInk update
|
screen->forceDisplay(true); // Force a new UI frame, then force an EInk update
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#elif defined(ELECROW_ThinkNode_M2)
|
#elif defined(ELECROW_ThinkNode_M1) || defined(ELECROW_ThinkNode_M2)
|
||||||
case 3:
|
case 3:
|
||||||
LOG_INFO("3 clicks: toggle buzzer");
|
LOG_INFO("3 clicks: toggle buzzer");
|
||||||
buzzer_flag = !buzzer_flag;
|
buzzer_flag = !buzzer_flag;
|
||||||
if (buzzer_flag) {
|
if (!buzzer_flag)
|
||||||
playBeep();
|
noTone(PIN_BUZZER);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#endif
|
#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
|
// 4 clicks: toggle backlight
|
||||||
case 4:
|
case 4:
|
||||||
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
||||||
@ -349,8 +349,12 @@ void ButtonThread::attachButtonInterrupts()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BUTTON_PIN_ALT
|
#ifdef BUTTON_PIN_ALT
|
||||||
|
#ifdef ELECROW_ThinkNode_M2
|
||||||
|
wakeOnIrq(BUTTON_PIN_ALT, RISING);
|
||||||
|
#else
|
||||||
wakeOnIrq(BUTTON_PIN_ALT, FALLING);
|
wakeOnIrq(BUTTON_PIN_ALT, FALLING);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef BUTTON_PIN_TOUCH
|
#ifdef BUTTON_PIN_TOUCH
|
||||||
wakeOnIrq(BUTTON_PIN_TOUCH, FALLING);
|
wakeOnIrq(BUTTON_PIN_TOUCH, FALLING);
|
||||||
|
@ -37,6 +37,9 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
void attachButtonInterrupts();
|
void attachButtonInterrupts();
|
||||||
void detachButtonInterrupts();
|
void detachButtonInterrupts();
|
||||||
void storeClickCount();
|
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
|
// Disconnect and reconnect interrupts for light sleep
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
@ -72,14 +75,12 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
|
|
||||||
static void wakeOnIrq(int irq, int mode);
|
static void wakeOnIrq(int irq, int mode);
|
||||||
|
|
||||||
|
static void sendAdHocPosition();
|
||||||
|
static void switchPage();
|
||||||
|
|
||||||
// IRQ callbacks
|
// IRQ callbacks
|
||||||
static void userButtonPressed() { btnEvent = BUTTON_EVENT_PRESSED; }
|
static void userButtonPressed() { btnEvent = BUTTON_EVENT_PRESSED; }
|
||||||
static void userButtonPressedScreen()
|
static void userButtonPressedScreen() { btnEvent = BUTTON_EVENT_PRESSED_SCREEN; }
|
||||||
{
|
|
||||||
if (millis() > c_holdOffTime) {
|
|
||||||
btnEvent = BUTTON_EVENT_PRESSED_SCREEN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void userButtonDoublePressed() { btnEvent = BUTTON_EVENT_DOUBLE_PRESSED; }
|
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 userButtonMultiPressed(void *callerThread); // Retrieve click count from non-static Onebutton while still valid
|
||||||
static void userButtonPressedLongStart();
|
static void userButtonPressedLongStart();
|
||||||
|
@ -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
|
// if we have a integrated device with a battery, we can assume that the battery is always connected
|
||||||
#ifdef BATTERY_IMMUTABLE
|
#ifdef BATTERY_IMMUTABLE
|
||||||
virtual bool isBatteryConnect() override { return true; }
|
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
|
#else
|
||||||
virtual bool isBatteryConnect() override { return getBatteryPercent() != -1; }
|
virtual bool isBatteryConnect() override { return getBatteryPercent() != -1; }
|
||||||
#endif
|
#endif
|
||||||
@ -533,9 +547,6 @@ Power::Power() : OSThread("Power")
|
|||||||
{
|
{
|
||||||
statusHandler = {};
|
statusHandler = {};
|
||||||
low_voltage_counter = 0;
|
low_voltage_counter = 0;
|
||||||
#if defined(ELECROW_ThinkNode_M1) || defined(POWER_CFG)
|
|
||||||
low_voltage_counter_led3 = 0;
|
|
||||||
#endif
|
|
||||||
#ifdef DEBUG_HEAP
|
#ifdef DEBUG_HEAP
|
||||||
lastheap = memGet.getFreeHeap();
|
lastheap = memGet.getFreeHeap();
|
||||||
#endif
|
#endif
|
||||||
@ -716,9 +727,6 @@ void Power::readPowerStatus()
|
|||||||
const PowerStatus powerStatus2 = PowerStatus(hasBattery, usbPowered, isChargingNow, 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(),
|
LOG_DEBUG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d", powerStatus2.getHasUSB(), powerStatus2.getIsCharging(),
|
||||||
powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
|
powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
|
||||||
#if defined(ELECROW_ThinkNode_M1) || defined(POWER_CFG)
|
|
||||||
power_num = powerStatus2.getBatteryVoltageMv();
|
|
||||||
#endif
|
|
||||||
newStatus.notifyObservers(&powerStatus2);
|
newStatus.notifyObservers(&powerStatus2);
|
||||||
#ifdef DEBUG_HEAP
|
#ifdef DEBUG_HEAP
|
||||||
if (lastheap != memGet.getFreeHeap()) {
|
if (lastheap != memGet.getFreeHeap()) {
|
||||||
@ -766,9 +774,6 @@ void Power::readPowerStatus()
|
|||||||
if (batteryLevel && powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) {
|
if (batteryLevel && powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) {
|
||||||
if (batteryLevel->getBattVoltage() < OCV[NUM_OCV_POINTS - 1]) {
|
if (batteryLevel->getBattVoltage() < OCV[NUM_OCV_POINTS - 1]) {
|
||||||
low_voltage_counter++;
|
low_voltage_counter++;
|
||||||
#if defined(ELECROW_ThinkNode_M1)
|
|
||||||
low_voltage_counter_led3 = low_voltage_counter;
|
|
||||||
#endif
|
|
||||||
LOG_DEBUG("Low voltage counter: %d/10", low_voltage_counter);
|
LOG_DEBUG("Low voltage counter: %d/10", low_voltage_counter);
|
||||||
if (low_voltage_counter > 10) {
|
if (low_voltage_counter > 10) {
|
||||||
#ifdef ARCH_NRF52
|
#ifdef ARCH_NRF52
|
||||||
@ -781,13 +786,7 @@ void Power::readPowerStatus()
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
low_voltage_counter = 0;
|
low_voltage_counter = 0;
|
||||||
#if defined(ELECROW_ThinkNode_M1)
|
|
||||||
low_voltage_counter_led3 = low_voltage_counter;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#ifdef POWER_CFG
|
|
||||||
low_voltage_counter_led3 = low_voltage_counter;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
#include "Throttle.h"
|
#include "Throttle.h"
|
||||||
#include "buzz.h"
|
#include "buzz.h"
|
||||||
|
#include "concurrency/Periodic.h"
|
||||||
#include "meshUtils.h"
|
#include "meshUtils.h"
|
||||||
|
|
||||||
#include "main.h" // pmu_found
|
#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)
|
static void UBXChecksum(uint8_t *message, size_t length)
|
||||||
{
|
{
|
||||||
uint8_t CK_A = 0, CK_B = 0;
|
uint8_t CK_A = 0, CK_B = 0;
|
||||||
@ -1206,7 +1246,8 @@ GnssModel_t GPS::probe(int serialSpeed)
|
|||||||
delay(20);
|
delay(20);
|
||||||
std::vector<ChipInfo> mtk = {{"L76B", "Quectel-L76B", GNSS_MODEL_MTK_L76B},
|
std::vector<ChipInfo> mtk = {{"L76B", "Quectel-L76B", GNSS_MODEL_MTK_L76B},
|
||||||
{"PA1616S", "1616S", GNSS_MODEL_MTK_PA1616S},
|
{"PA1616S", "1616S", GNSS_MODEL_MTK_PA1616S},
|
||||||
{"LS20031", "MC-1513", GNSS_MODEL_MTK_L76B}};
|
{"LS20031", "MC-1513", GNSS_MODEL_MTK_L76B},
|
||||||
|
{"L96", "Quectel-L96", GNSS_MODEL_MTK_L76B}};
|
||||||
PROBE_FAMILY("MTK Family", "$PMTK605*31", mtk, 500);
|
PROBE_FAMILY("MTK Family", "$PMTK605*31", mtk, 500);
|
||||||
|
|
||||||
uint8_t cfg_rate[] = {0xB5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00};
|
uint8_t cfg_rate[] = {0xB5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00};
|
||||||
@ -1389,6 +1430,12 @@ GPS *GPS::createGps()
|
|||||||
pinMode(PIN_GPS_PPS, INPUT);
|
pinMode(PIN_GPS_PPS, INPUT);
|
||||||
#endif
|
#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)
|
// Currently disabled per issue #525 (TinyGPS++ crash bug)
|
||||||
// when fixed upstream, can be un-disabled to enable 3D FixType and PDOP
|
// when fixed upstream, can be un-disabled to enable 3D FixType and PDOP
|
||||||
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
|
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
|
||||||
|
@ -224,7 +224,7 @@ static const uint8_t _message_GSA[] = {
|
|||||||
0x00, // Rate for DDC
|
0x00, // Rate for DDC
|
||||||
0x00, // Rate for UART1
|
0x00, // Rate for UART1
|
||||||
0x00, // Rate for UART2
|
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, // Rate for SPI
|
||||||
0x00 // Reserved
|
0x00 // Reserved
|
||||||
};
|
};
|
||||||
@ -258,7 +258,7 @@ static const uint8_t _message_RMC[] = {
|
|||||||
0x00, // Rate for DDC
|
0x00, // Rate for DDC
|
||||||
0x01, // Rate for UART1
|
0x01, // Rate for UART1
|
||||||
0x00, // Rate for UART2
|
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, // Rate for SPI
|
||||||
0x00 // Reserved
|
0x00 // Reserved
|
||||||
};
|
};
|
||||||
@ -269,7 +269,7 @@ static const uint8_t _message_GGA[] = {
|
|||||||
0x00, // Rate for DDC
|
0x00, // Rate for DDC
|
||||||
0x01, // Rate for UART1
|
0x01, // Rate for UART1
|
||||||
0x00, // Rate for UART2
|
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, // Rate for SPI
|
||||||
0x00 // Reserved
|
0x00 // Reserved
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#if !MESHTASTIC_EXCLUDE_GPS
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "ButtonThread.h"
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
@ -1606,6 +1607,7 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
|
|||||||
if (on != screenOn) {
|
if (on != screenOn) {
|
||||||
if (on) {
|
if (on) {
|
||||||
LOG_INFO("Turn on screen");
|
LOG_INFO("Turn on screen");
|
||||||
|
buttonThread->setScreenFlag(true);
|
||||||
powerMon->setState(meshtastic_PowerMon_State_Screen_On);
|
powerMon->setState(meshtastic_PowerMon_State_Screen_On);
|
||||||
#ifdef T_WATCH_S3
|
#ifdef T_WATCH_S3
|
||||||
PMU->enablePowerOutput(XPOWERS_ALDO2);
|
PMU->enablePowerOutput(XPOWERS_ALDO2);
|
||||||
@ -1641,6 +1643,7 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
|
|||||||
setScreensaverFrames(einkScreensaver);
|
setScreensaverFrames(einkScreensaver);
|
||||||
#endif
|
#endif
|
||||||
LOG_INFO("Turn off screen");
|
LOG_INFO("Turn off screen");
|
||||||
|
buttonThread->setScreenFlag(false);
|
||||||
#ifdef ELECROW_ThinkNode_M1
|
#ifdef ELECROW_ThinkNode_M1
|
||||||
if (digitalRead(PIN_EINK_EN) == HIGH) {
|
if (digitalRead(PIN_EINK_EN) == HIGH) {
|
||||||
digitalWrite(PIN_EINK_EN, LOW);
|
digitalWrite(PIN_EINK_EN, LOW);
|
||||||
|
74
src/main.cpp
74
src/main.cpp
@ -212,6 +212,64 @@ const char *getDeviceName()
|
|||||||
return name;
|
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()
|
static int32_t ledBlinker()
|
||||||
{
|
{
|
||||||
// Still set up the blinking (heartbeat) interval but skip code path below, so LED will blink if
|
// 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
|
// 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);
|
return powerStatus->getIsCharging() ? 1000 : (ledOn ? 1 : 1000);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t timeLastPowered = 0;
|
uint32_t timeLastPowered = 0;
|
||||||
|
|
||||||
@ -263,11 +322,6 @@ void printInfo()
|
|||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef POWER_CHRG
|
|
||||||
pinMode(POWER_CHRG, OUTPUT);
|
|
||||||
digitalWrite(POWER_CHRG, HIGH);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PIN_POWER_EN)
|
#if defined(PIN_POWER_EN)
|
||||||
pinMode(PIN_POWER_EN, OUTPUT);
|
pinMode(PIN_POWER_EN, OUTPUT);
|
||||||
digitalWrite(PIN_POWER_EN, HIGH);
|
digitalWrite(PIN_POWER_EN, HIGH);
|
||||||
@ -278,11 +332,6 @@ void setup()
|
|||||||
digitalWrite(LED_POWER, HIGH);
|
digitalWrite(LED_POWER, HIGH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef POWER_LED
|
|
||||||
pinMode(POWER_LED, OUTPUT);
|
|
||||||
digitalWrite(POWER_LED, HIGH);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USER_LED
|
#ifdef USER_LED
|
||||||
pinMode(USER_LED, OUTPUT);
|
pinMode(USER_LED, OUTPUT);
|
||||||
digitalWrite(USER_LED, LOW);
|
digitalWrite(USER_LED, LOW);
|
||||||
@ -414,7 +463,12 @@ void setup()
|
|||||||
|
|
||||||
OSThread::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);
|
ledPeriodic = new Periodic("Blink", ledBlinker);
|
||||||
|
#endif
|
||||||
|
|
||||||
fsInit();
|
fsInit();
|
||||||
|
|
||||||
|
@ -743,6 +743,15 @@ void NodeDB::installDefaultModuleConfig()
|
|||||||
moduleConfig.external_notification.output_ms = 100;
|
moduleConfig.external_notification.output_ms = 100;
|
||||||
moduleConfig.external_notification.active = true;
|
moduleConfig.external_notification.active = true;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ELECROW_ThinkNode_M1
|
||||||
|
// Default to Elecrow USER_LED (blue)
|
||||||
|
moduleConfig.external_notification.enabled = true;
|
||||||
|
moduleConfig.external_notification.output = USER_LED;
|
||||||
|
moduleConfig.external_notification.active = true;
|
||||||
|
moduleConfig.external_notification.alert_message = true;
|
||||||
|
moduleConfig.external_notification.output_ms = 1000;
|
||||||
|
moduleConfig.external_notification.nag_timeout = 60;
|
||||||
|
#endif
|
||||||
#ifdef BUTTON_SECONDARY_CANNEDMESSAGES
|
#ifdef BUTTON_SECONDARY_CANNEDMESSAGES
|
||||||
// Use a board's second built-in button as input source for canned messages
|
// Use a board's second built-in button as input source for canned messages
|
||||||
moduleConfig.canned_message.enabled = true;
|
moduleConfig.canned_message.enabled = true;
|
||||||
|
@ -180,14 +180,16 @@ typedef enum _meshtastic_Config_DisplayConfig_DisplayUnits {
|
|||||||
|
|
||||||
/* Override OLED outo detect with this if it fails. */
|
/* Override OLED outo detect with this if it fails. */
|
||||||
typedef enum _meshtastic_Config_DisplayConfig_OledType {
|
typedef enum _meshtastic_Config_DisplayConfig_OledType {
|
||||||
/* Default / Auto */
|
/* Default / Autodetect */
|
||||||
meshtastic_Config_DisplayConfig_OledType_OLED_AUTO = 0,
|
meshtastic_Config_DisplayConfig_OledType_OLED_AUTO = 0,
|
||||||
/* Default / Auto */
|
/* Default / Autodetect */
|
||||||
meshtastic_Config_DisplayConfig_OledType_OLED_SSD1306 = 1,
|
meshtastic_Config_DisplayConfig_OledType_OLED_SSD1306 = 1,
|
||||||
/* Default / Auto */
|
/* Default / Autodetect */
|
||||||
meshtastic_Config_DisplayConfig_OledType_OLED_SH1106 = 2,
|
meshtastic_Config_DisplayConfig_OledType_OLED_SH1106 = 2,
|
||||||
/* Can not be auto detected but set by proto. Used for 128x128 screens */
|
/* Can not be auto detected but set by proto. Used for 128x128 screens */
|
||||||
meshtastic_Config_DisplayConfig_OledType_OLED_SH1107 = 3
|
meshtastic_Config_DisplayConfig_OledType_OLED_SH1107 = 3,
|
||||||
|
/* Can not be auto detected but set by proto. Used for 128x64 screens */
|
||||||
|
meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_128_64 = 4
|
||||||
} meshtastic_Config_DisplayConfig_OledType;
|
} meshtastic_Config_DisplayConfig_OledType;
|
||||||
|
|
||||||
typedef enum _meshtastic_Config_DisplayConfig_DisplayMode {
|
typedef enum _meshtastic_Config_DisplayConfig_DisplayMode {
|
||||||
@ -639,8 +641,8 @@ extern "C" {
|
|||||||
#define _meshtastic_Config_DisplayConfig_DisplayUnits_ARRAYSIZE ((meshtastic_Config_DisplayConfig_DisplayUnits)(meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL+1))
|
#define _meshtastic_Config_DisplayConfig_DisplayUnits_ARRAYSIZE ((meshtastic_Config_DisplayConfig_DisplayUnits)(meshtastic_Config_DisplayConfig_DisplayUnits_IMPERIAL+1))
|
||||||
|
|
||||||
#define _meshtastic_Config_DisplayConfig_OledType_MIN meshtastic_Config_DisplayConfig_OledType_OLED_AUTO
|
#define _meshtastic_Config_DisplayConfig_OledType_MIN meshtastic_Config_DisplayConfig_OledType_OLED_AUTO
|
||||||
#define _meshtastic_Config_DisplayConfig_OledType_MAX meshtastic_Config_DisplayConfig_OledType_OLED_SH1107
|
#define _meshtastic_Config_DisplayConfig_OledType_MAX meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_128_64
|
||||||
#define _meshtastic_Config_DisplayConfig_OledType_ARRAYSIZE ((meshtastic_Config_DisplayConfig_OledType)(meshtastic_Config_DisplayConfig_OledType_OLED_SH1107+1))
|
#define _meshtastic_Config_DisplayConfig_OledType_ARRAYSIZE ((meshtastic_Config_DisplayConfig_OledType)(meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_128_64+1))
|
||||||
|
|
||||||
#define _meshtastic_Config_DisplayConfig_DisplayMode_MIN meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT
|
#define _meshtastic_Config_DisplayConfig_DisplayMode_MIN meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT
|
||||||
#define _meshtastic_Config_DisplayConfig_DisplayMode_MAX meshtastic_Config_DisplayConfig_DisplayMode_COLOR
|
#define _meshtastic_Config_DisplayConfig_DisplayMode_MAX meshtastic_Config_DisplayConfig_DisplayMode_COLOR
|
||||||
|
@ -242,7 +242,7 @@ typedef struct _meshtastic_AirQualityMetrics {
|
|||||||
/* 10.0um Particle Count */
|
/* 10.0um Particle Count */
|
||||||
bool has_particles_100um;
|
bool has_particles_100um;
|
||||||
uint32_t particles_100um;
|
uint32_t particles_100um;
|
||||||
/* 10.0um Particle Count */
|
/* CO2 concentration in ppm */
|
||||||
bool has_co2;
|
bool has_co2;
|
||||||
uint32_t co2;
|
uint32_t co2;
|
||||||
} meshtastic_AirQualityMetrics;
|
} meshtastic_AirQualityMetrics;
|
||||||
|
@ -109,9 +109,8 @@ void esp32Setup()
|
|||||||
randomSeed(seed);
|
randomSeed(seed);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef POWER_FULL
|
#ifdef ADC_V
|
||||||
pinMode(POWER_FULL, INPUT);
|
pinMode(ADC_V, INPUT);
|
||||||
pinMode(7, INPUT);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOG_DEBUG("Total heap: %d", ESP.getHeapSize());
|
LOG_DEBUG("Total heap: %d", ESP.getHeapSize());
|
||||||
|
@ -235,10 +235,6 @@ void nrf52InitSemiHosting()
|
|||||||
|
|
||||||
void nrf52Setup()
|
void nrf52Setup()
|
||||||
{
|
{
|
||||||
#ifdef USB_CHECK
|
|
||||||
pinMode(USB_CHECK, INPUT);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ADC_V
|
#ifdef ADC_V
|
||||||
pinMode(ADC_V, INPUT);
|
pinMode(ADC_V, INPUT);
|
||||||
#endif
|
#endif
|
||||||
@ -288,7 +284,7 @@ void cpuDeepSleep(uint32_t msecToWake)
|
|||||||
#endif
|
#endif
|
||||||
// This may cause crashes as debug messages continue to flow.
|
// This may cause crashes as debug messages continue to flow.
|
||||||
Serial.end();
|
Serial.end();
|
||||||
#ifdef PIN_SERIAL_RX1
|
#ifdef PIN_SERIAL1_RX
|
||||||
Serial1.end();
|
Serial1.end();
|
||||||
#endif
|
#endif
|
||||||
setBluetoothEnable(false);
|
setBluetoothEnable(false);
|
||||||
|
@ -84,11 +84,6 @@ class Power : private concurrency::OSThread
|
|||||||
void setStatusHandler(meshtastic::PowerStatus *handler) { statusHandler = handler; }
|
void setStatusHandler(meshtastic::PowerStatus *handler) { statusHandler = handler; }
|
||||||
const uint16_t OCV[11] = {OCV_ARRAY};
|
const uint16_t OCV[11] = {OCV_ARRAY};
|
||||||
|
|
||||||
#if defined(ELECROW_ThinkNode_M1) || defined(POWER_CFG)
|
|
||||||
uint8_t low_voltage_counter_led3;
|
|
||||||
int power_num = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
meshtastic::PowerStatus *statusHandler;
|
meshtastic::PowerStatus *statusHandler;
|
||||||
|
|
||||||
|
@ -41,16 +41,15 @@ extern "C" {
|
|||||||
#define NUM_ANALOG_INPUTS (1)
|
#define NUM_ANALOG_INPUTS (1)
|
||||||
#define NUM_ANALOG_OUTPUTS (0)
|
#define NUM_ANALOG_OUTPUTS (0)
|
||||||
|
|
||||||
#define PIN_LED1 -1
|
|
||||||
#define PIN_LED2 -1
|
#define PIN_LED2 -1
|
||||||
#define PIN_LED3 -1
|
#define PIN_LED3 -1
|
||||||
|
|
||||||
// LED
|
// LED
|
||||||
#define POWER_LED (32 + 6) // red
|
#define PIN_LED1 (32 + 6) // red
|
||||||
#define LED_POWER (32 + 4)
|
#define LED_POWER (32 + 4)
|
||||||
#define USER_LED (0 + 13) // green
|
#define USER_LED (0 + 13) // green
|
||||||
// USB_CHECK
|
// USB_CHECK
|
||||||
#define USB_CHECK (32 + 3)
|
#define EXT_PWR_DETECT (32 + 3)
|
||||||
#define ADC_V (0 + 8)
|
#define ADC_V (0 + 8)
|
||||||
|
|
||||||
#define LED_RED PIN_LED3
|
#define LED_RED PIN_LED3
|
||||||
@ -59,7 +58,7 @@ extern "C" {
|
|||||||
#define LED_BUILTIN LED_BLUE
|
#define LED_BUILTIN LED_BLUE
|
||||||
#define LED_CONN PIN_GREEN
|
#define LED_CONN PIN_GREEN
|
||||||
#define LED_STATE_ON 0 // State when LED is lit // LED灯亮时的状态
|
#define LED_STATE_ON 0 // State when LED is lit // LED灯亮时的状态
|
||||||
#define M1_buzzer (0 + 6)
|
#define PIN_BUZZER (0 + 6)
|
||||||
/*
|
/*
|
||||||
* Buttons
|
* Buttons
|
||||||
*/
|
*/
|
||||||
@ -82,6 +81,7 @@ extern "C" {
|
|||||||
static const uint8_t A0 = PIN_A0;
|
static const uint8_t A0 = PIN_A0;
|
||||||
|
|
||||||
#define ADC_RESOLUTION 14
|
#define ADC_RESOLUTION 14
|
||||||
|
#define BATTERY_SENSE_SAMPLES 30
|
||||||
|
|
||||||
#define PIN_NFC1 (9)
|
#define PIN_NFC1 (9)
|
||||||
#define PIN_NFC2 (10)
|
#define PIN_NFC2 (10)
|
||||||
@ -159,7 +159,7 @@ External serial flash WP25R1635FZUIL0
|
|||||||
|
|
||||||
#define GPS_THREAD_INTERVAL 50
|
#define GPS_THREAD_INTERVAL 50
|
||||||
|
|
||||||
#define PIN_GPS_PPS (32 + 1) // GPS开关判断
|
#define PIN_GPS_SWITCH (32 + 1) // GPS开关判断
|
||||||
|
|
||||||
#define PIN_SERIAL1_RX GPS_TX_PIN
|
#define PIN_SERIAL1_RX GPS_TX_PIN
|
||||||
#define PIN_SERIAL1_TX GPS_RX_PIN
|
#define PIN_SERIAL1_TX GPS_RX_PIN
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
// Status
|
// Status
|
||||||
#define LED_PIN_POWER 1
|
#define LED_PIN 1
|
||||||
#define BIAS_T_ENABLE LED_PIN_POWER
|
|
||||||
#define BIAS_T_VALUE HIGH
|
|
||||||
|
|
||||||
#define PIN_BUTTON1 47 // 功能键
|
#define PIN_BUTTON1 47 // 功能键
|
||||||
#define PIN_BUTTON2 4 // 电源键
|
#define PIN_BUTTON2 4 // 电源键
|
||||||
|
|
||||||
#define POWER_CFG
|
#define LED_PIN_POWER 6
|
||||||
#define POWER_CHRG 6
|
#define ADC_V 42
|
||||||
#define POWER_FULL 42
|
// USB_CHECK
|
||||||
|
#define EXT_PWR_DETECT 7
|
||||||
|
|
||||||
#define PIN_BUZZER 5
|
#define PIN_BUZZER 5
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ board = esp32-s3-devkitc-1
|
|||||||
board_level = extra
|
board_level = extra
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
build_flags =
|
build_flags =
|
||||||
${esp32_base.build_flags} -D CROWPANEL_ESP32S3_5_EPAPER -I variants/crowpanel-esp32s3-5-epaper
|
${esp32s3_base.build_flags} -D CROWPANEL_ESP32S3_5_EPAPER -I variants/crowpanel-esp32s3-5-epaper
|
||||||
-D PRIVATE_HW
|
-D PRIVATE_HW
|
||||||
-DBOARD_HAS_PSRAM
|
-DBOARD_HAS_PSRAM
|
||||||
-DGPS_POWER_TOGGLE
|
-DGPS_POWER_TOGGLE
|
||||||
@ -39,7 +39,7 @@ board = esp32-s3-devkitc-1
|
|||||||
board_level = extra
|
board_level = extra
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
build_flags =
|
build_flags =
|
||||||
${esp32_base.build_flags} -D CROWPANEL_ESP32S3_4_EPAPER -I variants/crowpanel-esp32s3-5-epaper
|
${esp32s3_base.build_flags} -D CROWPANEL_ESP32S3_4_EPAPER -I variants/crowpanel-esp32s3-5-epaper
|
||||||
-D PRIVATE_HW
|
-D PRIVATE_HW
|
||||||
-DBOARD_HAS_PSRAM
|
-DBOARD_HAS_PSRAM
|
||||||
-DGPS_POWER_TOGGLE
|
-DGPS_POWER_TOGGLE
|
||||||
@ -67,7 +67,7 @@ board = esp32-s3-devkitc-1
|
|||||||
board_level = extra
|
board_level = extra
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
build_flags =
|
build_flags =
|
||||||
${esp32_base.build_flags} -D CROWPANEL_ESP32S3_2_EPAPER -I variants/crowpanel-esp32s3-5-epaper
|
${esp32s3_base.build_flags} -D CROWPANEL_ESP32S3_2_EPAPER -I variants/crowpanel-esp32s3-5-epaper
|
||||||
-D PRIVATE_HW
|
-D PRIVATE_HW
|
||||||
-DBOARD_HAS_PSRAM
|
-DBOARD_HAS_PSRAM
|
||||||
-DGPS_POWER_TOGGLE
|
-DGPS_POWER_TOGGLE
|
||||||
|
@ -8,4 +8,6 @@ lib_deps =
|
|||||||
build_flags =
|
build_flags =
|
||||||
${esp32_base.build_flags} -D TBEAM_V10 -I variants/tbeam
|
${esp32_base.build_flags} -D TBEAM_V10 -I variants/tbeam
|
||||||
-DGPS_POWER_TOGGLE ; comment this line to disable double press function on the user button to turn off gps entirely.
|
-DGPS_POWER_TOGGLE ; comment this line to disable double press function on the user button to turn off gps entirely.
|
||||||
|
-DBOARD_HAS_PSRAM
|
||||||
|
-mfix-esp32-psram-cache-issue
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
Loading…
Reference in New Issue
Block a user