kopia lustrzana https://github.com/lora-aprs/LoRa_APRS_Tracker
Porównaj commity
118 Commity
Autor | SHA1 | Data |
---|---|---|
Peter Buchegger | 72c33cbf9f | |
Peter Buchegger | 04287e4e1f | |
Peter Buchegger | cdee7e75cd | |
Peter Buchegger | c4e39cb214 | |
Peter Buchegger | 293ca3378f | |
Peter Buchegger | 872132d1b7 | |
Peter Buchegger | dc7dcaf083 | |
root | 95ca590cb2 | |
root | 634f8d492f | |
Peter Buchegger | ff0b8a655f | |
Peter Buchegger | 84645e8476 | |
Peter Buchegger | 16a74ba536 | |
Peter Buchegger | eda125b79a | |
Peter Buchegger | af4827cfff | |
Peter Buchegger | ceda1518e9 | |
Peter Buchegger | 4d3826a983 | |
Peter Buchegger | 7dddd24dcd | |
Peter Buchegger | 14cf4ee73a | |
Peter Buchegger | 92b64097d9 | |
Peter Buchegger | 5eccb95413 | |
Peter Buchegger | 65eb0bb8d4 | |
Peter Buchegger | ec6f5c87ba | |
Peter Buchegger | a9966b60e9 | |
Peter Buchegger | 95f44fa99d | |
Peter Buchegger | b638d95153 | |
root | 5bb22e36c4 | |
root | 5e428b7286 | |
root | eaf6fa7dce | |
Peter Buchegger | 91319291b1 | |
root | ecee2c654b | |
Peter Buchegger | 22838b95fa | |
Peter Buchegger | f8376a6985 | |
Peter Buchegger | 33c205e268 | |
Peter Buchegger | c935fcf9e3 | |
Peter Buchegger | 53ab5b2628 | |
Peter Buchegger | e072b83746 | |
Tomáš Kukrál | 5c4edabea6 | |
Peter Buchegger | 3c7ab4d970 | |
Tomas Zejdlik | 71d1b9fb5e | |
Peter Buchegger | 4d6bdb226c | |
Peter Buchegger | a9ecf54e3e | |
Peter Buchegger | e9842ea011 | |
Peter Buchegger | e9476cc265 | |
Peter Buchegger | 45d9f9e1d0 | |
root | 4b6caf55e6 | |
root | 22efdb6798 | |
Peter Buchegger | f10229b0a7 | |
Peter Buchegger | 8d04e5ccef | |
Peter Buchegger | 5a49cba1d4 | |
Peter Buchegger | f55892bd98 | |
Peter Buchegger | 879e39bd9e | |
Peter Buchegger | 8202f72016 | |
Peter Buchegger | 4aa7d93b34 | |
Peter Buchegger | 4b215d1371 | |
Peter Buchegger | b772240bbf | |
Peter Buchegger | 0d41962f74 | |
Peter Buchegger | 23e1724e3b | |
Peter Buchegger | b93ae774d1 | |
Peter Buchegger | 48708ce3ea | |
Peter Buchegger | 3c6e75c266 | |
Peter Buchegger | fc4ffc8561 | |
Peter Buchegger | 9e6bbcc286 | |
Tomáš Kukrál | 01dd36946a | |
Peter Buchegger | e1d965a0e9 | |
Peter Buchegger | a5a3c6c88b | |
Peter Buchegger | 8e083cc9d0 | |
Peter Buchegger | d246fffe86 | |
Peter Buchegger | 0bac0c2d1d | |
Peter Buchegger | 81d64326a3 | |
Peter Buchegger | 9db47506d1 | |
Peter Buchegger | 049265f53b | |
root | 8cfd67a6ba | |
root | ab3dbd44df | |
root | c520e2c841 | |
root | b89010b422 | |
root | df63b8039b | |
Peter Buchegger | 7865cd570b | |
Peter Buchegger | f70c67d456 | |
Peter Buchegger | 719cf1b5c2 | |
Peter Buchegger | a51e5de3cb | |
root | a8f69daf87 | |
root | 16beaadcec | |
root | 160c4882c0 | |
Peter Buchegger | 6a5e115754 | |
Peter Buchegger | 2b36c7bc01 | |
Peter Buchegger | 0d07288fb7 | |
folkert van heusden | 3f6e01669e | |
Peter Buchegger | 780ad4ed6e | |
dahuafschmied | 906b3d7c5c | |
dahuafschmied | 93d606fe0b | |
Peter Buchegger | c78da085d5 | |
Peter Buchegger | 241dda2898 | |
Peter Buchegger | ea6ba8ca73 | |
Peter Buchegger | c19402f967 | |
Peter Buchegger | c1f0e0576e | |
Peter Buchegger | c02aab8403 | |
Peter Buchegger | 9cf7d58d2a | |
Peter Buchegger | 287cf5e3da | |
Peter Buchegger | 89155cf8d1 | |
Peter Buchegger | 129c7c6457 | |
Peter Buchegger | 0c95ed4e2c | |
Peter Buchegger | 2d04389266 | |
Peter Buchegger | 296f89bd46 | |
Peter Buchegger | 94ae1e2b7b | |
Peter Buchegger | d523e01c92 | |
Peter Buchegger | feaf0ebbad | |
Peter Kornherr | 5cde231e8c | |
Peter Buchegger | fe2612526b | |
Peter Buchegger | 64cfd3a0be | |
Peter Buchegger | 2dc2cb202a | |
Peter Buchegger | 7120010a83 | |
Peter Buchegger | e35de077e8 | |
Peter Buchegger | a87c3ddb76 | |
Peter Buchegger | f69a05eb08 | |
Tekk | 6f2fd7e959 | |
Tekk | df89fab51e | |
Tekk | 0c59659da3 | |
Sascha Bias | 5623096732 |
|
@ -12,7 +12,7 @@ AlignOperands: Align
|
|||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
|
@ -24,8 +24,8 @@ AlwaysBreakAfterDefinitionReturnType: None
|
|||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
|
@ -54,7 +54,7 @@ BreakConstructorInitializersBeforeComma: false
|
|||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 500
|
||||
ColumnLimit: 200
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: peterus
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS:
|
||||
- PlatformIO Version:
|
||||
- Firmware Version:
|
||||
|
||||
**Board name:**
|
||||
-
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: peterus
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
|
@ -0,0 +1,60 @@
|
|||
name: Integreation Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- '!master'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Compile Firmware
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
- name: Install PlatformIO
|
||||
run: python -m pip install --upgrade pip platformio
|
||||
- name: Run PlatformIO CI
|
||||
run: platformio run
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: firmware
|
||||
path: .pio/build/*/firmware.bin
|
||||
|
||||
formatting-check:
|
||||
name: Formatting Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Run clang-format style check for C/C++ programs.
|
||||
uses: jidicula/clang-format-action@v4.6.2
|
||||
with:
|
||||
clang-format-version: '11'
|
||||
check-path: src
|
||||
|
||||
cppcheck:
|
||||
name: Run cppcheck
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CPPCHECK_ARGS: --enable=all --std=c++14 --inline-suppr src
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v2
|
||||
- run: docker pull facthunder/cppcheck:latest
|
||||
- name: Run cppcheck and print result
|
||||
run: docker run --rm -v ${PWD}:/src facthunder/cppcheck:latest /bin/bash -c "cppcheck $CPPCHECK_ARGS"
|
||||
- name: Run cppcheck and create html
|
||||
run: docker run --rm -v ${PWD}:/src facthunder/cppcheck:latest /bin/bash -c "cppcheck --xml $CPPCHECK_ARGS 2> report.xml && cppcheck-htmlreport --file=report.xml --report-dir=output"
|
||||
- name: Upload report
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: Cppcheck Report
|
||||
path: output
|
|
@ -0,0 +1,19 @@
|
|||
name: PlatformIO Dependabot
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# Runs every day at 00:00
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
jobs:
|
||||
dependabot:
|
||||
runs-on: ubuntu-latest
|
||||
name: run PlatformIO Dependabot
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: run PlatformIO Dependabot
|
||||
uses: peterus/platformio_dependabot@v1
|
||||
with:
|
||||
github_token: ${{ secrets.DEPENDABOT_PAT }}
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
name: check and build
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
PlatformIO-Check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
restore-keys: ${{ runner.os }}-pip-
|
||||
- name: Cache PlatformIO
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.platformio
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
- name: Install PlatformIO
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install --upgrade platformio
|
||||
- name: Run PlatformIO Check
|
||||
run: platformio check --fail-on-defect low --fail-on-defect medium --fail-on-defect high
|
||||
|
||||
PlatformIO-Build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
restore-keys: ${{ runner.os }}-pip-
|
||||
- name: Cache PlatformIO
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.platformio
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
- name: Install PlatformIO
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install --upgrade platformio
|
||||
- name: Run PlatformIO CI
|
||||
run: platformio run
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: firmware
|
||||
path: .pio/build/*/firmware.bin
|
||||
|
||||
formatting-check:
|
||||
name: Formatting Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Run clang-format style check for C/C++ programs.
|
||||
uses: jidicula/clang-format-action@v3.2.0
|
||||
with:
|
||||
clang-format-version: '11'
|
||||
check-path: src
|
|
@ -0,0 +1,39 @@
|
|||
name: Create new release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
version_check:
|
||||
name: Version Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
- run: pip install GitPython
|
||||
- name: check version
|
||||
run: ./scripts/check_version.py
|
||||
|
||||
create_release:
|
||||
needs: version_check
|
||||
name: Create new release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sudo apt-get install python3-setuptools python3-wheel
|
||||
- run: pip3 install platformio
|
||||
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
- run: platformio run
|
||||
- run: echo "VERSION=$(./scripts/create_version_tag.py)" >> $GITHUB_ENV
|
||||
- uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: ${{ env.VERSION }}
|
||||
commit: master
|
||||
generateReleaseNotes: true
|
||||
artifacts: ".pio/build/lora_board/firmware.bin,data/is-cfg.json"
|
||||
owner: ${{ secrets.OWNER }}
|
||||
token: ${{ secrets.PAT }}
|
|
@ -0,0 +1,19 @@
|
|||
name: tweet-release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
tweet:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: Eomm/why-don-t-you-tweet@v1
|
||||
if: ${{ !github.event.repository.private }}
|
||||
with:
|
||||
tweet-message: "New ${{ github.event.repository.name }} release ${{ github.event.release.tag_name }}! ${{ github.event.release.html_url }} #LoRa #APRS #HAM #hamradio #Tracker"
|
||||
env:
|
||||
TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
|
||||
TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
|
||||
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
|
||||
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
|
|
@ -3,3 +3,4 @@
|
|||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
.vscode/settings.json
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide",
|
||||
"xaver.clang-format"
|
||||
],
|
||||
"unwantedRecommendations": [
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
]
|
||||
}
|
||||
|
|
21
README.md
21
README.md
|
@ -10,7 +10,8 @@ Try it out and be part of the APRS network.
|
|||
You can use one of the Lora32 boards:
|
||||
|
||||
* TTGO T-Beam V0.7 (433MHz SX1278)
|
||||
* TTGO T-Beam V1 (433MHz SX1278)
|
||||
* TTGO T-Beam V1.0 and V1.1 (433MHz SX1278)
|
||||
* TTGO T-Beam V1.2 AXP2101 (433MHz SX1278)
|
||||
|
||||
This boards cost around 30 Euros, they are very cheap but perfect for an LoRa iGate.
|
||||
Keep in minde: you need a 433MHz version!
|
||||
|
@ -30,6 +31,7 @@ The best success is to use PlatformIO (and it is the only platform where I can s
|
|||
* When installed click 'the ant head' on the left and choose import the project on the right.
|
||||
* Just open the folder and you can compile the Firmware.
|
||||
|
||||
|
||||
### Configuration
|
||||
|
||||
* You can find all nessesary settings to change for your configuration in **data/tracker.json**.
|
||||
|
@ -37,6 +39,23 @@ The best success is to use PlatformIO (and it is the only platform where I can s
|
|||
* To upload it to your board you have to do this via **Upload File System image** in PlatformIO!
|
||||
* To find the 'Upload File System image' click the PlatformIO symbol (the little alien) on the left side, choos your configuration, click on 'Platform' and search for 'Upload File System image'.
|
||||
|
||||
|
||||
#### Step on console
|
||||
|
||||
You may not need to use PlatformIO because compilation and configuration can be done via console.
|
||||
|
||||
```
|
||||
# switch to virtual env, for example using pipenv
|
||||
pipenv shell
|
||||
|
||||
# install platformio
|
||||
pipenv install platformio
|
||||
|
||||
# upload to board
|
||||
pio run -t upload
|
||||
```
|
||||
|
||||
|
||||
## LoRa iGate
|
||||
|
||||
Look at my other project: a [LoRa iGate](https://github.com/peterus/LoRa_APRS_iGate)
|
||||
|
|
|
@ -1,41 +1,43 @@
|
|||
{
|
||||
"callsign":"NOCALL-7",
|
||||
"debug": false,
|
||||
"enhance_precision": true,
|
||||
"beacon":
|
||||
{
|
||||
"message":"LoRa Tracker",
|
||||
"timeout": 1,
|
||||
"button_tx": false,
|
||||
"symbol": "[",
|
||||
"overlay": "/"
|
||||
"beacons": [
|
||||
{
|
||||
"callsign": "NOCALL-7",
|
||||
"path": "WIDE1-1",
|
||||
"message": "LoRa Tracker",
|
||||
"timeout": 1,
|
||||
"symbol": "[",
|
||||
"overlay": "/",
|
||||
"smart_beacon": {
|
||||
"active": true,
|
||||
"turn_min": 25,
|
||||
"slow_rate": 300,
|
||||
"slow_speed": 10,
|
||||
"fast_rate": 60,
|
||||
"fast_speed": 100,
|
||||
"min_tx_dist": 100,
|
||||
"min_bcn": 5
|
||||
},
|
||||
"enhance_precision": true
|
||||
}
|
||||
],
|
||||
"button": {
|
||||
"tx": true,
|
||||
"alt_message": true
|
||||
},
|
||||
"smart_beacon":
|
||||
{
|
||||
"active":true,
|
||||
"turn_min":25,
|
||||
"slow_rate":300,
|
||||
"slow_speed":10,
|
||||
"fast_rate":60,
|
||||
"fast_speed":100,
|
||||
"min_tx_dist":100,
|
||||
"min_bcn":5
|
||||
"lora": {
|
||||
"frequency_rx": 433775000,
|
||||
"frequency_tx": 433775000,
|
||||
"power": 20,
|
||||
"spreading_factor": 12,
|
||||
"signal_bandwidth": 125000,
|
||||
"coding_rate4": 5
|
||||
},
|
||||
"lora":
|
||||
{
|
||||
"frequency_rx":433775000,
|
||||
"frequency_tx":433775000,
|
||||
"power":20,
|
||||
"spreading_factor":12,
|
||||
"signal_bandwidth":125000,
|
||||
"coding_rate4":5
|
||||
},
|
||||
"ptt_output":
|
||||
{
|
||||
"active":false,
|
||||
"ptt_output": {
|
||||
"active": false,
|
||||
"io_pin": 4,
|
||||
"start_delay": 0,
|
||||
"end_delay": 0,
|
||||
"reverse":false
|
||||
"reverse": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,32 @@
|
|||
[platformio]
|
||||
default_envs = ttgo-t-beam-v1
|
||||
|
||||
[env]
|
||||
platform = espressif32 @ 3.0.0
|
||||
platform = espressif32 @ 6.4.0
|
||||
framework = arduino
|
||||
lib_ldf_mode = deep+
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
lib_deps =
|
||||
adafruit/Adafruit GFX Library @ 1.7.5
|
||||
adafruit/Adafruit SSD1306 @ 2.4.0
|
||||
bblanchon/ArduinoJson @ 6.17.0
|
||||
lewisxhe/AXP202X_Library @ 1.1.2
|
||||
sandeepmistry/LoRa @ 0.7.2
|
||||
peterus/APRS-Decoder-Lib @ 0.0.5
|
||||
mikalhart/TinyGPSPlus @ 1.0.2
|
||||
adafruit/Adafruit GFX Library @ 1.11.7
|
||||
adafruit/Adafruit SSD1306 @ 2.5.7
|
||||
bblanchon/ArduinoJson @ 6.21.3
|
||||
lewisxhe/XPowersLib @ 0.1.8
|
||||
sandeepmistry/LoRa @ 0.8.0
|
||||
peterus/APRS-Decoder-Lib @ 0.0.6
|
||||
mikalhart/TinyGPSPlus @ 1.0.3
|
||||
paulstoffregen/Time @ 1.6
|
||||
shaggydog/OneButton @ 1.5.0
|
||||
peterus/esp-logger @ 0.0.1
|
||||
peterus/esp-logger @ 1.0.0
|
||||
check_tool = cppcheck
|
||||
check_flags =
|
||||
cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK
|
||||
check_skip_packages = yes
|
||||
|
||||
[env:ttgo-t-beam-AXP2101-v1_2]
|
||||
board = ttgo-t-beam
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_2
|
||||
|
||||
[env:ttgo-t-beam-v1]
|
||||
board = ttgo-t-beam
|
||||
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_0
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import git
|
||||
from datetime import date
|
||||
|
||||
today = date.today()
|
||||
|
||||
current_year = int(str(today.isocalendar()[0])[2:])
|
||||
current_week = int(today.isocalendar()[1])
|
||||
|
||||
version = None
|
||||
with open("src/LoRa_APRS_Tracker.cpp") as f:
|
||||
for line in f:
|
||||
if line.startswith("#define VERSION"):
|
||||
version = line.strip().split(" ")[-1].replace('"', "")
|
||||
|
||||
version_split = version.split(".")
|
||||
version_year = int(version_split[0])
|
||||
version_week = int(version_split[1])
|
||||
version_vers = int(version_split[2])
|
||||
|
||||
print(f"[INFO] firmware version year: {version_year}")
|
||||
print(f"[INFO] firmware version week: {version_week}")
|
||||
print(f"[INFO] firmware version version: {version_vers}")
|
||||
print(f"[INFO] -> {version}")
|
||||
|
||||
print(f"[INFO] current year: {current_year}")
|
||||
print(f"[INFO] current week: {current_week}")
|
||||
print(f"[INFO] -> {current_year}.{current_week}.x")
|
||||
|
||||
error = False
|
||||
if version_year != current_year:
|
||||
print("[ERROR] firmware version is not current year!")
|
||||
error = True
|
||||
|
||||
if version_week != current_week:
|
||||
print("[ERROR] firmware version is not current week!")
|
||||
error = True
|
||||
|
||||
repo = git.Repo('.')
|
||||
print(f"[INFO] found {len(repo.tags)} tags in repo")
|
||||
if f"v{version}" in repo.tags:
|
||||
print("[ERROR] tag with this version is already existing")
|
||||
error = True
|
||||
|
||||
if error:
|
||||
print("[ERROR] check/update VERSION define in src/LoRa_APRS_iGate.cpp to fix this issue")
|
||||
|
||||
exit(error)
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from datetime import date
|
||||
|
||||
today = date.today()
|
||||
|
||||
current_year = int(str(today.isocalendar()[0])[2:])
|
||||
current_week = int(today.isocalendar()[1])
|
||||
|
||||
version = None
|
||||
with open("src/LoRa_APRS_Tracker.cpp") as f:
|
||||
for line in f:
|
||||
if line.startswith("#define VERSION"):
|
||||
version = line.strip().split(" ")[-1].replace('"', "")
|
||||
|
||||
version_split = version.split(".")
|
||||
version_year = int(version_split[0])
|
||||
version_week = int(version_split[1])
|
||||
version_vers = int(version_split[2])
|
||||
|
||||
print(f"v{version_year}.{version_week}.{version_vers}")
|
|
@ -0,0 +1,23 @@
|
|||
#include "BeaconManager.h"
|
||||
|
||||
BeaconManager::BeaconManager() : _currentBeaconConfig(_beacon_config.end()) {
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void BeaconManager::loadConfig(const std::list<Configuration::Beacon> &beacon_config) {
|
||||
_beacon_config = beacon_config;
|
||||
_currentBeaconConfig = _beacon_config.begin();
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
std::list<Configuration::Beacon>::iterator BeaconManager::getCurrentBeaconConfig() const {
|
||||
return _currentBeaconConfig;
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void BeaconManager::loadNextBeacon() {
|
||||
++_currentBeaconConfig;
|
||||
if (_currentBeaconConfig == _beacon_config.end()) {
|
||||
_currentBeaconConfig = _beacon_config.begin();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef BEACON_MANAGER_H_
|
||||
#define BEACON_MANAGER_H_
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
class BeaconManager {
|
||||
public:
|
||||
BeaconManager();
|
||||
|
||||
void loadConfig(const std::list<Configuration::Beacon> &beacon_config);
|
||||
|
||||
std::list<Configuration::Beacon>::iterator getCurrentBeaconConfig() const;
|
||||
void loadNextBeacon();
|
||||
|
||||
private:
|
||||
std::list<Configuration::Beacon> _beacon_config;
|
||||
std::list<Configuration::Beacon>::iterator _currentBeaconConfig;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -7,22 +7,35 @@
|
|||
#include <WiFi.h>
|
||||
#include <logger.h>
|
||||
|
||||
#include "BeaconManager.h"
|
||||
#include "configuration.h"
|
||||
#include "display.h"
|
||||
#include "pins.h"
|
||||
#include "power_management.h"
|
||||
|
||||
Configuration Config;
|
||||
#define VERSION "23.36.01"
|
||||
|
||||
PowerManagement powerManagement;
|
||||
OneButton userButton = OneButton(BUTTON_PIN, true, true);
|
||||
logging::Logger logger;
|
||||
|
||||
Configuration Config;
|
||||
BeaconManager BeaconMan;
|
||||
|
||||
#ifdef TTGO_T_Beam_V1_0
|
||||
AXP192 axp;
|
||||
PowerManagement *powerManagement = &axp;
|
||||
#endif
|
||||
#ifdef TTGO_T_Beam_V1_2
|
||||
AXP2101 axp;
|
||||
PowerManagement *powerManagement = &axp;
|
||||
#endif
|
||||
OneButton userButton = OneButton(BUTTON_PIN, true, true);
|
||||
|
||||
HardwareSerial ss(1);
|
||||
TinyGPSPlus gps;
|
||||
|
||||
void setup_gps();
|
||||
void load_config();
|
||||
void setup_lora();
|
||||
void setup_gps();
|
||||
|
||||
String create_lat_aprs(RawDegrees lat);
|
||||
String create_long_aprs(RawDegrees lng);
|
||||
|
@ -34,34 +47,49 @@ String createTimeString(time_t t);
|
|||
String getSmartBeaconState();
|
||||
String padding(unsigned int number, unsigned int width);
|
||||
|
||||
static bool send_update = true;
|
||||
static bool send_update = true;
|
||||
static bool display_toggle_value = true;
|
||||
|
||||
static void handle_tx_click() {
|
||||
send_update = true;
|
||||
}
|
||||
|
||||
static void handle_next_beacon() {
|
||||
BeaconMan.loadNextBeacon();
|
||||
show_display(BeaconMan.getCurrentBeaconConfig()->callsign, BeaconMan.getCurrentBeaconConfig()->message, 2000);
|
||||
}
|
||||
|
||||
static void toggle_display() {
|
||||
display_toggle_value = !display_toggle_value;
|
||||
display_toggle(display_toggle_value);
|
||||
if (display_toggle_value) {
|
||||
setup_display();
|
||||
}
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef TTGO_T_Beam_V1_0
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
|
||||
Wire.begin(SDA, SCL);
|
||||
if (!powerManagement.begin(Wire)) {
|
||||
logPrintlnI("AXP192 init done!");
|
||||
if (powerManagement->begin(Wire)) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "PMU", "init done!");
|
||||
} else {
|
||||
logPrintlnE("AXP192 init failed!");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "PMU", "init failed!");
|
||||
}
|
||||
powerManagement.activateLoRa();
|
||||
powerManagement.activateOLED();
|
||||
powerManagement.activateGPS();
|
||||
powerManagement.activateMeasurement();
|
||||
powerManagement->activateLoRa();
|
||||
powerManagement->activateOLED();
|
||||
powerManagement->activateGPS();
|
||||
powerManagement->activateMeasurement();
|
||||
#endif
|
||||
|
||||
delay(500);
|
||||
logPrintlnI("LoRa APRS Tracker by OE5BPA (Peter Buchegger)");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "LoRa APRS Tracker by OE5BPA (Peter Buchegger)");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "Version: " VERSION);
|
||||
setup_display();
|
||||
|
||||
show_display("OE5BPA", "LoRa APRS Tracker", "by Peter Buchegger", 2000);
|
||||
show_display("OE5BPA", "LoRa APRS Tracker", "by Peter Buchegger", "Version: " VERSION, 2000);
|
||||
load_config();
|
||||
|
||||
setup_gps();
|
||||
|
@ -76,14 +104,19 @@ void setup() {
|
|||
WiFi.mode(WIFI_OFF);
|
||||
btStop();
|
||||
|
||||
if (Config.beacon.button_tx) {
|
||||
if (Config.button.tx) {
|
||||
// attach TX action to user button (defined by BUTTON_PIN)
|
||||
userButton.attachClick(handle_tx_click);
|
||||
}
|
||||
|
||||
logPrintlnI("Smart Beacon is " + getSmartBeaconState());
|
||||
if (Config.button.alt_message) {
|
||||
userButton.attachLongPressStart(handle_next_beacon);
|
||||
}
|
||||
userButton.attachDoubleClick(toggle_display);
|
||||
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "Smart Beacon is: %s", getSmartBeaconState());
|
||||
show_display("INFO", "Smart Beacon is " + getSmartBeaconState(), 1000);
|
||||
logPrintlnI("setup done...");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "setup done...");
|
||||
delay(500);
|
||||
}
|
||||
|
||||
|
@ -105,9 +138,20 @@ void loop() {
|
|||
}
|
||||
}
|
||||
|
||||
bool gps_time_update = gps.time.isUpdated();
|
||||
bool gps_loc_update = gps.location.isUpdated();
|
||||
static time_t nextBeaconTimeStamp = -1;
|
||||
bool gps_time_update = gps.time.isUpdated();
|
||||
bool gps_loc_update = gps.location.isUpdated();
|
||||
static bool gps_loc_update_valid = false;
|
||||
static time_t nextBeaconTimeStamp = -1;
|
||||
|
||||
if (gps_loc_update != gps_loc_update_valid) {
|
||||
gps_loc_update_valid = gps_loc_update;
|
||||
|
||||
if (gps_loc_update) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Loop", "GPS fix state went to VALID");
|
||||
} else {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Loop", "GPS fix state went to INVALID");
|
||||
}
|
||||
}
|
||||
|
||||
static double currentHeading = 0;
|
||||
static double previousHeading = 0;
|
||||
|
@ -118,13 +162,13 @@ void loop() {
|
|||
|
||||
if (gps_loc_update && nextBeaconTimeStamp <= now()) {
|
||||
send_update = true;
|
||||
if (Config.smart_beacon.active) {
|
||||
if (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active) {
|
||||
currentHeading = gps.course.deg();
|
||||
// enforce message text on slowest Config.smart_beacon.slow_rate
|
||||
rate_limit_message_text = 0;
|
||||
} else {
|
||||
// enforce message text every n's Config.beacon.timeout frame
|
||||
if (Config.beacon.timeout * rate_limit_message_text > 30) {
|
||||
if (BeaconMan.getCurrentBeaconConfig()->timeout * rate_limit_message_text > 30) {
|
||||
rate_limit_message_text = 0;
|
||||
}
|
||||
}
|
||||
|
@ -141,17 +185,18 @@ void loop() {
|
|||
static bool BatteryIsConnected = false;
|
||||
static String batteryVoltage = "";
|
||||
static String batteryChargeCurrent = "";
|
||||
#ifdef TTGO_T_Beam_V1_0
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
|
||||
static unsigned int rate_limit_check_battery = 0;
|
||||
if (!(rate_limit_check_battery++ % 60))
|
||||
BatteryIsConnected = powerManagement.isBatteryConnect();
|
||||
if (!(rate_limit_check_battery++ % 60)) {
|
||||
BatteryIsConnected = powerManagement->isBatteryConnect();
|
||||
}
|
||||
if (BatteryIsConnected) {
|
||||
batteryVoltage = String(powerManagement.getBatteryVoltage(), 2);
|
||||
batteryChargeCurrent = String(powerManagement.getBatteryChargeDischargeCurrent(), 0);
|
||||
batteryVoltage = String(powerManagement->getBatteryVoltage(), 2);
|
||||
batteryChargeCurrent = String(powerManagement->getBatteryChargeDischargeCurrent(), 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!send_update && gps_loc_update && Config.smart_beacon.active) {
|
||||
if (!send_update && gps_loc_update && BeaconMan.getCurrentBeaconConfig()->smart_beacon.active) {
|
||||
uint32_t lastTx = millis() - lastTxTime;
|
||||
currentHeading = gps.course.deg();
|
||||
lastTxdistance = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), lastTxLat, lastTxLng);
|
||||
|
@ -167,9 +212,9 @@ void loop() {
|
|||
// Get headings and heading delta
|
||||
double headingDelta = abs(previousHeading - currentHeading);
|
||||
|
||||
if (lastTx > Config.smart_beacon.min_bcn * 1000) {
|
||||
if (lastTx > BeaconMan.getCurrentBeaconConfig()->smart_beacon.min_bcn * 1000) {
|
||||
// Check for heading more than 25 degrees
|
||||
if (headingDelta > Config.smart_beacon.turn_min && lastTxdistance > Config.smart_beacon.min_tx_dist) {
|
||||
if (headingDelta > BeaconMan.getCurrentBeaconConfig()->smart_beacon.turn_min && lastTxdistance > BeaconMan.getCurrentBeaconConfig()->smart_beacon.min_tx_dist) {
|
||||
send_update = true;
|
||||
}
|
||||
}
|
||||
|
@ -177,18 +222,21 @@ void loop() {
|
|||
}
|
||||
|
||||
if (send_update && gps_loc_update) {
|
||||
send_update = false;
|
||||
nextBeaconTimeStamp = now() + (Config.smart_beacon.active ? Config.smart_beacon.slow_rate : (Config.beacon.timeout * SECS_PER_MIN));
|
||||
send_update = false;
|
||||
|
||||
nextBeaconTimeStamp =
|
||||
now() + (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active ? BeaconMan.getCurrentBeaconConfig()->smart_beacon.slow_rate : (BeaconMan.getCurrentBeaconConfig()->timeout * SECS_PER_MIN));
|
||||
|
||||
APRSMessage msg;
|
||||
String lat;
|
||||
String lng;
|
||||
String dao;
|
||||
|
||||
msg.setSource(Config.callsign);
|
||||
msg.setDestination("APLT00-1");
|
||||
msg.setSource(BeaconMan.getCurrentBeaconConfig()->callsign);
|
||||
msg.setPath(BeaconMan.getCurrentBeaconConfig()->path);
|
||||
msg.setDestination("APLT00");
|
||||
|
||||
if (!Config.enhance_precision) {
|
||||
if (!BeaconMan.getCurrentBeaconConfig()->enhance_precision) {
|
||||
lat = create_lat_aprs(gps.location.rawLat());
|
||||
lng = create_long_aprs(gps.location.rawLng());
|
||||
} else {
|
||||
|
@ -232,25 +280,28 @@ void loop() {
|
|||
}
|
||||
|
||||
String aprsmsg;
|
||||
aprsmsg = "!" + lat + Config.beacon.overlay + lng + Config.beacon.symbol + course_and_speed + alt;
|
||||
aprsmsg = "!" + lat + BeaconMan.getCurrentBeaconConfig()->overlay + lng + BeaconMan.getCurrentBeaconConfig()->symbol + course_and_speed + alt;
|
||||
// message_text every 10's packet (i.e. if we have beacon rate 1min at high
|
||||
// speed -> every 10min). May be enforced above (at expirey of smart beacon
|
||||
// rate (i.e. every 30min), or every third packet on static rate (i.e.
|
||||
// static rate 10 -> every third packet)
|
||||
if (!(rate_limit_message_text++ % 10)) {
|
||||
aprsmsg += Config.beacon.message;
|
||||
aprsmsg += BeaconMan.getCurrentBeaconConfig()->message;
|
||||
}
|
||||
if (BatteryIsConnected) {
|
||||
aprsmsg += " - _Bat.: " + batteryVoltage + "V - Cur.: " + batteryChargeCurrent + "mA";
|
||||
aprsmsg += " - Bat.: " + batteryVoltage + "V";
|
||||
#ifdef TTGO_T_Beam_V1_0
|
||||
aprsmsg += " - Cur.: " + batteryChargeCurrent + "mA";
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Config.enhance_precision) {
|
||||
if (BeaconMan.getCurrentBeaconConfig()->enhance_precision) {
|
||||
aprsmsg += " " + dao;
|
||||
}
|
||||
|
||||
msg.getAPRSBody()->setData(aprsmsg);
|
||||
msg.getBody()->setData(aprsmsg);
|
||||
String data = msg.encode();
|
||||
logPrintlnD(data);
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, "Loop", "%s", data.c_str());
|
||||
show_display("<< TX >>", data);
|
||||
|
||||
if (Config.ptt.active) {
|
||||
|
@ -267,7 +318,7 @@ void loop() {
|
|||
LoRa.write((const uint8_t *)data.c_str(), data.length());
|
||||
LoRa.endPacket();
|
||||
|
||||
if (Config.smart_beacon.active) {
|
||||
if (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active) {
|
||||
lastTxLat = gps.location.lat();
|
||||
lastTxLng = gps.location.lng();
|
||||
previousHeading = currentHeading;
|
||||
|
@ -282,15 +333,29 @@ void loop() {
|
|||
}
|
||||
|
||||
if (gps_time_update) {
|
||||
show_display(Config.callsign, createDateString(now()) + " " + createTimeString(now()), String("Sats: ") + gps.satellites.value() + " HDOP: " + gps.hdop.hdop(), String("Nxt Bcn: ") + (Config.smart_beacon.active ? "~" : "") + createTimeString(nextBeaconTimeStamp), BatteryIsConnected ? (String("Bat: ") + batteryVoltage + "V, " + batteryChargeCurrent + "mA") : "Powered via USB", String("Smart Beacon: " + getSmartBeaconState()));
|
||||
|
||||
if (Config.smart_beacon.active) {
|
||||
show_display(BeaconMan.getCurrentBeaconConfig()->callsign,
|
||||
createDateString(now()) + " " + createTimeString(now()),
|
||||
String("Sats: ") + gps.satellites.value() + " HDOP: " + gps.hdop.hdop(),
|
||||
String("Next Bcn: ") + (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active ? "~" : "") + createTimeString(nextBeaconTimeStamp),
|
||||
BatteryIsConnected ? (String("Bat: ") + batteryVoltage + "V, " + batteryChargeCurrent + "mA") : "Powered via USB",
|
||||
String("Smart Beacon: " + getSmartBeaconState()));
|
||||
|
||||
Serial.println(BeaconMan.getCurrentBeaconConfig()->callsign);
|
||||
Serial.println(createDateString(now()) + " " + createTimeString(now()));
|
||||
Serial.println(String("Sats: ") + gps.satellites.value() + " HDOP: " + gps.hdop.hdop());
|
||||
Serial.println(String("Next Bcn: ") + (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active ? "~" : "") + createTimeString(nextBeaconTimeStamp));
|
||||
Serial.println(BatteryIsConnected ? (String("Bat: ") + batteryVoltage + "V, " + batteryChargeCurrent + "mA") : "Powered via USB");
|
||||
Serial.println(String("Smart Beacon: " + getSmartBeaconState()));
|
||||
Serial.println();
|
||||
|
||||
if (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active) {
|
||||
// Change the Tx internal based on the current speed
|
||||
int curr_speed = (int)gps.speed.kmph();
|
||||
if (curr_speed < Config.smart_beacon.slow_speed) {
|
||||
txInterval = Config.smart_beacon.slow_rate * 1000;
|
||||
} else if (curr_speed > Config.smart_beacon.fast_speed) {
|
||||
txInterval = Config.smart_beacon.fast_rate * 1000;
|
||||
if (curr_speed < BeaconMan.getCurrentBeaconConfig()->smart_beacon.slow_speed) {
|
||||
txInterval = BeaconMan.getCurrentBeaconConfig()->smart_beacon.slow_rate * 1000;
|
||||
} else if (curr_speed > BeaconMan.getCurrentBeaconConfig()->smart_beacon.fast_speed) {
|
||||
txInterval = BeaconMan.getCurrentBeaconConfig()->smart_beacon.fast_rate * 1000;
|
||||
} else {
|
||||
/* Interval inbetween low and high speed
|
||||
min(slow_rate, ..) because: if slow rate is 300s at slow speed <=
|
||||
|
@ -302,41 +367,52 @@ void loop() {
|
|||
would lead to decrease of beacon rate in between 5 to 20 km/h. what
|
||||
is even below the slow speed rate.
|
||||
*/
|
||||
txInterval = min(Config.smart_beacon.slow_rate, Config.smart_beacon.fast_speed * Config.smart_beacon.fast_rate / curr_speed) * 1000;
|
||||
if (curr_speed == 0) {
|
||||
curr_speed = 1;
|
||||
}
|
||||
txInterval = min(BeaconMan.getCurrentBeaconConfig()->smart_beacon.slow_rate,
|
||||
BeaconMan.getCurrentBeaconConfig()->smart_beacon.fast_speed * BeaconMan.getCurrentBeaconConfig()->smart_beacon.fast_rate / curr_speed) *
|
||||
1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((Config.debug == false) && (millis() > 5000 && gps.charsProcessed() < 10)) {
|
||||
logPrintlnE("No GPS frames detected! Try to reset the GPS Chip with this "
|
||||
"firmware: https://github.com/lora-aprs/TTGO-T-Beam_GPS-reset");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR,
|
||||
"GPS",
|
||||
"No GPS frames detected! Try to reset the GPS Chip with this "
|
||||
"firmware: https://github.com/lora-aprs/TTGO-T-Beam_GPS-reset");
|
||||
show_display("No GPS frames detected!", "Try to reset the GPS Chip", "https://github.com/lora-aprs/TTGO-T-Beam_GPS-reset", 2000);
|
||||
}
|
||||
}
|
||||
|
||||
void load_config() {
|
||||
ConfigurationManagement confmg("/tracker.json");
|
||||
Config = confmg.readConfiguration();
|
||||
if (Config.callsign == "NOCALL-10") {
|
||||
logPrintlnE("You have to change your settings in 'data/tracker.json' and "
|
||||
"upload it via \"Upload File System image\"!");
|
||||
show_display("ERROR", "You have to change your settings in 'data/tracker.json' and "
|
||||
"upload it via \"Upload File System image\"!");
|
||||
BeaconMan.loadConfig(Config.beacons);
|
||||
if (BeaconMan.getCurrentBeaconConfig()->callsign == "NOCALL-7") {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR,
|
||||
"Config",
|
||||
"You have to change your settings in 'data/tracker.json' and "
|
||||
"upload it via \"Upload File System image\"!");
|
||||
show_display("ERROR",
|
||||
"You have to change your settings in 'data/tracker.json' and "
|
||||
"upload it via \"Upload File System image\"!");
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup_lora() {
|
||||
logPrintlnI("Set SPI pins!");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!");
|
||||
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
|
||||
logPrintlnI("Set LoRa pins!");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set LoRa pins!");
|
||||
LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);
|
||||
|
||||
long freq = Config.lora.frequencyTx;
|
||||
logPrintI("frequency: ");
|
||||
logPrintlnI(String(freq));
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "frequency: %d", freq);
|
||||
if (!LoRa.begin(freq)) {
|
||||
logPrintlnE("Starting LoRa failed!");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "LoRa", "Starting LoRa failed!");
|
||||
show_display("ERROR", "Starting LoRa failed!");
|
||||
while (true) {
|
||||
}
|
||||
|
@ -347,7 +423,7 @@ void setup_lora() {
|
|||
LoRa.enableCrc();
|
||||
|
||||
LoRa.setTxPower(Config.lora.power);
|
||||
logPrintlnI("LoRa init done!");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "LoRa init done!");
|
||||
show_display("INFO", "LoRa init done!", 2000);
|
||||
}
|
||||
|
||||
|
@ -457,11 +533,11 @@ String createDateString(time_t t) {
|
|||
}
|
||||
|
||||
String createTimeString(time_t t) {
|
||||
return String(padding(hour(t), 2) + "." + padding(minute(t), 2) + "." + padding(second(t), 2));
|
||||
return String(padding(hour(t), 2) + ":" + padding(minute(t), 2) + ":" + padding(second(t), 2));
|
||||
}
|
||||
|
||||
String getSmartBeaconState() {
|
||||
if (Config.smart_beacon.active) {
|
||||
if (BeaconMan.getCurrentBeaconConfig()->smart_beacon.active) {
|
||||
return "On";
|
||||
}
|
||||
return "Off";
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
|
||||
#include "configuration.h"
|
||||
|
||||
extern logging::Logger logger;
|
||||
|
||||
ConfigurationManagement::ConfigurationManagement(String FilePath) : mFilePath(FilePath) {
|
||||
if (!SPIFFS.begin(true)) {
|
||||
logPrintlnE("Mounting SPIFFS was not possible. Trying to format SPIFFS...");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "Configuration", "Mounting SPIFFS was not possible. Trying to format SPIFFS...");
|
||||
SPIFFS.format();
|
||||
if (!SPIFFS.begin()) {
|
||||
logPrintlnE("Formating SPIFFS was not okay!");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "Configuration", "Formatting SPIFFS was not okay!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,40 +23,53 @@ ConfigurationManagement::ConfigurationManagement(String FilePath) : mFilePath(Fi
|
|||
Configuration ConfigurationManagement::readConfiguration() {
|
||||
File file = SPIFFS.open(mFilePath);
|
||||
if (!file) {
|
||||
logPrintlnE("Failed to open file for reading...");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "Configuration", "Failed to open file for reading...");
|
||||
return Configuration();
|
||||
}
|
||||
DynamicJsonDocument data(2048);
|
||||
DeserializationError error = deserializeJson(data, file);
|
||||
|
||||
if (error) {
|
||||
logPrintlnE("Failed to read file, using default configuration.");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "Configuration", "Failed to read file, using default configuration.");
|
||||
}
|
||||
file.close();
|
||||
|
||||
Configuration conf;
|
||||
if (data.containsKey("callsign"))
|
||||
conf.callsign = data["callsign"].as<String>();
|
||||
conf.debug = data["debug"] | false;
|
||||
conf.enhance_precision = data["enhance_precision"] | false;
|
||||
if (data.containsKey("beacon") && data["beacon"].containsKey("message"))
|
||||
conf.beacon.message = data["beacon"]["message"].as<String>();
|
||||
conf.beacon.timeout = data["beacon"]["timeout"] | 1;
|
||||
if (data.containsKey("beacon") && data["beacon"].containsKey("symbol"))
|
||||
conf.beacon.symbol = data["beacon"]["symbol"].as<String>();
|
||||
if (data.containsKey("beacon") && data["beacon"].containsKey("overlay"))
|
||||
conf.beacon.overlay = data["beacon"]["overlay"].as<String>();
|
||||
if (data.containsKey("beacon") && data["beacon"].containsKey("button_tx"))
|
||||
conf.beacon.button_tx = data["beacon"]["button_tx"] | false;
|
||||
|
||||
conf.smart_beacon.active = data["smart_beacon"]["active"] | false;
|
||||
conf.smart_beacon.turn_min = data["smart_beacon"]["turn_min"] | 25;
|
||||
conf.smart_beacon.slow_rate = data["smart_beacon"]["slow_rate"] | 300;
|
||||
conf.smart_beacon.slow_speed = data["smart_beacon"]["slow_speed"] | 10;
|
||||
conf.smart_beacon.fast_rate = data["smart_beacon"]["fast_rate"] | 60;
|
||||
conf.smart_beacon.fast_speed = data["smart_beacon"]["fast_speed"] | 100;
|
||||
conf.smart_beacon.min_tx_dist = data["smart_beacon"]["min_tx_dist"] | 100;
|
||||
conf.smart_beacon.min_bcn = data["smart_beacon"]["min_bcn"] | 5;
|
||||
conf.debug = data["debug"] | false;
|
||||
|
||||
JsonArray beacons = data["beacons"].as<JsonArray>();
|
||||
for (JsonVariant v : beacons) {
|
||||
Configuration::Beacon beacon;
|
||||
|
||||
if (v.containsKey("callsign"))
|
||||
beacon.callsign = v["callsign"].as<String>();
|
||||
if (v.containsKey("path"))
|
||||
beacon.path = v["path"].as<String>();
|
||||
if (v.containsKey("message"))
|
||||
beacon.message = v["message"].as<String>();
|
||||
beacon.timeout = v["timeout"] | 1;
|
||||
if (v.containsKey("symbol"))
|
||||
beacon.symbol = v["symbol"].as<String>();
|
||||
if (v.containsKey("overlay"))
|
||||
beacon.overlay = v["overlay"].as<String>();
|
||||
|
||||
beacon.smart_beacon.active = v["smart_beacon"]["active"] | false;
|
||||
beacon.smart_beacon.turn_min = v["smart_beacon"]["turn_min"] | 25;
|
||||
beacon.smart_beacon.slow_rate = v["smart_beacon"]["slow_rate"] | 300;
|
||||
beacon.smart_beacon.slow_speed = v["smart_beacon"]["slow_speed"] | 10;
|
||||
beacon.smart_beacon.fast_rate = v["smart_beacon"]["fast_rate"] | 60;
|
||||
beacon.smart_beacon.fast_speed = v["smart_beacon"]["fast_speed"] | 100;
|
||||
beacon.smart_beacon.min_tx_dist = v["smart_beacon"]["min_tx_dist"] | 100;
|
||||
beacon.smart_beacon.min_bcn = v["smart_beacon"]["min_bcn"] | 5;
|
||||
|
||||
beacon.enhance_precision = v["enhance_precision"] | false;
|
||||
|
||||
conf.beacons.push_back(beacon);
|
||||
}
|
||||
|
||||
conf.button.tx = data["button"]["tx"] | false;
|
||||
conf.button.alt_message = data["button"]["alt_message"] | false;
|
||||
|
||||
conf.lora.frequencyRx = data["lora"]["frequency_rx"] | 433775000;
|
||||
conf.lora.frequencyTx = data["lora"]["frequency_tx"] | 433775000;
|
||||
|
@ -76,27 +91,37 @@ Configuration ConfigurationManagement::readConfiguration() {
|
|||
void ConfigurationManagement::writeConfiguration(Configuration conf) {
|
||||
File file = SPIFFS.open(mFilePath, "w");
|
||||
if (!file) {
|
||||
logPrintlnE("Failed to open file for writing...");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "Configuration", "Failed to open file for writing...");
|
||||
return;
|
||||
}
|
||||
DynamicJsonDocument data(2048);
|
||||
|
||||
data["callsign"] = conf.callsign;
|
||||
data["debug"] = conf.debug;
|
||||
data["enhance_precision"] = conf.enhance_precision;
|
||||
data["beacon"]["message"] = conf.beacon.message;
|
||||
data["beacon"]["timeout"] = conf.beacon.timeout;
|
||||
data["beacon"]["symbol"] = conf.beacon.symbol;
|
||||
data["beacon"]["overlay"] = conf.beacon.overlay;
|
||||
data["beacon"]["button_tx"] = conf.beacon.button_tx;
|
||||
data["smart_beacon"]["active"] = conf.smart_beacon.active;
|
||||
data["smart_beacon"]["turn_min"] = conf.smart_beacon.turn_min;
|
||||
data["smart_beacon"]["slow_rate"] = conf.smart_beacon.slow_rate;
|
||||
data["smart_beacon"]["slow_speed"] = conf.smart_beacon.slow_speed;
|
||||
data["smart_beacon"]["fast_rate"] = conf.smart_beacon.fast_rate;
|
||||
data["smart_beacon"]["fast_speed"] = conf.smart_beacon.fast_speed;
|
||||
data["smart_beacon"]["min_tx_dist"] = conf.smart_beacon.min_tx_dist;
|
||||
data["smart_beacon"]["min_bcn"] = conf.smart_beacon.min_bcn;
|
||||
JsonArray beacons = data.createNestedArray("beacons");
|
||||
for (Configuration::Beacon beacon : conf.beacons) {
|
||||
JsonObject v = beacons.createNestedObject();
|
||||
v["callsign"] = beacon.callsign;
|
||||
v["path"] = beacon.path;
|
||||
v["message"] = beacon.message;
|
||||
v["timeout"] = beacon.timeout;
|
||||
v["symbol"] = beacon.symbol;
|
||||
v["overlay"] = beacon.overlay;
|
||||
|
||||
v["smart_beacon"]["active"] = beacon.smart_beacon.active;
|
||||
v["smart_beacon"]["turn_min"] = beacon.smart_beacon.turn_min;
|
||||
v["smart_beacon"]["slow_rate"] = beacon.smart_beacon.slow_rate;
|
||||
v["smart_beacon"]["slow_speed"] = beacon.smart_beacon.slow_speed;
|
||||
v["smart_beacon"]["fast_rate"] = beacon.smart_beacon.fast_rate;
|
||||
v["smart_beacon"]["fast_speed"] = beacon.smart_beacon.fast_speed;
|
||||
v["smart_beacon"]["min_tx_dist"] = beacon.smart_beacon.min_tx_dist;
|
||||
v["smart_beacon"]["min_bcn"] = beacon.smart_beacon.min_bcn;
|
||||
|
||||
v["enhance_precision"] = beacon.enhance_precision;
|
||||
}
|
||||
|
||||
data["debug"] = conf.debug;
|
||||
|
||||
data["button"]["tx"] = conf.button.tx;
|
||||
data["button"]["alt_message"] = conf.button.alt_message;
|
||||
|
||||
data["lora"]["frequency_rx"] = conf.lora.frequencyRx;
|
||||
data["lora"]["frequency_tx"] = conf.lora.frequencyTx;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef CONFIGURATION_H_
|
||||
#define CONFIGURATION_H_
|
||||
|
||||
#include <iterator>
|
||||
#include <list>
|
||||
|
||||
#include <Arduino.h>
|
||||
|
@ -9,29 +10,32 @@ class Configuration {
|
|||
public:
|
||||
class Beacon {
|
||||
public:
|
||||
Beacon() : message("LoRa Tracker, Info: github.com/lora-aprs/LoRa_APRS_Tracker"), timeout(1), symbol("["), overlay("/"), button_tx(false) {
|
||||
class Smart_Beacon {
|
||||
public:
|
||||
Smart_Beacon() : active(false), turn_min(25), slow_rate(300), slow_speed(10), fast_rate(60), fast_speed(100), min_tx_dist(100), min_bcn(5) {
|
||||
}
|
||||
|
||||
bool active;
|
||||
int turn_min;
|
||||
int slow_rate;
|
||||
int slow_speed;
|
||||
int fast_rate;
|
||||
int fast_speed;
|
||||
int min_tx_dist;
|
||||
int min_bcn;
|
||||
};
|
||||
|
||||
Beacon() : callsign("NOCALL-10"), path("WIDE1-1"), message("LoRa Tracker"), timeout(1), symbol("["), overlay("/"), enhance_precision(true) {
|
||||
}
|
||||
|
||||
String message;
|
||||
int timeout;
|
||||
String symbol;
|
||||
String overlay;
|
||||
bool button_tx;
|
||||
};
|
||||
|
||||
class Smart_Beacon {
|
||||
public:
|
||||
Smart_Beacon() : active(false), turn_min(25), slow_rate(300), slow_speed(10), fast_rate(60), fast_speed(100), min_tx_dist(100), min_bcn(5) {
|
||||
}
|
||||
|
||||
bool active;
|
||||
int turn_min;
|
||||
int slow_rate;
|
||||
int slow_speed;
|
||||
int fast_rate;
|
||||
int fast_speed;
|
||||
int min_tx_dist;
|
||||
int min_bcn;
|
||||
String callsign;
|
||||
String path;
|
||||
String message;
|
||||
int timeout;
|
||||
String symbol;
|
||||
String overlay;
|
||||
Smart_Beacon smart_beacon;
|
||||
bool enhance_precision;
|
||||
};
|
||||
|
||||
class LoRa {
|
||||
|
@ -59,15 +63,23 @@ public:
|
|||
bool reverse;
|
||||
};
|
||||
|
||||
Configuration() : callsign("NOCALL-10"), debug(false), enhance_precision(true){};
|
||||
class Button {
|
||||
public:
|
||||
Button() : tx(false), alt_message(false) {
|
||||
}
|
||||
|
||||
String callsign;
|
||||
bool debug;
|
||||
bool enhance_precision;
|
||||
Beacon beacon;
|
||||
Smart_Beacon smart_beacon;
|
||||
LoRa lora;
|
||||
PTT ptt;
|
||||
bool tx;
|
||||
int alt_message;
|
||||
};
|
||||
|
||||
Configuration() : debug(false) {
|
||||
}
|
||||
|
||||
bool debug;
|
||||
std::list<Beacon> beacons;
|
||||
LoRa lora;
|
||||
PTT ptt;
|
||||
Button button;
|
||||
};
|
||||
|
||||
class ConfigurationManagement {
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "display.h"
|
||||
#include "pins.h"
|
||||
|
||||
extern logging::Logger logger;
|
||||
|
||||
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST);
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
|
@ -18,7 +20,7 @@ void setup_display() {
|
|||
|
||||
Wire.begin(OLED_SDA, OLED_SCL);
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) {
|
||||
logPrintlnE("SSD1306 allocation failed");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "SSD1306", "allocation failed!");
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +35,15 @@ void setup_display() {
|
|||
display.display();
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void display_toggle(bool toggle) {
|
||||
if (toggle) {
|
||||
display.ssd1306_command(SSD1306_DISPLAYON);
|
||||
} else {
|
||||
display.ssd1306_command(SSD1306_DISPLAYOFF);
|
||||
}
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void show_display(String header, int wait) {
|
||||
display.clearDisplay();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#define DISPLAY_H_
|
||||
|
||||
void setup_display();
|
||||
void display_toggle(bool toggle);
|
||||
|
||||
void show_display(String header, int wait = 0);
|
||||
void show_display(String header, String line1, int wait = 0);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define GPS_TX 12
|
||||
#endif
|
||||
|
||||
#ifdef TTGO_T_Beam_V1_0
|
||||
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
|
||||
#define GPS_RX 12
|
||||
#define GPS_TX 34
|
||||
#endif
|
||||
|
|
|
@ -1,72 +1,218 @@
|
|||
#include <XPowersAXP192.tpp>
|
||||
#include <XPowersAXP2101.tpp>
|
||||
|
||||
#include "power_management.h"
|
||||
|
||||
// cppcheck-suppress uninitMemberVar
|
||||
PowerManagement::PowerManagement() {
|
||||
AXP192::AXP192() {
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
bool PowerManagement::begin(TwoWire &port) {
|
||||
bool result = axp.begin(port, AXP192_SLAVE_ADDRESS);
|
||||
if (!result) {
|
||||
axp.setDCDC1Voltage(3300);
|
||||
bool AXP192::begin(TwoWire &port) {
|
||||
_pmu = new XPowersAXP192(port);
|
||||
if (!_pmu->init()) {
|
||||
delete _pmu;
|
||||
_pmu = 0;
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
|
||||
// lora radio power channel
|
||||
_pmu->setPowerChannelVoltage(XPOWERS_LDO2, 3300);
|
||||
|
||||
// oled module power channel,
|
||||
// disable it will cause abnormal communication between boot and AXP power supply,
|
||||
// do not turn it off
|
||||
_pmu->setPowerChannelVoltage(XPOWERS_DCDC1, 3300);
|
||||
|
||||
// gnss module power channel - now turned on in setGpsPower
|
||||
_pmu->setPowerChannelVoltage(XPOWERS_LDO3, 3300);
|
||||
|
||||
// protected oled power source
|
||||
//_pmu->setProtectedChannel(XPOWERS_DCDC1);
|
||||
// protected esp32 power source
|
||||
_pmu->setProtectedChannel(XPOWERS_DCDC3);
|
||||
|
||||
// disable not use channel
|
||||
_pmu->disablePowerOutput(XPOWERS_DCDC2);
|
||||
|
||||
// disable all axp chip interrupt
|
||||
_pmu->disableIRQ(XPOWERS_AXP192_ALL_IRQ);
|
||||
|
||||
// Set constant current charging current
|
||||
_pmu->setChargerConstantCurr(XPOWERS_AXP192_CHG_CUR_780MA);
|
||||
|
||||
// Set up the charging voltage
|
||||
_pmu->setChargeTargetVoltage(XPOWERS_AXP192_CHG_VOL_4V2);
|
||||
|
||||
_pmu->setChargingLedMode(XPOWERS_CHG_LED_CTRL_CHG);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateLoRa() {
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
void AXP192::activateLoRa() {
|
||||
_pmu->enablePowerOutput(XPOWERS_LDO2);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateLoRa() {
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
|
||||
void AXP192::deactivateLoRa() {
|
||||
_pmu->disablePowerOutput(XPOWERS_LDO2);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateGPS() {
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
|
||||
void AXP192::activateGPS() {
|
||||
_pmu->enablePowerOutput(XPOWERS_LDO3);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateGPS() {
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF);
|
||||
void AXP192::deactivateGPS() {
|
||||
_pmu->disablePowerOutput(XPOWERS_LDO3);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateOLED() {
|
||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
|
||||
void AXP192::activateOLED() {
|
||||
_pmu->enablePowerOutput(XPOWERS_DCDC1);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::decativateOLED() {
|
||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
|
||||
void AXP192::deactivateOLED() {
|
||||
_pmu->disablePowerOutput(XPOWERS_DCDC1);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::activateMeasurement() {
|
||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, true);
|
||||
void AXP192::activateMeasurement() {
|
||||
_pmu->enableBattVoltageMeasure();
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void PowerManagement::deactivateMeasurement() {
|
||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, false);
|
||||
void AXP192::deactivateMeasurement() {
|
||||
_pmu->disableBattVoltageMeasure();
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
double PowerManagement::getBatteryVoltage() {
|
||||
return axp.getBattVoltage() / 1000.0;
|
||||
double AXP192::getBatteryVoltage() {
|
||||
return _pmu->getBattVoltage() / 1000.0;
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
double PowerManagement::getBatteryChargeDischargeCurrent() {
|
||||
if (axp.isChargeing()) {
|
||||
return axp.getBattChargeCurrent();
|
||||
double AXP192::getBatteryChargeDischargeCurrent() {
|
||||
if (isCharging()) {
|
||||
return ((XPowersAXP192 *)_pmu)->getBatteryChargeCurrent();
|
||||
}
|
||||
return -1.0 * axp.getBattDischargeCurrent();
|
||||
return -1.0 * ((XPowersAXP192 *)_pmu)->getBattDischargeCurrent();
|
||||
}
|
||||
|
||||
bool PowerManagement::isBatteryConnect() {
|
||||
return axp.isBatteryConnect();
|
||||
bool AXP192::isBatteryConnect() {
|
||||
return _pmu->isBatteryConnect();
|
||||
}
|
||||
|
||||
bool AXP192::isCharging() {
|
||||
return _pmu->isCharging();
|
||||
}
|
||||
|
||||
AXP2101::AXP2101() {
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
bool AXP2101::begin(TwoWire &port) {
|
||||
_pmu = new XPowersAXP2101(port);
|
||||
if (!_pmu->init()) {
|
||||
delete _pmu;
|
||||
_pmu = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Unuse power channel
|
||||
_pmu->disablePowerOutput(XPOWERS_DCDC2);
|
||||
_pmu->disablePowerOutput(XPOWERS_DCDC3);
|
||||
_pmu->disablePowerOutput(XPOWERS_DCDC4);
|
||||
_pmu->disablePowerOutput(XPOWERS_DCDC5);
|
||||
_pmu->disablePowerOutput(XPOWERS_ALDO1);
|
||||
_pmu->disablePowerOutput(XPOWERS_ALDO4);
|
||||
_pmu->disablePowerOutput(XPOWERS_BLDO1);
|
||||
_pmu->disablePowerOutput(XPOWERS_BLDO2);
|
||||
_pmu->disablePowerOutput(XPOWERS_DLDO1);
|
||||
_pmu->disablePowerOutput(XPOWERS_DLDO2);
|
||||
|
||||
// GNSS RTC PowerVDD 3300mV
|
||||
_pmu->setPowerChannelVoltage(XPOWERS_VBACKUP, 3300);
|
||||
_pmu->enablePowerOutput(XPOWERS_VBACKUP);
|
||||
|
||||
// LoRa VDD 3300mV
|
||||
_pmu->setPowerChannelVoltage(XPOWERS_ALDO2, 3300);
|
||||
_pmu->enablePowerOutput(XPOWERS_ALDO2);
|
||||
|
||||
// GNSS VDD 3300mV
|
||||
_pmu->setPowerChannelVoltage(XPOWERS_ALDO3, 3300);
|
||||
_pmu->enablePowerOutput(XPOWERS_ALDO3);
|
||||
|
||||
// disable all axp chip interrupt
|
||||
_pmu->disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
|
||||
|
||||
// Set constant current charging current
|
||||
_pmu->setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_800MA);
|
||||
|
||||
// Set up the charging voltage
|
||||
_pmu->setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V2);
|
||||
|
||||
_pmu->setChargingLedMode(XPOWERS_CHG_LED_CTRL_CHG);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void AXP2101::activateLoRa() {
|
||||
_pmu->enablePowerOutput(XPOWERS_ALDO2);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void AXP2101::deactivateLoRa() {
|
||||
_pmu->disablePowerOutput(XPOWERS_ALDO2);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void AXP2101::activateGPS() {
|
||||
_pmu->enablePowerOutput(XPOWERS_ALDO3);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void AXP2101::deactivateGPS() {
|
||||
_pmu->disablePowerOutput(XPOWERS_ALDO3);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void AXP2101::activateOLED() {
|
||||
_pmu->enablePowerOutput(XPOWERS_DCDC1);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void AXP2101::deactivateOLED() {
|
||||
_pmu->disablePowerOutput(XPOWERS_DCDC1);
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void AXP2101::activateMeasurement() {
|
||||
_pmu->enableBattVoltageMeasure();
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
void AXP2101::deactivateMeasurement() {
|
||||
_pmu->disableBattVoltageMeasure();
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
double AXP2101::getBatteryVoltage() {
|
||||
return _pmu->getBattVoltage() / 1000.0;
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
double AXP2101::getBatteryChargeDischargeCurrent() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool AXP2101::isBatteryConnect() {
|
||||
return _pmu->isBatteryConnect();
|
||||
}
|
||||
|
||||
bool AXP2101::isCharging() {
|
||||
return _pmu->isCharging();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,43 @@
|
|||
#ifndef POWER_MANAGEMENT_H_
|
||||
#define POWER_MANAGEMENT_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <axp20x.h>
|
||||
#include <Wire.h>
|
||||
#include <XPowersLibInterface.hpp>
|
||||
|
||||
class PowerManagement {
|
||||
public:
|
||||
PowerManagement();
|
||||
~PowerManagement() {
|
||||
}
|
||||
|
||||
virtual bool begin(TwoWire &port) = 0;
|
||||
|
||||
virtual void activateLoRa() = 0;
|
||||
virtual void deactivateLoRa() = 0;
|
||||
|
||||
virtual void activateGPS() = 0;
|
||||
virtual void deactivateGPS() = 0;
|
||||
|
||||
virtual void activateOLED() = 0;
|
||||
virtual void deactivateOLED() = 0;
|
||||
|
||||
virtual void activateMeasurement() = 0;
|
||||
virtual void deactivateMeasurement() = 0;
|
||||
|
||||
virtual double getBatteryVoltage() = 0;
|
||||
|
||||
virtual double getBatteryChargeDischargeCurrent() = 0;
|
||||
|
||||
virtual bool isBatteryConnect() = 0;
|
||||
virtual bool isCharging() = 0;
|
||||
|
||||
protected:
|
||||
XPowersLibInterface *_pmu = 0;
|
||||
};
|
||||
|
||||
class AXP192 : public PowerManagement {
|
||||
public:
|
||||
AXP192();
|
||||
|
||||
bool begin(TwoWire &port);
|
||||
|
||||
void activateLoRa();
|
||||
|
@ -16,7 +47,10 @@ public:
|
|||
void deactivateGPS();
|
||||
|
||||
void activateOLED();
|
||||
void decativateOLED();
|
||||
void deactivateOLED();
|
||||
|
||||
void enableChgLed();
|
||||
void disableChgLed();
|
||||
|
||||
void activateMeasurement();
|
||||
void deactivateMeasurement();
|
||||
|
@ -25,9 +59,35 @@ public:
|
|||
double getBatteryChargeDischargeCurrent();
|
||||
|
||||
bool isBatteryConnect();
|
||||
bool isCharging();
|
||||
};
|
||||
|
||||
private:
|
||||
AXP20X_Class axp;
|
||||
class AXP2101 : public PowerManagement {
|
||||
public:
|
||||
AXP2101();
|
||||
|
||||
bool begin(TwoWire &port);
|
||||
|
||||
void activateLoRa();
|
||||
void deactivateLoRa();
|
||||
|
||||
void activateGPS();
|
||||
void deactivateGPS();
|
||||
|
||||
void activateOLED();
|
||||
void deactivateOLED();
|
||||
|
||||
void enableChgLed();
|
||||
void disableChgLed();
|
||||
|
||||
void activateMeasurement();
|
||||
void deactivateMeasurement();
|
||||
|
||||
double getBatteryVoltage();
|
||||
double getBatteryChargeDischargeCurrent();
|
||||
|
||||
bool isBatteryConnect();
|
||||
bool isCharging();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue