clang-format implementation (#1740)
* Testing clang-format style check using github CI
* github/push: implement check-style for clang-format as a separate build step
* github/push: add missing packages for check-style/clang-format build step
* source/Makefile: check-style - reduce files of interest; update .clang-format to keep enums init
* source/Makefile: empty lines, spaces & tabs refactoring to unify style - part 1 out of N
* source/Makefile: fix formatting for multi-line variables
* source/Makefile: update formatting for multi-line variables
* source/Makefile: remove spaces on vars assignments to unify style
* source/Makefile: remove unused target style
* source/Makefile: implement exclude vars for clang-format related files
* source/Makefile: exclude configuration.h from clang-format check
* Dockerfile: add diffutils in a container to make check-style target using advanced version of diff to get more advanced output to parse & navigate log more easily
* source/Makefile: implement parser for clang-format inside check-style target to make output compatible with gcc-like error compilation format for compatibility with IDEs/editors for easy navigation over files to fix style errors
* source/Makefile: probably final touches on unifying style
* source/Makefile: implement check-style-list target to only list affected file names with wrong code style for debug purposes
* source/Makefile: fix missed spaces
* deploy.sh: add helper routine to deal with clang-format error output logging from makefile
* gitignore: add clang-format log explicitly
* Refactoring for clang-format compiance
* Dockerfile: add sed
* Dockerfile: false alarm - remove sed since busybox-sed seems fine
* source/Makefile: reduce calls of clang-format & make error log more clean, clear, and tidy
* deploy.sh:check_style() - add removal of DOS EOLs for generated log
* source/Makefile:check-style: add more empty lines between blocks with errors for readability when suggestion is too long & heavy
* source/Makefile: add STOP var to check-style for exit on first failed file
* source/Makefile: check-style: make log looks more like traditional diff/patch output
* source/Core/BSP/Pinecilv2/MemMang/heap_5.c: clang-format refactoring using reasonable advises ... and then disable it in Makefile from scanning by clang-format
* Return headers include order
* clang-format config: disable warnings about non-alphabetic include order
* clang-format refactoring
* clang-format refactoring, part 2
* clang-format refactoring, part 3
* settingsGUI.cpp: refactoring, part 1
* settingsGUI.cpp: refactoring, part 2
* settingsGUI.cpp: refactoring, part 3
* settingsGUI.cpp: refactoring, part 4
* clang-format should be happy now
* workflows/push: put readme check into separate build step & update style
* clang-format: giving SortIncludes option second chance by tweaking a couple of headers a bit
* source/Makefile: check-style: add homebrew parser to check for { } in conditional blocks
* homebrew-format: add { } for if/else, while, and for & unify some comments style; left two errors intentionally to debug & improve parser
* source/Makefile: homebrew-format: fix false negative trigger for multi-line condition in if-s
* Sleep.cpp: unify style & comments
* source/Makefile: remove unused debug target
This commit is contained in:
66
.github/workflows/push.yml
vendored
66
.github/workflows/push.yml
vendored
@@ -26,10 +26,10 @@ jobs:
|
|||||||
- name: Git ownership exception
|
- name: Git ownership exception
|
||||||
run: git config --global --add safe.directory /__w/IronOS/IronOS && git config --global safe.directory "$GITHUB_WORKSPACE"
|
run: git config --global --add safe.directory /__w/IronOS/IronOS && git config --global safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
- name: build ${{ matrix.model }}
|
- name: Build ${{ matrix.model }}
|
||||||
run: cd source && ./build.sh -m ${{ matrix.model }}
|
run: cd source && ./build.sh -m ${{ matrix.model }}
|
||||||
|
|
||||||
- name: copy license text
|
- name: Copy license files
|
||||||
run: |
|
run: |
|
||||||
cp LICENSE source/Hexfile/LICENSE
|
cp LICENSE source/Hexfile/LICENSE
|
||||||
cp scripts/LICENSE_RELEASE.md source/Hexfile/LICENSE_RELEASE.md
|
cp scripts/LICENSE_RELEASE.md source/Hexfile/LICENSE_RELEASE.md
|
||||||
@@ -55,6 +55,7 @@ jobs:
|
|||||||
name: metadata
|
name: metadata
|
||||||
path: source/Hexfile/${{ matrix.model }}.json
|
path: source/Hexfile/${{ matrix.model }}.json
|
||||||
|
|
||||||
|
|
||||||
build_multi-lang:
|
build_multi-lang:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
container:
|
container:
|
||||||
@@ -77,10 +78,10 @@ jobs:
|
|||||||
- name: Git ownership exception
|
- name: Git ownership exception
|
||||||
run: git config --global --add safe.directory /__w/IronOS/IronOS && git config --global safe.directory "$GITHUB_WORKSPACE"
|
run: git config --global --add safe.directory /__w/IronOS/IronOS && git config --global safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
- name: build ${{ matrix.model }}
|
- name: Build ${{ matrix.model }}
|
||||||
run: cd source && make -j$(nproc) model="${{ matrix.model }}" firmware-multi_compressed_European firmware-multi_compressed_Bulgarian+Russian+Serbian+Ukrainian firmware-multi_Chinese+Japanese
|
run: cd source && make -j$(nproc) model="${{ matrix.model }}" firmware-multi_compressed_European firmware-multi_compressed_Bulgarian+Russian+Serbian+Ukrainian firmware-multi_Chinese+Japanese
|
||||||
|
|
||||||
- name: copy license text
|
- name: Copy license files
|
||||||
run: |
|
run: |
|
||||||
cp LICENSE source/Hexfile/LICENSE
|
cp LICENSE source/Hexfile/LICENSE
|
||||||
cp scripts/LICENSE_RELEASE.md source/Hexfile/LICENSE_RELEASE.md
|
cp scripts/LICENSE_RELEASE.md source/Hexfile/LICENSE_RELEASE.md
|
||||||
@@ -106,20 +107,21 @@ jobs:
|
|||||||
name: metadata
|
name: metadata
|
||||||
path: source/Hexfile/${{ matrix.model }}_multi-lang.json
|
path: source/Hexfile/${{ matrix.model }}_multi-lang.json
|
||||||
|
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
container:
|
container:
|
||||||
image: alpine:3.16
|
image: alpine:3.16
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: deps
|
- name: Install dependencies (apk)
|
||||||
run: apk add --no-cache python3 py3-pip make git bash findutils gcc musl-dev
|
run: apk add --no-cache python3 py3-pip make git bash findutils gcc musl-dev
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
- name: install black
|
- name: Install dependencies (python)
|
||||||
run: python3 -m pip install bdflib
|
run: python3 -m pip install bdflib
|
||||||
|
|
||||||
- name: Run python tests
|
- name: Run python tests
|
||||||
@@ -133,36 +135,49 @@ jobs:
|
|||||||
chmod +x brieflz_test.py
|
chmod +x brieflz_test.py
|
||||||
./brieflz_test.py
|
./brieflz_test.py
|
||||||
|
|
||||||
check_formatting:
|
|
||||||
|
check_c-cpp:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
container:
|
container:
|
||||||
image: alpine:3.16
|
image: alpine:3.16
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: deps
|
- name: Install dependencies (apk)
|
||||||
run: apk add --no-cache python3 py3-pip make git black sed diffutils
|
run: apk add --no-cache make git diffutils findutils clang-extra-tools
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
- name: install black
|
- name: Check format style with clang-format
|
||||||
run: python3 -m pip install bdflib flake8
|
|
||||||
|
|
||||||
- name: Check formatting with clang-format
|
|
||||||
run: cd source && make clean && make check-style
|
run: cd source && make clean && make check-style
|
||||||
|
|
||||||
|
|
||||||
|
check_python:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
container:
|
||||||
|
image: alpine:3.16
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install dependencies (apk)
|
||||||
|
run: apk add --no-cache python3 py3-pip make git black
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Install dependencies (python)
|
||||||
|
run: python3 -m pip install bdflib flake8
|
||||||
|
|
||||||
- name: Check python formatting with black
|
- name: Check python formatting with black
|
||||||
run: black --check Translations
|
run: black --check Translations
|
||||||
|
|
||||||
- name: Check python with flake8
|
- name: Check python with flake8
|
||||||
run: flake8 Translations
|
run: flake8 Translations
|
||||||
|
|
||||||
- name: Check autogenerated Documentation/README.md
|
|
||||||
run: /bin/sh ./scripts/deploy.sh docs_readme
|
|
||||||
|
|
||||||
shellcheck:
|
check_shell:
|
||||||
name: runner / shellcheck
|
name: check_shell
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -173,3 +188,20 @@ jobs:
|
|||||||
reporter: github-pr-review # Change reporter.
|
reporter: github-pr-review # Change reporter.
|
||||||
exclude: "./.git/*" # Optional.
|
exclude: "./.git/*" # Optional.
|
||||||
check_all_files_with_shebangs: "false" # Optional.
|
check_all_files_with_shebangs: "false" # Optional.
|
||||||
|
|
||||||
|
|
||||||
|
check_readme:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
container:
|
||||||
|
image: alpine:3.16
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install dependencies (apk)
|
||||||
|
run: apk add --no-cache git
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Check autogenerated Documentation/README.md
|
||||||
|
run: /bin/sh ./scripts/deploy.sh docs_readme
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -212,3 +212,6 @@ TS100/KiCad/TS100.bak
|
|||||||
Logo GUI/TS100 Logo Editor/TS100 Logo Editor/obj/
|
Logo GUI/TS100 Logo Editor/TS100 Logo Editor/obj/
|
||||||
Logo GUI/TS100 Logo Editor/TS100 Logo Editor/bin/
|
Logo GUI/TS100 Logo Editor/TS100 Logo Editor/bin/
|
||||||
|
|
||||||
|
# Tests/linters/sanitizers
|
||||||
|
source/check-style.log
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ WORKDIR /build/source
|
|||||||
# Installing the two compilers (ARM & RISCV), python3 & pip, clang tools:
|
# Installing the two compilers (ARM & RISCV), python3 & pip, clang tools:
|
||||||
## - compilers: gcc-*, newlib-*
|
## - compilers: gcc-*, newlib-*
|
||||||
## - python3: py*, black (required to check Python code formatting)
|
## - python3: py*, black (required to check Python code formatting)
|
||||||
## - misc: findutils, make, git
|
## - misc: findutils, make, git, diffutils
|
||||||
## - musl-dev (required for the multi lang firmwares)
|
## - musl-dev (required for the multi lang firmwares)
|
||||||
## - clang (required for clang-format to check C++ code formatting)
|
## - clang (required for clang-format to check C++ code formatting)
|
||||||
|
|
||||||
ARG APK_COMPS="gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf \
|
ARG APK_COMPS="gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf \
|
||||||
newlib-arm-none-eabi"
|
newlib-arm-none-eabi"
|
||||||
ARG APK_PYTHON="python3 py3-pip black"
|
ARG APK_PYTHON="python3 py3-pip black"
|
||||||
ARG APK_MISC="findutils make git"
|
ARG APK_MISC="findutils make git diffutils"
|
||||||
ARG APK_DEV="musl-dev clang bash clang-extra-tools"
|
ARG APK_DEV="musl-dev clang bash clang-extra-tools"
|
||||||
|
|
||||||
# PIP packages
|
# PIP packages
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
### helper functions
|
### helper functions
|
||||||
|
|
||||||
|
# brief help (some supported commands may be missing!)
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
echo -e "\nUsage: ${0} [CMD]\n"
|
echo -e "\nUsage: ${0} [CMD]\n"
|
||||||
@@ -19,9 +20,11 @@ usage()
|
|||||||
echo -e "\tclean - delete created docker container (but not pre-downloaded data for it)\n"
|
echo -e "\tclean - delete created docker container (but not pre-downloaded data for it)\n"
|
||||||
echo "CMD (helper routines):"
|
echo "CMD (helper routines):"
|
||||||
echo -e "\tdocs_readme - generate & OVERWRITE(!) README.md inside Documentation/ based on nav section from mkdocs.yml if it changed\n"
|
echo -e "\tdocs_readme - generate & OVERWRITE(!) README.md inside Documentation/ based on nav section from mkdocs.yml if it changed\n"
|
||||||
|
echo -e "\tcheck_style - run clang-format using source/Makefile and generate gcc-compatible error log in source/check-style.log\n"
|
||||||
echo -e "STORAGE NOTICE: for \"shell\" and \"build\" commands extra files will be downloaded so make sure that you have ~5GB of free space.\n"
|
echo -e "STORAGE NOTICE: for \"shell\" and \"build\" commands extra files will be downloaded so make sure that you have ~5GB of free space.\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Documentation/README.md automagical generation routine
|
||||||
docs_readme()
|
docs_readme()
|
||||||
{
|
{
|
||||||
# WARNING: ON RUN Documentaion/README.md MAY BE OVERWRITTEN WITHOUT ANY WARNINGS / CONFIRMATIONS !!!
|
# WARNING: ON RUN Documentaion/README.md MAY BE OVERWRITTEN WITHOUT ANY WARNINGS / CONFIRMATIONS !!!
|
||||||
@@ -67,10 +70,34 @@ EOF
|
|||||||
return "${ret}"
|
return "${ret}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check_style routine for those who too lazy to do it everytime manually
|
||||||
|
check_style()
|
||||||
|
{
|
||||||
|
log="source/check-style.log"
|
||||||
|
make -C source check-style 2>&1 | tee "${log}"
|
||||||
|
chmod 0666 "${log}"
|
||||||
|
sed -i -e 's,\r,,g' "${log}"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
### main
|
### main
|
||||||
|
|
||||||
docker_conf="Env.yml"
|
docker_conf="Env.yml"
|
||||||
|
|
||||||
|
# get absolute location of project root dir to make docker happy with config(s)
|
||||||
|
# (successfully tested on relatively POSIX-compliant Dash shell)
|
||||||
|
|
||||||
|
# this script
|
||||||
|
script_file="/deploy.sh"
|
||||||
|
# IronOS/scripts/deploy.sh
|
||||||
|
script_path="${PWD}"/"${0}"
|
||||||
|
# IronOS/scripts/
|
||||||
|
script_dir=${script_path%"${script_file}"}
|
||||||
|
# IronOS/
|
||||||
|
root_dir="${script_dir}/.."
|
||||||
|
# IronOS/Env.yml
|
||||||
|
docker_file="-f ${root_dir}/${docker_conf}"
|
||||||
|
|
||||||
# allow providing custom path to docker tool using DOCKER_BIN external env. var.
|
# allow providing custom path to docker tool using DOCKER_BIN external env. var.
|
||||||
# (compose sub-command must be included, i.e. DOCKER_BIN="/usr/local/bin/docker compose" ./deploy.sh)
|
# (compose sub-command must be included, i.e. DOCKER_BIN="/usr/local/bin/docker compose" ./deploy.sh)
|
||||||
|
|
||||||
@@ -103,6 +130,11 @@ if [ "docs_readme" = "${cmd}" ]; then
|
|||||||
exit "${?}"
|
exit "${?}"
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
|
if [ "check_style" = "${cmd}" ]; then
|
||||||
|
check_style
|
||||||
|
exit "${?}"
|
||||||
|
fi;
|
||||||
|
|
||||||
# if docker is not presented in any way show warning & exit
|
# if docker is not presented in any way show warning & exit
|
||||||
|
|
||||||
if [ -z "${docker_bin}" ]; then
|
if [ -z "${docker_bin}" ]; then
|
||||||
@@ -124,20 +156,6 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
# get absolute location of project root dir to make docker happy with config(s)
|
|
||||||
# (successfully tested on relatively POSIX-compliant Dash shell)
|
|
||||||
|
|
||||||
# this script
|
|
||||||
script_file="/deploy.sh"
|
|
||||||
# IronOS/scripts/deploy.sh
|
|
||||||
script_path="${PWD}"/"${0}"
|
|
||||||
# IronOS/scripts/
|
|
||||||
script_dir=${script_path%"${script_file}"}
|
|
||||||
# IronOS/
|
|
||||||
root_dir="${script_dir}/.."
|
|
||||||
# IronOS/Env.yml
|
|
||||||
docker_file="-f ${root_dir}/${docker_conf}"
|
|
||||||
|
|
||||||
# change dir to project root dir & run constructed command
|
# change dir to project root dir & run constructed command
|
||||||
|
|
||||||
cd "${root_dir}" || exit 1
|
cd "${root_dir}" || exit 1
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ AllowShortFunctionsOnASingleLine: All
|
|||||||
AllowShortLambdasOnASingleLine: All
|
AllowShortLambdasOnASingleLine: All
|
||||||
AllowShortIfStatementsOnASingleLine: Never
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
AllowShortLoopsOnASingleLine: false
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: false ### <<< Keeps enums as is
|
||||||
AlwaysBreakAfterDefinitionReturnType: None
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
AlwaysBreakAfterReturnType: None
|
AlwaysBreakAfterReturnType: None
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ void Setup_HAL() {
|
|||||||
MX_IWDG_Init();
|
MX_IWDG_Init();
|
||||||
HAL_ADC_Start(&hadc2);
|
HAL_ADC_Start(&hadc2);
|
||||||
HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADCReadings,
|
HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADCReadings,
|
||||||
(ADC_SAMPLES * ADC_CHANNELS)); // start DMA of normal readings
|
(ADC_SAMPLES * ADC_CHANNELS)); // start DMA of normal readings
|
||||||
// HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings
|
// HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings
|
||||||
// HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings
|
// HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings
|
||||||
}
|
}
|
||||||
|
|
||||||
// channel 0 -> temperature sensor, 1-> VIN, 2-> tip
|
// channel 0 -> temperature sensor, 1-> VIN, 2-> tip
|
||||||
@@ -154,8 +154,9 @@ static void MX_ADC1_Init(void) {
|
|||||||
|
|
||||||
SET_BIT(hadc1.Instance->CR1, (ADC_CR1_EOSIE)); // Enable end of Normal
|
SET_BIT(hadc1.Instance->CR1, (ADC_CR1_EOSIE)); // Enable end of Normal
|
||||||
// Run ADC internal calibration
|
// Run ADC internal calibration
|
||||||
while (HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK)
|
while (HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK) {
|
||||||
;
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ADC2 init function */
|
/* ADC2 init function */
|
||||||
@@ -191,8 +192,9 @@ static void MX_ADC2_Init(void) {
|
|||||||
HAL_ADC_ConfigChannel(&hadc2, &sConfig);
|
HAL_ADC_ConfigChannel(&hadc2, &sConfig);
|
||||||
|
|
||||||
// Run ADC internal calibration
|
// Run ADC internal calibration
|
||||||
while (HAL_ADCEx_Calibration_Start(&hadc2) != HAL_OK)
|
while (HAL_ADCEx_Calibration_Start(&hadc2) != HAL_OK) {
|
||||||
;
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* I2C1 init function */
|
/* I2C1 init function */
|
||||||
static void MX_I2C1_Init(void) {
|
static void MX_I2C1_Init(void) {
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ void flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
|||||||
HAL_FLASH_Unlock();
|
HAL_FLASH_Unlock();
|
||||||
for (uint16_t i = 0; i < (length / 2); i++) {
|
for (uint16_t i = 0; i < (length / 2); i++) {
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, SETTINGS_START_PAGE+ (i*sizeof(uint16_t)), data[i]);
|
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, SETTINGS_START_PAGE + (i * sizeof(uint16_t)), data[i]);
|
||||||
}
|
}
|
||||||
HAL_FLASH_Lock();
|
HAL_FLASH_Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void flash_read_buffer(uint8_t *buffer, const uint16_t length) { memcpy(buffer, (uint8_t*)SETTINGS_START_PAGE, length); }
|
void flash_read_buffer(uint8_t *buffer, const uint16_t length) { memcpy(buffer, (uint8_t *)SETTINGS_START_PAGE, length); }
|
||||||
|
|||||||
@@ -229,8 +229,9 @@ static void MX_ADC1_Init(void) {
|
|||||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||||
SET_BIT(hadc1.Instance->CR1, (ADC_CR1_JEOCIE)); // Enable end of injected conv irq
|
SET_BIT(hadc1.Instance->CR1, (ADC_CR1_JEOCIE)); // Enable end of injected conv irq
|
||||||
// Run ADC internal calibration
|
// Run ADC internal calibration
|
||||||
while (HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK)
|
while (HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK) {
|
||||||
;
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ADC2 init function */
|
/* ADC2 init function */
|
||||||
@@ -272,8 +273,9 @@ static void MX_ADC2_Init(void) {
|
|||||||
HAL_ADCEx_InjectedConfigChannel(&hadc2, &sConfigInjected);
|
HAL_ADCEx_InjectedConfigChannel(&hadc2, &sConfigInjected);
|
||||||
|
|
||||||
// Run ADC internal calibration
|
// Run ADC internal calibration
|
||||||
while (HAL_ADCEx_Calibration_Start(&hadc2) != HAL_OK)
|
while (HAL_ADCEx_Calibration_Start(&hadc2) != HAL_OK) {
|
||||||
;
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* I2C1 init function */
|
/* I2C1 init function */
|
||||||
static void MX_I2C1_Init(void) {
|
static void MX_I2C1_Init(void) {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
|
|
||||||
void flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
void flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
||||||
FLASH_EraseInitTypeDef pEraseInit;
|
FLASH_EraseInitTypeDef pEraseInit;
|
||||||
pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
|
pEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||||
|
|||||||
@@ -208,9 +208,7 @@ static void prvTaskExitError(void) {
|
|||||||
// therefore not output an 'unreachable code' warning for code that appears
|
// therefore not output an 'unreachable code' warning for code that appears
|
||||||
// after it. */
|
// after it. */
|
||||||
// }
|
// }
|
||||||
for(;;){
|
for (;;) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <I2C_Wrapper.hpp>
|
#include <I2C_Wrapper.hpp>
|
||||||
|
|
||||||
|
|
||||||
void preRToSInit() {
|
void preRToSInit() {
|
||||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick.
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ void log_system_state(int32_t PWMWattsx10) {
|
|||||||
// Tip_Temp_C,Handle_Temp_C,Output_Power_Wattx10,PWM,Tip_Raw\r\n
|
// Tip_Temp_C,Handle_Temp_C,Output_Power_Wattx10,PWM,Tip_Raw\r\n
|
||||||
// 3+1+3+1+3+1+3+1+5+2 = 23, so sizing at 32 for now
|
// 3+1+3+1+3+1+3+1+5+2 = 23, so sizing at 32 for now
|
||||||
|
|
||||||
outputLength = snprintf(uartOutputBuffer, uartOutputBufferLength, "%lu,%u,%li,%u,%lu\r\n", //
|
outputLength = snprintf(uartOutputBuffer, uartOutputBufferLength, "%lu,%u,%li,%u,%lu\r\n",
|
||||||
TipThermoModel::getTipInC(false), // Tip temp in C
|
TipThermoModel::getTipInC(false), // Tip temp in C
|
||||||
getHandleTemperature(0), // Handle temp in C X10
|
getHandleTemperature(0), // Handle temp in C X10
|
||||||
PWMWattsx10, // Output Wattage
|
PWMWattsx10, // Output Wattage
|
||||||
pendingPWM, // PWM
|
pendingPWM, // PWM
|
||||||
TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true) // Tip temp in uV
|
TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true) // Tip temp in uV
|
||||||
);
|
);
|
||||||
|
|
||||||
// Now print this out the uart via IRQ (DMA cant be used as oled has it)
|
// Now print this out the uart via IRQ (DMA cant be used as oled has it)
|
||||||
currentOutputPos = 0;
|
currentOutputPos = 0;
|
||||||
|
|||||||
@@ -40,18 +40,19 @@ enum class i2c_step {
|
|||||||
Wait_stop, // Wait for stop to send and we are done
|
Wait_stop, // Wait for stop to send and we are done
|
||||||
Done, // Finished
|
Done, // Finished
|
||||||
Error_occured, // Error occured on the bus
|
Error_occured, // Error occured on the bus
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct i2c_state {
|
struct i2c_state {
|
||||||
i2c_step currentStep;
|
i2c_step currentStep;
|
||||||
bool isMemoryWrite;
|
bool isMemoryWrite;
|
||||||
bool wakePart;
|
bool wakePart;
|
||||||
uint8_t deviceAddress;
|
uint8_t deviceAddress;
|
||||||
uint8_t memoryAddress;
|
uint8_t memoryAddress;
|
||||||
uint8_t * buffer;
|
uint8_t *buffer;
|
||||||
uint16_t numberOfBytes;
|
uint16_t numberOfBytes;
|
||||||
dma_parameter_struct dma_init_struct;
|
dma_parameter_struct dma_init_struct;
|
||||||
};
|
};
|
||||||
|
|
||||||
i2c_state currentState;
|
i2c_state currentState;
|
||||||
|
|
||||||
void perform_i2c_step() {
|
void perform_i2c_step() {
|
||||||
|
|||||||
@@ -40,8 +40,9 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
|
|||||||
i2cCfg.data = p_buffer;
|
i2cCfg.data = p_buffer;
|
||||||
i2cCfg.subAddrSize = 1; // one byte address
|
i2cCfg.subAddrSize = 1; // one byte address
|
||||||
|
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
err = I2C_MasterReceiveBlocking(I2C0_ID, &i2cCfg);
|
/* --------------- */
|
||||||
|
err = I2C_MasterReceiveBlocking(I2C0_ID, &i2cCfg);
|
||||||
taskEXIT_CRITICAL();
|
taskEXIT_CRITICAL();
|
||||||
bool res = err == SUCCESS;
|
bool res = err == SUCCESS;
|
||||||
if (!res) {
|
if (!res) {
|
||||||
@@ -63,8 +64,10 @@ bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_bu
|
|||||||
i2cCfg.dataSize = number_of_byte;
|
i2cCfg.dataSize = number_of_byte;
|
||||||
i2cCfg.data = p_buffer;
|
i2cCfg.data = p_buffer;
|
||||||
i2cCfg.subAddrSize = 1; // one byte address
|
i2cCfg.subAddrSize = 1; // one byte address
|
||||||
taskENTER_CRITICAL();
|
|
||||||
err = I2C_MasterSendBlocking(I2C0_ID, &i2cCfg);
|
taskENTER_CRITICAL();
|
||||||
|
/* --------------- */
|
||||||
|
err = I2C_MasterSendBlocking(I2C0_ID, &i2cCfg);
|
||||||
taskEXIT_CRITICAL();
|
taskEXIT_CRITICAL();
|
||||||
bool res = err == SUCCESS;
|
bool res = err == SUCCESS;
|
||||||
if (!res) {
|
if (!res) {
|
||||||
|
|||||||
@@ -80,21 +80,20 @@
|
|||||||
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
|
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
|
||||||
|
|
||||||
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 )
|
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 )
|
||||||
#error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
|
#error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Block sizes must not get too small. */
|
/* Block sizes must not get too small. */
|
||||||
#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) )
|
#define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) )
|
||||||
|
|
||||||
/* Assumes 8bit bytes! */
|
/* Assumes 8bit bytes! */
|
||||||
#define heapBITS_PER_BYTE ( ( size_t ) 8 )
|
#define heapBITS_PER_BYTE ( ( size_t ) 8 )
|
||||||
|
|
||||||
/* Define the linked list structure. This is used to link free blocks in order
|
/* Define the linked list structure. This is used to link free blocks in order
|
||||||
* of their memory address. */
|
* of their memory address. */
|
||||||
typedef struct A_BLOCK_LINK
|
typedef struct A_BLOCK_LINK {
|
||||||
{
|
struct A_BLOCK_LINK *pxNextFreeBlock; /*<< The next free block in the list. */
|
||||||
struct A_BLOCK_LINK * pxNextFreeBlock; /*<< The next free block in the list. */
|
size_t xBlockSize; /*<< The size of the free block. */
|
||||||
size_t xBlockSize; /*<< The size of the free block. */
|
|
||||||
} BlockLink_t;
|
} BlockLink_t;
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
@@ -105,7 +104,7 @@ typedef struct A_BLOCK_LINK
|
|||||||
* the block in front it and/or the block behind it if the memory blocks are
|
* the block in front it and/or the block behind it if the memory blocks are
|
||||||
* adjacent to each other.
|
* adjacent to each other.
|
||||||
*/
|
*/
|
||||||
static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert );
|
static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert );
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -114,14 +113,14 @@ static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert );
|
|||||||
static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK );
|
static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK );
|
||||||
|
|
||||||
/* Create a couple of list links to mark the start and end of the list. */
|
/* Create a couple of list links to mark the start and end of the list. */
|
||||||
static BlockLink_t xStart, * pxEnd = NULL;
|
static BlockLink_t xStart, *pxEnd = NULL;
|
||||||
|
|
||||||
/* Keeps track of the number of calls to allocate and free memory as well as the
|
/* Keeps track of the number of calls to allocate and free memory as well as the
|
||||||
* number of free bytes remaining, but says nothing about fragmentation. */
|
* number of free bytes remaining, but says nothing about fragmentation. */
|
||||||
static size_t xFreeBytesRemaining = 0U;
|
static size_t xFreeBytesRemaining = 0U;
|
||||||
static size_t xMinimumEverFreeBytesRemaining = 0U;
|
static size_t xMinimumEverFreeBytesRemaining = 0U;
|
||||||
static size_t xNumberOfSuccessfulAllocations = 0;
|
static size_t xNumberOfSuccessfulAllocations = 0;
|
||||||
static size_t xNumberOfSuccessfulFrees = 0;
|
static size_t xNumberOfSuccessfulFrees = 0;
|
||||||
|
|
||||||
/* Gets set to the top bit of an size_t type. When this bit in the xBlockSize
|
/* Gets set to the top bit of an size_t type. When this bit in the xBlockSize
|
||||||
* member of an BlockLink_t structure is set then the block belongs to the
|
* member of an BlockLink_t structure is set then the block belongs to the
|
||||||
@@ -131,420 +130,354 @@ static size_t xBlockAllocatedBit = 0;
|
|||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void * pvPortMalloc( size_t xWantedSize )
|
void *pvPortMalloc( size_t xWantedSize ) {
|
||||||
{
|
BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
|
||||||
BlockLink_t * pxBlock, * pxPreviousBlock, * pxNewBlockLink;
|
void *pvReturn = NULL;
|
||||||
void * pvReturn = NULL;
|
|
||||||
|
|
||||||
/* The heap must be initialised before the first call to
|
/* The heap must be initialised before the first call to
|
||||||
* prvPortMalloc(). */
|
* prvPortMalloc(). */
|
||||||
configASSERT( pxEnd );
|
configASSERT( pxEnd );
|
||||||
|
|
||||||
vTaskSuspendAll();
|
vTaskSuspendAll();
|
||||||
{
|
{
|
||||||
/* Check the requested block size is not so large that the top bit is
|
/* Check the requested block size is not so large that the top bit is
|
||||||
* set. The top bit of the block size member of the BlockLink_t structure
|
* set. The top bit of the block size member of the BlockLink_t structure
|
||||||
* is used to determine who owns the block - the application or the
|
* is used to determine who owns the block - the application or the
|
||||||
* kernel, so it must be free. */
|
* kernel, so it must be free. */
|
||||||
if( ( xWantedSize & xBlockAllocatedBit ) == 0 )
|
if ( ( xWantedSize & xBlockAllocatedBit ) == 0 ) {
|
||||||
{
|
/* The wanted size is increased so it can contain a BlockLink_t
|
||||||
/* The wanted size is increased so it can contain a BlockLink_t
|
* structure in addition to the requested amount of bytes. */
|
||||||
* structure in addition to the requested amount of bytes. */
|
if ( xWantedSize > 0 ) {
|
||||||
if( xWantedSize > 0 )
|
xWantedSize += xHeapStructSize;
|
||||||
{
|
|
||||||
xWantedSize += xHeapStructSize;
|
|
||||||
|
|
||||||
/* Ensure that blocks are always aligned to the required number
|
/* Ensure that blocks are always aligned to the required number
|
||||||
* of bytes. */
|
* of bytes. */
|
||||||
if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )
|
if ( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) {
|
||||||
{
|
/* Byte alignment required. */
|
||||||
/* Byte alignment required. */
|
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
|
||||||
xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
|
} else {
|
||||||
}
|
mtCOVERAGE_TEST_MARKER();
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )
|
|
||||||
{
|
|
||||||
/* Traverse the list from the start (lowest address) block until
|
|
||||||
* one of adequate size is found. */
|
|
||||||
pxPreviousBlock = &xStart;
|
|
||||||
pxBlock = xStart.pxNextFreeBlock;
|
|
||||||
|
|
||||||
while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) )
|
|
||||||
{
|
|
||||||
pxPreviousBlock = pxBlock;
|
|
||||||
pxBlock = pxBlock->pxNextFreeBlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the end marker was reached then a block of adequate size
|
|
||||||
* was not found. */
|
|
||||||
if( pxBlock != pxEnd )
|
|
||||||
{
|
|
||||||
/* Return the memory space pointed to - jumping over the
|
|
||||||
* BlockLink_t structure at its start. */
|
|
||||||
pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize );
|
|
||||||
|
|
||||||
/* This block is being returned for use so must be taken out
|
|
||||||
* of the list of free blocks. */
|
|
||||||
pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;
|
|
||||||
|
|
||||||
/* If the block is larger than required it can be split into
|
|
||||||
* two. */
|
|
||||||
if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )
|
|
||||||
{
|
|
||||||
/* This block is to be split into two. Create a new
|
|
||||||
* block following the number of bytes requested. The void
|
|
||||||
* cast is used to prevent byte alignment warnings from the
|
|
||||||
* compiler. */
|
|
||||||
pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );
|
|
||||||
|
|
||||||
/* Calculate the sizes of two blocks split from the
|
|
||||||
* single block. */
|
|
||||||
pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;
|
|
||||||
pxBlock->xBlockSize = xWantedSize;
|
|
||||||
|
|
||||||
/* Insert the new block into the list of free blocks. */
|
|
||||||
prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
|
|
||||||
xFreeBytesRemaining -= pxBlock->xBlockSize;
|
|
||||||
|
|
||||||
if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining )
|
|
||||||
{
|
|
||||||
xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The block is being returned - it is allocated and owned
|
|
||||||
* by the application and has no "next" block. */
|
|
||||||
pxBlock->xBlockSize |= xBlockAllocatedBit;
|
|
||||||
pxBlock->pxNextFreeBlock = NULL;
|
|
||||||
xNumberOfSuccessfulAllocations++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
|
|
||||||
traceMALLOC( pvReturn, xWantedSize );
|
|
||||||
}
|
|
||||||
( void ) xTaskResumeAll();
|
|
||||||
|
|
||||||
#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
|
|
||||||
{
|
|
||||||
if( pvReturn == NULL )
|
|
||||||
{
|
|
||||||
extern void vApplicationMallocFailedHook( void );
|
|
||||||
vApplicationMallocFailedHook();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* if ( configUSE_MALLOC_FAILED_HOOK == 1 ) */
|
|
||||||
|
|
||||||
return pvReturn;
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
void vPortFree( void * pv )
|
|
||||||
{
|
|
||||||
uint8_t * puc = ( uint8_t * ) pv;
|
|
||||||
BlockLink_t * pxLink;
|
|
||||||
|
|
||||||
if( pv != NULL )
|
|
||||||
{
|
|
||||||
/* The memory being freed will have an BlockLink_t structure immediately
|
|
||||||
* before it. */
|
|
||||||
puc -= xHeapStructSize;
|
|
||||||
|
|
||||||
/* This casting is to keep the compiler from issuing warnings. */
|
|
||||||
pxLink = ( void * ) puc;
|
|
||||||
|
|
||||||
/* Check the block is actually allocated. */
|
|
||||||
configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );
|
|
||||||
configASSERT( pxLink->pxNextFreeBlock == NULL );
|
|
||||||
|
|
||||||
if( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 )
|
|
||||||
{
|
|
||||||
if( pxLink->pxNextFreeBlock == NULL )
|
|
||||||
{
|
|
||||||
/* The block is being returned to the heap - it is no longer
|
|
||||||
* allocated. */
|
|
||||||
pxLink->xBlockSize &= ~xBlockAllocatedBit;
|
|
||||||
|
|
||||||
vTaskSuspendAll();
|
|
||||||
{
|
|
||||||
/* Add this block to the list of free blocks. */
|
|
||||||
xFreeBytesRemaining += pxLink->xBlockSize;
|
|
||||||
traceFREE( pv, pxLink->xBlockSize );
|
|
||||||
prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) );
|
|
||||||
xNumberOfSuccessfulFrees++;
|
|
||||||
}
|
|
||||||
( void ) xTaskResumeAll();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
size_t xPortGetFreeHeapSize( void )
|
|
||||||
{
|
|
||||||
return xFreeBytesRemaining;
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
size_t xPortGetMinimumEverFreeHeapSize( void )
|
|
||||||
{
|
|
||||||
return xMinimumEverFreeBytesRemaining;
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert )
|
|
||||||
{
|
|
||||||
BlockLink_t * pxIterator;
|
|
||||||
uint8_t * puc;
|
|
||||||
|
|
||||||
/* Iterate through the list until a block is found that has a higher address
|
|
||||||
* than the block being inserted. */
|
|
||||||
for( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock )
|
|
||||||
{
|
|
||||||
/* Nothing to do here, just iterate to the right position. */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Do the block being inserted, and the block it is being inserted after
|
|
||||||
* make a contiguous block of memory? */
|
|
||||||
puc = ( uint8_t * ) pxIterator;
|
|
||||||
|
|
||||||
if( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert )
|
|
||||||
{
|
|
||||||
pxIterator->xBlockSize += pxBlockToInsert->xBlockSize;
|
|
||||||
pxBlockToInsert = pxIterator;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mtCOVERAGE_TEST_MARKER();
|
mtCOVERAGE_TEST_MARKER();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do the block being inserted, and the block it is being inserted before
|
if ( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) {
|
||||||
* make a contiguous block of memory? */
|
/* Traverse the list from the start (lowest address) block until
|
||||||
puc = ( uint8_t * ) pxBlockToInsert;
|
* one of adequate size is found. */
|
||||||
|
pxPreviousBlock = &xStart;
|
||||||
|
pxBlock = xStart.pxNextFreeBlock;
|
||||||
|
|
||||||
if( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock )
|
while ( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ) ) {
|
||||||
{
|
pxPreviousBlock = pxBlock;
|
||||||
if( pxIterator->pxNextFreeBlock != pxEnd )
|
pxBlock = pxBlock->pxNextFreeBlock;
|
||||||
{
|
|
||||||
/* Form one big block from the two blocks. */
|
|
||||||
pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize;
|
|
||||||
pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
pxBlockToInsert->pxNextFreeBlock = pxEnd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the block being inserted plugged a gab, so was merged with the block
|
/* If the end marker was reached then a block of adequate size
|
||||||
* before and the block after, then it's pxNextFreeBlock pointer will have
|
* was not found. */
|
||||||
* already been set, and should not be set here as that would make it point
|
if ( pxBlock != pxEnd ) {
|
||||||
* to itself. */
|
/* Return the memory space pointed to - jumping over the
|
||||||
if( pxIterator != pxBlockToInsert )
|
* BlockLink_t structure at its start. */
|
||||||
{
|
pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock->pxNextFreeBlock ) + xHeapStructSize );
|
||||||
pxIterator->pxNextFreeBlock = pxBlockToInsert;
|
|
||||||
}
|
/* This block is being returned for use so must be taken out
|
||||||
else
|
* of the list of free blocks. */
|
||||||
{
|
pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;
|
||||||
|
|
||||||
|
/* If the block is larger than required it can be split into
|
||||||
|
* two. */
|
||||||
|
if ( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) {
|
||||||
|
/* This block is to be split into two. Create a new
|
||||||
|
* block following the number of bytes requested. The void
|
||||||
|
* cast is used to prevent byte alignment warnings from the
|
||||||
|
* compiler. */
|
||||||
|
pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );
|
||||||
|
|
||||||
|
/* Calculate the sizes of two blocks split from the
|
||||||
|
* single block. */
|
||||||
|
pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;
|
||||||
|
pxBlock->xBlockSize = xWantedSize;
|
||||||
|
|
||||||
|
/* Insert the new block into the list of free blocks. */
|
||||||
|
prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );
|
||||||
|
} else {
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
|
||||||
|
xFreeBytesRemaining -= pxBlock->xBlockSize;
|
||||||
|
|
||||||
|
if ( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) {
|
||||||
|
xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;
|
||||||
|
} else {
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The block is being returned - it is allocated and owned
|
||||||
|
* by the application and has no "next" block. */
|
||||||
|
pxBlock->xBlockSize |= xBlockAllocatedBit;
|
||||||
|
pxBlock->pxNextFreeBlock = NULL;
|
||||||
|
xNumberOfSuccessfulAllocations++;
|
||||||
|
} else {
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
mtCOVERAGE_TEST_MARKER();
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
traceMALLOC( pvReturn, xWantedSize );
|
||||||
|
}
|
||||||
|
( void ) xTaskResumeAll();
|
||||||
|
|
||||||
|
#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
|
||||||
|
{
|
||||||
|
if ( pvReturn == NULL ) {
|
||||||
|
extern void vApplicationMallocFailedHook( void );
|
||||||
|
vApplicationMallocFailedHook();
|
||||||
|
} else {
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* if ( configUSE_MALLOC_FAILED_HOOK == 1 ) */
|
||||||
|
|
||||||
|
return pvReturn;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions )
|
void vPortFree( void *pv ) {
|
||||||
{
|
uint8_t *puc = ( uint8_t * ) pv;
|
||||||
BlockLink_t * pxFirstFreeBlockInRegion = NULL, * pxPreviousFreeBlock;
|
BlockLink_t *pxLink;
|
||||||
size_t xAlignedHeap;
|
|
||||||
size_t xTotalRegionSize, xTotalHeapSize = 0;
|
|
||||||
BaseType_t xDefinedRegions = 0;
|
|
||||||
size_t xAddress;
|
|
||||||
const HeapRegion_t * pxHeapRegion;
|
|
||||||
|
|
||||||
/* Can only call once! */
|
if ( pv != NULL ) {
|
||||||
configASSERT( pxEnd == NULL );
|
/* The memory being freed will have an BlockLink_t structure immediately
|
||||||
|
* before it. */
|
||||||
|
puc -= xHeapStructSize;
|
||||||
|
|
||||||
|
/* This casting is to keep the compiler from issuing warnings. */
|
||||||
|
pxLink = ( void * ) puc;
|
||||||
|
|
||||||
|
/* Check the block is actually allocated. */
|
||||||
|
configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );
|
||||||
|
configASSERT( pxLink->pxNextFreeBlock == NULL );
|
||||||
|
|
||||||
|
if ( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 ) {
|
||||||
|
if ( pxLink->pxNextFreeBlock == NULL ) {
|
||||||
|
/* The block is being returned to the heap - it is no longer
|
||||||
|
* allocated. */
|
||||||
|
pxLink->xBlockSize &= ~xBlockAllocatedBit;
|
||||||
|
|
||||||
|
vTaskSuspendAll();
|
||||||
|
{
|
||||||
|
/* Add this block to the list of free blocks. */
|
||||||
|
xFreeBytesRemaining += pxLink->xBlockSize;
|
||||||
|
traceFREE( pv, pxLink->xBlockSize );
|
||||||
|
prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) );
|
||||||
|
xNumberOfSuccessfulFrees++;
|
||||||
|
}
|
||||||
|
( void ) xTaskResumeAll();
|
||||||
|
} else {
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
size_t xPortGetFreeHeapSize( void ) { return xFreeBytesRemaining; }
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
size_t xPortGetMinimumEverFreeHeapSize( void ) { return xMinimumEverFreeBytesRemaining; }
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert ) {
|
||||||
|
BlockLink_t *pxIterator;
|
||||||
|
uint8_t *puc;
|
||||||
|
|
||||||
|
/* Iterate through the list until a block is found that has a higher address
|
||||||
|
* than the block being inserted. */
|
||||||
|
for ( pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock ) {
|
||||||
|
/* Nothing to do here, just iterate to the right position. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do the block being inserted, and the block it is being inserted after
|
||||||
|
* make a contiguous block of memory? */
|
||||||
|
puc = ( uint8_t * ) pxIterator;
|
||||||
|
|
||||||
|
if ( ( puc + pxIterator->xBlockSize ) == ( uint8_t * ) pxBlockToInsert ) {
|
||||||
|
pxIterator->xBlockSize += pxBlockToInsert->xBlockSize;
|
||||||
|
pxBlockToInsert = pxIterator;
|
||||||
|
} else {
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do the block being inserted, and the block it is being inserted before
|
||||||
|
* make a contiguous block of memory? */
|
||||||
|
puc = ( uint8_t * ) pxBlockToInsert;
|
||||||
|
|
||||||
|
if ( ( puc + pxBlockToInsert->xBlockSize ) == ( uint8_t * ) pxIterator->pxNextFreeBlock ) {
|
||||||
|
if ( pxIterator->pxNextFreeBlock != pxEnd ) {
|
||||||
|
/* Form one big block from the two blocks. */
|
||||||
|
pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize;
|
||||||
|
pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock;
|
||||||
|
} else {
|
||||||
|
pxBlockToInsert->pxNextFreeBlock = pxEnd;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the block being inserted plugged a gab, so was merged with the block
|
||||||
|
* before and the block after, then it's pxNextFreeBlock pointer will have
|
||||||
|
* already been set, and should not be set here as that would make it point
|
||||||
|
* to itself. */
|
||||||
|
if ( pxIterator != pxBlockToInsert ) {
|
||||||
|
pxIterator->pxNextFreeBlock = pxBlockToInsert;
|
||||||
|
} else {
|
||||||
|
mtCOVERAGE_TEST_MARKER();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) {
|
||||||
|
BlockLink_t *pxFirstFreeBlockInRegion = NULL, *pxPreviousFreeBlock;
|
||||||
|
size_t xAlignedHeap;
|
||||||
|
size_t xTotalRegionSize, xTotalHeapSize = 0;
|
||||||
|
BaseType_t xDefinedRegions = 0;
|
||||||
|
size_t xAddress;
|
||||||
|
const HeapRegion_t *pxHeapRegion;
|
||||||
|
|
||||||
|
/* Can only call once! */
|
||||||
|
configASSERT( pxEnd == NULL );
|
||||||
|
|
||||||
|
pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );
|
||||||
|
|
||||||
|
while ( pxHeapRegion->xSizeInBytes > 0 ) {
|
||||||
|
xTotalRegionSize = pxHeapRegion->xSizeInBytes;
|
||||||
|
|
||||||
|
/* Ensure the heap region starts on a correctly aligned boundary. */
|
||||||
|
xAddress = ( size_t ) pxHeapRegion->pucStartAddress;
|
||||||
|
|
||||||
|
if ( ( xAddress & portBYTE_ALIGNMENT_MASK ) != 0 ) {
|
||||||
|
xAddress += ( portBYTE_ALIGNMENT - 1 );
|
||||||
|
xAddress &= ~portBYTE_ALIGNMENT_MASK;
|
||||||
|
|
||||||
|
/* Adjust the size for the bytes lost to alignment. */
|
||||||
|
xTotalRegionSize -= xAddress - ( size_t ) pxHeapRegion->pucStartAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
xAlignedHeap = xAddress;
|
||||||
|
|
||||||
|
/* Set xStart if it has not already been set. */
|
||||||
|
if ( xDefinedRegions == 0 ) {
|
||||||
|
/* xStart is used to hold a pointer to the first item in the list of
|
||||||
|
* free blocks. The void cast is used to prevent compiler warnings. */
|
||||||
|
xStart.pxNextFreeBlock = ( BlockLink_t * ) xAlignedHeap;
|
||||||
|
xStart.xBlockSize = ( size_t ) 0;
|
||||||
|
} else {
|
||||||
|
/* Should only get here if one region has already been added to the
|
||||||
|
* heap. */
|
||||||
|
configASSERT( pxEnd != NULL );
|
||||||
|
|
||||||
|
/* Check blocks are passed in with increasing start addresses. */
|
||||||
|
configASSERT( xAddress > ( size_t ) pxEnd );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remember the location of the end marker in the previous region, if
|
||||||
|
* any. */
|
||||||
|
pxPreviousFreeBlock = pxEnd;
|
||||||
|
|
||||||
|
/* pxEnd is used to mark the end of the list of free blocks and is
|
||||||
|
* inserted at the end of the region space. */
|
||||||
|
xAddress = xAlignedHeap + xTotalRegionSize;
|
||||||
|
xAddress -= xHeapStructSize;
|
||||||
|
xAddress &= ~portBYTE_ALIGNMENT_MASK;
|
||||||
|
|
||||||
|
pxEnd = ( BlockLink_t * ) xAddress;
|
||||||
|
pxEnd->xBlockSize = 0;
|
||||||
|
pxEnd->pxNextFreeBlock = NULL;
|
||||||
|
|
||||||
|
/* To start with there is a single free block in this region that is
|
||||||
|
* sized to take up the entire heap region minus the space taken by the
|
||||||
|
* free block structure. */
|
||||||
|
pxFirstFreeBlockInRegion = ( BlockLink_t * ) xAlignedHeap;
|
||||||
|
pxFirstFreeBlockInRegion->xBlockSize = xAddress - ( size_t ) pxFirstFreeBlockInRegion;
|
||||||
|
pxFirstFreeBlockInRegion->pxNextFreeBlock = pxEnd;
|
||||||
|
|
||||||
|
/* If this is not the first region that makes up the entire heap space
|
||||||
|
* then link the previous region to this region. */
|
||||||
|
if ( pxPreviousFreeBlock != NULL ) {
|
||||||
|
pxPreviousFreeBlock->pxNextFreeBlock = pxFirstFreeBlockInRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
xTotalHeapSize += pxFirstFreeBlockInRegion->xBlockSize;
|
||||||
|
|
||||||
|
/* Move onto the next HeapRegion_t structure. */
|
||||||
|
xDefinedRegions++;
|
||||||
pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );
|
pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );
|
||||||
|
}
|
||||||
|
|
||||||
while( pxHeapRegion->xSizeInBytes > 0 )
|
xMinimumEverFreeBytesRemaining = xTotalHeapSize;
|
||||||
{
|
xFreeBytesRemaining = xTotalHeapSize;
|
||||||
xTotalRegionSize = pxHeapRegion->xSizeInBytes;
|
|
||||||
|
|
||||||
/* Ensure the heap region starts on a correctly aligned boundary. */
|
/* Check something was actually defined before it is accessed. */
|
||||||
xAddress = ( size_t ) pxHeapRegion->pucStartAddress;
|
configASSERT( xTotalHeapSize );
|
||||||
|
|
||||||
if( ( xAddress & portBYTE_ALIGNMENT_MASK ) != 0 )
|
/* Work out the position of the top bit in a size_t variable. */
|
||||||
{
|
xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 );
|
||||||
xAddress += ( portBYTE_ALIGNMENT - 1 );
|
|
||||||
xAddress &= ~portBYTE_ALIGNMENT_MASK;
|
|
||||||
|
|
||||||
/* Adjust the size for the bytes lost to alignment. */
|
|
||||||
xTotalRegionSize -= xAddress - ( size_t ) pxHeapRegion->pucStartAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
xAlignedHeap = xAddress;
|
|
||||||
|
|
||||||
/* Set xStart if it has not already been set. */
|
|
||||||
if( xDefinedRegions == 0 )
|
|
||||||
{
|
|
||||||
/* xStart is used to hold a pointer to the first item in the list of
|
|
||||||
* free blocks. The void cast is used to prevent compiler warnings. */
|
|
||||||
xStart.pxNextFreeBlock = ( BlockLink_t * ) xAlignedHeap;
|
|
||||||
xStart.xBlockSize = ( size_t ) 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Should only get here if one region has already been added to the
|
|
||||||
* heap. */
|
|
||||||
configASSERT( pxEnd != NULL );
|
|
||||||
|
|
||||||
/* Check blocks are passed in with increasing start addresses. */
|
|
||||||
configASSERT( xAddress > ( size_t ) pxEnd );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remember the location of the end marker in the previous region, if
|
|
||||||
* any. */
|
|
||||||
pxPreviousFreeBlock = pxEnd;
|
|
||||||
|
|
||||||
/* pxEnd is used to mark the end of the list of free blocks and is
|
|
||||||
* inserted at the end of the region space. */
|
|
||||||
xAddress = xAlignedHeap + xTotalRegionSize;
|
|
||||||
xAddress -= xHeapStructSize;
|
|
||||||
xAddress &= ~portBYTE_ALIGNMENT_MASK;
|
|
||||||
pxEnd = ( BlockLink_t * ) xAddress;
|
|
||||||
pxEnd->xBlockSize = 0;
|
|
||||||
pxEnd->pxNextFreeBlock = NULL;
|
|
||||||
|
|
||||||
/* To start with there is a single free block in this region that is
|
|
||||||
* sized to take up the entire heap region minus the space taken by the
|
|
||||||
* free block structure. */
|
|
||||||
pxFirstFreeBlockInRegion = ( BlockLink_t * ) xAlignedHeap;
|
|
||||||
pxFirstFreeBlockInRegion->xBlockSize = xAddress - ( size_t ) pxFirstFreeBlockInRegion;
|
|
||||||
pxFirstFreeBlockInRegion->pxNextFreeBlock = pxEnd;
|
|
||||||
|
|
||||||
/* If this is not the first region that makes up the entire heap space
|
|
||||||
* then link the previous region to this region. */
|
|
||||||
if( pxPreviousFreeBlock != NULL )
|
|
||||||
{
|
|
||||||
pxPreviousFreeBlock->pxNextFreeBlock = pxFirstFreeBlockInRegion;
|
|
||||||
}
|
|
||||||
|
|
||||||
xTotalHeapSize += pxFirstFreeBlockInRegion->xBlockSize;
|
|
||||||
|
|
||||||
/* Move onto the next HeapRegion_t structure. */
|
|
||||||
xDefinedRegions++;
|
|
||||||
pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
xMinimumEverFreeBytesRemaining = xTotalHeapSize;
|
|
||||||
xFreeBytesRemaining = xTotalHeapSize;
|
|
||||||
|
|
||||||
/* Check something was actually defined before it is accessed. */
|
|
||||||
configASSERT( xTotalHeapSize );
|
|
||||||
|
|
||||||
/* Work out the position of the top bit in a size_t variable. */
|
|
||||||
xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 );
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortGetHeapStats( HeapStats_t * pxHeapStats )
|
void vPortGetHeapStats( HeapStats_t *pxHeapStats ) {
|
||||||
{
|
BlockLink_t *pxBlock;
|
||||||
BlockLink_t * pxBlock;
|
size_t xBlocks = 0, xMaxSize = 0, xMinSize = portMAX_DELAY; /* portMAX_DELAY used as a portable way of getting the maximum value. */
|
||||||
size_t xBlocks = 0, xMaxSize = 0, xMinSize = portMAX_DELAY; /* portMAX_DELAY used as a portable way of getting the maximum value. */
|
|
||||||
|
|
||||||
vTaskSuspendAll();
|
vTaskSuspendAll();
|
||||||
{
|
{
|
||||||
pxBlock = xStart.pxNextFreeBlock;
|
pxBlock = xStart.pxNextFreeBlock;
|
||||||
|
|
||||||
/* pxBlock will be NULL if the heap has not been initialised. The heap
|
/* pxBlock will be NULL if the heap has not been initialised. The heap
|
||||||
* is initialised automatically when the first allocation is made. */
|
* is initialised automatically when the first allocation is made. */
|
||||||
if( pxBlock != NULL )
|
if ( pxBlock != NULL ) {
|
||||||
{
|
do {
|
||||||
do
|
/* Increment the number of blocks and record the largest block seen
|
||||||
{
|
* so far. */
|
||||||
/* Increment the number of blocks and record the largest block seen
|
xBlocks++;
|
||||||
* so far. */
|
|
||||||
xBlocks++;
|
|
||||||
|
|
||||||
if( pxBlock->xBlockSize > xMaxSize )
|
if ( pxBlock->xBlockSize > xMaxSize ) {
|
||||||
{
|
xMaxSize = pxBlock->xBlockSize;
|
||||||
xMaxSize = pxBlock->xBlockSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Heap five will have a zero sized block at the end of each
|
|
||||||
* each region - the block is only used to link to the next
|
|
||||||
* heap region so it not a real block. */
|
|
||||||
if( pxBlock->xBlockSize != 0 )
|
|
||||||
{
|
|
||||||
if( pxBlock->xBlockSize < xMinSize )
|
|
||||||
{
|
|
||||||
xMinSize = pxBlock->xBlockSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Move to the next block in the chain until the last block is
|
|
||||||
* reached. */
|
|
||||||
pxBlock = pxBlock->pxNextFreeBlock;
|
|
||||||
} while( pxBlock != pxEnd );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
( void ) xTaskResumeAll();
|
|
||||||
|
|
||||||
pxHeapStats->xSizeOfLargestFreeBlockInBytes = xMaxSize;
|
/* Heap five will have a zero sized block at the end of each
|
||||||
pxHeapStats->xSizeOfSmallestFreeBlockInBytes = xMinSize;
|
* each region - the block is only used to link to the next
|
||||||
pxHeapStats->xNumberOfFreeBlocks = xBlocks;
|
* heap region so it not a real block. */
|
||||||
|
if ( pxBlock->xBlockSize != 0 ) {
|
||||||
|
if ( pxBlock->xBlockSize < xMinSize ) {
|
||||||
|
xMinSize = pxBlock->xBlockSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
taskENTER_CRITICAL();
|
/* Move to the next block in the chain until the last block is
|
||||||
{
|
* reached. */
|
||||||
pxHeapStats->xAvailableHeapSpaceInBytes = xFreeBytesRemaining;
|
pxBlock = pxBlock->pxNextFreeBlock;
|
||||||
pxHeapStats->xNumberOfSuccessfulAllocations = xNumberOfSuccessfulAllocations;
|
} while ( pxBlock != pxEnd );
|
||||||
pxHeapStats->xNumberOfSuccessfulFrees = xNumberOfSuccessfulFrees;
|
|
||||||
pxHeapStats->xMinimumEverFreeBytesRemaining = xMinimumEverFreeBytesRemaining;
|
|
||||||
}
|
}
|
||||||
taskEXIT_CRITICAL();
|
}
|
||||||
|
( void ) xTaskResumeAll();
|
||||||
|
|
||||||
|
pxHeapStats->xSizeOfLargestFreeBlockInBytes = xMaxSize;
|
||||||
|
pxHeapStats->xSizeOfSmallestFreeBlockInBytes = xMinSize;
|
||||||
|
pxHeapStats->xNumberOfFreeBlocks = xBlocks;
|
||||||
|
|
||||||
|
taskENTER_CRITICAL();
|
||||||
|
{
|
||||||
|
pxHeapStats->xAvailableHeapSpaceInBytes = xFreeBytesRemaining;
|
||||||
|
pxHeapStats->xNumberOfSuccessfulAllocations = xNumberOfSuccessfulAllocations;
|
||||||
|
pxHeapStats->xNumberOfSuccessfulFrees = xNumberOfSuccessfulFrees;
|
||||||
|
pxHeapStats->xMinimumEverFreeBytesRemaining = xMinimumEverFreeBytesRemaining;
|
||||||
|
}
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,70 +1,61 @@
|
|||||||
#include <errno.h>
|
#include "ble.h"
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <FreeRTOS.h>
|
|
||||||
#include "bflb_platform.h"
|
|
||||||
#include <task.h>
|
|
||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
|
#include "bflb_platform.h"
|
||||||
|
#include "bl702_glb.h"
|
||||||
|
#include "ble_characteristics.h"
|
||||||
|
#include "ble_peripheral.h"
|
||||||
#include "bluetooth.h"
|
#include "bluetooth.h"
|
||||||
#include "conn.h"
|
#include "conn.h"
|
||||||
#include "gatt.h"
|
#include "gatt.h"
|
||||||
#include "hci_core.h"
|
|
||||||
#include "uuid.h"
|
|
||||||
#include "ble_peripheral.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "bl702_glb.h"
|
|
||||||
#include "ble_characteristics.h"
|
|
||||||
#include "hal_clock.h"
|
#include "hal_clock.h"
|
||||||
#include "ble.h"
|
#include "hci_core.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "uuid.h"
|
||||||
|
#include <FreeRTOS.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <task.h>
|
||||||
|
|
||||||
|
void ble_stack_start(void) {
|
||||||
|
MSG("BLE Starting\n");
|
||||||
|
GLB_Set_EM_Sel(GLB_EM_8KB);
|
||||||
|
ble_controller_init(configMAX_PRIORITIES - 1);
|
||||||
|
|
||||||
|
// Initialize BLE Host stack
|
||||||
|
hci_driver_init();
|
||||||
|
|
||||||
|
bt_enable(bt_enable_cb);
|
||||||
void ble_stack_start(void)
|
MSG("BLE Starting...Done\n");
|
||||||
{
|
|
||||||
MSG("BLE Starting\n");
|
|
||||||
GLB_Set_EM_Sel(GLB_EM_8KB);
|
|
||||||
ble_controller_init(configMAX_PRIORITIES - 1);
|
|
||||||
|
|
||||||
// // Initialize BLE Host stack
|
|
||||||
hci_driver_init();
|
|
||||||
|
|
||||||
bt_enable(bt_enable_cb);
|
|
||||||
MSG("BLE Starting...Done\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
|
/* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
|
||||||
application must provide an implementation of vApplicationGetTimerTaskMemory()
|
application must provide an implementation of vApplicationGetTimerTaskMemory()
|
||||||
to provide the memory that is used by the Timer service task. */
|
to provide the memory that is used by the Timer service task. */
|
||||||
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize)
|
void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize) {
|
||||||
{
|
/* If the buffers to be provided to the Timer task are declared inside this
|
||||||
/* If the buffers to be provided to the Timer task are declared inside this
|
function then they must be declared static - otherwise they will be allocated on
|
||||||
function then they must be declared static - otherwise they will be allocated on
|
the stack and so not exists after this function exits. */
|
||||||
the stack and so not exists after this function exits. */
|
static StaticTask_t xTimerTaskTCB;
|
||||||
static StaticTask_t xTimerTaskTCB;
|
static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];
|
||||||
static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];
|
|
||||||
|
|
||||||
/* Pass out a pointer to the StaticTask_t structure in which the Timer
|
/* Pass out a pointer to the StaticTask_t structure in which the Timer
|
||||||
task's state will be stored. */
|
task's state will be stored. */
|
||||||
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
|
||||||
|
|
||||||
/* Pass out the array that will be used as the Timer task's stack. */
|
/* Pass out the array that will be used as the Timer task's stack. */
|
||||||
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
|
||||||
|
|
||||||
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
|
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
|
||||||
Note that, as the array is necessarily of type StackType_t,
|
Note that, as the array is necessarily of type StackType_t,
|
||||||
configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
|
configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
|
||||||
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vApplicationMallocFailedHook(void) {
|
||||||
|
MSG("vApplicationMallocFailedHook\r\n");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
void vApplicationMallocFailedHook(void)
|
;
|
||||||
{
|
}
|
||||||
MSG("vApplicationMallocFailedHook\r\n");
|
}
|
||||||
|
|
||||||
while (1)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -113,8 +113,9 @@ int ble_char_read_status_callback(struct bt_conn *conn, const struct bt_gatt_att
|
|||||||
// hall sensor
|
// hall sensor
|
||||||
{
|
{
|
||||||
int16_t hallEffectStrength = getRawHallEffect();
|
int16_t hallEffectStrength = getRawHallEffect();
|
||||||
if (hallEffectStrength < 0)
|
if (hallEffectStrength < 0) {
|
||||||
hallEffectStrength = -hallEffectStrength;
|
hallEffectStrength = -hallEffectStrength;
|
||||||
|
}
|
||||||
temp = hallEffectStrength;
|
temp = hallEffectStrength;
|
||||||
memcpy(buf, &temp, sizeof(temp));
|
memcpy(buf, &temp, sizeof(temp));
|
||||||
return sizeof(temp);
|
return sizeof(temp);
|
||||||
|
|||||||
@@ -258,7 +258,9 @@ static struct bt_gatt_attr ble_attrs_declaration[] = {
|
|||||||
NAME
|
NAME
|
||||||
get_attr
|
get_attr
|
||||||
*/
|
*/
|
||||||
struct bt_gatt_attr *get_attr(u8_t index) { return &ble_attrs_declaration[index]; }
|
struct bt_gatt_attr *get_attr(u8_t index) {
|
||||||
|
return &ble_attrs_declaration[index];
|
||||||
|
}
|
||||||
|
|
||||||
static struct bt_gatt_service ble_tp_server = BT_GATT_SERVICE(ble_attrs_declaration);
|
static struct bt_gatt_service ble_tp_server = BT_GATT_SERVICE(ble_attrs_declaration);
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ NOTES
|
|||||||
#ifndef _BLE_TP_SVC_H_
|
#ifndef _BLE_TP_SVC_H_
|
||||||
#define _BLE_TP_SVC_H_
|
#define _BLE_TP_SVC_H_
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
#include "ble_config.h"
|
#include "ble_config.h"
|
||||||
|
|
||||||
// read value handle offset 2
|
// read value handle offset 2
|
||||||
|
|||||||
@@ -206,8 +206,9 @@ static void MX_ADC1_Init(void) {
|
|||||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||||
SET_BIT(hadc1.Instance->CR1, (ADC_CR1_JEOCIE)); // Enable end of injected conv irq
|
SET_BIT(hadc1.Instance->CR1, (ADC_CR1_JEOCIE)); // Enable end of injected conv irq
|
||||||
// Run ADC internal calibration
|
// Run ADC internal calibration
|
||||||
while (HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK)
|
while (HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK) {
|
||||||
;
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ADC2 init function */
|
/* ADC2 init function */
|
||||||
@@ -244,8 +245,9 @@ static void MX_ADC2_Init(void) {
|
|||||||
HAL_ADCEx_InjectedConfigChannel(&hadc2, &sConfigInjected);
|
HAL_ADCEx_InjectedConfigChannel(&hadc2, &sConfigInjected);
|
||||||
|
|
||||||
// Run ADC internal calibration
|
// Run ADC internal calibration
|
||||||
while (HAL_ADCEx_Calibration_Start(&hadc2) != HAL_OK)
|
while (HAL_ADCEx_Calibration_Start(&hadc2) != HAL_OK) {
|
||||||
;
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* I2C1 init function */
|
/* I2C1 init function */
|
||||||
static void MX_I2C1_Init(void) {
|
static void MX_I2C1_Init(void) {
|
||||||
|
|||||||
@@ -30,10 +30,9 @@ void flash_save_buffer(const uint8_t *buffer, const uint16_t length) {
|
|||||||
HAL_FLASH_Unlock();
|
HAL_FLASH_Unlock();
|
||||||
for (uint16_t i = 0; i < (length / 2); i++) {
|
for (uint16_t i = 0; i < (length / 2); i++) {
|
||||||
resetWatchdog();
|
resetWatchdog();
|
||||||
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, SETTINGS_START_PAGE+ (i*sizeof(uint16_t)), data[i]);
|
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, SETTINGS_START_PAGE + (i * sizeof(uint16_t)), data[i]);
|
||||||
}
|
}
|
||||||
HAL_FLASH_Lock();
|
HAL_FLASH_Lock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void flash_read_buffer(uint8_t *buffer, const uint16_t length) { memcpy(buffer, (uint8_t*)SETTINGS_START_PAGE, length); }
|
void flash_read_buffer(uint8_t *buffer, const uint16_t length) { memcpy(buffer, (uint8_t *)SETTINGS_START_PAGE, length); }
|
||||||
|
|||||||
@@ -208,40 +208,38 @@ static void prvTaskExitError(void) {
|
|||||||
// therefore not output an 'unreachable code' warning for code that appears
|
// therefore not output an 'unreachable code' warning for code that appears
|
||||||
// after it. */
|
// after it. */
|
||||||
// }
|
// }
|
||||||
for(;;){
|
for (;;) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortSVCHandler(void) {
|
void vPortSVCHandler(void) {
|
||||||
__asm volatile(" ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */
|
__asm volatile(" ldr r3, pxCurrentTCBConst2 \n" /* Restore the context. */
|
||||||
" ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */
|
" ldr r1, [r3] \n" /* Use pxCurrentTCBConst to get the pxCurrentTCB address. */
|
||||||
" ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */
|
" ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. */
|
||||||
" ldmia r0!, {r4-r11} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */
|
" ldmia r0!, {r4-r11} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */
|
||||||
" msr psp, r0 \n" /* Restore the task stack pointer. */
|
" msr psp, r0 \n" /* Restore the task stack pointer. */
|
||||||
" isb \n"
|
" isb \n"
|
||||||
" mov r0, #0 \n"
|
" mov r0, #0 \n"
|
||||||
" msr basepri, r0 \n"
|
" msr basepri, r0 \n"
|
||||||
" orr r14, #0xd \n"
|
" orr r14, #0xd \n"
|
||||||
" bx r14 \n"
|
" bx r14 \n"
|
||||||
" \n"
|
" \n"
|
||||||
" .align 4 \n"
|
" .align 4 \n"
|
||||||
"pxCurrentTCBConst2: .word pxCurrentTCB \n");
|
"pxCurrentTCBConst2: .word pxCurrentTCB \n");
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvPortStartFirstTask(void) {
|
static void prvPortStartFirstTask(void) {
|
||||||
__asm volatile(" ldr r0, =0xE000ED08 \n" /* Use the NVIC offset register to locate the stack. */
|
__asm volatile(" ldr r0, =0xE000ED08 \n" /* Use the NVIC offset register to locate the stack. */
|
||||||
" ldr r0, [r0] \n"
|
" ldr r0, [r0] \n"
|
||||||
" ldr r0, [r0] \n"
|
" ldr r0, [r0] \n"
|
||||||
" msr msp, r0 \n" /* Set the msp back to the start of the stack. */
|
" msr msp, r0 \n" /* Set the msp back to the start of the stack. */
|
||||||
" cpsie i \n" /* Globally enable interrupts. */
|
" cpsie i \n" /* Globally enable interrupts. */
|
||||||
" cpsie f \n"
|
" cpsie f \n"
|
||||||
" dsb \n"
|
" dsb \n"
|
||||||
" isb \n"
|
" isb \n"
|
||||||
" svc 0 \n" /* System call to start first task. */
|
" svc 0 \n" /* System call to start first task. */
|
||||||
" nop \n");
|
" nop \n");
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackTyp
|
|||||||
/* place for user code */
|
/* place for user code */
|
||||||
}
|
}
|
||||||
|
|
||||||
void vApplicationStackOverflowHook( TaskHandle_t xTask,
|
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) {
|
||||||
char * pcTaskName ) {
|
|
||||||
(void)xTask;
|
(void)xTask;
|
||||||
(void)pcTaskName;
|
(void)pcTaskName;
|
||||||
|
|
||||||
|
|||||||
@@ -11,29 +11,34 @@
|
|||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
|
|
||||||
enum QCState {
|
enum QCState {
|
||||||
NOT_STARTED = 0, // Have not checked
|
NOT_STARTED = 0, // Have not checked
|
||||||
QC_3 = 1,
|
QC_3 = 1,
|
||||||
QC_2 = 2,
|
QC_2 = 2,
|
||||||
NO_QC = 3,
|
NO_QC = 3,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void QC_Seek9V() {
|
void QC_Seek9V() {
|
||||||
QC_DNegZero_Six();
|
QC_DNegZero_Six();
|
||||||
QC_DPlusThree_Three();
|
QC_DPlusThree_Three();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QC_Seek12V() {
|
void QC_Seek12V() {
|
||||||
QC_DNegZero_Six();
|
QC_DNegZero_Six();
|
||||||
QC_DPlusZero_Six();
|
QC_DPlusZero_Six();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QC_Seek20V() {
|
void QC_Seek20V() {
|
||||||
QC_DNegThree_Three();
|
QC_DNegThree_Three();
|
||||||
QC_DPlusThree_Three();
|
QC_DPlusThree_Three();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QC_SeekContMode() {
|
void QC_SeekContMode() {
|
||||||
QC_DNegThree_Three();
|
QC_DNegThree_Three();
|
||||||
QC_DPlusZero_Six();
|
QC_DPlusZero_Six();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QC_SeekContPlus() {
|
void QC_SeekContPlus() {
|
||||||
QC_SeekContMode();
|
QC_SeekContMode();
|
||||||
osDelay(30);
|
osDelay(30);
|
||||||
@@ -41,6 +46,7 @@ void QC_SeekContPlus() {
|
|||||||
osDelay(10);
|
osDelay(10);
|
||||||
QC_SeekContMode();
|
QC_SeekContMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QC_SeekContNeg() {
|
void QC_SeekContNeg() {
|
||||||
QC_SeekContMode();
|
QC_SeekContMode();
|
||||||
osDelay(30);
|
osDelay(30);
|
||||||
@@ -48,17 +54,21 @@ void QC_SeekContNeg() {
|
|||||||
osDelay(10);
|
osDelay(10);
|
||||||
QC_SeekContMode();
|
QC_SeekContMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
QCState QCMode = QCState::NOT_STARTED;
|
QCState QCMode = QCState::NOT_STARTED;
|
||||||
uint8_t QCTries = 0;
|
uint8_t QCTries = 0;
|
||||||
void seekQC(int16_t Vx10, uint16_t divisor) {
|
void seekQC(int16_t Vx10, uint16_t divisor) {
|
||||||
if (QCMode == QCState::NOT_STARTED)
|
if (QCMode == QCState::NOT_STARTED) {
|
||||||
startQC(divisor);
|
startQC(divisor);
|
||||||
|
}
|
||||||
|
|
||||||
if (Vx10 < 40) // Bail out if less than 4V
|
if (Vx10 < 40) { // Bail out if less than 4V
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (xTaskGetTickCount() < TICKS_SECOND)
|
if (xTaskGetTickCount() < TICKS_SECOND) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Seek the QC to the Voltage given if this adapter supports continuous mode
|
// Seek the QC to the Voltage given if this adapter supports continuous mode
|
||||||
// try and step towards the wanted value
|
// try and step towards the wanted value
|
||||||
@@ -87,8 +97,9 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
// Re-measure
|
// Re-measure
|
||||||
/* Disabled due to nothing to test and code space of around 1k*/
|
/* Disabled due to nothing to test and code space of around 1k*/
|
||||||
steps = vStart - getInputVoltageX10(divisor, 0);
|
steps = vStart - getInputVoltageX10(divisor, 0);
|
||||||
if (steps < 0)
|
if (steps < 0) {
|
||||||
steps = -steps;
|
steps = -steps;
|
||||||
|
}
|
||||||
if (steps > 4) {
|
if (steps > 4) {
|
||||||
// No continuous mode, so QC2
|
// No continuous mode, so QC2
|
||||||
QCMode = QCState::QC_2;
|
QCMode = QCState::QC_2;
|
||||||
@@ -104,8 +115,9 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
QC_Seek9V();
|
QC_Seek9V();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* ENABLE_QC2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must be called after FreeRToS Starts
|
// Must be called after FreeRToS Starts
|
||||||
void startQC(uint16_t divisor) {
|
void startQC(uint16_t divisor) {
|
||||||
// Pre check that the input could be >5V already, and if so, dont both
|
// Pre check that the input could be >5V already, and if so, dont both
|
||||||
@@ -143,7 +155,9 @@ void startQC(uint16_t divisor) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QC_DM_No_PullDown();
|
QC_DM_No_PullDown();
|
||||||
|
|
||||||
if (enteredQC) {
|
if (enteredQC) {
|
||||||
// We have a QC capable charger
|
// We have a QC capable charger
|
||||||
QC_Seek9V();
|
QC_Seek9V();
|
||||||
@@ -161,7 +175,6 @@ void startQC(uint16_t divisor) {
|
|||||||
}
|
}
|
||||||
QCMode = QCState::NOT_STARTED;
|
QCMode = QCState::NOT_STARTED;
|
||||||
QCTries++;
|
QCTries++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no QC
|
// no QC
|
||||||
QCTries++;
|
QCTries++;
|
||||||
|
|||||||
@@ -261,8 +261,9 @@ uint16_t lookupHallEffectThreshold() {
|
|||||||
uint8_t lookupVoltageLevel() {
|
uint8_t lookupVoltageLevel() {
|
||||||
auto minVoltageOnCell = getSettingValue(SettingsOptions::MinDCVoltageCells);
|
auto minVoltageOnCell = getSettingValue(SettingsOptions::MinDCVoltageCells);
|
||||||
auto minVoltageCellCount = getSettingValue(SettingsOptions::MinVoltageCells);
|
auto minVoltageCellCount = getSettingValue(SettingsOptions::MinVoltageCells);
|
||||||
if (minVoltageOnCell == 0)
|
if (minVoltageOnCell == 0) {
|
||||||
return 90; // 9V since iron does not function effectively below this
|
return 90; // 9V since iron does not function effectively below this
|
||||||
else
|
} else {
|
||||||
return (minVoltageOnCell * minVoltageCellCount) + (minVoltageCellCount * 2);
|
return (minVoltageOnCell * minVoltageCellCount) + (minVoltageCellCount * 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ static bool enterAdvancedMenu(void);
|
|||||||
* Display Orientation
|
* Display Orientation
|
||||||
* Cooldown Blink
|
* Cooldown Blink
|
||||||
* Scrolling Speed
|
* Scrolling Speed
|
||||||
* Swap Temp Change Buttons + -
|
* Swap Temp Change Buttons +/-
|
||||||
* Animation Speed
|
* Animation Speed
|
||||||
* -Animation Loop
|
* -Animation Loop
|
||||||
* OLED Brightness
|
* OLED Brightness
|
||||||
@@ -196,6 +196,14 @@ static bool enterAdvancedMenu(void);
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* vvv !!!DISABLE CLANG-FORMAT for menuitems initialization!!! vvv */
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
|
/* A lot of suggestions by clang-format can be useful
|
||||||
|
* but not when dealing with such menuitems declarations.
|
||||||
|
*/
|
||||||
|
|
||||||
const menuitem rootSettingsMenu[] {
|
const menuitem rootSettingsMenu[] {
|
||||||
/*
|
/*
|
||||||
* Power Menu
|
* Power Menu
|
||||||
@@ -207,177 +215,233 @@ const menuitem rootSettingsMenu[] {
|
|||||||
* Exit
|
* Exit
|
||||||
*/
|
*/
|
||||||
#if defined(POW_DC) || defined(POW_QC)
|
#if defined(POW_DC) || defined(POW_QC)
|
||||||
{0, enterPowerMenu, displayPowerMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}, /*Power*/
|
/* Power */
|
||||||
#endif /* POW_DC or POW_QC */
|
{0, enterPowerMenu, displayPowerMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0},
|
||||||
{0, enterSolderingMenu, displaySolderingMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}, /*Soldering*/
|
#endif
|
||||||
{0, enterPowerSavingMenu, displayPowerSavingMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}, /*Sleep Options Menu*/
|
/* Soldering */
|
||||||
{0, enterUIMenu, displayUIMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}, /*UI Menu*/
|
{0, enterSolderingMenu, displaySolderingMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0},
|
||||||
{0, enterAdvancedMenu, displayAdvancedMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}, /*Advanced Menu*/
|
/* Sleep Options Menu */
|
||||||
{0, settings_setLanguageSwitch, settings_displayLanguageSwitch, settings_showLanguageSwitch, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}, /*Language Switch*/
|
{0, enterPowerSavingMenu, displayPowerSavingMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0},
|
||||||
{
|
/* UI Menu */
|
||||||
0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0
|
{0, enterUIMenu, displayUIMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0},
|
||||||
} // end of menu marker. DO NOT REMOVE
|
/* Advanced Menu */
|
||||||
|
{0, enterAdvancedMenu, displayAdvancedMenu, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0},
|
||||||
|
/* Language Switch */
|
||||||
|
{0, settings_setLanguageSwitch, settings_displayLanguageSwitch, settings_showLanguageSwitch, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0},
|
||||||
|
/* vvvv end of menu marker. DO NOT REMOVE vvvv */
|
||||||
|
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}
|
||||||
|
/* ^^^^ end of menu marker. DO NOT REMOVE ^^^^ */
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(POW_DC) || defined(POW_QC) || defined(POW_PD)
|
#if defined(POW_DC) || defined(POW_QC) || defined(POW_PD)
|
||||||
const menuitem powerMenu[] = {
|
const menuitem powerMenu[] = {
|
||||||
/*
|
/*
|
||||||
* Power Source
|
* Power Source
|
||||||
* -Minimum Voltage
|
* -Minimum Voltage
|
||||||
* QC Voltage
|
* QC Voltage
|
||||||
* PD Timeout
|
* PD Timeout
|
||||||
* PDVpdo
|
* PDVpdo
|
||||||
*/
|
*/
|
||||||
#ifdef POW_DC
|
#ifdef POW_DC
|
||||||
{SETTINGS_DESC(SettingsItemIndex::DCInCutoff), nullptr, displayInputVRange, nullptr, SettingsOptions::MinDCVoltageCells, SettingsItemIndex::DCInCutoff, 6}, /*Voltage input*/
|
/* Voltage input */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::MinVolCell), nullptr, displayInputMinVRange, showInputVOptions, SettingsOptions::MinVoltageCells, SettingsItemIndex::MinVolCell, 5}, /*Minimum voltage input*/
|
{SETTINGS_DESC(SettingsItemIndex::DCInCutoff), nullptr, displayInputVRange, nullptr, SettingsOptions::MinDCVoltageCells, SettingsItemIndex::DCInCutoff, 6},
|
||||||
#endif /* POW_DC */
|
/* Minimum voltage input */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::MinVolCell), nullptr, displayInputMinVRange, showInputVOptions, SettingsOptions::MinVoltageCells, SettingsItemIndex::MinVolCell, 5},
|
||||||
|
#endif
|
||||||
#ifdef POW_QC
|
#ifdef POW_QC
|
||||||
{SETTINGS_DESC(SettingsItemIndex::QCMaxVoltage), nullptr, displayQCInputV, nullptr, SettingsOptions::QCIdealVoltage, SettingsItemIndex::QCMaxVoltage, 4}, /*Voltage input*/
|
/* Voltage input */
|
||||||
#endif /* POW_QC */
|
{SETTINGS_DESC(SettingsItemIndex::QCMaxVoltage), nullptr, displayQCInputV, nullptr, SettingsOptions::QCIdealVoltage, SettingsItemIndex::QCMaxVoltage, 4},
|
||||||
|
#endif
|
||||||
#ifdef POW_PD
|
#ifdef POW_PD
|
||||||
{SETTINGS_DESC(SettingsItemIndex::PDNegTimeout), nullptr, displayPDNegTimeout, nullptr, SettingsOptions::PDNegTimeout, SettingsItemIndex::PDNegTimeout, 5}, /*PD timeout setup*/
|
/* PD timeout setup */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::PDVpdo), nullptr, displayPDVpdo, nullptr, SettingsOptions::PDVpdo, SettingsItemIndex::PDVpdo, 7 }, /*Toggle PPS & EPR*/
|
{SETTINGS_DESC(SettingsItemIndex::PDNegTimeout), nullptr, displayPDNegTimeout, nullptr, SettingsOptions::PDNegTimeout, SettingsItemIndex::PDNegTimeout, 5},
|
||||||
#endif /* POW_PD */
|
/* Toggle PPS & EPR */
|
||||||
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0} // end of menu marker. DO NOT REMOVE
|
{SETTINGS_DESC(SettingsItemIndex::PDVpdo), nullptr, displayPDVpdo, nullptr, SettingsOptions::PDVpdo, SettingsItemIndex::PDVpdo, 7},
|
||||||
|
#endif
|
||||||
|
/* vvvv end of menu marker. DO NOT REMOVE vvvv */
|
||||||
|
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}
|
||||||
|
/* ^^^^ end of menu marker. DO NOT REMOVE ^^^^ */
|
||||||
};
|
};
|
||||||
#endif /* POW_DC or POW_QC or POW_PD */
|
#endif /* POW_DC or POW_QC or POW_PD */
|
||||||
|
|
||||||
const menuitem solderingMenu[] = {
|
const menuitem solderingMenu[] = {
|
||||||
/*
|
/*
|
||||||
* Boost Mode Temp
|
* Boost Mode Temp
|
||||||
* Auto Start
|
* Auto Start
|
||||||
* Temp Change Short Step
|
* Temp Change Short Step
|
||||||
* Temp Change Long Step
|
* Temp Change Long Step
|
||||||
* Locking Mode
|
* Locking Mode
|
||||||
* Profile Phases
|
* Profile Phases
|
||||||
* Profile Preheat Temperature
|
* Profile Preheat Temperature
|
||||||
* Profile Preheat Max Temperature Change Per Second
|
* Profile Preheat Max Temperature Change Per Second
|
||||||
* Profile Phase 1 Temperature
|
* Profile Phase 1 Temperature
|
||||||
* Profile Phase 1 Duration (s)
|
* Profile Phase 1 Duration (s)
|
||||||
* Profile Phase 2 Temperature
|
* Profile Phase 2 Temperature
|
||||||
* Profile Phase 2 Duration (s)
|
* Profile Phase 2 Duration (s)
|
||||||
* Profile Phase 3 Temperature
|
* Profile Phase 3 Temperature
|
||||||
* Profile Phase 3 Duration (s)
|
* Profile Phase 3 Duration (s)
|
||||||
* Profile Phase 4 Temperature
|
* Profile Phase 4 Temperature
|
||||||
* Profile Phase 4 Duration (s)
|
* Profile Phase 4 Duration (s)
|
||||||
* Profile Phase 5 Temperature
|
* Profile Phase 5 Temperature
|
||||||
* Profile Phase 5 Duration (s)
|
* Profile Phase 5 Duration (s)
|
||||||
* Profile Cooldown Max Temperature Change Per Second
|
* Profile Cooldown Max Temperature Change Per Second
|
||||||
*/
|
*/
|
||||||
{SETTINGS_DESC(SettingsItemIndex::BoostTemperature), setBoostTemp, displayBoostTemp, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::BoostTemperature, 5}, /*Boost Temp*/
|
/* Boost Temp */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::AutoStart), nullptr, displayAutomaticStartMode, nullptr, SettingsOptions::AutoStartMode, SettingsItemIndex::AutoStart, 7}, /*Auto start*/
|
{SETTINGS_DESC(SettingsItemIndex::BoostTemperature), setBoostTemp, displayBoostTemp, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::BoostTemperature, 5},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::TempChangeShortStep), nullptr, displayTempChangeShortStep, nullptr, SettingsOptions::TempChangeShortStep, SettingsItemIndex::TempChangeShortStep,
|
/* Auto start */
|
||||||
6}, /*Temp change short step*/
|
{SETTINGS_DESC(SettingsItemIndex::AutoStart), nullptr, displayAutomaticStartMode, nullptr, SettingsOptions::AutoStartMode, SettingsItemIndex::AutoStart, 7},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::TempChangeLongStep), nullptr, displayTempChangeLongStep, nullptr, SettingsOptions::TempChangeLongStep, SettingsItemIndex::TempChangeLongStep,
|
/* Temp change short step */
|
||||||
6}, /*Temp change long step*/
|
{SETTINGS_DESC(SettingsItemIndex::TempChangeShortStep), nullptr, displayTempChangeShortStep, nullptr, SettingsOptions::TempChangeShortStep, SettingsItemIndex::TempChangeShortStep, 6},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::LockingMode), nullptr, displayLockingMode, nullptr, SettingsOptions::LockingMode, SettingsItemIndex::LockingMode, 7}, /*Locking Mode*/
|
/* Temp change long step */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::TempChangeLongStep), nullptr, displayTempChangeLongStep, nullptr, SettingsOptions::TempChangeLongStep, SettingsItemIndex::TempChangeLongStep, 6},
|
||||||
|
/* Locking Mode */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::LockingMode), nullptr, displayLockingMode, nullptr, SettingsOptions::LockingMode, SettingsItemIndex::LockingMode, 7},
|
||||||
#ifdef PROFILE_SUPPORT
|
#ifdef PROFILE_SUPPORT
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhases), nullptr, displayProfilePhases, nullptr, SettingsOptions::ProfilePhases, SettingsItemIndex::ProfilePhases, 7}, /*Profile Phases*/
|
/* Profile Phases */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePreheatTemp), setProfilePreheatTemp, displayProfilePreheatTemp, showProfileOptions, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePreheatTemp, 5}, /*Profile Preheat Temp*/
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhases), nullptr, displayProfilePhases, nullptr, SettingsOptions::ProfilePhases, SettingsItemIndex::ProfilePhases, 7},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePreheatSpeed), nullptr, displayProfilePreheatSpeed, showProfileOptions, SettingsOptions::ProfilePreheatSpeed, SettingsItemIndex::ProfilePreheatSpeed, 5}, /*Profile Preheat Speed*/
|
/* Profile Preheat Temp */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase1Temp, displayProfilePhase1Temp, showProfileOptions, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase1Temp, 5}, /*Phase 1 Temp*/
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePreheatTemp), setProfilePreheatTemp, displayProfilePreheatTemp, showProfileOptions, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePreheatTemp, 5},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase1Duration, showProfileOptions, SettingsOptions::ProfilePhase1Duration, SettingsItemIndex::ProfilePhase1Duration, 5}, /*Phase 1 Duration*/
|
/* Profile Preheat Speed */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase2Temp, displayProfilePhase2Temp, showProfilePhase2Options, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase2Temp, 5}, /*Phase 2 Temp*/
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePreheatSpeed), nullptr, displayProfilePreheatSpeed, showProfileOptions, SettingsOptions::ProfilePreheatSpeed, SettingsItemIndex::ProfilePreheatSpeed, 5},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase2Duration, showProfilePhase2Options, SettingsOptions::ProfilePhase2Duration, SettingsItemIndex::ProfilePhase2Duration, 5}, /*Phase 2 Duration*/
|
/* Phase 1 Temp */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase3Temp, displayProfilePhase3Temp, showProfilePhase3Options, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase3Temp, 5}, /*Phase 3 Temp*/
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase1Temp, displayProfilePhase1Temp, showProfileOptions, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase1Temp, 5},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase3Duration, showProfilePhase3Options, SettingsOptions::ProfilePhase3Duration, SettingsItemIndex::ProfilePhase3Duration, 5}, /*Phase 3 Duration*/
|
/* Phase 1 Duration */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase4Temp, displayProfilePhase4Temp, showProfilePhase4Options, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase4Temp, 5}, /*Phase 4 Temp*/
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase1Duration, showProfileOptions, SettingsOptions::ProfilePhase1Duration, SettingsItemIndex::ProfilePhase1Duration, 5},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase4Duration, showProfilePhase4Options, SettingsOptions::ProfilePhase4Duration, SettingsItemIndex::ProfilePhase4Duration, 5}, /*Phase 4 Duration*/
|
/* Phase 2 Temp */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase5Temp, displayProfilePhase5Temp, showProfilePhase5Options, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase5Temp, 5}, /*Phase 5 Temp*/
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase2Temp, displayProfilePhase2Temp, showProfilePhase2Options, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase2Temp, 5},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase5Duration, showProfilePhase5Options, SettingsOptions::ProfilePhase5Duration, SettingsItemIndex::ProfilePhase5Duration, 5}, /*Phase 5 Duration*/
|
/* Phase 2 Duration */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ProfileCooldownSpeed), nullptr, displayProfileCooldownSpeed, showProfileOptions, SettingsOptions::ProfileCooldownSpeed, SettingsItemIndex::ProfileCooldownSpeed, 5}, /*Profile Cooldown Speed*/
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase2Duration, showProfilePhase2Options, SettingsOptions::ProfilePhase2Duration, SettingsItemIndex::ProfilePhase2Duration, 5},
|
||||||
|
/* Phase 3 Temp */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase3Temp, displayProfilePhase3Temp, showProfilePhase3Options, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase3Temp, 5},
|
||||||
|
/* Phase 3 Duration */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase3Duration, showProfilePhase3Options, SettingsOptions::ProfilePhase3Duration, SettingsItemIndex::ProfilePhase3Duration, 5},
|
||||||
|
/* Phase 4 Temp */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase4Temp, displayProfilePhase4Temp, showProfilePhase4Options, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase4Temp, 5},
|
||||||
|
/* Phase 4 Duration */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase4Duration, showProfilePhase4Options, SettingsOptions::ProfilePhase4Duration, SettingsItemIndex::ProfilePhase4Duration, 5},
|
||||||
|
/* Phase 5 Temp */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Temp), setProfilePhase5Temp, displayProfilePhase5Temp, showProfilePhase5Options, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::ProfilePhase5Temp, 5},
|
||||||
|
/* Phase 5 Duration */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::ProfilePhase1Duration), nullptr, displayProfilePhase5Duration, showProfilePhase5Options, SettingsOptions::ProfilePhase5Duration, SettingsItemIndex::ProfilePhase5Duration, 5},
|
||||||
|
/* Profile Cooldown Speed */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::ProfileCooldownSpeed), nullptr, displayProfileCooldownSpeed, showProfileOptions, SettingsOptions::ProfileCooldownSpeed, SettingsItemIndex::ProfileCooldownSpeed, 5},
|
||||||
#endif /* PROFILE_SUPPORT */
|
#endif /* PROFILE_SUPPORT */
|
||||||
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0} // end of menu marker. DO NOT REMOVE
|
/* vvvv end of menu marker. DO NOT REMOVE vvvv */
|
||||||
|
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}
|
||||||
|
/* ^^^^ end of menu marker. DO NOT REMOVE ^^^^ */
|
||||||
};
|
};
|
||||||
|
|
||||||
const menuitem PowerSavingMenu[] = {
|
const menuitem PowerSavingMenu[] = {
|
||||||
/*
|
/*
|
||||||
* Motion Sensitivity
|
* Motion Sensitivity
|
||||||
* -Sleep Temp
|
* -Sleep Temp
|
||||||
* -Sleep Time
|
* -Sleep Time
|
||||||
* -Shutdown Time
|
* -Shutdown Time
|
||||||
* Hall Sensor Sensitivity
|
* Hall Sensor Sensitivity
|
||||||
*/
|
*/
|
||||||
{SETTINGS_DESC(SettingsItemIndex::MotionSensitivity), nullptr, displaySensitivity, nullptr, SettingsOptions::Sensitivity, SettingsItemIndex::MotionSensitivity, 7}, /* Motion Sensitivity*/
|
/* Motion Sensitivity */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::MotionSensitivity), nullptr, displaySensitivity, nullptr, SettingsOptions::Sensitivity, SettingsItemIndex::MotionSensitivity, 7},
|
||||||
#ifndef NO_SLEEP_MODE
|
#ifndef NO_SLEEP_MODE
|
||||||
{SETTINGS_DESC(SettingsItemIndex::SleepTemperature), setSleepTemp, displaySleepTemp, showSleepOptions, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::SleepTemperature,
|
/* Sleep Temp */
|
||||||
5}, /*Sleep Temp*/
|
{SETTINGS_DESC(SettingsItemIndex::SleepTemperature), setSleepTemp, displaySleepTemp, showSleepOptions, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::SleepTemperature, 5},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::SleepTimeout), nullptr, displaySleepTime, showSleepOptions, SettingsOptions::SleepTime, SettingsItemIndex::SleepTimeout, 5}, /*Sleep Time*/
|
/* Sleep Time */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::SleepTimeout), nullptr, displaySleepTime, showSleepOptions, SettingsOptions::SleepTime, SettingsItemIndex::SleepTimeout, 5},
|
||||||
#endif /* *not* NO_SLEEP_MODE */
|
#endif /* *not* NO_SLEEP_MODE */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ShutdownTimeout), nullptr, displayShutdownTime, showSleepOptions, SettingsOptions::ShutdownTime, SettingsItemIndex::ShutdownTimeout, 5}, /*Shutdown Time*/
|
/* Shutdown Time */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::ShutdownTimeout), nullptr, displayShutdownTime, showSleepOptions, SettingsOptions::ShutdownTime, SettingsItemIndex::ShutdownTimeout, 5},
|
||||||
#ifdef HALL_SENSOR
|
#ifdef HALL_SENSOR
|
||||||
{SETTINGS_DESC(SettingsItemIndex::HallEffSensitivity), nullptr, displayHallEffect, showHallEffect, SettingsOptions::HallEffectSensitivity, SettingsItemIndex::HallEffSensitivity,
|
/* Hall Effect Sensitivity */
|
||||||
7}, /* HallEffect Sensitivity*/
|
{SETTINGS_DESC(SettingsItemIndex::HallEffSensitivity), nullptr, displayHallEffect, showHallEffect, SettingsOptions::HallEffectSensitivity, SettingsItemIndex::HallEffSensitivity, 7},
|
||||||
#endif /* HALL_SENSOR */
|
#endif /* HALL_SENSOR */
|
||||||
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0} // end of menu marker. DO NOT REMOVE
|
/* vvvv end of menu marker. DO NOT REMOVE vvvv */
|
||||||
|
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}
|
||||||
|
/* ^^^^ end of menu marker. DO NOT REMOVE ^^^^ */
|
||||||
};
|
};
|
||||||
|
|
||||||
const menuitem UIMenu[] = {
|
const menuitem UIMenu[] = {
|
||||||
/*
|
/*
|
||||||
* Temperature Unit
|
* Temperature Unit
|
||||||
* Display Orientation
|
* Display Orientation
|
||||||
* Cooldown Blink
|
* Cooldown Blink
|
||||||
* Scrolling Speed
|
* Scrolling Speed
|
||||||
* Swap Temp Change Buttons + -
|
* Swap Temp Change Buttons +/-
|
||||||
* Animation Speed
|
* Animation Speed
|
||||||
* -Animation Loop
|
* -Animation Loop
|
||||||
* OLED Brightness
|
* OLED Brightness
|
||||||
* Invert Screen
|
* Invert Screen
|
||||||
* Logo Timeout
|
* Logo Timeout
|
||||||
* Detailed IDLE
|
* Detailed IDLE
|
||||||
* Detailed Soldering
|
* Detailed Soldering
|
||||||
*/
|
*/
|
||||||
{SETTINGS_DESC(SettingsItemIndex::TemperatureUnit), setTempF, displayTempF, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::TemperatureUnit,
|
/* Temperature units, this has to be the first element in the array to work with the logic in enterUIMenu() */
|
||||||
7}, /* Temperature units, this has to be the first element in the array to work with the logic in enterUIMenu() */
|
{SETTINGS_DESC(SettingsItemIndex::TemperatureUnit), setTempF, displayTempF, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::TemperatureUnit, 7},
|
||||||
#ifndef NO_DISPLAY_ROTATE
|
#ifndef NO_DISPLAY_ROTATE
|
||||||
{SETTINGS_DESC(SettingsItemIndex::DisplayRotation), setDisplayRotation, displayDisplayRotation, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::DisplayRotation,
|
/* Display Rotation */
|
||||||
7}, /*Display Rotation*/
|
{SETTINGS_DESC(SettingsItemIndex::DisplayRotation), setDisplayRotation, displayDisplayRotation, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::DisplayRotation, 7},
|
||||||
#endif /* *not* NO_DISPLAY_ROTATE */
|
#endif /* *not* NO_DISPLAY_ROTATE */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::CooldownBlink), nullptr, displayCoolingBlinkEnabled, nullptr, SettingsOptions::CoolingTempBlink, SettingsItemIndex::CooldownBlink, 7}, /*Cooling blink warning*/
|
/* Cooling blink warning */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ScrollingSpeed), nullptr, displayScrollSpeed, nullptr, SettingsOptions::DescriptionScrollSpeed, SettingsItemIndex::ScrollingSpeed,
|
{SETTINGS_DESC(SettingsItemIndex::CooldownBlink), nullptr, displayCoolingBlinkEnabled, nullptr, SettingsOptions::CoolingTempBlink, SettingsItemIndex::CooldownBlink, 7},
|
||||||
7}, /*Scroll Speed for descriptions*/
|
/* Scroll Speed for descriptions */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ReverseButtonTempChange), nullptr, displayReverseButtonTempChangeEnabled, nullptr, SettingsOptions::ReverseButtonTempChangeEnabled,
|
{SETTINGS_DESC(SettingsItemIndex::ScrollingSpeed), nullptr, displayScrollSpeed, nullptr, SettingsOptions::DescriptionScrollSpeed, SettingsItemIndex::ScrollingSpeed, 7},
|
||||||
SettingsItemIndex::ReverseButtonTempChange, 7}, /*Reverse Temp change buttons + - */
|
/* Reverse Temp change buttons +/- */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::AnimSpeed), nullptr, displayAnimationSpeed, nullptr, SettingsOptions::AnimationSpeed, SettingsItemIndex::AnimSpeed, 7}, /*Animation Speed adjustment */
|
{SETTINGS_DESC(SettingsItemIndex::ReverseButtonTempChange), nullptr, displayReverseButtonTempChangeEnabled, nullptr, SettingsOptions::ReverseButtonTempChangeEnabled, SettingsItemIndex::ReverseButtonTempChange, 7},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::AnimLoop), nullptr, displayAnimationLoop, displayAnimationOptions, SettingsOptions::AnimationLoop, SettingsItemIndex::AnimLoop, 7}, /*Animation Loop switch */
|
/* Animation Speed adjustment */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::Brightness), nullptr, displayBrightnessLevel, nullptr, SettingsOptions::OLEDBrightness, SettingsItemIndex::Brightness, 7}, /*Brightness Level*/
|
{SETTINGS_DESC(SettingsItemIndex::AnimSpeed), nullptr, displayAnimationSpeed, nullptr, SettingsOptions::AnimationSpeed, SettingsItemIndex::AnimSpeed, 7},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::ColourInversion), nullptr, displayInvertColor, nullptr, SettingsOptions::OLEDInversion, SettingsItemIndex::ColourInversion, 7}, /*Invert screen colour*/
|
/* Animation Loop switch */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::LOGOTime), nullptr, displayLogoTime, nullptr, SettingsOptions::LOGOTime, SettingsItemIndex::LOGOTime, 5}, /*Set logo duration*/
|
{SETTINGS_DESC(SettingsItemIndex::AnimLoop), nullptr, displayAnimationLoop, displayAnimationOptions, SettingsOptions::AnimationLoop, SettingsItemIndex::AnimLoop, 7},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::AdvancedIdle), nullptr, displayAdvancedIDLEScreens, nullptr, SettingsOptions::DetailedIDLE, SettingsItemIndex::AdvancedIdle, 7}, /*Advanced idle screen*/
|
/* Brightness Level */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::AdvancedSoldering), nullptr, displayAdvancedSolderingScreens, nullptr, SettingsOptions::DetailedSoldering, SettingsItemIndex::AdvancedSoldering,
|
{SETTINGS_DESC(SettingsItemIndex::Brightness), nullptr, displayBrightnessLevel, nullptr, SettingsOptions::OLEDBrightness, SettingsItemIndex::Brightness, 7},
|
||||||
7}, /*Advanced soldering screen*/
|
/* Invert screen colour */
|
||||||
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0} // end of menu marker. DO NOT REMOVE
|
{SETTINGS_DESC(SettingsItemIndex::ColourInversion), nullptr, displayInvertColor, nullptr, SettingsOptions::OLEDInversion, SettingsItemIndex::ColourInversion, 7},
|
||||||
|
/* Set logo duration */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::LOGOTime), nullptr, displayLogoTime, nullptr, SettingsOptions::LOGOTime, SettingsItemIndex::LOGOTime, 5},
|
||||||
|
/* Advanced idle screen */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::AdvancedIdle), nullptr, displayAdvancedIDLEScreens, nullptr, SettingsOptions::DetailedIDLE, SettingsItemIndex::AdvancedIdle, 7},
|
||||||
|
/* Advanced soldering screen */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::AdvancedSoldering), nullptr, displayAdvancedSolderingScreens, nullptr, SettingsOptions::DetailedSoldering, SettingsItemIndex::AdvancedSoldering, 7},
|
||||||
|
/* vvvv end of menu marker. DO NOT REMOVE vvvv */
|
||||||
|
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}
|
||||||
|
/* ^^^^ end of menu marker. DO NOT REMOVE ^^^^ */
|
||||||
};
|
};
|
||||||
|
|
||||||
const menuitem advancedMenu[] = {
|
const menuitem advancedMenu[] = {
|
||||||
/*
|
/*
|
||||||
* BluetoothLE
|
* BluetoothLE
|
||||||
* Power Limit
|
* Power Limit
|
||||||
* Calibrate CJC At Next Boot
|
* Calibrate CJC At Next Boot
|
||||||
* Calibrate Input V
|
* Calibrate Input V
|
||||||
* Power Pulse
|
* Power Pulse
|
||||||
* -Power Pulse Delay
|
* -Power Pulse Delay
|
||||||
* -Power Pulse Duration
|
* -Power Pulse Duration
|
||||||
* Factory Reset
|
* Factory Reset
|
||||||
*/
|
*/
|
||||||
#ifdef BLE_ENABLED
|
#ifdef BLE_ENABLED
|
||||||
{SETTINGS_DESC(SettingsItemIndex::BluetoothLE), nullptr, displayBluetoothLE, nullptr, SettingsOptions::BluetoothLE, SettingsItemIndex::BluetoothLE, 7}, /*Toggle BLE*/
|
/* Toggle BLE */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::BluetoothLE), nullptr, displayBluetoothLE, nullptr, SettingsOptions::BluetoothLE, SettingsItemIndex::BluetoothLE, 7},
|
||||||
#endif /* BLE_ENABLED */
|
#endif /* BLE_ENABLED */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::PowerLimit), nullptr, displayPowerLimit, nullptr, SettingsOptions::PowerLimit, SettingsItemIndex::PowerLimit, 4}, /*Power limit*/
|
/* Power limit */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::CalibrateCJC), setCalibrate, displayCalibrate, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::CalibrateCJC,
|
{SETTINGS_DESC(SettingsItemIndex::PowerLimit), nullptr, displayPowerLimit, nullptr, SettingsOptions::PowerLimit, SettingsItemIndex::PowerLimit, 4},
|
||||||
7}, /*Calibrate Cold Junktion Compensation at next boot*/
|
/* Calibrate Cold Junktion Compensation at next boot */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::VoltageCalibration), setCalibrateVIN, displayCalibrateVIN, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::VoltageCalibration,
|
{SETTINGS_DESC(SettingsItemIndex::CalibrateCJC), setCalibrate, displayCalibrate, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::CalibrateCJC, 7},
|
||||||
5}, /*Voltage input cal*/
|
/* Voltage input cal */
|
||||||
{SETTINGS_DESC(SettingsItemIndex::PowerPulsePower), nullptr, displayPowerPulse, nullptr, SettingsOptions::KeepAwakePulse, SettingsItemIndex::PowerPulsePower, 5}, /*Power Pulse adjustment */
|
{SETTINGS_DESC(SettingsItemIndex::VoltageCalibration), setCalibrateVIN, displayCalibrateVIN, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::VoltageCalibration, 5},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::PowerPulseWait), nullptr, displayPowerPulseWait, showPowerPulseOptions, SettingsOptions::KeepAwakePulseWait, SettingsItemIndex::PowerPulseWait,
|
/* Power Pulse adjustment */
|
||||||
7}, /*Power Pulse Wait adjustment*/
|
{SETTINGS_DESC(SettingsItemIndex::PowerPulsePower), nullptr, displayPowerPulse, nullptr, SettingsOptions::KeepAwakePulse, SettingsItemIndex::PowerPulsePower, 5},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::PowerPulseDuration), nullptr, displayPowerPulseDuration, showPowerPulseOptions, SettingsOptions::KeepAwakePulseDuration, SettingsItemIndex::PowerPulseDuration,
|
/* Power Pulse Wait adjustment */
|
||||||
7}, /*Power Pulse Duration adjustment*/
|
{SETTINGS_DESC(SettingsItemIndex::PowerPulseWait), nullptr, displayPowerPulseWait, showPowerPulseOptions, SettingsOptions::KeepAwakePulseWait, SettingsItemIndex::PowerPulseWait, 7},
|
||||||
{SETTINGS_DESC(SettingsItemIndex::SettingsReset), setResetSettings, displayResetSettings, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::SettingsReset, 7}, /*Resets settings*/
|
/* Power Pulse Duration adjustment */
|
||||||
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0} // end of menu marker. DO NOT REMOVE
|
{SETTINGS_DESC(SettingsItemIndex::PowerPulseDuration), nullptr, displayPowerPulseDuration, showPowerPulseOptions, SettingsOptions::KeepAwakePulseDuration, SettingsItemIndex::PowerPulseDuration, 7},
|
||||||
|
/* Resets settings */
|
||||||
|
{SETTINGS_DESC(SettingsItemIndex::SettingsReset), setResetSettings, displayResetSettings, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::SettingsReset, 7},
|
||||||
|
/* vvvv end of menu marker. DO NOT REMOVE vvvv */
|
||||||
|
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}
|
||||||
|
/* ^^^^ end of menu marker. DO NOT REMOVE ^^^^ */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
|
/* ^^^ !!!ENABLE CLANG-FORMAT back!!! ^^^ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints two small lines (or one line for CJK) of short description for
|
* Prints two small lines (or one line for CJK) of short description for
|
||||||
* setting items and prepares cursor after it.
|
* setting items and prepares cursor after it.
|
||||||
@@ -552,26 +616,26 @@ static void displayLockingMode(void) {
|
|||||||
|
|
||||||
#ifdef PROFILE_SUPPORT
|
#ifdef PROFILE_SUPPORT
|
||||||
|
|
||||||
static void displayProfilePhases(void) {
|
static void displayProfilePhases(void) { OLED::printNumber(getSettingValue(SettingsOptions::ProfilePhases), 1, FontStyle::LARGE); }
|
||||||
OLED::printNumber(getSettingValue(SettingsOptions::ProfilePhases), 1, FontStyle::LARGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool setProfileTemp(const enum SettingsOptions option) {
|
static bool setProfileTemp(const enum SettingsOptions option) {
|
||||||
// If in C, 5 deg, if in F 10 deg
|
// If in C, 5 deg, if in F 10 deg
|
||||||
uint16_t temp = getSettingValue(option);
|
uint16_t temp = getSettingValue(option);
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
temp += 10;
|
temp += 10;
|
||||||
if (temp > MAX_TEMP_F)
|
if (temp > MAX_TEMP_F) {
|
||||||
temp = MIN_TEMP_F;
|
temp = MIN_TEMP_F;
|
||||||
setSettingValue(option, temp);
|
|
||||||
return temp == MAX_TEMP_F;
|
|
||||||
} else {
|
|
||||||
temp += 5;
|
|
||||||
if (temp > MAX_TEMP_C)
|
|
||||||
temp = MIN_TEMP_C;
|
|
||||||
setSettingValue(option, temp);
|
|
||||||
return temp == MAX_TEMP_C;
|
|
||||||
}
|
}
|
||||||
|
setSettingValue(option, temp);
|
||||||
|
return temp == MAX_TEMP_F;
|
||||||
|
} else {
|
||||||
|
temp += 5;
|
||||||
|
if (temp > MAX_TEMP_C) {
|
||||||
|
temp = MIN_TEMP_C;
|
||||||
|
}
|
||||||
|
setSettingValue(option, temp);
|
||||||
|
return temp == MAX_TEMP_C;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool setProfilePreheatTemp(void) { return setProfileTemp(SettingsOptions::ProfilePreheatTemp); }
|
static bool setProfilePreheatTemp(void) { return setProfileTemp(SettingsOptions::ProfilePreheatTemp); }
|
||||||
@@ -613,14 +677,16 @@ static bool setSleepTemp(void) {
|
|||||||
uint16_t temp = getSettingValue(SettingsOptions::SleepTemp);
|
uint16_t temp = getSettingValue(SettingsOptions::SleepTemp);
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
temp += 20;
|
temp += 20;
|
||||||
if (temp > 580)
|
if (temp > 580) {
|
||||||
temp = 60;
|
temp = 60;
|
||||||
|
}
|
||||||
setSettingValue(SettingsOptions::SleepTemp, temp);
|
setSettingValue(SettingsOptions::SleepTemp, temp);
|
||||||
return temp == 580;
|
return temp == 580;
|
||||||
} else {
|
} else {
|
||||||
temp += 10;
|
temp += 10;
|
||||||
if (temp > 300)
|
if (temp > 300) {
|
||||||
temp = 10;
|
temp = 10;
|
||||||
|
}
|
||||||
setSettingValue(SettingsOptions::SleepTemp, temp);
|
setSettingValue(SettingsOptions::SleepTemp, temp);
|
||||||
return temp == 300;
|
return temp == 300;
|
||||||
}
|
}
|
||||||
@@ -657,20 +723,20 @@ static bool showHallEffect(void) { return getHallSensorFitted(); }
|
|||||||
#endif /* HALL_SENSOR */
|
#endif /* HALL_SENSOR */
|
||||||
|
|
||||||
static void setTempF(const enum SettingsOptions option) {
|
static void setTempF(const enum SettingsOptions option) {
|
||||||
uint16_t Temp = getSettingValue(option);
|
uint16_t Temp = getSettingValue(option);
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
// Change temp to the F equiv
|
// Change temp to the F equiv
|
||||||
// C to F == F= ( (C*9) +160)/5
|
// C to F == F= ( (C*9) +160)/5
|
||||||
Temp = ((Temp * 9) + 160) / 5;
|
Temp = ((Temp * 9) + 160) / 5;
|
||||||
} else {
|
} else {
|
||||||
// Change temp to the C equiv
|
// Change temp to the C equiv
|
||||||
// F->C == C = ((F-32)*5)/9
|
// F->C == C = ((F-32)*5)/9
|
||||||
Temp = ((Temp - 32) * 5) / 9;
|
Temp = ((Temp - 32) * 5) / 9;
|
||||||
}
|
}
|
||||||
// Rescale to be multiples of 10
|
// Rescale to be multiples of 10
|
||||||
Temp = BoostTemp / 10;
|
Temp = BoostTemp / 10;
|
||||||
Temp *= 10;
|
Temp *= 10;
|
||||||
setSettingValue(option, Temp);
|
setSettingValue(option, Temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool setTempF(void) {
|
static bool setTempF(void) {
|
||||||
@@ -1057,10 +1123,12 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
menu[currentScreen].draw();
|
menu[currentScreen].draw();
|
||||||
uint8_t indicatorHeight = OLED_HEIGHT / scrollContentSize;
|
uint8_t indicatorHeight = OLED_HEIGHT / scrollContentSize;
|
||||||
uint8_t position = OLED_HEIGHT * (currentScreen - screensSkipped) / scrollContentSize;
|
uint8_t position = OLED_HEIGHT * (currentScreen - screensSkipped) / scrollContentSize;
|
||||||
if (lastValue)
|
if (lastValue) {
|
||||||
scrollBlink = !scrollBlink;
|
scrollBlink = !scrollBlink;
|
||||||
if (!lastValue || !scrollBlink)
|
}
|
||||||
|
if (!lastValue || !scrollBlink) {
|
||||||
OLED::drawScrollIndicator(position, indicatorHeight);
|
OLED::drawScrollIndicator(position, indicatorHeight);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Draw description
|
// Draw description
|
||||||
const char *description = translatedString(Tr->SettingsDescriptions[menu[currentScreen].description - 1]);
|
const char *description = translatedString(Tr->SettingsDescriptions[menu[currentScreen].description - 1]);
|
||||||
@@ -1107,29 +1175,28 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
// increment
|
// increment
|
||||||
if (scrollMessage.isReset()) {
|
if (scrollMessage.isReset()) {
|
||||||
lastValue = callIncrementHandler();
|
lastValue = callIncrementHandler();
|
||||||
} else
|
} else {
|
||||||
scrollMessage.reset();
|
scrollMessage.reset();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BUTTON_B_SHORT:
|
case BUTTON_B_SHORT:
|
||||||
if (scrollMessage.isReset()) {
|
if (scrollMessage.isReset()) {
|
||||||
currentScreen++;
|
currentScreen++;
|
||||||
navState = NavState::ScrollingDown;
|
navState = NavState::ScrollingDown;
|
||||||
lastValue = false;
|
lastValue = false;
|
||||||
} else
|
} else {
|
||||||
scrollMessage.reset();
|
scrollMessage.reset();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BUTTON_F_LONG:
|
case BUTTON_F_LONG:
|
||||||
if (xTaskGetTickCount() + autoRepeatAcceleration > autoRepeatTimer + PRESS_ACCEL_INTERVAL_MAX) {
|
if (xTaskGetTickCount() + autoRepeatAcceleration > autoRepeatTimer + PRESS_ACCEL_INTERVAL_MAX) {
|
||||||
|
if ((lastValue = callIncrementHandler())) {
|
||||||
if ((lastValue = callIncrementHandler()))
|
|
||||||
autoRepeatTimer = 1000;
|
autoRepeatTimer = 1000;
|
||||||
else
|
} else {
|
||||||
autoRepeatTimer = 0;
|
autoRepeatTimer = 0;
|
||||||
|
}
|
||||||
autoRepeatTimer += xTaskGetTickCount();
|
autoRepeatTimer += xTaskGetTickCount();
|
||||||
|
|
||||||
scrollMessage.reset();
|
scrollMessage.reset();
|
||||||
|
|
||||||
autoRepeatAcceleration += PRESS_ACCEL_STEP;
|
autoRepeatAcceleration += PRESS_ACCEL_STEP;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1139,7 +1206,6 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
navState = NavState::ScrollingDown;
|
navState = NavState::ScrollingDown;
|
||||||
autoRepeatTimer = xTaskGetTickCount();
|
autoRepeatTimer = xTaskGetTickCount();
|
||||||
scrollMessage.reset();
|
scrollMessage.reset();
|
||||||
|
|
||||||
autoRepeatAcceleration += PRESS_ACCEL_STEP;
|
autoRepeatAcceleration += PRESS_ACCEL_STEP;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ void performCJCC(void) {
|
|||||||
OLED::print(translatedString(Tr->CJCCalibrating), FontStyle::SMALL);
|
OLED::print(translatedString(Tr->CJCCalibrating), FontStyle::SMALL);
|
||||||
OLED::setCursor(0, 8);
|
OLED::setCursor(0, 8);
|
||||||
OLED::print(SmallSymbolDot, FontStyle::SMALL);
|
OLED::print(SmallSymbolDot, FontStyle::SMALL);
|
||||||
for (uint8_t x = 0; x < (i / 4); x++)
|
for (uint8_t x = 0; x < (i / 4); x++) {
|
||||||
OLED::print(SmallSymbolDot, FontStyle::SMALL);
|
OLED::print(SmallSymbolDot, FontStyle::SMALL);
|
||||||
|
}
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
osDelay(100);
|
osDelay(100);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ void showDebugMenu(void) {
|
|||||||
case 9: // Movement Timestamp
|
case 9: // Movement Timestamp
|
||||||
OLED::printNumber(lastMovementTime / TICKS_100MS, 8, FontStyle::SMALL);
|
OLED::printNumber(lastMovementTime / TICKS_100MS, 8, FontStyle::SMALL);
|
||||||
break;
|
break;
|
||||||
case 10: // Tip Resistance in Ω
|
case 10: // Tip Resistance in Ω large to pad over so that we cover ID left overs
|
||||||
OLED::printNumber(getTipResistanceX10() / 10, 6, FontStyle::SMALL); // large to pad over so that we cover ID left overs
|
OLED::printNumber(getTipResistanceX10() / 10, 6, FontStyle::SMALL);
|
||||||
OLED::print(SmallSymbolDot, FontStyle::SMALL);
|
OLED::print(SmallSymbolDot, FontStyle::SMALL);
|
||||||
OLED::printNumber(getTipResistanceX10() % 10, 1, FontStyle::SMALL);
|
OLED::printNumber(getTipResistanceX10() % 10, 1, FontStyle::SMALL);
|
||||||
break;
|
break;
|
||||||
@@ -82,8 +82,9 @@ void showDebugMenu(void) {
|
|||||||
case 16: // Raw Hall Effect Value
|
case 16: // Raw Hall Effect Value
|
||||||
{
|
{
|
||||||
int16_t hallEffectStrength = getRawHallEffect();
|
int16_t hallEffectStrength = getRawHallEffect();
|
||||||
if (hallEffectStrength < 0)
|
if (hallEffectStrength < 0) {
|
||||||
hallEffectStrength = -hallEffectStrength;
|
hallEffectStrength = -hallEffectStrength;
|
||||||
|
}
|
||||||
OLED::printNumber(hallEffectStrength, 6, FontStyle::SMALL);
|
OLED::printNumber(hallEffectStrength, 6, FontStyle::SMALL);
|
||||||
} break;
|
} break;
|
||||||
#endif
|
#endif
|
||||||
@@ -94,9 +95,9 @@ void showDebugMenu(void) {
|
|||||||
|
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
b = getButtonState();
|
b = getButtonState();
|
||||||
if (b == BUTTON_B_SHORT)
|
if (b == BUTTON_B_SHORT) {
|
||||||
return;
|
return;
|
||||||
else if (b == BUTTON_F_SHORT) {
|
} else if (b == BUTTON_F_SHORT) {
|
||||||
screen++;
|
screen++;
|
||||||
#ifdef HALL_SENSOR
|
#ifdef HALL_SENSOR
|
||||||
screen = screen % 17;
|
screen = screen % 17;
|
||||||
@@ -104,6 +105,7 @@ void showDebugMenu(void) {
|
|||||||
screen = screen % 16;
|
screen = screen % 16;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIDelay();
|
GUIDelay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,21 +103,24 @@ void drawDetailedHomeScreen(uint32_t tipTemp) {
|
|||||||
}
|
}
|
||||||
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
|
OLED::print(SmallSymbolVolts, FontStyle::SMALL);
|
||||||
} else {
|
} else {
|
||||||
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (tipTemp > 55) && (xTaskGetTickCount() % 1000 < 300)))
|
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (tipTemp > 55) && (xTaskGetTickCount() % 1000 < 300))) {
|
||||||
// Blink temp if setting enable and temp < 55°
|
// Blink temp if setting enable and temp < 55°
|
||||||
// 1000 tick/sec
|
// 1000 tick/sec
|
||||||
// OFF 300ms ON 700ms
|
// OFF 300ms ON 700ms
|
||||||
gui_drawTipTemp(true, FontStyle::LARGE); // draw in the temp
|
gui_drawTipTemp(true, FontStyle::LARGE); // draw in the temp
|
||||||
|
}
|
||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
OLED::setCursor(6, 0);
|
OLED::setCursor(6, 0);
|
||||||
} else {
|
} else {
|
||||||
OLED::setCursor(73, 0); // top right
|
OLED::setCursor(73, 0); // top right
|
||||||
}
|
}
|
||||||
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL); // draw set temp
|
// draw set temp
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL);
|
||||||
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
|
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
|
||||||
else
|
} else {
|
||||||
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
|
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
|
||||||
|
}
|
||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
OLED::setCursor(0, 8);
|
OLED::setCursor(0, 8);
|
||||||
} else {
|
} else {
|
||||||
@@ -142,10 +145,11 @@ void drawSimplifiedHomeScreen(uint32_t tipTemp) {
|
|||||||
gui_drawBatteryIcon();
|
gui_drawBatteryIcon();
|
||||||
}
|
}
|
||||||
tipDisconnectedDisplay = false;
|
tipDisconnectedDisplay = false;
|
||||||
if (tipTemp > 55)
|
if (tipTemp > 55) {
|
||||||
tempOnDisplay = true;
|
tempOnDisplay = true;
|
||||||
else if (tipTemp < 45)
|
} else if (tipTemp < 45) {
|
||||||
tempOnDisplay = false;
|
tempOnDisplay = false;
|
||||||
|
}
|
||||||
if (isTipDisconnected()) {
|
if (isTipDisconnected()) {
|
||||||
tempOnDisplay = false;
|
tempOnDisplay = false;
|
||||||
tipDisconnectedDisplay = true;
|
tipDisconnectedDisplay = true;
|
||||||
@@ -164,8 +168,9 @@ void drawSimplifiedHomeScreen(uint32_t tipTemp) {
|
|||||||
// If we have a tip connected draw the temp, if not we leave it blank
|
// If we have a tip connected draw the temp, if not we leave it blank
|
||||||
if (!tipDisconnectedDisplay) {
|
if (!tipDisconnectedDisplay) {
|
||||||
// draw in the temp
|
// draw in the temp
|
||||||
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300)))
|
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300))) {
|
||||||
gui_drawTipTemp(false, FontStyle::LARGE); // draw in the temp
|
gui_drawTipTemp(false, FontStyle::LARGE); // draw in the temp
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Draw in missing tip symbol
|
// Draw in missing tip symbol
|
||||||
|
|
||||||
|
|||||||
@@ -12,14 +12,18 @@ int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
|
|||||||
// If in the first two seconds we disable this to let accelerometer warm up
|
// If in the first two seconds we disable this to let accelerometer warm up
|
||||||
|
|
||||||
#ifdef POW_DC
|
#ifdef POW_DC
|
||||||
if (checkForUnderVoltage())
|
if (checkForUnderVoltage()) {
|
||||||
return 1; // return non-zero on error
|
// return non-zero on error
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC(min(getSettingValue(SettingsOptions::SleepTemp), getSettingValue(SettingsOptions::SolderingTemp)));
|
currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC(min(getSettingValue(SettingsOptions::SleepTemp), getSettingValue(SettingsOptions::SolderingTemp)));
|
||||||
} else {
|
} else {
|
||||||
currentTempTargetDegC = stayOff ? 0 : min(getSettingValue(SettingsOptions::SleepTemp), getSettingValue(SettingsOptions::SolderingTemp));
|
currentTempTargetDegC = stayOff ? 0 : min(getSettingValue(SettingsOptions::SleepTemp), getSettingValue(SettingsOptions::SolderingTemp));
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the lcd
|
// draw the lcd
|
||||||
uint16_t tipTemp = getSettingValue(SettingsOptions::TemperatureInF) ? TipThermoModel::getTipInF() : TipThermoModel::getTipInC();
|
uint16_t tipTemp = getSettingValue(SettingsOptions::TemperatureInF) ? TipThermoModel::getTipInF() : TipThermoModel::getTipInC();
|
||||||
|
|
||||||
@@ -30,9 +34,10 @@ int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
|
|||||||
OLED::setCursor(0, 8);
|
OLED::setCursor(0, 8);
|
||||||
OLED::print(translatedString(Tr->SleepingTipAdvancedString), FontStyle::SMALL);
|
OLED::print(translatedString(Tr->SleepingTipAdvancedString), FontStyle::SMALL);
|
||||||
OLED::printNumber(tipTemp, 3, FontStyle::SMALL);
|
OLED::printNumber(tipTemp, 3, FontStyle::SMALL);
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
|
||||||
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
|
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
|
||||||
else {
|
} else {
|
||||||
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
|
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,9 +47,10 @@ int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
|
|||||||
} else {
|
} else {
|
||||||
OLED::print(translatedString(Tr->SleepingSimpleString), FontStyle::LARGE);
|
OLED::print(translatedString(Tr->SleepingSimpleString), FontStyle::LARGE);
|
||||||
OLED::printNumber(tipTemp, 3, FontStyle::LARGE);
|
OLED::printNumber(tipTemp, 3, FontStyle::LARGE);
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
|
||||||
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
OLED::drawSymbol(0);
|
OLED::drawSymbol(0);
|
||||||
else {
|
} else {
|
||||||
OLED::drawSymbol(1);
|
OLED::drawSymbol(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,9 +65,11 @@ int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
|
|||||||
if (shouldShutdown()) {
|
if (shouldShutdown()) {
|
||||||
// shutdown
|
// shutdown
|
||||||
currentTempTargetDegC = 0;
|
currentTempTargetDegC = 0;
|
||||||
return 1; // we want to exit soldering mode
|
// we want to exit soldering mode
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,15 +147,15 @@ void gui_solderingMode(uint8_t jumpToSleep) {
|
|||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
// Update the setpoints for the temperature
|
// Update the setpoints for the temperature
|
||||||
if (boostModeOn) {
|
if (boostModeOn) {
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
currentTempTargetDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::BoostTemp));
|
currentTempTargetDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::BoostTemp));
|
||||||
else {
|
} else {
|
||||||
currentTempTargetDegC = (getSettingValue(SettingsOptions::BoostTemp));
|
currentTempTargetDegC = (getSettingValue(SettingsOptions::BoostTemp));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
currentTempTargetDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::SolderingTemp));
|
currentTempTargetDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::SolderingTemp));
|
||||||
else {
|
} else {
|
||||||
currentTempTargetDegC = (getSettingValue(SettingsOptions::SolderingTemp));
|
currentTempTargetDegC = (getSettingValue(SettingsOptions::SolderingTemp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,4 +187,3 @@ void gui_solderingMode(uint8_t jumpToSleep) {
|
|||||||
GUIDelay();
|
GUIDelay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ void gui_solderingProfileMode() {
|
|||||||
* --> Long hold back button to exit
|
* --> Long hold back button to exit
|
||||||
* --> Double button to exit
|
* --> Double button to exit
|
||||||
*/
|
*/
|
||||||
currentMode = OperatingMode::soldering;
|
currentMode = OperatingMode::soldering;
|
||||||
|
|
||||||
TickType_t buzzerEnd = 0;
|
TickType_t buzzerEnd = 0;
|
||||||
|
|
||||||
bool waitForRelease = true;
|
bool waitForRelease = true;
|
||||||
TickType_t phaseStartTime = xTaskGetTickCount();
|
TickType_t phaseStartTime = xTaskGetTickCount();
|
||||||
|
|
||||||
uint16_t tipTemp = 0;
|
uint16_t tipTemp = 0;
|
||||||
uint8_t profilePhase = 0;
|
uint8_t profilePhase = 0;
|
||||||
|
|
||||||
uint16_t phaseElapsedSeconds = 0;
|
uint16_t phaseElapsedSeconds = 0;
|
||||||
uint16_t phaseTotalSeconds = 0;
|
uint16_t phaseTotalSeconds = 0;
|
||||||
@@ -32,24 +32,26 @@ void gui_solderingProfileMode() {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
ButtonState buttons = getButtonState();
|
ButtonState buttons = getButtonState();
|
||||||
if (buttons) {
|
if (buttons) {
|
||||||
if (waitForRelease) buttons = BUTTON_NONE;
|
if (waitForRelease) {
|
||||||
|
buttons = BUTTON_NONE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
waitForRelease = false;
|
waitForRelease = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (buttons) {
|
switch (buttons) {
|
||||||
case BUTTON_NONE:
|
case BUTTON_NONE:
|
||||||
break;
|
break;
|
||||||
case BUTTON_BOTH:
|
case BUTTON_BOTH:
|
||||||
case BUTTON_B_LONG:
|
case BUTTON_B_LONG:
|
||||||
return; // exit on back long hold
|
return; // exit on back long hold
|
||||||
case BUTTON_F_LONG:
|
case BUTTON_F_LONG:
|
||||||
case BUTTON_F_SHORT:
|
case BUTTON_F_SHORT:
|
||||||
case BUTTON_B_SHORT:
|
case BUTTON_B_SHORT:
|
||||||
// Not used yet
|
// Not used yet
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
@@ -73,39 +75,41 @@ void gui_solderingProfileMode() {
|
|||||||
// have we finished this phase?
|
// have we finished this phase?
|
||||||
if (phaseElapsedSeconds >= phaseTotalSeconds && tipTemp == phaseEndTemp) {
|
if (phaseElapsedSeconds >= phaseTotalSeconds && tipTemp == phaseEndTemp) {
|
||||||
profilePhase++;
|
profilePhase++;
|
||||||
phaseStartTemp = phaseEndTemp;
|
|
||||||
phaseStartTime = xTaskGetTickCount();
|
phaseStartTemp = phaseEndTemp;
|
||||||
|
phaseStartTime = xTaskGetTickCount();
|
||||||
phaseElapsedSeconds = 0;
|
phaseElapsedSeconds = 0;
|
||||||
|
|
||||||
if (profilePhase > getSettingValue(SettingsOptions::ProfilePhases)) {
|
if (profilePhase > getSettingValue(SettingsOptions::ProfilePhases)) {
|
||||||
// done with all phases, lets go to cooldown
|
// done with all phases, lets go to cooldown
|
||||||
phaseTotalSeconds = 0;
|
phaseTotalSeconds = 0;
|
||||||
phaseEndTemp = 0;
|
phaseEndTemp = 0;
|
||||||
phaseTicksPerDegree = TICKS_SECOND / getSettingValue(SettingsOptions::ProfileCooldownSpeed);
|
phaseTicksPerDegree = TICKS_SECOND / getSettingValue(SettingsOptions::ProfileCooldownSpeed);
|
||||||
} else {
|
} else {
|
||||||
// set up next phase
|
// set up next phase
|
||||||
switch(profilePhase) {
|
switch (profilePhase) {
|
||||||
case 1:
|
case 1:
|
||||||
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase1Duration);
|
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase1Duration);
|
||||||
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase1Temp);
|
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase1Temp);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase2Duration);
|
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase2Duration);
|
||||||
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase2Temp);
|
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase2Temp);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase3Duration);
|
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase3Duration);
|
||||||
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase3Temp);
|
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase3Temp);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase4Duration);
|
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase4Duration);
|
||||||
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase4Temp);
|
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase4Temp);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase5Duration);
|
phaseTotalSeconds = getSettingValue(SettingsOptions::ProfilePhase5Duration);
|
||||||
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase5Temp);
|
phaseEndTemp = getSettingValue(SettingsOptions::ProfilePhase5Temp);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (phaseStartTemp < phaseEndTemp) {
|
if (phaseStartTemp < phaseEndTemp) {
|
||||||
phaseTicksPerDegree = (phaseTotalSeconds * TICKS_SECOND) / (phaseEndTemp - phaseStartTemp);
|
phaseTicksPerDegree = (phaseTotalSeconds * TICKS_SECOND) / (phaseEndTemp - phaseStartTemp);
|
||||||
@@ -152,10 +156,11 @@ void gui_solderingProfileMode() {
|
|||||||
OLED::print(SmallSymbolSlash, FontStyle::SMALL);
|
OLED::print(SmallSymbolSlash, FontStyle::SMALL);
|
||||||
OLED::printNumber(profileCurrentTargetTemp, 3, FontStyle::SMALL);
|
OLED::printNumber(profileCurrentTargetTemp, 3, FontStyle::SMALL);
|
||||||
|
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
|
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
|
||||||
else
|
} else {
|
||||||
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
|
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
|
||||||
|
}
|
||||||
|
|
||||||
// print phase
|
// print phase
|
||||||
if (profilePhase > 0 && profilePhase <= getSettingValue(SettingsOptions::ProfilePhases)) {
|
if (profilePhase > 0 && profilePhase <= getSettingValue(SettingsOptions::ProfilePhases)) {
|
||||||
@@ -186,7 +191,7 @@ void gui_solderingProfileMode() {
|
|||||||
OLED::print(SmallSymbolSlash, FontStyle::SMALL);
|
OLED::print(SmallSymbolSlash, FontStyle::SMALL);
|
||||||
|
|
||||||
// blink if we can't keep up with the time goal
|
// blink if we can't keep up with the time goal
|
||||||
if (phaseElapsedSeconds < phaseTotalSeconds+2 || (xTaskGetTickCount() / TICKS_SECOND) % 2 == 0) {
|
if (phaseElapsedSeconds < phaseTotalSeconds + 2 || (xTaskGetTickCount() / TICKS_SECOND) % 2 == 0) {
|
||||||
OLED::printNumber(phaseTotalSeconds / 60, 1, FontStyle::SMALL);
|
OLED::printNumber(phaseTotalSeconds / 60, 1, FontStyle::SMALL);
|
||||||
OLED::print(SmallSymbolColon, FontStyle::SMALL);
|
OLED::print(SmallSymbolColon, FontStyle::SMALL);
|
||||||
OLED::printNumber(phaseTotalSeconds % 60, 2, FontStyle::SMALL, false);
|
OLED::printNumber(phaseTotalSeconds % 60, 2, FontStyle::SMALL, false);
|
||||||
@@ -225,4 +230,3 @@ void gui_solderingProfileMode() {
|
|||||||
GUIDelay();
|
GUIDelay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "OperatingModes.h"
|
#include "OperatingModes.h"
|
||||||
void gui_solderingTempAdjust(void) {
|
void gui_solderingTempAdjust(void) {
|
||||||
TickType_t lastChange = xTaskGetTickCount();
|
TickType_t lastChange = xTaskGetTickCount();
|
||||||
currentTempTargetDegC = 0; // Turn off heater while adjusting temp
|
currentTempTargetDegC = 0; // Turn off heater while adjusting temp
|
||||||
TickType_t autoRepeatTimer = 0;
|
TickType_t autoRepeatTimer = 0;
|
||||||
uint8_t autoRepeatAcceleration = 0;
|
uint8_t autoRepeatAcceleration = 0;
|
||||||
#ifndef PROFILE_SUPPORT
|
#ifndef PROFILE_SUPPORT
|
||||||
bool waitForRelease = false;
|
bool waitForRelease = false;
|
||||||
ButtonState buttons = getButtonState();
|
ButtonState buttons = getButtonState();
|
||||||
|
|
||||||
if (buttons != BUTTON_NONE) {
|
if (buttons != BUTTON_NONE) {
|
||||||
// Temp adjust entered by long-pressing F button.
|
// Temp adjust entered by long-pressing F button.
|
||||||
@@ -79,20 +79,25 @@ void gui_solderingTempAdjust(void) {
|
|||||||
newTemp = (newTemp / delta) * delta;
|
newTemp = (newTemp / delta) * delta;
|
||||||
|
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
if (newTemp > MAX_TEMP_F)
|
if (newTemp > MAX_TEMP_F) {
|
||||||
newTemp = MAX_TEMP_F;
|
newTemp = MAX_TEMP_F;
|
||||||
if (newTemp < MIN_TEMP_F)
|
}
|
||||||
|
if (newTemp < MIN_TEMP_F) {
|
||||||
newTemp = MIN_TEMP_F;
|
newTemp = MIN_TEMP_F;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (newTemp > MAX_TEMP_C)
|
if (newTemp > MAX_TEMP_C) {
|
||||||
newTemp = MAX_TEMP_C;
|
newTemp = MAX_TEMP_C;
|
||||||
if (newTemp < MIN_TEMP_C)
|
}
|
||||||
|
if (newTemp < MIN_TEMP_C) {
|
||||||
newTemp = MIN_TEMP_C;
|
newTemp = MIN_TEMP_C;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setSettingValue(SettingsOptions::SolderingTemp, (uint16_t)newTemp);
|
setSettingValue(SettingsOptions::SolderingTemp, (uint16_t)newTemp);
|
||||||
}
|
}
|
||||||
if (xTaskGetTickCount() - lastChange > (TICKS_SECOND * 2))
|
if (xTaskGetTickCount() - lastChange > (TICKS_SECOND * 2)) {
|
||||||
return; // exit if user just doesn't press anything for a bit
|
return; // exit if user just doesn't press anything for a bit
|
||||||
|
}
|
||||||
|
|
||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolPlus : LargeSymbolMinus, FontStyle::LARGE);
|
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? LargeSymbolPlus : LargeSymbolMinus, FontStyle::LARGE);
|
||||||
@@ -102,9 +107,9 @@ void gui_solderingTempAdjust(void) {
|
|||||||
|
|
||||||
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
|
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
|
||||||
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::LARGE);
|
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::LARGE);
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
OLED::drawSymbol(0);
|
OLED::drawSymbol(0);
|
||||||
else {
|
} else {
|
||||||
OLED::drawSymbol(1);
|
OLED::drawSymbol(1);
|
||||||
}
|
}
|
||||||
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
|
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
|
||||||
@@ -116,4 +121,4 @@ void gui_solderingTempAdjust(void) {
|
|||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
GUIDelay();
|
GUIDelay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,11 +81,12 @@ void showPDDebug(void) {
|
|||||||
|
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
b = getButtonState();
|
b = getButtonState();
|
||||||
if (b == BUTTON_B_SHORT)
|
if (b == BUTTON_B_SHORT) {
|
||||||
return;
|
return;
|
||||||
else if (b == BUTTON_F_SHORT) {
|
} else if (b == BUTTON_F_SHORT) {
|
||||||
screen++;
|
screen++;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIDelay();
|
GUIDelay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,11 +43,12 @@ void showPDDebug(void) {
|
|||||||
|
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
b = getButtonState();
|
b = getButtonState();
|
||||||
if (b == BUTTON_B_SHORT)
|
if (b == BUTTON_B_SHORT) {
|
||||||
return;
|
return;
|
||||||
else if (b == BUTTON_F_SHORT) {
|
} else if (b == BUTTON_F_SHORT) {
|
||||||
screen++;
|
screen++;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIDelay();
|
GUIDelay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,16 +14,18 @@ void gui_drawTipTemp(bool symbol, const FontStyle font) {
|
|||||||
if (symbol) {
|
if (symbol) {
|
||||||
if (font == FontStyle::LARGE) {
|
if (font == FontStyle::LARGE) {
|
||||||
// Big font, can draw nice symbols
|
// Big font, can draw nice symbols
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
OLED::drawSymbol(0);
|
OLED::drawSymbol(0);
|
||||||
else
|
} else {
|
||||||
OLED::drawSymbol(1);
|
OLED::drawSymbol(1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Otherwise fall back to chars
|
// Otherwise fall back to chars
|
||||||
if (getSettingValue(SettingsOptions::TemperatureInF))
|
if (getSettingValue(SettingsOptions::TemperatureInF)) {
|
||||||
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
|
OLED::print(SmallSymbolDegF, FontStyle::SMALL);
|
||||||
else
|
} else {
|
||||||
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
|
OLED::print(SmallSymbolDegC, FontStyle::SMALL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
// Created by laura on 24.04.23.
|
// Created by laura on 24.04.23.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "OperatingModes.h"
|
|
||||||
#include "SolderingCommon.h"
|
#include "SolderingCommon.h"
|
||||||
|
#include "OperatingModes.h"
|
||||||
|
|
||||||
extern bool heaterThermalRunaway;
|
extern bool heaterThermalRunaway;
|
||||||
|
|
||||||
@@ -16,7 +16,8 @@ void detailedPowerStatus() {
|
|||||||
// Print wattage
|
// Print wattage
|
||||||
{
|
{
|
||||||
uint32_t x10Watt = x10WattHistory.average();
|
uint32_t x10Watt = x10WattHistory.average();
|
||||||
if (x10Watt > 999) { // If we exceed 99.9W we drop the decimal place to keep it all fitting
|
if (x10Watt > 999) {
|
||||||
|
// If we exceed 99.9W we drop the decimal place to keep it all fitting
|
||||||
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
|
OLED::print(SmallSymbolSpace, FontStyle::SMALL);
|
||||||
OLED::printNumber(x10WattHistory.average() / 10, 3, FontStyle::SMALL);
|
OLED::printNumber(x10WattHistory.average() / 10, 3, FontStyle::SMALL);
|
||||||
} else {
|
} else {
|
||||||
@@ -42,30 +43,35 @@ void basicSolderingStatus(bool boostModeOn) {
|
|||||||
if (OLED::getRotation()) {
|
if (OLED::getRotation()) {
|
||||||
// battery
|
// battery
|
||||||
gui_drawBatteryIcon();
|
gui_drawBatteryIcon();
|
||||||
OLED::print(LargeSymbolSpace, FontStyle::LARGE); // Space out gap between battery <-> temp
|
// Space out gap between battery <-> temp
|
||||||
gui_drawTipTemp(true, FontStyle::LARGE); // Draw current tip temp
|
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
|
||||||
|
// Draw current tip temp
|
||||||
|
gui_drawTipTemp(true, FontStyle::LARGE);
|
||||||
|
|
||||||
// We draw boost arrow if boosting, or else gap temp <-> heat
|
// We draw boost arrow if boosting,
|
||||||
// indicator
|
// or else gap temp <-> heat indicator
|
||||||
if (boostModeOn)
|
if (boostModeOn) {
|
||||||
OLED::drawSymbol(2);
|
OLED::drawSymbol(2);
|
||||||
else
|
} else {
|
||||||
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
|
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw heating/cooling symbols
|
// Draw heating/cooling symbols
|
||||||
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
|
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
|
||||||
} else {
|
} else {
|
||||||
// Draw heating/cooling symbols
|
// Draw heating/cooling symbols
|
||||||
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
|
OLED::drawHeatSymbol(X10WattsToPWM(x10WattHistory.average()));
|
||||||
// We draw boost arrow if boosting, or else gap temp <-> heat
|
// We draw boost arrow if boosting,
|
||||||
// indicator
|
// or else gap temp <-> heat indicator
|
||||||
if (boostModeOn)
|
if (boostModeOn) {
|
||||||
OLED::drawSymbol(2);
|
OLED::drawSymbol(2);
|
||||||
else
|
} else {
|
||||||
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
|
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
|
||||||
gui_drawTipTemp(true, FontStyle::LARGE); // Draw current tip temp
|
}
|
||||||
|
// Draw current tip temp
|
||||||
OLED::print(LargeSymbolSpace, FontStyle::LARGE); // Space out gap between battery <-> temp
|
gui_drawTipTemp(true, FontStyle::LARGE);
|
||||||
|
// Space out gap between battery <-> temp
|
||||||
|
OLED::print(LargeSymbolSpace, FontStyle::LARGE);
|
||||||
|
|
||||||
gui_drawBatteryIcon();
|
gui_drawBatteryIcon();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ void gui_drawBatteryIcon(void) {
|
|||||||
// On non-DC inputs we replace this symbol with the voltage we are operating on
|
// On non-DC inputs we replace this symbol with the voltage we are operating on
|
||||||
// If <9V then show single digit, if not show dual small ones vertically stacked
|
// If <9V then show single digit, if not show dual small ones vertically stacked
|
||||||
uint16_t V = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
|
uint16_t V = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
|
||||||
if (V % 10 >= 5)
|
if (V % 10 >= 5) {
|
||||||
V = (V / 10) + 1; // round up
|
V = (V / 10) + 1; // round up
|
||||||
else
|
} else {
|
||||||
V = V / 10;
|
V = V / 10;
|
||||||
|
}
|
||||||
if (V > 9) {
|
if (V > 9) {
|
||||||
int16_t xPos = OLED::getCursorX();
|
int16_t xPos = OLED::getCursorX();
|
||||||
OLED::printNumber(V / 10, 1, FontStyle::SMALL);
|
OLED::printNumber(V / 10, 1, FontStyle::SMALL);
|
||||||
@@ -30,14 +31,16 @@ void gui_drawBatteryIcon(void) {
|
|||||||
uint32_t cellV = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0) / cellCount;
|
uint32_t cellV = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0) / cellCount;
|
||||||
// Should give us approx cell voltage X10
|
// Should give us approx cell voltage X10
|
||||||
// Range is 42 -> Minimum voltage setting (systemSettings.minVoltageCells) = 9 steps therefore we will use battery 0-9
|
// Range is 42 -> Minimum voltage setting (systemSettings.minVoltageCells) = 9 steps therefore we will use battery 0-9
|
||||||
if (cellV < getSettingValue(SettingsOptions::MinVoltageCells))
|
if (cellV < getSettingValue(SettingsOptions::MinVoltageCells)) {
|
||||||
cellV = getSettingValue(SettingsOptions::MinVoltageCells);
|
cellV = getSettingValue(SettingsOptions::MinVoltageCells);
|
||||||
|
}
|
||||||
cellV -= getSettingValue(SettingsOptions::MinVoltageCells); // Should leave us a number of 0-9
|
cellV -= getSettingValue(SettingsOptions::MinVoltageCells); // Should leave us a number of 0-9
|
||||||
if (cellV > 9)
|
if (cellV > 9) {
|
||||||
cellV = 9;
|
cellV = 9;
|
||||||
|
}
|
||||||
OLED::drawBattery(cellV + 1);
|
OLED::drawBattery(cellV + 1);
|
||||||
} else {
|
} else {
|
||||||
OLED::drawSymbol(15); // Draw the DC Logo
|
OLED::drawSymbol(15); // Draw the DC Logo
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,13 @@ uint32_t getSleepTimeout(void) {
|
|||||||
if (getSettingValue(SettingsOptions::Sensitivity) && getSettingValue(SettingsOptions::SleepTime)) {
|
if (getSettingValue(SettingsOptions::Sensitivity) && getSettingValue(SettingsOptions::SleepTime)) {
|
||||||
|
|
||||||
uint32_t sleepThres = 0;
|
uint32_t sleepThres = 0;
|
||||||
if (getSettingValue(SettingsOptions::SleepTime) < 6)
|
if (getSettingValue(SettingsOptions::SleepTime) < 6) {
|
||||||
sleepThres = getSettingValue(SettingsOptions::SleepTime) * 10 * 1000;
|
sleepThres = getSettingValue(SettingsOptions::SleepTime) * 10 * 1000;
|
||||||
else
|
} else {
|
||||||
sleepThres = (getSettingValue(SettingsOptions::SleepTime) - 5) * 60 * 1000;
|
sleepThres = (getSettingValue(SettingsOptions::SleepTime) - 5) * 60 * 1000;
|
||||||
|
}
|
||||||
return sleepThres;
|
return sleepThres;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
#include "OperatingModeUtilities.h"
|
#include "OperatingModeUtilities.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
uint16_t min(uint16_t a, uint16_t b) {
|
uint16_t min(uint16_t a, uint16_t b) {
|
||||||
if (a > b)
|
if (a > b) {
|
||||||
return b;
|
return b;
|
||||||
else
|
} else {
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ bool shouldBeSleeping(bool inAutoStart) {
|
|||||||
// threshold, and if so then we force sleep
|
// threshold, and if so then we force sleep
|
||||||
if (getHallSensorFitted() && lookupHallEffectThreshold()) {
|
if (getHallSensorFitted() && lookupHallEffectThreshold()) {
|
||||||
int16_t hallEffectStrength = getRawHallEffect();
|
int16_t hallEffectStrength = getRawHallEffect();
|
||||||
if (hallEffectStrength < 0)
|
if (hallEffectStrength < 0) {
|
||||||
hallEffectStrength = -hallEffectStrength;
|
hallEffectStrength = -hallEffectStrength;
|
||||||
|
}
|
||||||
// Have absolute value of measure of magnetic field strength
|
// Have absolute value of measure of magnetic field strength
|
||||||
if (hallEffectStrength > lookupHallEffectThreshold()) {
|
if (hallEffectStrength > lookupHallEffectThreshold()) {
|
||||||
if (lastHallEffectSleepStart == 0) {
|
if (lastHallEffectSleepStart == 0) {
|
||||||
@@ -43,4 +44,4 @@ bool shouldBeSleeping(bool inAutoStart) {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
|
|
||||||
// Small worker thread to handle power (PD + QC) related steps
|
// Small worker thread to handle power (PD + QC) related steps
|
||||||
|
|
||||||
void startPOWTask(void const *argument __unused) {
|
void startPOWTask(void const *argument __unused) {
|
||||||
|
|||||||
1061
source/Makefile
1061
source/Makefile
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user