Compare commits
121 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
48d4d920be | |
|
|
b2dd038814 | |
|
|
3aed994b9c | |
|
|
e089be4ff8 | |
|
|
9e3b300b2e | |
|
|
9c23658445 | |
|
|
3d32c300a3 | |
|
|
f4388b8d20 | |
|
|
5d8fa524fb | |
|
|
42cb40eeb9 | |
|
|
06f41bf1e6 | |
|
|
b6bdd55def | |
|
|
c1aa190d05 | |
|
|
88a241c741 | |
|
|
7a250c24db | |
|
|
39b24f8b43 | |
|
|
22a8f1df57 | |
|
|
ceda1cce08 | |
|
|
5e50516fe7 | |
|
|
454619bfd4 | |
|
|
f240bb24d1 | |
|
|
b00ac883c4 | |
|
|
9e44c06f1e | |
|
|
e9889ec066 | |
|
|
4e4e2df739 | |
|
|
b8ed9abc7f | |
|
|
e28ab28824 | |
|
|
255dc8726a | |
|
|
b23d6827a7 | |
|
|
dc68b70cff | |
|
|
0eeef4cafd | |
|
|
4ab07d627a | |
|
|
0a205e41ff | |
|
|
3c8663d900 | |
|
|
195aad9cf0 | |
|
|
e7abc6a7d8 | |
|
|
32d5f3b4be | |
|
|
ca1d09ad15 | |
|
|
89d3c6fc47 | |
|
|
75570a82ff | |
|
|
3cd341f95f | |
|
|
5d0f772270 | |
|
|
3ee1e22e9a | |
|
|
ef23490a49 | |
|
|
08171415ca | |
|
|
5ed48aee0b | |
|
|
00fd54f7a4 | |
|
|
e14175d9cd | |
|
|
2933737b3b | |
|
|
878c763878 | |
|
|
6ca0d650da | |
|
|
df97d70d8e | |
|
|
8b04f7f9c7 | |
|
|
3a28bfe887 | |
|
|
1c0c732291 | |
|
|
cc5c425538 | |
|
|
67e3a3c06c | |
|
|
d510e1e482 | |
|
|
58577b832d | |
|
|
19a0cd3ebb | |
|
|
ce0df08b89 | |
|
|
d68ccd6552 | |
|
|
f019de539b | |
|
|
4845d0b335 | |
|
|
6b96f983c0 | |
|
|
8d6e4d1be5 | |
|
|
a5ca4612d2 | |
|
|
fb65f4e563 | |
|
|
09bacabb05 | |
|
|
a7286de016 | |
|
|
b0eac8f523 | |
|
|
dda3899156 | |
|
|
03b0d6f776 | |
|
|
18a040c278 | |
|
|
8073ce66fb | |
|
|
515b93e9e7 | |
|
|
c60d562c8c | |
|
|
6340421f51 | |
|
|
1d1d2f23ec | |
|
|
fe354a1f51 | |
|
|
4e9ad80384 | |
|
|
fbb00f38d3 | |
|
|
1f66a8b908 | |
|
|
e2f396e2a2 | |
|
|
2e02eccd91 | |
|
|
f6a943812f | |
|
|
d68efb994e | |
|
|
90c1601159 | |
|
|
063130726a | |
|
|
3f4658dd56 | |
|
|
3924cb3d4f | |
|
|
ad03df4271 | |
|
|
1ebc4995d0 | |
|
|
36ae4fc250 | |
|
|
8d9e9ea8b6 | |
|
|
ee2ffba0c3 | |
|
|
3189e7845d | |
|
|
c90db080e5 | |
|
|
b9677f922a | |
|
|
8e7f3d8b96 | |
|
|
6a0f49859e | |
|
|
034d007b33 | |
|
|
ad2e944531 | |
|
|
fbda9faa2a | |
|
|
11d205484b | |
|
|
0419bdefd7 | |
|
|
19aa7ce2c7 | |
|
|
41f5d29083 | |
|
|
570153b5d4 | |
|
|
3a105cab4a | |
|
|
77a8788821 | |
|
|
93a344bde8 | |
|
|
96985c1502 | |
|
|
1661132819 | |
|
|
f164a8afa0 | |
|
|
169925fc9f | |
|
|
5293547094 | |
|
|
35a89d2452 | |
|
|
aaee8cab30 | |
|
|
1979d02027 | |
|
|
040cb8a2a6 |
|
|
@ -0,0 +1,11 @@
|
|||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Questions and Discussions
|
||||
url: https://github.com/prusa3d/Prusa-Firmware-MMU/discussions
|
||||
about: Please use Discussions for questions, chat, and open-ended ideas. Be sure to search before creating a new topic, your question may already have been answered!
|
||||
- name: Issues with an MMU3 on a Prusa MK3S/MK3S+
|
||||
url: https://github.com/prusa3d/Prusa-Firmware/issues
|
||||
about: If you have an issue or bug pertaining to the MMU3 on an 8-bit Prusa Printer, create it here.
|
||||
- name: Issues with an MMU3 on a Prusa MK3.9/MK4
|
||||
url: https://github.com/prusa3d/Prusa-Firmware-Buddy/issues
|
||||
about: If you have an issue or bug pertaining to the MMU3 on a 32-bit Prusa Printer, create it here.
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
name: ci-build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
push:
|
||||
branches: [ main, MMU_* ]
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
|
||||
# setup base required dependencies
|
||||
- name: Setup dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install cmake ninja-build python3-pyelftools python3-regex python3-polib
|
||||
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- name: Checkout ${{ github.event.pull_request.head.ref }}
|
||||
uses: actions/checkout@v4
|
||||
if: ${{ github.event.pull_request }}
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
submodules: true
|
||||
|
||||
- name: Checkout ${{ github.event.ref }}
|
||||
uses: actions/checkout@v4
|
||||
if: ${{ !github.event.pull_request }}
|
||||
with:
|
||||
ref: ${{ github.event.ref }}
|
||||
submodules: true
|
||||
|
||||
- name: Cache Dependencies
|
||||
uses: actions/cache@v4
|
||||
id: cache-pkgs
|
||||
with:
|
||||
path: ".dependencies"
|
||||
key: "build-deps-1_0_0-linux"
|
||||
|
||||
- name: Setup build dependencies
|
||||
run: |
|
||||
./utils/bootstrap.py
|
||||
|
||||
- name: Cache permissions
|
||||
run: sudo chmod -R 744 .dependencies
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE="../cmake/AvrGcc.cmake" -DCMAKE_BUILD_TYPE=Release -G Ninja
|
||||
ninja
|
||||
|
||||
- name: Upload artifacts
|
||||
if: ${{ !github.event.pull_request }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Firmware
|
||||
path: build/*.hex
|
||||
|
||||
- name: RELEASE THE KRAKEN
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: "marvinpinto/action-automatic-releases@latest"
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
draft: true
|
||||
files: |
|
||||
build/autopublish/*.hex
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#!/bin/sh
|
||||
MESSAGE=$1
|
||||
BASE_DIR=$2
|
||||
PR_DIR=$3
|
||||
shift 3
|
||||
|
||||
# this assumes we're running from the repository root
|
||||
AVR_SIZE=$(echo .dependencies/avr-gcc-*/bin/avr-size)
|
||||
test -x "$AVR_SIZE" || exit 2
|
||||
|
||||
avr_size()
|
||||
{
|
||||
"$AVR_SIZE" --mcu=atmel32u4 -C "$@"
|
||||
}
|
||||
|
||||
avr_flash()
|
||||
{
|
||||
avr_size "$@" | sed -ne 's/^Program: *\([0-9]\+\).*/\1/p'
|
||||
}
|
||||
|
||||
avr_ram()
|
||||
{
|
||||
avr_size "$@" | sed -ne 's/^Data: *\([0-9]\+\).*/\1/p'
|
||||
}
|
||||
|
||||
cat <<EOF > "$MESSAGE"
|
||||
All values in bytes. Δ Delta to base
|
||||
|
||||
| ΔFlash | ΔSRAM | Used Flash | Used SRAM | Free Flash | Free SRAM |
|
||||
| ------ | ----- | -----------| --------- | ---------- | --------- |
|
||||
EOF
|
||||
|
||||
atmel32u4_max_upload_size=$(grep "prusa_mm_control.upload.maximum_size=" .dependencies/prusa3dboards-*/boards.txt | cut -d "=" -f2)
|
||||
atmel32u4_max_upload_data_size=$(grep "prusa_mm_control.upload.maximum_data_size=" .dependencies/prusa3dboards-*/boards.txt | cut -d "=" -f2)
|
||||
|
||||
base_bin=$(echo ${BASE_DIR}/firmware)
|
||||
base_flash=$(avr_flash "$base_bin")
|
||||
base_ram=$(avr_ram "$base_bin")
|
||||
|
||||
pr_bin=$(echo ${PR_DIR}/firmware)
|
||||
pr_flash=$(avr_flash "$pr_bin")
|
||||
pr_ram=$(avr_ram "$pr_bin")
|
||||
|
||||
flash_d=$(($pr_flash - $base_flash))
|
||||
ram_d=$(($pr_ram - $base_ram))
|
||||
|
||||
flash_free=$(($atmel32u4_max_upload_size - $pr_flash))
|
||||
ram_free=$(($atmel32u4_max_upload_data_size - $pr_ram))
|
||||
|
||||
echo "| $flash_d | $ram_d | $pr_flash | $pr_ram | $flash_free | $ram_free |" >> "$MESSAGE"
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
name: pr-size
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
branches: [ main, MMU_* ]
|
||||
|
||||
env:
|
||||
TARGETS: "firmware"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
|
||||
# setup base required dependencies
|
||||
- name: Setup dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install cmake ninja-build python3-pyelftools python3-regex python3-polib
|
||||
|
||||
# build the base branch
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache Dependencies
|
||||
uses: actions/cache@v4
|
||||
id: cache-pkgs
|
||||
with:
|
||||
path: ".dependencies"
|
||||
key: "build-deps-1_0_0-linux"
|
||||
|
||||
- name: Setup build dependencies
|
||||
run: |
|
||||
./utils/bootstrap.py
|
||||
|
||||
- name: Cache permissions
|
||||
run: sudo chmod -R 744 .dependencies
|
||||
|
||||
- name: Build base
|
||||
run: |
|
||||
rm -rf build-base
|
||||
mkdir build-base
|
||||
cd build-base
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE="../cmake/AvrGcc.cmake" -DCMAKE_BUILD_TYPE=Release -G Ninja
|
||||
ninja
|
||||
|
||||
# save pr-size for later use
|
||||
- name: Save base data
|
||||
run: |
|
||||
cp -f ./.github/workflows/pr-size.sh build-base
|
||||
|
||||
# build the PR branch
|
||||
- name: Checkout PR
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
clean: false
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: Build PR
|
||||
run: |
|
||||
rm -rf build-pr
|
||||
mkdir build-pr
|
||||
cd build-pr
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE="../cmake/AvrGcc.cmake" -DCMAKE_BUILD_TYPE=Release -G Ninja
|
||||
ninja
|
||||
|
||||
# extract/show build differences
|
||||
- name: Calculate binary changes
|
||||
run: |
|
||||
rm -rf build-changes
|
||||
./build-base/pr-size.sh build-changes build-base build-pr
|
||||
|
||||
- name: Add PR Comment
|
||||
uses: mshick/add-pr-comment@v2.8.2
|
||||
with:
|
||||
message-path: build-changes
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
name: Mark stale issues
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# 1:30 AM on MON/THU
|
||||
- cron: "30 1 * * 1,2,3,4"
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Don't ever mark PRs as stale.
|
||||
days-before-pr-stale: -1
|
||||
stale-issue-message: 'This issue has been flagged as stale because it has been open for 60 days with no activity. The issue will be closed in 7 days unless someone removes the "stale" label or adds a comment.'
|
||||
close-issue-message: 'This issue has been closed due to lack of recent activity.'
|
||||
# Don't act on things assigned to a milestone or assigned to someone.
|
||||
exempt-all-milestones: true
|
||||
exempt-all-assignees: true
|
||||
enable-statistics: true
|
||||
# Disable this and change the operations per run back to 30 when this goes live.
|
||||
debug-only: false
|
||||
operations-per-run: 30
|
||||
stale-issue-label: 'stale-issue'
|
||||
stale-pr-label: 'stale-pr'
|
||||
ascending: true
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
name: tests
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
branches: [ main, MMU_* ]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
|
||||
# setup base required dependencies
|
||||
- name: Setup dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-11 g++11 lcov cmake ninja-build python3-pyelftools python3-regex python3-polib
|
||||
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- name: Checkout ${{ github.event.pull_request.head.ref }}
|
||||
uses: actions/checkout@v4
|
||||
if: ${{ github.event.pull_request }}
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
submodules: true
|
||||
|
||||
- name: Checkout ${{ github.event.ref }}
|
||||
uses: actions/checkout@v4
|
||||
if: ${{ !github.event.pull_request }}
|
||||
with:
|
||||
ref: ${{ github.event.ref }}
|
||||
submodules: true
|
||||
|
||||
- name: Cache Dependencies
|
||||
uses: actions/cache@v4
|
||||
id: cache-pkgs
|
||||
with:
|
||||
path: ".dependencies"
|
||||
key: "build-deps-1_0_0-linux"
|
||||
|
||||
- name: Setup build dependencies
|
||||
run: |
|
||||
./utils/bootstrap.py
|
||||
|
||||
- name: Cache permissions
|
||||
run: sudo chmod -R 744 .dependencies
|
||||
|
||||
- name: Build
|
||||
id: tests_run
|
||||
continue-on-error: true
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -G Ninja
|
||||
ninja test_coverage_report
|
||||
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Coverage
|
||||
path: build/Coverage
|
||||
|
||||
- name: Add PR Comment
|
||||
if: ${{ github.event.pull_request }}
|
||||
uses: mshick/add-pr-comment@v2.8.2
|
||||
with:
|
||||
message-path: build/Summary.txt
|
||||
message-id: "coverage"
|
||||
|
||||
- name: Report failure
|
||||
if: steps.tests_run.outcome == 'failure'
|
||||
run: echo ${{ steps.tests_run.outcome }} && test -n ""
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
"name": "avr-gcc",
|
||||
"toolchainFile": "${workspaceFolder}/cmake/AvrGcc.cmake",
|
||||
"cmakeSettings": {
|
||||
"CMAKE_MAKE_PROGRAM": "${workspaceFolder}/.dependencies/ninja-1.10.2/ninja",
|
||||
"CMAKE_MAKE_PROGRAM": "${workspaceFolder}/.dependencies/ninja-1.12.1/ninja",
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ set(BUILD_NUMBER
|
|||
""
|
||||
CACHE STRING "Build number of the firmware. Resolved automatically if not specified."
|
||||
)
|
||||
set(PROJECT_VERSION_TIMESTAMP
|
||||
""
|
||||
CACHE STRING "Timestamp for the build. Resolved automatically if not specified."
|
||||
)
|
||||
set(CUSTOM_COMPILE_OPTIONS
|
||||
""
|
||||
CACHE STRING "Allows adding custom C/C++ flags"
|
||||
|
|
@ -96,8 +100,8 @@ add_compile_options(-g)
|
|||
|
||||
# optimizations
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
# TODO: get date from the last git commit to set as epoch
|
||||
set_source_epoch(0)
|
||||
# set source epoch
|
||||
set_source_epoch(${PROJECT_VERSION_TIMESTAMP})
|
||||
|
||||
# default optimization flags
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
|
||||
|
|
@ -155,12 +159,10 @@ set_target_properties(firmware PROPERTIES CXX_STANDARD 17)
|
|||
set_target_properties(firmware PROPERTIES INTERPROCEDURAL_OPTIMIZATION True)
|
||||
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
#[[
|
||||
# configure linker script
|
||||
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/src/avr5.xn)
|
||||
target_link_options(firmware PUBLIC -Wl,-T,${LINKER_SCRIPT})
|
||||
add_link_dependency(firmware ${LINKER_SCRIPT})
|
||||
#]]
|
||||
|
||||
# limit the text section to 28K (32K - 4k reserved for the bootloader)
|
||||
target_link_options(firmware PUBLIC -Wl,--defsym=__TEXT_REGION_LENGTH__=28K)
|
||||
|
|
@ -179,7 +181,11 @@ if(CMAKE_CROSSCOMPILING)
|
|||
COMMAND ${CMAKE_OBJCOPY} firmware -O binary --gap-fill 0xFF --pad-to 0x00007000 firmware.bin
|
||||
COMMAND ${CMAKE_COMMAND} -E cat firmware.bin bootloader.bin > fw_bootloader.bin
|
||||
COMMAND ${CMAKE_OBJCOPY} -I binary -O ihex fw_bootloader.bin
|
||||
"MMU2SR_${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}_bootloader.hex"
|
||||
"MMU2S_MMU3_BOOTLOADER_${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}.hex"
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy
|
||||
"MMU2S_MMU3_BOOTLOADER_${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}.hex"
|
||||
"MMU2S_MMU3_BOOTLOADER_${PROJECT_VERSION}.hex"
|
||||
BYPRODUCTS bootloader.bin firmware.bin fw_bootloader.bin
|
||||
)
|
||||
|
||||
|
|
@ -208,8 +214,14 @@ if(CMAKE_CROSSCOMPILING)
|
|||
POST_BUILD
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -D WORK_DIR=${CMAKE_BINARY_DIR} -D
|
||||
HEX_NAME="MMU2SR_${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}.hex" -P
|
||||
HEX_NAME="MMU2S_MMU3_FW${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}.hex" -P
|
||||
${CMAKE_SOURCE_DIR}/cmake/HexConcat.cmake DEPENDS firmware.hex
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy "MMU2S_MMU3_FW${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}.hex"
|
||||
"MMU2S_MMU3_FW${PROJECT_VERSION}.hex"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/autopublish
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
"MMU2S_MMU3_FW${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}.hex" "autopublish/"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
|
|
|||
2
Doxyfile
2
Doxyfile
|
|
@ -44,7 +44,7 @@ PROJECT_NUMBER =
|
|||
# for a project that appears at the top of each page and should give viewer a
|
||||
# quick idea about the purpose of the project. Keep the description short.
|
||||
|
||||
PROJECT_BRIEF = PrusaMultiMaterialUpgradev2firmwareforMK4
|
||||
PROJECT_BRIEF = PrusaMultiMaterialUpgradev3firmwareforMK3SMK4
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
|
|
|||
|
|
@ -0,0 +1,861 @@
|
|||
This firmware for the Original Prusa MMU3 and Original Prusa MMU2/S is distributed under the following licenses:
|
||||
|
||||
- The firmware source code is licensed under the GNU General Public License v3.0. Meaning you and your company can use the code both for the commercial and non-commercial activities, but you have to fulfil the requirements of the license. Read more about the permissions and limitations below.
|
||||
- The graphics and design are licensed under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). Meaning you and your company are strictly prohibited from using these elements in a commercial product. You have to create your own graphics and design. Read more about the permissions and limitations below. Violating these conditions will lead to a legal dispute.
|
||||
|
||||
Original Prusa® MMU3 and Original Prusa® MMU2S are registered trademarks of Prusa Research a.s.
|
||||
|
||||
---
|
||||
|
||||
### GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
### Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom
|
||||
to share and change all versions of a program--to make sure it remains
|
||||
free software for all its users. We, the Free Software Foundation, use
|
||||
the GNU General Public License for most of our software; it applies
|
||||
also to any other work released this way by its authors. You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you
|
||||
have certain responsibilities if you distribute copies of the
|
||||
software, or if you modify it: responsibilities to respect the freedom
|
||||
of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the
|
||||
manufacturer can do so. This is fundamentally incompatible with the
|
||||
aim of protecting users' freedom to change the software. The
|
||||
systematic pattern of such abuse occurs in the area of products for
|
||||
individuals to use, which is precisely where it is most unacceptable.
|
||||
Therefore, we have designed this version of the GPL to prohibit the
|
||||
practice for those products. If such problems arise substantially in
|
||||
other domains, we stand ready to extend this provision to those
|
||||
domains in future versions of the GPL, as needed to protect the
|
||||
freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish
|
||||
to avoid the special danger that patents applied to a free program
|
||||
could make it effectively proprietary. To prevent this, the GPL
|
||||
assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
### TERMS AND CONDITIONS
|
||||
|
||||
#### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
#### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
#### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
#### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
#### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
#### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
#### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
#### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
#### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
#### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
#### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
#### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
#### 13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
#### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in
|
||||
detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU General Public
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that numbered version or
|
||||
of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public
|
||||
License, you may choose any version ever published by the Free
|
||||
Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU General Public License can be used, that proxy's public
|
||||
statement of acceptance of a version permanently authorizes you to
|
||||
choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
#### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
#### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
#### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
### How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively state
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands \`show w' and \`show c' should show the
|
||||
appropriate parts of the General Public License. Of course, your
|
||||
program's commands might be different; for a GUI interface, you would
|
||||
use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. For more information on this, and how to apply and follow
|
||||
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your
|
||||
program into proprietary programs. If your program is a subroutine
|
||||
library, you may consider it more useful to permit linking proprietary
|
||||
applications with the library. If this is what you want to do, use the
|
||||
GNU Lesser General Public License instead of this License. But first,
|
||||
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
|
||||
|
||||
## creative commons
|
||||
|
||||
# Attribution-NonCommercial-ShareAlike 4.0 International
|
||||
|
||||
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
|
||||
|
||||
### Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
|
||||
|
||||
* __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors).
|
||||
|
||||
* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees).
|
||||
|
||||
## Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
||||
|
||||
### Section 1 – Definitions.
|
||||
|
||||
a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
||||
|
||||
b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. __BY-NC-SA Compatible License__ means a license listed at [creativecommons.org/compatiblelicenses](http://creativecommons.org/compatiblelicenses), approved by Creative Commons as essentially the equivalent of this Public License.
|
||||
|
||||
d. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
||||
|
||||
e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
||||
|
||||
f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
||||
|
||||
g. __License Elements__ means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike.
|
||||
|
||||
h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
||||
|
||||
i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
j. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License.
|
||||
|
||||
k. __NonCommercial__ means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
||||
|
||||
l. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
||||
|
||||
m. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||
|
||||
n. __You__ means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
|
||||
|
||||
### Section 2 – Scope.
|
||||
|
||||
a. ___License grant.___
|
||||
|
||||
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
|
||||
|
||||
B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
|
||||
|
||||
2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
||||
|
||||
3. __Term.__ The term of this Public License is specified in Section 6(a).
|
||||
|
||||
4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
||||
|
||||
5. __Downstream recipients.__
|
||||
|
||||
A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
||||
|
||||
B. __Additional offer from the Licensor – Adapted Material.__ Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
|
||||
|
||||
C. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
||||
|
||||
6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. ___Other rights.___
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
|
||||
|
||||
### Section 3 – License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||
|
||||
a. ___Attribution.___
|
||||
|
||||
1. If You Share the Licensed Material (including in modified form), You must:
|
||||
|
||||
A. retain the following if it is supplied by the Licensor with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
||||
|
||||
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
||||
|
||||
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
||||
|
||||
b. ___ShareAlike.___
|
||||
|
||||
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
|
||||
|
||||
1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License.
|
||||
|
||||
2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
|
||||
|
||||
3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
|
||||
|
||||
### Section 4 – Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
|
||||
|
||||
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
||||
|
||||
### Section 5 – Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__
|
||||
|
||||
b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||
|
||||
### Section 6 – Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
||||
|
||||
### Section 7 – Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
||||
|
||||
### Section 8 – Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||
|
||||
> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
|
||||
>
|
||||
> Creative Commons may be contacted at creativecommons.org
|
||||
69
README.md
69
README.md
|
|
@ -1,21 +1,56 @@
|
|||
# Prusa-Firmware-MMU-Private
|
||||
# Prusa-Firmware-MMU
|
||||
This repository includes source code and firmware releases for the Original Prusa Multi Material Unit based on 8-bit ATMEL microcontroller.
|
||||
|
||||
## How to prepare build env and tools
|
||||
The currently supported models are:
|
||||
- Original Prusa MMU3
|
||||
- Original Prusa MMU2S
|
||||
|
||||
## Introduction
|
||||
This is the new firmware for the Multi Material Unit (MMU).
|
||||
|
||||
### Motivation
|
||||
The key motivation for developing a new firmware structure were as follows:
|
||||
|
||||
- adding a possibility of reporting the MMU's state even during running commands - the architecture of the original MM-control-01 project didn't allow to achieve this requirement
|
||||
- while being able to report the internal state of the MMU, the printer should be able to describe the error states clearly on its LCD without leaving the user to rely on some blinking LEDs
|
||||
- modular design prepared for possible future upgrades
|
||||
|
||||
### Firmware architecture
|
||||
The whole firmware is composed of simple state machines which run all at once - it is a kind of simple cooperative multi-tasking while not eating up any significant resources by deploying generic task switching solutions like RTOS or similar. The general rule is to avoid waiting inside these state machines, no state machine is allowed to block execution of others. That implies making separate waiting states which only check for some condition to be true before proceeding further.
|
||||
|
||||
The firmware is separated into 4 layers:
|
||||
|
||||
- HAL is responsible for talking to the physical hardware, in our case an AVR processor and its peripherals, TMC2130 stepper drivers, shift registers etc.
|
||||
- modules are the components abstracted of the real hardware and/or connection. A typical example are the buttons, LEDs, Idler, Selector etc.
|
||||
- logic layer is the application logic - this layer provides the sequences and logical relations between modules thus forming the behavior of the MMU.
|
||||
- main is the top layer, it is responsible for initialization of the whole firmware and performing the main loop, where the stepping of all the automata is located.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Requirements
|
||||
|
||||
- Python 3.6 or newer (with pip)
|
||||
|
||||
### Cloning this repository
|
||||
|
||||
Run `git clone https://github.com/prusa3d/Prusa-Firmware-MMU.git`.
|
||||
|
||||
### How to prepare build env and tools
|
||||
Run `./utils/bootstrap.py`
|
||||
|
||||
`bootstrap.py` will now download all the "missing" dependencies into the `.dependencies` folder:
|
||||
- clang-format-9.0.0-noext
|
||||
- cmake-3.22.5
|
||||
- ninja-1.10.2
|
||||
- ninja-1.12.1
|
||||
- avr-gcc-7.3.0
|
||||
|
||||
## How to build the preliminary project so far:
|
||||
### How to build the preliminary project so far:
|
||||
Now the process is the same as in the Buddy Firmware:
|
||||
```
|
||||
./utils/build.py
|
||||
```
|
||||
|
||||
builds the firmware.hex in build/mmu_release
|
||||
builds the `MMU3_<major>.<minor>.<revision>+<commit nr>`` in build/release folder
|
||||
|
||||
In case you'd like to build the project directly via cmake you can use an approach like this:
|
||||
```
|
||||
|
|
@ -25,4 +60,26 @@ cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/AvrGcc.cmake
|
|||
ninja
|
||||
```
|
||||
|
||||
It will produce a `MMU2SR_<version>.hex` file.
|
||||
It will produce a `MMU3_<version>.hex` file.
|
||||
|
||||
### Development
|
||||
|
||||
The build process of this project is driven by CMake and `build.py` is just a high-level wrapper around it. As most modern IDEs support some kind of CMake integration, it should be possible to use almost any editor for development. Below are some documents describing how to setup some popular text editors.
|
||||
|
||||
- Visual Studio Code
|
||||
- Vim
|
||||
- Other LSP-based IDEs (Atom, Sublime Text, ...)
|
||||
|
||||
#### Formatting
|
||||
|
||||
All the source code in this repository is automatically formatted:
|
||||
|
||||
- C/C++ files using [clang-format](https://clang.llvm.org/docs/ClangFormat.html),
|
||||
- Python files using [yapf](https://github.com/google/yapf),
|
||||
- and CMake files using [cmake-format](https://github.com/cheshirekow/cmake_format).
|
||||
|
||||
If you want to contribute, make sure to install [pre-commit](https://pre-commit.com) and then run `pre-commit install` within the repository. This makes sure that all your future commits will be formatted appropriately. Our build server automatically rejects improperly formatted pull requests.
|
||||
|
||||
## License
|
||||
|
||||
The firmware source code is licensed under the GNU General Public License v3.0 and the graphics and design are licensed under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0). Fonts are licensed under different license (see [LICENSE](LICENSE.md)).
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@
|
|||
# I don't know if get_git_head_revision() must be called internally or not, as reason of calling it
|
||||
# is not clear for me also in git_local_changes().
|
||||
#
|
||||
# git_head_commit_timestamp(<var>)
|
||||
#
|
||||
# Returns the timestamp of the HEAD commit.
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author: 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
|
|
@ -230,3 +234,51 @@ function(git_count_parent_commits _var)
|
|||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
function(git_get_commit_timestamp _var hash)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" show -s "--format=%ct" "${hash}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(res EQUAL 0)
|
||||
set(${_var}
|
||||
"${out}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
else()
|
||||
set(${_var}
|
||||
"0"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
function(git_head_commit_timestamp _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var}
|
||||
"GIT-NOTFOUND"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var}
|
||||
"HEAD-HASH-NOTFOUND"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
git_get_commit_timestamp(timestamp ${hash})
|
||||
set(${_var}
|
||||
"${timestamp}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endfunction()
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
# PROJECT_VERSION_FULL (4.0.3-BETA+1035.PR111.B4)
|
||||
# PROJECT_VERSION_SUFFIX (-BETA+1035.PR111.B4)
|
||||
# PROJECT_VERSION_SUFFIX_SHORT (+1035)
|
||||
# PROJECT_VERSION_TIMESTAMP (unix timestamp)
|
||||
#
|
||||
# The `PROJECT_VERSION` variable is set as soon as the file is included.
|
||||
# To set the rest, the function `resolve_version_variables` has to be called.
|
||||
|
|
@ -55,4 +56,19 @@ function(resolve_version_variables)
|
|||
"${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
# PROJECT_VERSION_TIMESTAMP
|
||||
if(NOT PROJECT_VERSION_TIMESTAMP)
|
||||
git_head_commit_timestamp(timestamp)
|
||||
set(ERRORS "GIT-NOTFOUND" "HEAD-FORMAT-NOTFOUND" "HEAD-HASH-NOTFOUND")
|
||||
if(timestamp IN_LIST ERRORS)
|
||||
# git not available, set fallback values
|
||||
set(timestamp 0)
|
||||
endif()
|
||||
set(PROJECT_VERSION_TIMESTAMP
|
||||
"${timestamp}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_xmlwriter.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <iomanip>
|
||||
#include <type_traits>
|
||||
|
||||
|
|
|
|||
|
|
@ -162,13 +162,13 @@ const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARR
|
|||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"Prusa3D");
|
||||
const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"prusa3d.com");
|
||||
|
||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"Original Prusa i3 MK3 Multi Material 2.0 upgrade 🐑");
|
||||
const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"Original Prusa MMU unit 🐑");
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@
|
|||
#include "lufa/LUFA/Drivers/USB/USB.h"
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint address of the CDC device-to-host notification IN endpoint. */
|
||||
#define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2)
|
||||
|
||||
/** Endpoint address of the CDC device-to-host data IN endpoint. */
|
||||
#define CDC_TX_EPADDR (ENDPOINT_DIR_IN | 3)
|
||||
#define CDC_TX_EPADDR (ENDPOINT_DIR_IN | 1)
|
||||
|
||||
/** Endpoint address of the CDC host-to-device data OUT endpoint. */
|
||||
#define CDC_RX_EPADDR (ENDPOINT_DIR_OUT | 4)
|
||||
#define CDC_RX_EPADDR (ENDPOINT_DIR_OUT | 2)
|
||||
|
||||
/** Endpoint address of the CDC device-to-host notification IN endpoint. */
|
||||
#define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 3)
|
||||
|
||||
/** Size in bytes of the CDC device-to-host notification IN endpoint. */
|
||||
#define CDC_NOTIFICATION_EPSIZE 8
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
#define USB_DEVICE_ONLY
|
||||
#define DEVICE_STATE_AS_GPIOR 0
|
||||
// #define ORDERED_EP_CONFIG
|
||||
#define ORDERED_EP_CONFIG
|
||||
#define FIXED_CONTROL_ENDPOINT_SIZE 8
|
||||
#define FIXED_NUM_CONFIGURATIONS 1
|
||||
#define INTERRUPT_CONTROL_ENDPOINT
|
||||
#define USE_FLASH_DESCRIPTORS
|
||||
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
|
||||
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_MANUAL_PLL)
|
||||
#define NO_INTERNAL_SERIAL
|
||||
#define NO_DEVICE_SELF_POWER
|
||||
#define NO_DEVICE_REMOTE_WAKEUP
|
||||
// #define NO_SOF_EVENTS
|
||||
#define NO_SOF_EVENTS
|
||||
#define F_USB F_CPU
|
||||
#define DEVICE_VID 0x2C99
|
||||
#define DEVICE_PID 0x0004
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
target_sources(firmware PRIVATE application.cpp debug.cpp main.cpp registers.cpp version.hpp)
|
||||
target_sources(firmware PRIVATE application.cpp debug.cpp main.cpp registers.cpp version.cpp)
|
||||
|
||||
target_link_libraries(firmware LUFA)
|
||||
|
||||
|
|
|
|||
|
|
@ -255,6 +255,7 @@ void Application::ProcessRequestMsg(const mp::RequestMsg &rq) {
|
|||
case mp::RequestMsgCodes::Eject:
|
||||
case mp::RequestMsgCodes::Home:
|
||||
case mp::RequestMsgCodes::Load:
|
||||
case mp::RequestMsgCodes::Mode:
|
||||
case mp::RequestMsgCodes::Tool:
|
||||
case mp::RequestMsgCodes::Unload:
|
||||
PlanCommand(rq);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,271 @@
|
|||
/* Script for -n: mix text and data on same page */
|
||||
/* Copyright (C) 2014-2015 Free Software Foundation, Inc.
|
||||
Copying and distribution of this script, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. */
|
||||
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
|
||||
OUTPUT_ARCH(avr:5)
|
||||
__TEXT_REGION_ORIGIN__ = DEFINED(__TEXT_REGION_ORIGIN__) ? __TEXT_REGION_ORIGIN__ : 0;
|
||||
__DATA_REGION_ORIGIN__ = DEFINED(__DATA_REGION_ORIGIN__) ? __DATA_REGION_ORIGIN__ : 0x800060;
|
||||
__TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : 128K;
|
||||
__DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : 0xffa0;
|
||||
__EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : 64K;
|
||||
__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 1K;
|
||||
__LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : 1K;
|
||||
__SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : 1K;
|
||||
__USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) ? __USER_SIGNATURE_REGION_LENGTH__ : 1K;
|
||||
MEMORY
|
||||
{
|
||||
text (rx) : ORIGIN = __TEXT_REGION_ORIGIN__, LENGTH = __TEXT_REGION_LENGTH__
|
||||
data (rw!x) : ORIGIN = __DATA_REGION_ORIGIN__, LENGTH = __DATA_REGION_LENGTH__
|
||||
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__
|
||||
fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
|
||||
lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
|
||||
signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__
|
||||
user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__
|
||||
}
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.gnu.version : { *(.gnu.version) }
|
||||
.gnu.version_d : { *(.gnu.version_d) }
|
||||
.gnu.version_r : { *(.gnu.version_r) }
|
||||
.rel.init : { *(.rel.init) }
|
||||
.rela.init : { *(.rela.init) }
|
||||
.rel.text :
|
||||
{
|
||||
*(.rel.text)
|
||||
*(.rel.text.*)
|
||||
*(.rel.gnu.linkonce.t*)
|
||||
}
|
||||
.rela.text :
|
||||
{
|
||||
*(.rela.text)
|
||||
*(.rela.text.*)
|
||||
*(.rela.gnu.linkonce.t*)
|
||||
}
|
||||
.rel.fini : { *(.rel.fini) }
|
||||
.rela.fini : { *(.rela.fini) }
|
||||
.rel.rodata :
|
||||
{
|
||||
*(.rel.rodata)
|
||||
*(.rel.rodata.*)
|
||||
*(.rel.gnu.linkonce.r*)
|
||||
}
|
||||
.rela.rodata :
|
||||
{
|
||||
*(.rela.rodata)
|
||||
*(.rela.rodata.*)
|
||||
*(.rela.gnu.linkonce.r*)
|
||||
}
|
||||
.rel.data :
|
||||
{
|
||||
*(.rel.data)
|
||||
*(.rel.data.*)
|
||||
*(.rel.gnu.linkonce.d*)
|
||||
}
|
||||
.rela.data :
|
||||
{
|
||||
*(.rela.data)
|
||||
*(.rela.data.*)
|
||||
*(.rela.gnu.linkonce.d*)
|
||||
}
|
||||
.rel.ctors : { *(.rel.ctors) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rel.dtors : { *(.rel.dtors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rel.got : { *(.rel.got) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rel.bss : { *(.rel.bss) }
|
||||
.rela.bss : { *(.rela.bss) }
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
/* Internal text space or external memory. */
|
||||
.text :
|
||||
{
|
||||
*(.vectors)
|
||||
KEEP(*(.vectors))
|
||||
|
||||
/* Version information kept in flash at a fixed address after the vectors */
|
||||
. = ALIGN(2);
|
||||
KEEP(*(.version))
|
||||
. = ALIGN(2);
|
||||
|
||||
/* For data that needs to reside in the lower 64k of progmem. */
|
||||
*(.progmem.gcc*)
|
||||
/* PR 13812: Placing the trampolines here gives a better chance
|
||||
that they will be in range of the code that uses them. */
|
||||
. = ALIGN(2);
|
||||
__trampolines_start = . ;
|
||||
/* The jump trampolines for the 16-bit limited relocs will reside here. */
|
||||
*(.trampolines)
|
||||
*(.trampolines*)
|
||||
__trampolines_end = . ;
|
||||
/* avr-libc expects these data to reside in lower 64K. */
|
||||
*libprintf_flt.a:*(.progmem.data)
|
||||
*libc.a:*(.progmem.data)
|
||||
*(.progmem*)
|
||||
. = ALIGN(2);
|
||||
/* For future tablejump instruction arrays for 3 byte pc devices.
|
||||
We don't relax jump/call instructions within these sections. */
|
||||
*(.jumptables)
|
||||
*(.jumptables*)
|
||||
/* For code that needs to reside in the lower 128k progmem. */
|
||||
*(.lowtext)
|
||||
*(.lowtext*)
|
||||
__ctors_start = . ;
|
||||
*(.ctors)
|
||||
__ctors_end = . ;
|
||||
__dtors_start = . ;
|
||||
*(.dtors)
|
||||
__dtors_end = . ;
|
||||
KEEP(SORT(*)(.ctors))
|
||||
KEEP(SORT(*)(.dtors))
|
||||
/* From this point on, we don't bother about wether the insns are
|
||||
below or above the 16 bits boundary. */
|
||||
*(.init0) /* Start here after reset. */
|
||||
KEEP (*(.init0))
|
||||
*(.init1)
|
||||
KEEP (*(.init1))
|
||||
*(.init2) /* Clear __zero_reg__, set up stack pointer. */
|
||||
KEEP (*(.init2))
|
||||
*(.init3)
|
||||
KEEP (*(.init3))
|
||||
*(.init4) /* Initialize data and BSS. */
|
||||
KEEP (*(.init4))
|
||||
*(.init5)
|
||||
KEEP (*(.init5))
|
||||
*(.init6) /* C++ constructors. */
|
||||
KEEP (*(.init6))
|
||||
*(.init7)
|
||||
KEEP (*(.init7))
|
||||
*(.init8)
|
||||
KEEP (*(.init8))
|
||||
*(.init9) /* Call main(). */
|
||||
KEEP (*(.init9))
|
||||
*(.text)
|
||||
. = ALIGN(2);
|
||||
*(.text.*)
|
||||
. = ALIGN(2);
|
||||
*(.fini9) /* _exit() starts here. */
|
||||
KEEP (*(.fini9))
|
||||
*(.fini8)
|
||||
KEEP (*(.fini8))
|
||||
*(.fini7)
|
||||
KEEP (*(.fini7))
|
||||
*(.fini6) /* C++ destructors. */
|
||||
KEEP (*(.fini6))
|
||||
*(.fini5)
|
||||
KEEP (*(.fini5))
|
||||
*(.fini4)
|
||||
KEEP (*(.fini4))
|
||||
*(.fini3)
|
||||
KEEP (*(.fini3))
|
||||
*(.fini2)
|
||||
KEEP (*(.fini2))
|
||||
*(.fini1)
|
||||
KEEP (*(.fini1))
|
||||
*(.fini0) /* Infinite loop after program termination. */
|
||||
KEEP (*(.fini0))
|
||||
_etext = . ;
|
||||
} > text
|
||||
.data :
|
||||
{
|
||||
PROVIDE (__data_start = .) ;
|
||||
*(.data)
|
||||
*(.data*)
|
||||
*(.gnu.linkonce.d*)
|
||||
*(.rodata) /* We need to include .rodata here if gcc is used */
|
||||
*(.rodata*) /* with -fdata-sections. */
|
||||
*(.gnu.linkonce.r*)
|
||||
. = ALIGN(2);
|
||||
_edata = . ;
|
||||
PROVIDE (__data_end = .) ;
|
||||
} > data AT> text
|
||||
.bss ADDR(.data) + SIZEOF (.data) : AT (ADDR (.bss))
|
||||
{
|
||||
PROVIDE (__bss_start = .) ;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
PROVIDE (__bss_end = .) ;
|
||||
} > data
|
||||
__data_load_start = LOADADDR(.data);
|
||||
__data_load_end = __data_load_start + SIZEOF(.data);
|
||||
/* Global data not cleared after reset. */
|
||||
.noinit ADDR(.bss) + SIZEOF (.bss) : AT (ADDR (.noinit))
|
||||
{
|
||||
PROVIDE (__noinit_start = .) ;
|
||||
*(.noinit*)
|
||||
PROVIDE (__noinit_end = .) ;
|
||||
_end = . ;
|
||||
PROVIDE (__heap_start = .) ;
|
||||
} > data
|
||||
.eeprom :
|
||||
{
|
||||
/* See .data above... */
|
||||
KEEP(*(.eeprom*))
|
||||
__eeprom_end = . ;
|
||||
} > eeprom
|
||||
.fuse :
|
||||
{
|
||||
KEEP(*(.fuse))
|
||||
KEEP(*(.lfuse))
|
||||
KEEP(*(.hfuse))
|
||||
KEEP(*(.efuse))
|
||||
} > fuse
|
||||
.lock :
|
||||
{
|
||||
KEEP(*(.lock*))
|
||||
} > lock
|
||||
.signature :
|
||||
{
|
||||
KEEP(*(.signature*))
|
||||
} > signature
|
||||
.user_signatures :
|
||||
{
|
||||
KEEP(*(.user_signatures*))
|
||||
} > user_signatures
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/* DWARF 3 */
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
/* DWARF Extension. */
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ struct AxisConfig {
|
|||
uint8_t iHold; ///< holding current
|
||||
bool stealth; ///< Default to Stealth mode
|
||||
long double stepsPerUnit; ///< steps per unit
|
||||
long double stepsPerUnitReciprocal; ///< reciprocal of step per unit (used to avoid divisions)
|
||||
int8_t sg_thrs; /// @todo 7bit two's complement for the sg_thrs
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,10 @@
|
|||
/// Wrangler for assorted compile-time configuration and constants.
|
||||
namespace config {
|
||||
|
||||
static constexpr const uint8_t toolCount = 5U; ///< Max number of extruders/tools/slots
|
||||
/// Max number of extruders/tools/slots
|
||||
/// Beware - if you change this, the EEPROM structure will become invalid and no migration procedures have been implemented.
|
||||
/// So if you really have to change this, erase your EEPROM content then.
|
||||
static constexpr const uint8_t toolCount = 5U;
|
||||
static_assert(toolCount < 15, "Up to 14 valid slots (+1 parking) is supported in EEPROM storage");
|
||||
|
||||
// Printer's filament sensor setup
|
||||
|
|
@ -82,25 +85,26 @@ static constexpr U_mm pulleyToCuttingEdge = 33.0_mm; /// 33.0_mm /// Pulley to c
|
|||
static constexpr U_mm filamentMinLoadedToMMU = 20.0_mm; /// Limit of retraction.
|
||||
static constexpr U_mm ejectFromCuttingEdge = 40.0_mm; /// Eject should ignore FilamentMinLoadedToMMU and retract
|
||||
static constexpr U_mm cuttingEdgeRetract = 5.0_mm; /// Cutting retraction distance (filament should be flush with outlet)
|
||||
static constexpr U_mm cuttingEdgeToFinda = 18.5_mm; /// Cutting edge to FINDA MMU2 side -1mm tolerance should be ~18.5. FINDA shouldn't trigger here.
|
||||
static constexpr U_mm cuttingEdgeToFinda = 18.5_mm; /// Cutting edge to FINDA MMU side -1mm tolerance should be ~18.5. FINDA shouldn't trigger here.
|
||||
static constexpr U_mm findaTriggerDistance = 4.5_mm; /// FINDA trigger distance +1.0_mm tolerance.
|
||||
static constexpr U_mm cuttingEdgeToFindaMidpoint = 22.85_mm; /// Cutting edge to Midpoint of FINDA should be 22.85_mm.
|
||||
static constexpr U_mm findaToCoupler = 12.0_mm; /// FINDA Coupler side to coupler screw.
|
||||
static constexpr U_mm couplerToBowden = 3.5_mm; /// FINDA Coupler screw to bowden mmu2s side (in coupling).
|
||||
static constexpr U_mm couplerToBowden = 3.5_mm; /// FINDA Coupler screw to bowden mmu side (in coupling).
|
||||
|
||||
// Min, max and default bowden length setup
|
||||
static constexpr U_mm defaultBowdenLength = 360.0_mm; /// ~360.0_mm - Default Bowden length.
|
||||
static constexpr U_mm minimumBowdenLength = 341.0_mm; /// ~341.0_mm - Minimum bowden length.
|
||||
static constexpr U_mm maximumBowdenLength = 1000.0_mm; /// ~1000.0_mm - Maximum bowden length.
|
||||
static_assert(minimumBowdenLength.v <= defaultBowdenLength.v);
|
||||
static_assert(maximumBowdenLength.v > defaultBowdenLength.v);
|
||||
|
||||
// @@TODO this is very tricky - the same MMU, same PTFE,
|
||||
// just another piece of PLA (probably having more resistance in the tubes)
|
||||
// and we are at least 40mm off! It looks like this really depends on the exact position
|
||||
// We'll probably need to check for StallGuard while pushing the filament to avoid ginding the filament
|
||||
static constexpr U_mm defaultBowdenLength = 427.0_mm; ///< ~427.0_mm - Default Bowden length. TODO Should be stored in EEPROM. 392 a 784
|
||||
static constexpr U_mm minimumBowdenLength = 341.0_mm; ///< ~341.0_mm - Minimum bowden length. TODO Should be stored in EEPROM.
|
||||
static constexpr U_mm maximumBowdenLength = 792.0_mm; ///< ~792.0_mm - Maximum bowden length. TODO Should be stored in EEPROM.
|
||||
static constexpr U_mm feedToFinda = cuttingEdgeToFindaMidpoint + filamentMinLoadedToMMU;
|
||||
static constexpr U_mm maximumFeedToFinda = feedToFinda + 20.0_mm; ///< allow for some safety margin to load to FINDA
|
||||
static constexpr U_mm pulleyHelperMove = 10.0_mm; ///< Helper move for Load/Unload error states - when the MMU should slowly move the filament a bit
|
||||
static constexpr U_mm cutLength = 8.0_mm;
|
||||
static constexpr U_mm fsensorToNozzle = 30.0_mm; ///< ~20mm from MK4's filament sensor through extruder gears into nozzle
|
||||
static constexpr U_mm fsensorToNozzleAvoidGrind = 5.0_mm;
|
||||
static constexpr U_mm fsensorToNozzleAvoidGrindUnload = 20.0_mm;
|
||||
/// Check the state of FSensor after this amount of filament got (hopefully) pulled out while unloading.
|
||||
static constexpr U_mm fsensorUnloadCheckDistance = 40.0_mm;
|
||||
|
||||
|
|
@ -112,6 +116,7 @@ static constexpr AxisConfig pulley = {
|
|||
.iHold = 0, /// 17mA in SpreadCycle, freewheel in StealthChop
|
||||
.stealth = false,
|
||||
.stepsPerUnit = (200 * 8 / 19.147274),
|
||||
.stepsPerUnitReciprocal = 1 / ((200 * 8 / 19.147274)),
|
||||
.sg_thrs = 8,
|
||||
};
|
||||
|
||||
|
|
@ -137,6 +142,7 @@ static constexpr AxisConfig selector = {
|
|||
.iHold = 0, /// 17mA in SpreadCycle, freewheel in StealthChop
|
||||
.stealth = false,
|
||||
.stepsPerUnit = (200 * 8 / 8.),
|
||||
.stepsPerUnitReciprocal = 1 / ((200 * 8 / 8.)),
|
||||
.sg_thrs = 3,
|
||||
};
|
||||
|
||||
|
|
@ -154,7 +160,7 @@ static constexpr U_mm SelectorOffsetFromMax = 1.0_mm; /// Selector offset from h
|
|||
static constexpr U_mm SelectorOffsetFromMin = 75.5_mm; /// Selector offset from home min to slot 0
|
||||
|
||||
/// slots 0-4 are the real ones, the 5th is the farthest parking positions
|
||||
/// selector.dirOn = true = Home at max: selector hits left side of the MMU2S body
|
||||
/// selector.dirOn = true = Home at max: selector hits left side of the MMU body
|
||||
/// selector.dirOn = false = Home at min: selector POM nut hit the selector motor
|
||||
static constexpr U_mm selectorSlotPositions[toolCount + 1] = {
|
||||
|
||||
|
|
@ -187,6 +193,7 @@ static constexpr AxisConfig idler = {
|
|||
.iHold = 5, /// 99mA - parked current
|
||||
.stealth = false,
|
||||
.stepsPerUnit = (200 * 16 / 360.),
|
||||
.stepsPerUnitReciprocal = 1 / ((200 * 16 / 360.)),
|
||||
.sg_thrs = 7,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,5 +20,13 @@ void EEPROM::UpdateByte(EEPROM::addr_t addr, uint8_t value) {
|
|||
eeprom_update_byte((uint8_t *)addr, value);
|
||||
}
|
||||
|
||||
uint16_t EEPROM::ReadWord(EEPROM::addr_t addr) {
|
||||
return eeprom_read_word((const uint16_t *)addr);
|
||||
}
|
||||
|
||||
void EEPROM::UpdateWord(EEPROM::addr_t addr, uint16_t value) {
|
||||
eeprom_update_word((uint16_t *)addr, value);
|
||||
}
|
||||
|
||||
} // namespace eeprom
|
||||
} // namespace hal
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
template <typename index_t = uint_fast8_t, index_t size = 16>
|
||||
class CircularIndex {
|
||||
public:
|
||||
static constexpr bool size_is_power2 = !(size & (size - 1));
|
||||
|
||||
static_assert(size <= std::numeric_limits<index_t>::max() / 2,
|
||||
"index_t is too small for the requested size");
|
||||
|
||||
|
|
@ -26,9 +28,7 @@ public:
|
|||
|
||||
/// @returns true if full
|
||||
inline bool full() const {
|
||||
// alternative without wrap-around logic:
|
||||
// return tail != head && mask(tail) == mask(head);
|
||||
return ((index_t)(head - tail) % (size * 2)) == size;
|
||||
return count() == size;
|
||||
}
|
||||
|
||||
/// Reset the indexes to empty
|
||||
|
|
@ -62,7 +62,13 @@ public:
|
|||
|
||||
/// @returns number of elements in the buffer
|
||||
inline index_t count() const {
|
||||
return head - tail;
|
||||
if constexpr (size_is_power2)
|
||||
return head - tail;
|
||||
else {
|
||||
return head >= tail
|
||||
? (head - tail)
|
||||
: (size * 2 + head) - tail;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
@ -76,8 +82,10 @@ protected:
|
|||
static index_t next(index_t cursor) {
|
||||
// note: the modulo can be avoided if size is a power of two: we can do this
|
||||
// relying on the optimizer eliding the following check at compile time.
|
||||
static constexpr bool power2 = !(size & (size - 1));
|
||||
return power2 ? (cursor + 1) : (cursor + 1) % (size * 2);
|
||||
if constexpr (size_is_power2)
|
||||
return (cursor + 1);
|
||||
else
|
||||
return (cursor + 1) % (size * 2);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/// @file eeprom.h
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace hal {
|
||||
|
||||
|
|
@ -9,7 +10,11 @@ namespace eeprom {
|
|||
|
||||
class EEPROM {
|
||||
public:
|
||||
#ifdef UNITTEST
|
||||
using addr_t = size_t;
|
||||
#else
|
||||
using addr_t = uint16_t;
|
||||
#endif
|
||||
|
||||
static void WriteByte(addr_t addr, uint8_t value);
|
||||
static void UpdateByte(addr_t addr, uint8_t value);
|
||||
|
|
|
|||
|
|
@ -52,31 +52,31 @@ struct GPIO_pin {
|
|||
// No constructor here in order to allow brace-initialization in old
|
||||
// gcc versions/standards
|
||||
GPIO_TypeDef *const port;
|
||||
const uint8_t pin;
|
||||
const uint8_t pin_mask;
|
||||
};
|
||||
|
||||
__attribute__((always_inline)) inline void WritePin(const GPIO_pin portPin, Level level) {
|
||||
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
|
||||
if (level == Level::high)
|
||||
portPin.port->PORTx |= (1 << portPin.pin);
|
||||
portPin.port->PORTx |= portPin.pin_mask;
|
||||
else
|
||||
portPin.port->PORTx &= ~(1 << portPin.pin);
|
||||
portPin.port->PORTx &= ~portPin.pin_mask;
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) inline Level ReadPin(const GPIO_pin portPin) {
|
||||
#ifdef __AVR__
|
||||
return (Level)((portPin.port->PINx & (1 << portPin.pin)) != 0);
|
||||
return (Level)((portPin.port->PINx & portPin.pin_mask) != 0);
|
||||
#else
|
||||
// Return the value modified by WritePin
|
||||
return (Level)((portPin.port->PORTx & (1 << portPin.pin)) != 0);
|
||||
return (Level)((portPin.port->PORTx & portPin.pin_mask) != 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) inline void TogglePin(const GPIO_pin portPin) {
|
||||
#ifdef __AVR__
|
||||
// Optimized path for AVR, resulting in a pin toggle
|
||||
portPin.port->PINx = (1 << portPin.pin);
|
||||
portPin.port->PINx = portPin.pin_mask;
|
||||
#else
|
||||
WritePin(portPin, (Level)(ReadPin(portPin) != Level::high));
|
||||
#endif
|
||||
|
|
@ -85,9 +85,9 @@ __attribute__((always_inline)) inline void TogglePin(const GPIO_pin portPin) {
|
|||
__attribute__((always_inline)) inline void Init(const GPIO_pin portPin, GPIO_InitTypeDef GPIO_Init) {
|
||||
if (GPIO_Init.mode == Mode::output) {
|
||||
WritePin(portPin, GPIO_Init.level);
|
||||
portPin.port->DDRx |= (1 << portPin.pin);
|
||||
portPin.port->DDRx |= portPin.pin_mask;
|
||||
} else {
|
||||
portPin.port->DDRx &= ~(1 << portPin.pin);
|
||||
portPin.port->DDRx &= ~portPin.pin_mask;
|
||||
WritePin(portPin, (Level)GPIO_Init.pull);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,5 +31,18 @@ static inline uint8_t read_byte(const uint8_t *addr) {
|
|||
#endif
|
||||
}
|
||||
|
||||
/// read a ptr from PROGMEM
|
||||
/// Introduced mainly for compatibility reasons with the unit tests
|
||||
/// and to hide the ugly reinterpret_casts.
|
||||
/// Returns a correctly typed pointer: a 16-bit on AVR, but a 64bit address on x86_64
|
||||
template <typename RT>
|
||||
static inline RT read_ptr(const void *addr) {
|
||||
#ifndef __AVR__
|
||||
return reinterpret_cast<RT>(*reinterpret_cast<const uint64_t *>(addr));
|
||||
#else
|
||||
return reinterpret_cast<RT>(pgm_read_ptr(addr));
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace progmem
|
||||
} // namespace hal
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ private:
|
|||
ErrorFlags errorFlags;
|
||||
bool initialized = false;
|
||||
bool enabled = false;
|
||||
uint8_t sg_filter_threshold;
|
||||
uint8_t sg_filter_threshold = 0;
|
||||
uint8_t sg_filter_counter = 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ inline ErrorCode &operator|=(ErrorCode &a, ErrorCode b) {
|
|||
return a = (ErrorCode)((uint16_t)a | (uint16_t)b);
|
||||
}
|
||||
|
||||
inline ErrorCode operator<<(ErrorCode a, uint8_t b) {
|
||||
return a = (ErrorCode)((uint16_t)a << b);
|
||||
}
|
||||
|
||||
static ErrorCode TMC2130ToErrorCode(const hal::tmc2130::ErrorFlags &ef) {
|
||||
ErrorCode e = ErrorCode::RUNNING;
|
||||
|
||||
|
|
@ -39,21 +43,13 @@ static ErrorCode TMC2130ToErrorCode(const hal::tmc2130::ErrorFlags &ef) {
|
|||
return e;
|
||||
}
|
||||
|
||||
static ErrorCode __attribute__((noinline)) AddErrorAxisBit(ErrorCode ec, uint8_t tmcIndex) {
|
||||
switch (tmcIndex) {
|
||||
case config::Axis::Pulley:
|
||||
ec |= ErrorCode::TMC_PULLEY_BIT;
|
||||
break;
|
||||
case config::Axis::Selector:
|
||||
ec |= ErrorCode::TMC_SELECTOR_BIT;
|
||||
break;
|
||||
case config::Axis::Idler:
|
||||
ec |= ErrorCode::TMC_IDLER_BIT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ec;
|
||||
ErrorCode __attribute__((noinline)) AddErrorAxisBit(ErrorCode ec, uint8_t axis) {
|
||||
// From now on, we rely on specific ErrorCode bitmask values - that allowed some important optimizations.
|
||||
// In case someone fiddles with the bits, the build must fail.
|
||||
static_assert((uint16_t)ErrorCode::TMC_PULLEY_BIT == 0x0040);
|
||||
static_assert((uint16_t)ErrorCode::TMC_SELECTOR_BIT == 0x0080);
|
||||
static_assert((uint16_t)ErrorCode::TMC_IDLER_BIT == 0x0100);
|
||||
return ec |= (ErrorCode::TMC_PULLEY_BIT << axis);
|
||||
}
|
||||
|
||||
ErrorCode CheckMovable(const mm::MovableBase &m) {
|
||||
|
|
@ -216,7 +212,7 @@ void CommandBase::ErrDisengagingIdler() {
|
|||
void CommandBase::GoToErrDisengagingIdler(ErrorCode deferredEC) {
|
||||
state = ProgressCode::ERRDisengagingIdler;
|
||||
deferredErrorCode = deferredEC;
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::off, ml::blink0);
|
||||
ml::leds.ActiveSlotError();
|
||||
mi::idler.Disengage();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ class MovableBase;
|
|||
/// The logic namespace handles the application logic on top of the modules.
|
||||
namespace logic {
|
||||
|
||||
/// Bitwise OR (ErrorCode::TMC_PULLEY_BIT << axis) into ec
|
||||
/// where axis ranges from 0 to 2
|
||||
ErrorCode AddErrorAxisBit(ErrorCode ec, uint8_t axis);
|
||||
|
||||
/// @brief Base class defining common API for high-level operations/commands/state machines
|
||||
///
|
||||
/// Which state machines are high-level? Those which are being initiated either by a command over the serial line or from a button
|
||||
|
|
@ -24,7 +28,7 @@ namespace logic {
|
|||
/// These tasks report their progress and only one of these tasks is allowed to run at once.
|
||||
class CommandBase {
|
||||
public:
|
||||
inline CommandBase()
|
||||
inline constexpr CommandBase()
|
||||
: state(ProgressCode::OK)
|
||||
, error(ErrorCode::OK)
|
||||
, deferredErrorCode(ErrorCode::OK)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ bool CutFilament::StepInner() {
|
|||
// move selector aside - prepare the blade into active position
|
||||
state = ProgressCode::PreparingBlade;
|
||||
mg::globals.SetFilamentLoaded(cutSlot, mg::FilamentLoadState::AtPulley);
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
|
||||
ml::leds.ActiveSlotProcessing();
|
||||
MoveSelector(cutSlot + 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ bool CutFilament::StepInner() {
|
|||
case ProgressCode::PreparingBlade:
|
||||
if (ms::selector.Slot() == cutSlot + 1) {
|
||||
state = ProgressCode::PushingFilament;
|
||||
mpu::pulley.PlanMove(config::cutLength + config::cuttingEdgeRetract, config::pulleySlowFeedrate);
|
||||
mpu::pulley.PlanMove(mg::globals.CutLength() + config::cuttingEdgeRetract, mg::globals.PulleySlowFeedrate_mm_s());
|
||||
}
|
||||
break;
|
||||
case ProgressCode::PushingFilament:
|
||||
|
|
@ -123,7 +123,7 @@ bool CutFilament::StepInner() {
|
|||
// revert move speed
|
||||
mg::globals.SetSelectorFeedrate_mm_s(savedSelectorFeedRate_mm_s);
|
||||
ms::selector.InvalidateHoming();
|
||||
mpu::pulley.PlanMove(-config::cuttingEdgeRetract, config::pulleySlowFeedrate);
|
||||
mpu::pulley.PlanMove(-config::cuttingEdgeRetract, mg::globals.PulleySlowFeedrate_mm_s());
|
||||
}
|
||||
break;
|
||||
case ProgressCode::Homing:
|
||||
|
|
@ -134,7 +134,7 @@ bool CutFilament::StepInner() {
|
|||
case ProgressCode::ReturningSelector:
|
||||
if (ms::selector.State() == ms::selector.Ready) {
|
||||
FinishedOK();
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::on, ml::off);
|
||||
ml::leds.ActiveSlotDonePrimed();
|
||||
}
|
||||
break;
|
||||
case ProgressCode::OK:
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ namespace logic {
|
|||
/// @brief A high-level command state machine - handles the complex logic of cutting filament
|
||||
class CutFilament : public CommandBase {
|
||||
public:
|
||||
inline CutFilament()
|
||||
: CommandBase() {}
|
||||
inline constexpr CutFilament()
|
||||
: CommandBase()
|
||||
, cutSlot(0)
|
||||
, savedSelectorFeedRate_mm_s(0) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param param index of filament slot to perform cut onto
|
||||
|
|
@ -26,8 +28,6 @@ public:
|
|||
ErrorCode Error() const override;
|
||||
|
||||
private:
|
||||
constexpr static const uint16_t cutStepsPre = 700;
|
||||
constexpr static const uint16_t cutStepsPost = 150;
|
||||
UnloadFilament unl; ///< a high-level command/operation may be used as a building block of other operations as well
|
||||
FeedToFinda feed;
|
||||
RetractFromFinda retract;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ bool EjectFilament::StepInner() {
|
|||
if (mi::idler.Engaged()) {
|
||||
state = ProgressCode::EjectingFilament;
|
||||
mpu::pulley.InitAxis();
|
||||
mpu::pulley.PlanMove(config::ejectFromCuttingEdge, config::pulleySlowFeedrate);
|
||||
mpu::pulley.PlanMove(config::ejectFromCuttingEdge, mg::globals.PulleySlowFeedrate_mm_s());
|
||||
}
|
||||
break;
|
||||
case ProgressCode::EjectingFilament:
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@
|
|||
|
||||
namespace logic {
|
||||
|
||||
// These cannot be class memebers without definition until c++17
|
||||
static constexpr modules::motion::P_pos_t ejectLength = 50.0_P_mm; //@@TODO
|
||||
static constexpr modules::motion::P_speed_t ejectSpeed = 1000.0_P_mm_s; //@@TODO
|
||||
|
||||
/// @brief A high-level command state machine - handles the complex logic of ejecting filament
|
||||
///
|
||||
/// The eject operation consists of:
|
||||
|
|
@ -26,8 +22,9 @@ static constexpr modules::motion::P_speed_t ejectSpeed = 1000.0_P_mm_s; //@@TODO
|
|||
/// The Eject message is not an error, but we'll leverage existing infrastructure of error screens + user input to model a nice UI dialog.
|
||||
class EjectFilament : public CommandBase {
|
||||
public:
|
||||
inline EjectFilament()
|
||||
: CommandBase() {}
|
||||
inline constexpr EjectFilament()
|
||||
: CommandBase()
|
||||
, slot(0) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param param index of filament slot to eject
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "../modules/permanent_storage.h"
|
||||
#include "../modules/pulley.h"
|
||||
#include "../debug.h"
|
||||
#include "../config/axis.h"
|
||||
|
||||
namespace logic {
|
||||
|
||||
|
|
@ -16,14 +17,14 @@ void FeedToBondtech::Reset(uint8_t maxRetries) {
|
|||
dbg_logic_P(PSTR("\nFeed to Bondtech\n\n"));
|
||||
state = EngagingIdler;
|
||||
this->maxRetries = maxRetries;
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0);
|
||||
ml::leds.ActiveSlotProcessing();
|
||||
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||
}
|
||||
|
||||
void logic::FeedToBondtech::GoToPushToNozzle() {
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InFSensor);
|
||||
// plan a slow move to help push filament into the nozzle
|
||||
//@@TODO the speed in mm/s must correspond to printer's feeding speed!
|
||||
// the speed in mm/s must correspond to printer's feeding speed!
|
||||
mpu::pulley.PlanMove(mg::globals.FSensorToNozzle_mm(), mg::globals.PulleySlowFeedrate_mm_s());
|
||||
state = PushingFilamentIntoNozzle;
|
||||
}
|
||||
|
|
@ -37,11 +38,13 @@ bool FeedToBondtech::Step() {
|
|||
state = PushingFilamentFast;
|
||||
mpu::pulley.InitAxis();
|
||||
// plan a fast move while in the safe minimal length
|
||||
mpu::pulley.PlanMove(config::minimumBowdenLength,
|
||||
// fast feed in millimeters - if the EEPROM value is incorrect, we'll get the default length
|
||||
unit::U_mm fastFeedDistance = { (long double)mps::BowdenLength::Get() };
|
||||
mpu::pulley.PlanMove(fastFeedDistance,
|
||||
mg::globals.PulleyLoadFeedrate_mm_s(),
|
||||
mg::globals.PulleySlowFeedrate_mm_s());
|
||||
// plan additional slow move while waiting for fsensor to trigger
|
||||
mpu::pulley.PlanMove(config::maximumBowdenLength - config::minimumBowdenLength,
|
||||
mpu::pulley.PlanMove(config::maximumBowdenLength - fastFeedDistance,
|
||||
mg::globals.PulleySlowFeedrate_mm_s(),
|
||||
mg::globals.PulleySlowFeedrate_mm_s());
|
||||
}
|
||||
|
|
@ -75,7 +78,7 @@ bool FeedToBondtech::Step() {
|
|||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InNozzle);
|
||||
mi::idler.PartiallyDisengage(mg::globals.ActiveSlot());
|
||||
// while disengaging the idler, keep on moving with the pulley to avoid grinding while the printer is trying to grab the filament itself
|
||||
mpu::pulley.PlanMove(config::fsensorToNozzleAvoidGrind, config::pulleySlowFeedrate);
|
||||
mpu::pulley.PlanMove(config::fsensorToNozzleAvoidGrind, mg::globals.PulleySlowFeedrate_mm_s());
|
||||
state = PartiallyDisengagingIdler;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -92,7 +95,7 @@ bool FeedToBondtech::Step() {
|
|||
dbg_logic_P(PSTR("Feed to Bondtech --> Idler disengaged"));
|
||||
dbg_logic_fP(PSTR("Pulley end steps %u"), mpu::pulley.CurrentPosition_mm());
|
||||
state = OK;
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on);
|
||||
ml::leds.ActiveSlotDonePrimed();
|
||||
}
|
||||
return false;
|
||||
case OK:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/// @file feed_to_bondtech.h
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include "../modules/axisunit.h"
|
||||
|
||||
namespace logic {
|
||||
|
||||
|
|
@ -10,9 +11,13 @@ namespace logic {
|
|||
/// Then it feeds a bit more very gently to push the filament into the nozzle
|
||||
/// Disengages the Idler after finishing the feed.
|
||||
/// Disables the Pulley axis after disengaging the idler.
|
||||
///
|
||||
/// If filament has been successfully fed into the fsensor,
|
||||
/// records/updates PTFE length.
|
||||
/// To prevent constant EEPROM updates only significant changes are recorded.
|
||||
struct FeedToBondtech {
|
||||
/// internal states of the state machine
|
||||
enum {
|
||||
enum : uint8_t {
|
||||
EngagingIdler,
|
||||
PushingFilamentFast,
|
||||
PushingFilamentToFSensor,
|
||||
|
|
@ -25,7 +30,7 @@ struct FeedToBondtech {
|
|||
// PulleyStalled
|
||||
};
|
||||
|
||||
inline FeedToBondtech()
|
||||
inline constexpr FeedToBondtech()
|
||||
: state(OK)
|
||||
, maxRetries(1) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ bool FeedToFinda::Reset(bool feedPhaseLimited, bool haltAtEnd) {
|
|||
state = EngagingIdler;
|
||||
this->feedPhaseLimited = feedPhaseLimited;
|
||||
this->haltAtEnd = haltAtEnd;
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
|
||||
ml::leds.ActiveSlotProcessing();
|
||||
if (ms::selector.MoveToSlot(mg::globals.ActiveSlot()) != ms::Selector::OperationResult::Accepted) {
|
||||
// We can't get any FINDA readings if the selector is at the wrong spot - move it accordingly if necessary
|
||||
// And prevent issuing any commands to the idler in such an error state
|
||||
|
|
@ -44,14 +44,14 @@ bool FeedToFinda::Step() {
|
|||
// mpu::pulley.PlanMove(config::filamentMinLoadedToMMU, config::pulleySlowFeedrate);
|
||||
// }
|
||||
|
||||
mpu::pulley.PlanMove(config::maximumFeedToFinda, config::pulleySlowFeedrate);
|
||||
mpu::pulley.PlanMove(config::maximumFeedToFinda, mg::globals.PulleySlowFeedrate_mm_s());
|
||||
if (feedPhaseLimited) {
|
||||
state = PushingFilament;
|
||||
} else {
|
||||
state = PushingFilamentUnlimited;
|
||||
// in unlimited move we plan 2 moves at once to make the move "seamless"
|
||||
// one move has already been planned above, this is the second one
|
||||
mpu::pulley.PlanMove(config::maximumFeedToFinda, config::pulleySlowFeedrate);
|
||||
mpu::pulley.PlanMove(config::maximumFeedToFinda, mg::globals.PulleySlowFeedrate_mm_s());
|
||||
}
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InSelector);
|
||||
mui::userInput.Clear(); // remove all buffered events if any just before we wait for some input
|
||||
|
|
@ -68,7 +68,7 @@ bool FeedToFinda::Step() {
|
|||
return true; // return immediately to allow for a seamless planning of another move (like feeding to bondtech)
|
||||
} else if (mm::motion.QueueEmpty()) { // all moves have been finished and FINDA didn't switch on
|
||||
state = Failed;
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::off, ml::blink0);
|
||||
ml::leds.ActiveSlotError();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -85,7 +85,7 @@ bool FeedToFinda::Step() {
|
|||
return true; // return immediately to allow for a seamless planning of another move (like feeding to bondtech)
|
||||
} else if (mm::motion.PlannedMoves(mm::Pulley) < 2) {
|
||||
// plan another move to make the illusion of unlimited moves
|
||||
mpu::pulley.PlanMove(config::maximumFeedToFinda, config::pulleySlowFeedrate);
|
||||
mpu::pulley.PlanMove(config::maximumFeedToFinda, mg::globals.PulleySlowFeedrate_mm_s());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace logic {
|
|||
/// Leaves the Pulley axis enabled for chaining potential next operations
|
||||
struct FeedToFinda {
|
||||
/// internal states of the state machine
|
||||
enum {
|
||||
enum : uint8_t {
|
||||
EngagingIdler,
|
||||
PushingFilament,
|
||||
PushingFilamentUnlimited,
|
||||
|
|
@ -23,9 +23,10 @@ struct FeedToFinda {
|
|||
Stopped
|
||||
};
|
||||
|
||||
inline FeedToFinda()
|
||||
inline constexpr FeedToFinda()
|
||||
: state(OK)
|
||||
, feedPhaseLimited(true) {}
|
||||
, feedPhaseLimited(true)
|
||||
, haltAtEnd(0) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param feedPhaseLimited
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace logic {
|
|||
/// This high-level command is just a way to invoke re-homing from the printer while all safety measures are kept.
|
||||
class Home : public CommandBase {
|
||||
public:
|
||||
inline Home()
|
||||
inline constexpr Home()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
/// @file hw_sanity.cpp
|
||||
#include <string.h>
|
||||
#include "hw_sanity.h"
|
||||
#include "command_base.h"
|
||||
#include "../modules/globals.h"
|
||||
#include "../modules/motion.h"
|
||||
#include "../modules/leds.h"
|
||||
|
|
@ -26,13 +28,11 @@ bool HWSanity::Reset(uint8_t param) {
|
|||
state = ProgressCode::HWTestBegin;
|
||||
error = ErrorCode::RUNNING;
|
||||
axis = config::Axis::Idler;
|
||||
fault_masks[0] = 0;
|
||||
fault_masks[1] = 0;
|
||||
fault_masks[2] = 0;
|
||||
memset(fault_masks, 0, sizeof(fault_masks));
|
||||
return true;
|
||||
}
|
||||
|
||||
enum pin_bits {
|
||||
enum pin_bits : uint8_t {
|
||||
BIT_STEP = 0b001,
|
||||
BIT_DIR = 0b010,
|
||||
BIT_ENA = 0b100,
|
||||
|
|
@ -140,20 +140,12 @@ bool HWSanity::StepInner() {
|
|||
// error, display it and return the code.
|
||||
state = ProgressCode::ErrHwTestFailed;
|
||||
error = ErrorCode::MMU_SOLDERING_NEEDS_ATTENTION;
|
||||
uint8_t mask = fault_masks[Axis::Idler];
|
||||
if (mask) {
|
||||
error |= ErrorCode::TMC_IDLER_BIT;
|
||||
SetFaultDisplay(0, mask);
|
||||
}
|
||||
mask = fault_masks[Axis::Pulley];
|
||||
if (mask) {
|
||||
error |= ErrorCode::TMC_PULLEY_BIT;
|
||||
SetFaultDisplay(2, mask);
|
||||
}
|
||||
mask = fault_masks[Axis::Selector];
|
||||
if (mask) {
|
||||
error |= ErrorCode::TMC_SELECTOR_BIT;
|
||||
SetFaultDisplay(1, mask);
|
||||
for (uint8_t axis = 0; axis < 3; axis++) {
|
||||
const uint8_t mask = fault_masks[axis];
|
||||
if (mask) {
|
||||
error = logic::AddErrorAxisBit(error, axis);
|
||||
SetFaultDisplay(axis, mask);
|
||||
}
|
||||
}
|
||||
ml::leds.SetMode(3, ml::red, ml::off);
|
||||
ml::leds.SetMode(3, ml::green, ml::off);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace logic {
|
|||
|
||||
class HWSanity : public CommandBase {
|
||||
public:
|
||||
inline HWSanity()
|
||||
inline constexpr HWSanity()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
@ -44,7 +44,7 @@ private:
|
|||
static void PrepareAxis(config::Axis axis);
|
||||
|
||||
uint8_t test_step = 0;
|
||||
config::Axis axis;
|
||||
config::Axis axis = config::Axis::Pulley;
|
||||
uint8_t fault_masks[3] = { 0 };
|
||||
ProgressCode next_state = ProgressCode::HWTestBegin;
|
||||
uint16_t wait_start = 0;
|
||||
|
|
|
|||
|
|
@ -50,8 +50,6 @@ void logic::LoadFilament::Reset2(bool feedPhaseLimited) {
|
|||
if (!feed.Reset(feedPhaseLimited, true)) {
|
||||
// selector refused to move
|
||||
GoToErrDisengagingIdler(ErrorCode::FINDA_FLICKERS);
|
||||
} else {
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@ namespace logic {
|
|||
/// @brief A high-level command state machine - handles the complex logic of loading filament into a filament slot.
|
||||
class LoadFilament : public CommandBase {
|
||||
public:
|
||||
inline LoadFilament()
|
||||
inline constexpr LoadFilament()
|
||||
: CommandBase()
|
||||
, verifyLoadedFilament(0) {}
|
||||
, verifyLoadedFilament(0)
|
||||
, result(ResultCode::OK) {}
|
||||
|
||||
/// Restart the automaton - performs unlimited rotation of the Pulley
|
||||
/// @param param index of filament slot to load
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace logic {
|
|||
/// and/or from the MMU's buttons while all safety measures are kept.
|
||||
class MoveSelector : public CommandBase {
|
||||
public:
|
||||
inline MoveSelector()
|
||||
inline constexpr MoveSelector()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace logic {
|
|||
/// @brief A dummy No-command operation just to make the init of the firmware consistent (and cleaner code during processing).
|
||||
class NoCommand : public CommandBase {
|
||||
public:
|
||||
inline NoCommand()
|
||||
inline constexpr NoCommand()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -2,16 +2,19 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
/// Base class for ProgressCode and its extensions
|
||||
using RawProgressCode = uint_fast8_t;
|
||||
|
||||
/// A complete set of progress codes which may be reported while running a high-level command/operation
|
||||
/// This header file shall be included in the printer's firmware as well as a reference,
|
||||
/// therefore the progress codes have been extracted to one place
|
||||
enum class ProgressCode : uint_fast8_t {
|
||||
enum class ProgressCode : RawProgressCode {
|
||||
OK = 0, ///< finished ok
|
||||
|
||||
EngagingIdler, // P1
|
||||
DisengagingIdler, // P2
|
||||
UnloadingToFinda, // P3
|
||||
UnloadingToPulley, //P4
|
||||
UnloadingToPulley, // P4
|
||||
FeedingToFinda, // P5
|
||||
FeedingToBondtech, // P6
|
||||
FeedingToNozzle, // P7
|
||||
|
|
@ -37,7 +40,7 @@ enum class ProgressCode : uint_fast8_t {
|
|||
RetractingFromFinda, // P25
|
||||
|
||||
Homing, // P26
|
||||
MovingSelector, // P27
|
||||
MovingSelector, // P2
|
||||
|
||||
FeedingToFSensor, // P28
|
||||
|
||||
|
|
@ -50,5 +53,9 @@ enum class ProgressCode : uint_fast8_t {
|
|||
HWTestDisplay, // P35
|
||||
ErrHwTestFailed, // P36
|
||||
|
||||
/// Keep as the last item (except for Empty)
|
||||
/// Used for extending the progress codes on the printer side
|
||||
_cnt,
|
||||
|
||||
Empty = 0xff // dummy empty state
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
/// therefore the error codes have been extracted to one place.
|
||||
///
|
||||
/// Please note that currently only LoadFilament can return something else than "OK"
|
||||
enum class ResultCode : uint_fast16_t {
|
||||
enum class ResultCode : uint_fast8_t {
|
||||
OK = 0,
|
||||
Cancelled = 1
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace logic {
|
|||
void RetractFromFinda::Reset() {
|
||||
dbg_logic_P(PSTR("\nRetract from FINDA\n\n"));
|
||||
state = EngagingIdler;
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
|
||||
ml::leds.ActiveSlotProcessing();
|
||||
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||
}
|
||||
|
||||
|
|
@ -33,10 +33,10 @@ bool RetractFromFinda::Step() {
|
|||
state = OK;
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::AtPulley);
|
||||
dbg_logic_fP(PSTR("Pulley end steps %u"), mpu::pulley.CurrentPosition_mm());
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
|
||||
ml::leds.ActiveSlotDoneEmpty();
|
||||
} else { // FINDA didn't switch off
|
||||
state = Failed;
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::off, ml::blink0);
|
||||
ml::leds.ActiveSlotError();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ namespace logic {
|
|||
/// - leaves idler engaged for chaining operations
|
||||
struct RetractFromFinda {
|
||||
/// internal states of the state machine
|
||||
enum {
|
||||
enum : uint8_t {
|
||||
EngagingIdler,
|
||||
UnloadBackToPTFE,
|
||||
OK,
|
||||
Failed
|
||||
};
|
||||
|
||||
inline RetractFromFinda()
|
||||
inline constexpr RetractFromFinda()
|
||||
: state(OK) {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace logic {
|
|||
/// (regardless of how long it takes it to finish) - that implies no motor moves are being performed while M0/M1 is being applied.
|
||||
class SetMode : public CommandBase {
|
||||
public:
|
||||
inline SetMode()
|
||||
inline constexpr SetMode()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace logic {
|
|||
/// @brief Firmware start up sequence with error handling & reporting
|
||||
class StartUp : public CommandBase {
|
||||
public:
|
||||
inline StartUp()
|
||||
inline constexpr StartUp()
|
||||
: CommandBase() {}
|
||||
|
||||
/// Restart the automaton
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ bool ToolChange::Reset(uint8_t param) {
|
|||
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
||||
dbg_logic_P(PSTR("Filament is loaded --> unload"));
|
||||
state = ProgressCode::UnloadingFilament;
|
||||
unl.Reset(mg::globals.ActiveSlot());
|
||||
unl.Reset2(mg::globals.ActiveSlot());
|
||||
} else {
|
||||
mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::InSelector); // activate the correct slot, feed uses that
|
||||
if (feed.Reset(true, false)) {
|
||||
|
|
@ -54,20 +54,19 @@ bool ToolChange::Reset(uint8_t param) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void logic::ToolChange::GoToFeedingToBondtech() {
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
|
||||
void ToolChange::GoToFeedingToBondtech() {
|
||||
james.Reset(3);
|
||||
state = ProgressCode::FeedingToBondtech;
|
||||
error = ErrorCode::RUNNING;
|
||||
}
|
||||
|
||||
void logic::ToolChange::ToolChangeFinishedCorrectly() {
|
||||
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::on, ml::off);
|
||||
void ToolChange::ToolChangeFinishedCorrectly() {
|
||||
ml::leds.ActiveSlotDonePrimed();
|
||||
mui::userInput.SetPrinterInCharge(false);
|
||||
FinishedOK();
|
||||
}
|
||||
|
||||
void logic::ToolChange::GoToFeedingToFinda() {
|
||||
void ToolChange::GoToFeedingToFinda() {
|
||||
state = ProgressCode::FeedingToFinda;
|
||||
error = ErrorCode::RUNNING;
|
||||
mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::AtPulley);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ namespace logic {
|
|||
/// @brief A high-level command state machine - handles the complex logic of tool change - which is basically a chain of an Unload and a Load operation.
|
||||
class ToolChange : public CommandBase {
|
||||
public:
|
||||
inline ToolChange()
|
||||
: CommandBase() {}
|
||||
inline constexpr ToolChange()
|
||||
: CommandBase()
|
||||
, plannedSlot(-1) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param param index of filament slot to change to - i.e. to load
|
||||
|
|
|
|||
|
|
@ -28,11 +28,17 @@ bool UnloadFilament::Reset(uint8_t /*param*/) {
|
|||
mpu::pulley.InitAxis();
|
||||
state = ProgressCode::UnloadingToFinda;
|
||||
error = ErrorCode::RUNNING;
|
||||
skipDisengagingIdler = false;
|
||||
unl.Reset(maxRetries);
|
||||
ml::leds.SetAllOff();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UnloadFilament::Reset2(uint8_t param) {
|
||||
bool rv = Reset(param);
|
||||
skipDisengagingIdler = true;
|
||||
return rv;
|
||||
}
|
||||
|
||||
void UnloadFilament::UnloadFinishedCorrectly() {
|
||||
FinishedOK();
|
||||
mpu::pulley.Disable();
|
||||
|
|
@ -77,7 +83,11 @@ bool UnloadFilament::StepInner() {
|
|||
GoToErrDisengagingIdler(ErrorCode::FINDA_DIDNT_SWITCH_OFF); // signal unloading error
|
||||
} else {
|
||||
state = ProgressCode::DisengagingIdler;
|
||||
mi::idler.Disengage();
|
||||
if (skipDisengagingIdler && ms::selector.State() == ms::Selector::Ready) {
|
||||
UnloadFinishedCorrectly(); // skip disengaging the Idler - to be used inside ToolChange to speed up
|
||||
} else {
|
||||
mi::idler.Disengage();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -11,13 +11,16 @@ namespace logic {
|
|||
/// @brief A high-level command state machine - handles the complex logic of unloading filament
|
||||
class UnloadFilament : public CommandBase {
|
||||
public:
|
||||
inline UnloadFilament()
|
||||
: CommandBase() {}
|
||||
inline constexpr UnloadFilament()
|
||||
: CommandBase()
|
||||
, skipDisengagingIdler(false) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param param is not used, always unloads from the active slot
|
||||
bool Reset(uint8_t param) override;
|
||||
|
||||
bool Reset2(uint8_t param);
|
||||
|
||||
/// @returns true if the state machine finished its job, false otherwise
|
||||
bool StepInner() override;
|
||||
|
||||
|
|
@ -32,6 +35,7 @@ private:
|
|||
UnloadToFinda unl;
|
||||
FeedToFinda feed;
|
||||
RetractFromFinda retract;
|
||||
bool skipDisengagingIdler;
|
||||
};
|
||||
|
||||
/// The one and only instance of UnloadFilament state machine in the FW
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "../modules/motion.h"
|
||||
#include "../modules/permanent_storage.h"
|
||||
#include "../modules/pulley.h"
|
||||
#include "../modules/timebase.h"
|
||||
|
||||
namespace logic {
|
||||
|
||||
|
|
@ -19,19 +20,40 @@ void UnloadToFinda::Reset(uint8_t maxTries) {
|
|||
} else {
|
||||
// FINDA is sensing the filament, plan moves to unload it
|
||||
state = EngagingIdler;
|
||||
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||
mi::idler.PartiallyDisengage(mg::globals.ActiveSlot()); // basically prepare before the active slot - saves ~1s
|
||||
started_ms = mt::timebase.Millis();
|
||||
ml::leds.ActiveSlotProcessing();
|
||||
}
|
||||
}
|
||||
|
||||
bool UnloadToFinda::Step() {
|
||||
switch (state) {
|
||||
// start by engaging the idler into intermediate position
|
||||
// Then, wait for !fsensor.Pressed: that's to speed-up the pull process - unload operation will be started during the purging moves
|
||||
// and as soon as the fsensor turns off, the MMU engages the idler fully and starts pulling.
|
||||
// It will not wait for the extruder to finish the relieve move.
|
||||
// However, such an approach breaks running the MMU on a non-reworked MK4/C1, which hasn't been officially supported, but possible (with some level of uncertainity).
|
||||
case EngagingIdler:
|
||||
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
||||
state = UnloadingToFinda;
|
||||
mpu::pulley.InitAxis();
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0);
|
||||
if (!mi::idler.PartiallyDisengaged()) { // just waiting for Idler to get into the target intermediate position
|
||||
return false;
|
||||
}
|
||||
if (mfs::fsensor.Pressed()) { // still pressed, printer didn't free the filament yet
|
||||
if (mt::timebase.Elapsed(started_ms, 4000)) {
|
||||
state = FailedFSensor; // fsensor didn't turn off within 4 seconds, something is seriously wrong
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
state = FailedFINDA;
|
||||
// fsensor is OFF and Idler is partially engaged, engage the Idler fully and pull
|
||||
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
||||
state = UnloadingToFinda;
|
||||
mpu::pulley.InitAxis();
|
||||
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||
|
||||
// slow move for the first few millimeters - help the printer relieve the filament while engaging the Idler fully
|
||||
mpu::pulley.PlanMove(-config::fsensorToNozzleAvoidGrindUnload, mg::globals.PulleySlowFeedrate_mm_s(), mg::globals.PulleySlowFeedrate_mm_s());
|
||||
} else {
|
||||
state = FailedFINDA;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
case UnloadingToFinda:
|
||||
|
|
@ -39,7 +61,13 @@ bool UnloadToFinda::Step() {
|
|||
state = WaitingForFINDA;
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InSelector);
|
||||
unloadStart_mm = mpu::pulley.CurrentPosition_mm();
|
||||
mpu::pulley.PlanMove(-config::defaultBowdenLength - config::feedToFinda - config::filamentMinLoadedToMMU, mg::globals.PulleyUnloadFeedrate_mm_s());
|
||||
// We can always plan the unload move for the maximum allowed bowden length,
|
||||
// it should be even more reliable than doing just the specified bowden length:
|
||||
// - if the filament is slipping for some reason, planning a longer move will not stop in the middle of the bowden tube
|
||||
// - a faster unload (shorter than the specified bowden length) will be interrupted by FINDA turning off
|
||||
// - if FINDA is misaligned or faulty, the only issue will be, that the filament will be thrown behind the pulley
|
||||
// which could have happened with the previous implementation as well, because default bowden length was set to 42cm
|
||||
mpu::pulley.PlanMove(-config::maximumBowdenLength - config::feedToFinda - config::filamentMinLoadedToMMU, mg::globals.PulleyUnloadFeedrate_mm_s());
|
||||
}
|
||||
return false;
|
||||
case WaitingForFINDA: {
|
||||
|
|
@ -49,17 +77,20 @@ bool UnloadToFinda::Step() {
|
|||
// This scenario should not be tried again - repeating it may cause more damage to filament + potentially more collateral damage
|
||||
state = FailedFSensor;
|
||||
mm::motion.AbortPlannedMoves(); // stop rotating the pulley
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
|
||||
ml::leds.ActiveSlotDoneEmpty();
|
||||
} else if (!mf::finda.Pressed()) {
|
||||
// detected end of filament
|
||||
state = OK;
|
||||
mm::motion.AbortPlannedMoves(); // stop rotating the pulley
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
|
||||
ml::leds.ActiveSlotDoneEmpty();
|
||||
} else if (/*tmc2130_read_gstat() &&*/ mm::motion.QueueEmpty()) {
|
||||
// we reached the end of move queue, but the FINDA didn't switch off
|
||||
// two possible causes - grinded filament or malfunctioning FINDA
|
||||
if (--maxTries) {
|
||||
Reset(maxTries); // try again
|
||||
// Ideally, the Idler shall rehome and then try again.
|
||||
// That would auto-resolve errors caused by slipped or misaligned Idler
|
||||
mi::idler.InvalidateHoming();
|
||||
Reset(maxTries);
|
||||
} else {
|
||||
state = FailedFINDA;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace logic {
|
|||
/// - load/unload to finda
|
||||
struct UnloadToFinda {
|
||||
/// internal states of the state machine
|
||||
enum {
|
||||
enum : uint8_t {
|
||||
EngagingIdler,
|
||||
UnloadingToFinda,
|
||||
WaitingForFINDA,
|
||||
|
|
@ -21,8 +21,11 @@ struct UnloadToFinda {
|
|||
FailedFINDA,
|
||||
FailedFSensor
|
||||
};
|
||||
inline UnloadToFinda()
|
||||
: maxTries(3) {}
|
||||
inline constexpr UnloadToFinda()
|
||||
: state(OK)
|
||||
, maxTries(3)
|
||||
, unloadStart_mm(0)
|
||||
, started_ms(0) {}
|
||||
|
||||
/// Restart the automaton
|
||||
/// @param maxTries maximum number of retried attempts before reporting a fail
|
||||
|
|
@ -38,6 +41,7 @@ private:
|
|||
uint8_t state;
|
||||
uint8_t maxTries;
|
||||
int32_t unloadStart_mm; // intentionally trying to avoid using U_mm because it is a float (reps. long double)
|
||||
uint16_t started_ms; // timeout on fsensor turn off
|
||||
};
|
||||
|
||||
} // namespace logic
|
||||
|
|
|
|||
|
|
@ -95,10 +95,7 @@ static void setup2() {
|
|||
mb::buttons.Step();
|
||||
|
||||
// Turn off all leds
|
||||
for (uint8_t i = 0; i < config::toolCount; i++) {
|
||||
ml::leds.SetMode(i, ml::green, ml::off);
|
||||
ml::leds.SetMode(i, ml::red, ml::off);
|
||||
}
|
||||
ml::leds.SetAllOff();
|
||||
ml::leds.Step();
|
||||
mb::buttons.Step();
|
||||
|
||||
|
|
@ -128,7 +125,7 @@ static void setup2() {
|
|||
|
||||
// activate the correct LED if filament is present
|
||||
if (mg::globals.FilamentLoaded() > mg::FilamentLoadState::AtPulley) {
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on);
|
||||
ml::leds.ActiveSlotDonePrimed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
///@mainpage Prusa Multi Material Unit for the MK4
|
||||
///@mainpage Prusa Multi Material Unit for the MKS3 and MK4
|
||||
///@section intro_sec Introduction
|
||||
///
|
||||
/// This is the new firmware for the Multi Material Unit (MMU).
|
||||
|
|
|
|||
|
|
@ -94,12 +94,13 @@ constexpr AxisUnit<T, A, U> operator*(const long double f, const AxisUnit<T, A,
|
|||
struct AxisScale {
|
||||
unit::UnitBase base;
|
||||
long double stepsPerUnit;
|
||||
long double stepsPerUnitReciprocal;
|
||||
};
|
||||
|
||||
static constexpr AxisScale axisScale[config::NUM_AXIS] = {
|
||||
{ config::pulleyLimits.base, config::pulley.stepsPerUnit },
|
||||
{ config::selectorLimits.base, config::selector.stepsPerUnit },
|
||||
{ config::idlerLimits.base, config::idler.stepsPerUnit },
|
||||
{ config::pulleyLimits.base, config::pulley.stepsPerUnit, config::pulley.stepsPerUnitReciprocal },
|
||||
{ config::selectorLimits.base, config::selector.stepsPerUnit, config::selector.stepsPerUnitReciprocal },
|
||||
{ config::idlerLimits.base, config::idler.stepsPerUnit, config::idler.stepsPerUnitReciprocal },
|
||||
};
|
||||
|
||||
/// Convert a unit::Unit to AxisUnit.
|
||||
|
|
@ -126,7 +127,7 @@ template <typename U, typename AU, typename T = int32_t>
|
|||
static constexpr T axisUnitToTruncatedUnit(AU v, long double mul = 1.) {
|
||||
static_assert(AU::unit == U::unit, "incorrect unit type conversion");
|
||||
static_assert(U::base == axisScale[AU::axis].base, "incorrect unit base conversion");
|
||||
return { ((T)v.v / (T)(axisScale[AU::axis].stepsPerUnit / mul)) };
|
||||
return { ((T)(v.v * (axisScale[AU::axis].stepsPerUnitReciprocal / mul))) };
|
||||
}
|
||||
|
||||
/// Truncate an Unit type to an integer (normally int32_t)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ private:
|
|||
};
|
||||
|
||||
/// Enum of buttons - used also as indices in an array of buttons to keep the code size tight.
|
||||
enum {
|
||||
enum : uint8_t {
|
||||
Right = 0,
|
||||
Middle,
|
||||
Left
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ private:
|
|||
/// Intentionally not modeled as an enum class
|
||||
/// as it would impose additional casts which do not play well with the struct Flags
|
||||
/// and would make the code less readable
|
||||
enum State {
|
||||
enum State : uint8_t {
|
||||
Waiting = 0,
|
||||
Detected,
|
||||
WaitForRelease,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ void Globals::Init() {
|
|||
ResetIdlerHomingFeedrate();
|
||||
|
||||
ResetCutIRunCurrent();
|
||||
ResetCutLength();
|
||||
}
|
||||
|
||||
uint8_t Globals::ActiveSlot() const {
|
||||
|
|
|
|||
|
|
@ -109,6 +109,10 @@ public:
|
|||
void ResetCutIRunCurrent() { cutIRunCurrent = config::selectorCutIRun; }
|
||||
void SetCutIRunCurrent(uint8_t v) { cutIRunCurrent = v; }
|
||||
|
||||
config::U_mm CutLength() const { return config::U_mm({ (long double)cutLength_mm }); }
|
||||
void ResetCutLength() { cutLength_mm = config::cutLength.v; }
|
||||
void SetCutLength(uint8_t v) { cutLength_mm = v; }
|
||||
|
||||
private:
|
||||
/// Sets the active slot, usually after some command/operation.
|
||||
/// Also updates the EEPROM records accordingly
|
||||
|
|
@ -132,6 +136,7 @@ private:
|
|||
uint16_t idlerHomingFeedrate_deg_s;
|
||||
|
||||
uint8_t cutIRunCurrent;
|
||||
uint8_t cutLength_mm;
|
||||
};
|
||||
|
||||
/// The one and only instance of global state variables
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ void Idler::PlanHomingMoveBack() {
|
|||
bool Idler::FinishHomingAndPlanMoveToParkPos() {
|
||||
// check the axis' length
|
||||
if (AxisDistance(mm::axisUnitToTruncatedUnit<config::U_deg>(mm::motion.CurPosition<mm::Idler>()))
|
||||
< (config::idlerLimits.lenght.v - 10)) { //@@TODO is 10 degrees ok?
|
||||
< uint16_t(config::idlerLimits.lenght.v - 10)) { //@@TODO is 10 degrees ok?
|
||||
return false; // we couldn't home correctly, we cannot set the Idler's position
|
||||
}
|
||||
|
||||
|
|
@ -64,32 +64,12 @@ void Idler::FinishMove() {
|
|||
}
|
||||
|
||||
bool Idler::StallGuardAllowed(bool forward) const {
|
||||
const uint8_t checkDistance = forward ? 220 : 200;
|
||||
const uint8_t checkDistance = forward ? 200 : 180;
|
||||
return AxisDistance(mm::axisUnitToTruncatedUnit<config::U_deg>(mm::motion.CurPosition<mm::Idler>())) > checkDistance;
|
||||
}
|
||||
|
||||
Idler::OperationResult Idler::Disengage() {
|
||||
if (state == Moving || IsOnHold()) {
|
||||
dbg_logic_P(PSTR("Moving --> Disengage refused"));
|
||||
return OperationResult::Refused;
|
||||
}
|
||||
plannedSlot = IdleSlotIndex();
|
||||
plannedMove = Operation::disengage;
|
||||
|
||||
// coordinates invalid, first home, then disengage
|
||||
if (!homingValid) {
|
||||
PlanHome();
|
||||
return OperationResult::Accepted;
|
||||
}
|
||||
|
||||
// already disengaged
|
||||
if (Disengaged()) {
|
||||
dbg_logic_P(PSTR("Idler Disengaged"));
|
||||
return OperationResult::Accepted;
|
||||
}
|
||||
|
||||
// disengaging
|
||||
return InitMovementNoReinitAxis();
|
||||
return PlanMoveInner(IdleSlotIndex(), Operation::disengage);
|
||||
}
|
||||
|
||||
Idler::OperationResult Idler::PartiallyDisengage(uint8_t slot) {
|
||||
|
|
@ -114,7 +94,7 @@ Idler::OperationResult Idler::PlanMoveInner(uint8_t slot, Operation plannedOp) {
|
|||
return OperationResult::Accepted;
|
||||
}
|
||||
|
||||
// coordinates invalid, first home, then engage
|
||||
// coordinates invalid, first home, then engage or disengage
|
||||
// The MMU FW only decides to engage the Idler when it is supposed to do something and not while it is idle
|
||||
// so rebooting the MMU while the printer is printing (and thus holding the filament by the moving Idler)
|
||||
// should not be an issue
|
||||
|
|
@ -123,8 +103,8 @@ Idler::OperationResult Idler::PlanMoveInner(uint8_t slot, Operation plannedOp) {
|
|||
return OperationResult::Accepted;
|
||||
}
|
||||
|
||||
// already engaged
|
||||
if (currentlyEngaged == plannedMove) {
|
||||
// already engaged or disengaged
|
||||
if (currentlyEngaged == plannedMove && currentSlot == plannedSlot) {
|
||||
return OperationResult::Accepted;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "leds.h"
|
||||
#include "../hal/shr16.h"
|
||||
#include "timebase.h"
|
||||
#include "globals.h"
|
||||
|
||||
namespace modules {
|
||||
namespace leds {
|
||||
|
|
@ -68,5 +69,21 @@ void LEDs::SetAllOff() {
|
|||
}
|
||||
}
|
||||
|
||||
void LEDs::ActiveSlotProcessing() {
|
||||
SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
|
||||
}
|
||||
|
||||
void LEDs::ActiveSlotError() {
|
||||
SetPairButOffOthers(mg::globals.ActiveSlot(), ml::off, ml::blink0);
|
||||
}
|
||||
|
||||
void LEDs::ActiveSlotDoneEmpty() {
|
||||
SetPairButOffOthers(mg::globals.ActiveSlot(), ml::off, ml::off);
|
||||
}
|
||||
|
||||
void LEDs::ActiveSlotDonePrimed() {
|
||||
SetPairButOffOthers(mg::globals.ActiveSlot(), ml::on, ml::off);
|
||||
}
|
||||
|
||||
} // namespace leds
|
||||
} // namespace modules
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace leds {
|
|||
|
||||
/// Enum of LED modes
|
||||
/// blink0 and blink1 allow for interlaced blinking of LEDs (one is on and the other off)
|
||||
enum Mode {
|
||||
enum Mode : uint8_t {
|
||||
off,
|
||||
on,
|
||||
blink0, ///< start blinking at even periods
|
||||
|
|
@ -28,7 +28,7 @@ enum Mode {
|
|||
};
|
||||
|
||||
/// Enum of LEDs color - green or red
|
||||
enum Color {
|
||||
enum Color : uint8_t {
|
||||
red = 0,
|
||||
green = 1
|
||||
};
|
||||
|
|
@ -122,6 +122,14 @@ public:
|
|||
/// Turn off all LEDs
|
||||
void SetAllOff();
|
||||
|
||||
/// Convenience functions - provide uniform implementation of LED behaviour through all the logic commands.
|
||||
/// Intentionally not inlined to save quite some space (140B)
|
||||
/// It's not a clean solution, LEDs should not know about mg::globals.ActiveSlot(), but the savings are important
|
||||
void ActiveSlotProcessing();
|
||||
void ActiveSlotError();
|
||||
void ActiveSlotDoneEmpty();
|
||||
void ActiveSlotDonePrimed();
|
||||
|
||||
private:
|
||||
constexpr static const uint8_t ledPairs = config::toolCount;
|
||||
/// pairs of LEDs:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace motion {
|
|||
class MovableBase {
|
||||
public:
|
||||
/// Internal states of the state machine
|
||||
enum {
|
||||
enum : uint8_t {
|
||||
Ready = 0, // intentionally set as zero in order to allow zeroing the Idler structure upon startup -> avoid explicit initialization code
|
||||
Moving = 1,
|
||||
PlannedHome = 2,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "../hal/eeprom.h"
|
||||
#include "globals.h"
|
||||
#include "../config/config.h"
|
||||
#include "axisunit.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
|
@ -19,13 +20,14 @@ namespace permanent_storage {
|
|||
/// Last byte in EEPROM is reserved for layoutVersion. If some field is repurposed, layoutVersion
|
||||
/// needs to be changed to force an EEPROM erase.
|
||||
struct eeprom_t {
|
||||
uint8_t eepromLengthCorrection; ///< Legacy bowden length correction
|
||||
uint16_t eepromBowdenLen[config::toolCount]; ///< Bowden length for each filament
|
||||
uint8_t eepromLengthCorrection; ///< pre-MMU Legacy bowden length correction - not used
|
||||
uint16_t eepromBowdenLen[config::toolCount]; ///< MMU Bowden length for each filament - not used
|
||||
uint8_t eepromFilamentStatus[3]; ///< Majority vote status of eepromFilament wear leveling
|
||||
uint8_t eepromFilament[800]; ///< Top nibble status, bottom nibble last filament loaded
|
||||
uint8_t eepromDriveErrorCountH;
|
||||
uint8_t eepromDriveErrorCountL[2];
|
||||
uint8_t sg_thrs[3];
|
||||
uint16_t bowdenLengthMM; ///< MMU3 default bowden length in millimeters
|
||||
} __attribute__((packed));
|
||||
|
||||
static_assert(sizeof(eeprom_t) - 2 <= hal::eeprom::EEPROM::End(), "eeprom_t doesn't fit into EEPROM available.");
|
||||
|
|
@ -44,14 +46,13 @@ static const uint8_t layoutVersion = 0xff;
|
|||
// ideally, this would have been a nice constexpr (since it is a compile time constant), but the C++ standard prohibits reinterpret_casts in constexpr
|
||||
static eeprom_t *const eepromBase = reinterpret_cast<eeprom_t *>(0); ///< First EEPROM address
|
||||
constexpr const uint16_t eepromEmpty = 0xffffU; ///< EEPROM content when erased
|
||||
constexpr const uint16_t eepromLengthCorrectionBase = 7900U; ///< legacy bowden length correction base (~391mm)
|
||||
constexpr const uint16_t eepromBowdenLenDefault = 8900U; ///< Default bowden length (~427 mm)
|
||||
constexpr const uint16_t eepromBowdenLenMinimum = 6900U; ///< Minimum bowden length (~341 mm)
|
||||
constexpr const uint16_t eepromBowdenLenMaximum = 16000U; ///< Maximum bowden length (~792 mm)
|
||||
constexpr const uint16_t eepromBowdenLenDefault = config::defaultBowdenLength.v; ///< Default bowden length (~360 mm)
|
||||
constexpr const uint16_t eepromBowdenLenMinimum = config::minimumBowdenLength.v; ///< Minimum bowden length (~341 mm)
|
||||
constexpr const uint16_t eepromBowdenLenMaximum = config::maximumBowdenLength.v; ///< Maximum bowden length (~1000 mm)
|
||||
|
||||
namespace ee = hal::eeprom;
|
||||
|
||||
#define EEOFFSET(x) reinterpret_cast<size_t>(&(x))
|
||||
#define EEOFFSET(x) reinterpret_cast<ee::EEPROM::addr_t>(&(x))
|
||||
|
||||
void Init() {
|
||||
if (ee::EEPROM::ReadByte(ee::EEPROM::End()) != layoutVersion) {
|
||||
|
|
@ -66,88 +67,22 @@ void EraseAll() {
|
|||
ee::EEPROM::UpdateByte(ee::EEPROM::End(), layoutVersion);
|
||||
}
|
||||
|
||||
/// @brief Is filament number valid?
|
||||
/// @retval true valid
|
||||
/// @retval false invalid
|
||||
static bool validFilament(uint8_t filament) {
|
||||
return filament < ARR_SIZE(eeprom_t::eepromBowdenLen);
|
||||
}
|
||||
|
||||
/// @brief Is bowden length in valid range?
|
||||
/// @param BowdenLength bowden length
|
||||
/// @retval true valid
|
||||
/// @retval false invalid
|
||||
static bool validBowdenLen(const uint16_t BowdenLength) {
|
||||
if ((BowdenLength >= eepromBowdenLenMinimum)
|
||||
&& BowdenLength <= eepromBowdenLenMaximum) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
static constexpr bool validBowdenLen(const uint16_t BowdenLength) {
|
||||
return ((BowdenLength >= eepromBowdenLenMinimum)
|
||||
&& BowdenLength <= eepromBowdenLenMaximum);
|
||||
}
|
||||
|
||||
/// @brief Get bowden length for active filament
|
||||
///
|
||||
/// Returns stored value, doesn't return actual value when it is edited by increase() / decrease() unless it is stored.
|
||||
/// @return stored bowden length
|
||||
uint16_t BowdenLength::get() {
|
||||
uint8_t filament = mg::globals.ActiveSlot();
|
||||
if (validFilament(filament)) {
|
||||
// @@TODO these reinterpret_cast expressions look horrible but I'm keeping them almost intact to respect the original code from MM_control_01
|
||||
uint16_t bowdenLength = ee::EEPROM::ReadByte(reinterpret_cast<size_t>(&(eepromBase->eepromBowdenLen[filament])));
|
||||
|
||||
if (eepromEmpty == bowdenLength) {
|
||||
const uint8_t LengthCorrectionLegacy = ee::EEPROM::ReadByte(reinterpret_cast<size_t>(&(eepromBase->eepromLengthCorrection)));
|
||||
if (LengthCorrectionLegacy <= 200) {
|
||||
bowdenLength = eepromLengthCorrectionBase + LengthCorrectionLegacy * 10;
|
||||
}
|
||||
}
|
||||
if (validBowdenLen(bowdenLength))
|
||||
return bowdenLength;
|
||||
}
|
||||
|
||||
return eepromBowdenLenDefault;
|
||||
uint16_t BowdenLength::Get() {
|
||||
uint16_t bl = ee::EEPROM::ReadWord(EEOFFSET(eepromBase->bowdenLengthMM));
|
||||
return validBowdenLen(bl) ? bl : eepromBowdenLenDefault;
|
||||
}
|
||||
|
||||
/// @brief Construct BowdenLength object which allows bowden length manipulation
|
||||
///
|
||||
/// To be created on stack, new value is permanently stored when object goes out of scope.
|
||||
/// Active filament and associated bowden length is stored in member variables.
|
||||
BowdenLength::BowdenLength()
|
||||
: filament(mg::globals.ActiveSlot()) // @@TODO - verify correct initialization order
|
||||
, length(BowdenLength::get()) // @@TODO
|
||||
{
|
||||
}
|
||||
|
||||
/// @brief Increase bowden length
|
||||
///
|
||||
/// New value is not stored immediately. See ~BowdenLength() for storing permanently.
|
||||
/// @retval true passed
|
||||
/// @retval false failed, it is not possible to increase, new bowden length would be out of range
|
||||
bool BowdenLength::increase() {
|
||||
if (validBowdenLen(length + stepSize)) {
|
||||
length += stepSize;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @brief Decrease bowden length
|
||||
///
|
||||
/// New value is not stored immediately. See ~BowdenLength() for storing permanently.
|
||||
/// @retval true passed
|
||||
/// @retval false failed, it is not possible to decrease, new bowden length would be out of range
|
||||
bool BowdenLength::decrease() {
|
||||
if (validBowdenLen(length - stepSize)) {
|
||||
length -= stepSize;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @brief Store bowden length permanently.
|
||||
BowdenLength::~BowdenLength() {
|
||||
if (validFilament(filament))
|
||||
ee::EEPROM::UpdateWord(EEOFFSET(eepromBase->eepromBowdenLen[filament]), length);
|
||||
void BowdenLength::Set(uint16_t mm) {
|
||||
ee::EEPROM::UpdateWord(EEOFFSET(eepromBase->bowdenLengthMM), mm);
|
||||
}
|
||||
|
||||
/// @brief Get filament storage status
|
||||
|
|
|
|||
|
|
@ -17,22 +17,21 @@ void Init();
|
|||
/// Erase the whole EEPROM
|
||||
void EraseAll();
|
||||
|
||||
/// @brief Read manipulate and store bowden length
|
||||
/// @brief Read and store bowden length
|
||||
///
|
||||
/// Value is stored independently for each filament.
|
||||
/// Active filament is deduced from active_extruder global variable.
|
||||
/// Legacy functions for setting bowden length for each slot have been removed (we are out of space).
|
||||
/// It doesn't look to be practical to set bowden lengths for per slot anymore,
|
||||
/// because the filament loading algoritm is much more intelligent than in FW 1.0.6
|
||||
/// and slight differences in pulley gear diameters will be hard to spot at runtime.
|
||||
/// Moreover, the FW now contains autotuning of the bowden length,
|
||||
/// so the user should not need to set the register in any way.
|
||||
class BowdenLength {
|
||||
public:
|
||||
static uint16_t get();
|
||||
static const uint8_t stepSize = 10u; ///< increase()/decrease() bowden length step size
|
||||
BowdenLength();
|
||||
bool increase();
|
||||
bool decrease();
|
||||
~BowdenLength();
|
||||
/// @returns default bowden length in millimeters
|
||||
static uint16_t Get();
|
||||
|
||||
private:
|
||||
uint8_t filament; ///< Selected filament
|
||||
uint16_t length; ///< Selected filament bowden length
|
||||
/// Sets
|
||||
static void Set(uint16_t mm);
|
||||
};
|
||||
|
||||
/// @brief Read and store last filament loaded to nozzle
|
||||
|
|
@ -69,7 +68,7 @@ public:
|
|||
static bool set(uint8_t filament);
|
||||
|
||||
private:
|
||||
enum Key {
|
||||
enum Key : uint8_t {
|
||||
KeyFront1,
|
||||
KeyReverse1,
|
||||
KeyFront2,
|
||||
|
|
|
|||
|
|
@ -11,11 +11,6 @@ namespace pulley {
|
|||
|
||||
Pulley pulley;
|
||||
|
||||
bool __attribute__((noinline)) Pulley::FinishHomingAndPlanMoveToParkPos() {
|
||||
mm::motion.SetPosition(mm::Pulley, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Pulley::Step() {
|
||||
if (IsOnHold()) {
|
||||
return true; // just wait, do nothing!
|
||||
|
|
@ -28,10 +23,6 @@ bool Pulley::Step() {
|
|||
case Moving:
|
||||
PerformMove();
|
||||
return false;
|
||||
case HomeBack:
|
||||
homingValid = true;
|
||||
FinishHomingAndPlanMoveToParkPos();
|
||||
return true;
|
||||
case Ready:
|
||||
return true;
|
||||
case TMCFailed:
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ protected:
|
|||
virtual void PrepareMoveToPlannedSlot() override {}
|
||||
virtual void PlanHomingMoveForward() override {}
|
||||
virtual void PlanHomingMoveBack() override {}
|
||||
virtual bool FinishHomingAndPlanMoveToParkPos() override;
|
||||
virtual bool FinishHomingAndPlanMoveToParkPos() override { return true; }
|
||||
virtual void FinishMove() override {}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ void Selector::PlanHomingMoveBack() {
|
|||
|
||||
bool Selector::FinishHomingAndPlanMoveToParkPos() {
|
||||
// check the axis' length
|
||||
if (AxisDistance(mm::axisUnitToTruncatedUnit<config::U_mm>(mm::motion.CurPosition<mm::Selector>())) < (config::selectorLimits.lenght.v - 3)) { //@@TODO is 3mm ok?
|
||||
if (AxisDistance(mm::axisUnitToTruncatedUnit<config::U_mm>(mm::motion.CurPosition<mm::Selector>())) < uint16_t(config::selectorLimits.lenght.v - 3)) { //@@TODO is 3mm ok?
|
||||
return false; // we couldn't home correctly, we cannot set the Selector's position
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = {
|
|||
.Address = CDC_TX_EPADDR,
|
||||
.Size = CDC_TXRX_EPSIZE,
|
||||
.Type = EP_TYPE_BULK,
|
||||
.Banks = 2,
|
||||
.Banks = 1,
|
||||
},
|
||||
.DataOUTEndpoint = {
|
||||
.Address = CDC_RX_EPADDR,
|
||||
.Size = CDC_TXRX_EPSIZE,
|
||||
.Type = EP_TYPE_BULK,
|
||||
.Banks = 2,
|
||||
.Banks = 1,
|
||||
},
|
||||
.NotificationEndpoint = {
|
||||
.Address = CDC_NOTIFICATION_EPADDR,
|
||||
|
|
@ -90,6 +90,14 @@ namespace usb {
|
|||
CDC cdc;
|
||||
|
||||
void CDC::Init() {
|
||||
#if defined(USE_STATIC_OPTIONS) && (USE_STATIC_OPTIONS & USB_OPT_MANUAL_PLL)
|
||||
#if defined(USB_SERIES_4_AVR)
|
||||
PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1));
|
||||
#endif
|
||||
USB_PLL_On();
|
||||
while (!(USB_PLL_IsReady()));
|
||||
#endif
|
||||
|
||||
USB_Init();
|
||||
|
||||
/* Create a regular character stream for the interface so that it can be used with the stdio.h functions */
|
||||
|
|
|
|||
38
src/pins.h
38
src/pins.h
|
|
@ -3,28 +3,28 @@
|
|||
#include "hal/gpio.h"
|
||||
|
||||
/// pin definitions
|
||||
static constexpr hal::gpio::GPIO_pin TMC2130_SPI_MISO_PIN = { GPIOB, 3 };
|
||||
static constexpr hal::gpio::GPIO_pin TMC2130_SPI_MOSI_PIN = { GPIOB, 2 };
|
||||
static constexpr hal::gpio::GPIO_pin TMC2130_SPI_SCK_PIN = { GPIOB, 1 };
|
||||
static constexpr hal::gpio::GPIO_pin TMC2130_SPI_SS_PIN = { GPIOB, 0 };
|
||||
static constexpr hal::gpio::GPIO_pin TMC2130_SPI_MISO_PIN = { GPIOB, (1 << 3) };
|
||||
static constexpr hal::gpio::GPIO_pin TMC2130_SPI_MOSI_PIN = { GPIOB, (1 << 2) };
|
||||
static constexpr hal::gpio::GPIO_pin TMC2130_SPI_SCK_PIN = { GPIOB, (1 << 1) };
|
||||
static constexpr hal::gpio::GPIO_pin TMC2130_SPI_SS_PIN = { GPIOB, (1 << 0) };
|
||||
|
||||
static constexpr hal::gpio::GPIO_pin SHR16_DATA = { GPIOB, 5 }; ///DS
|
||||
static constexpr hal::gpio::GPIO_pin SHR16_LATCH = { GPIOB, 6 }; ///STCP
|
||||
static constexpr hal::gpio::GPIO_pin SHR16_CLOCK = { GPIOC, 7 }; ///SHCP
|
||||
static constexpr hal::gpio::GPIO_pin SHR16_DATA = { GPIOB, (1 << 5) }; ///DS
|
||||
static constexpr hal::gpio::GPIO_pin SHR16_LATCH = { GPIOB, (1 << 6) }; ///STCP
|
||||
static constexpr hal::gpio::GPIO_pin SHR16_CLOCK = { GPIOC, (1 << 7) }; ///SHCP
|
||||
|
||||
static constexpr hal::gpio::GPIO_pin USART_RX = { GPIOD, 2 };
|
||||
static constexpr hal::gpio::GPIO_pin USART_TX = { GPIOD, 3 };
|
||||
static constexpr hal::gpio::GPIO_pin USART_RX = { GPIOD, (1 << 2) };
|
||||
static constexpr hal::gpio::GPIO_pin USART_TX = { GPIOD, (1 << 3) };
|
||||
|
||||
static constexpr hal::gpio::GPIO_pin PULLEY_CS_PIN = { GPIOC, 6 };
|
||||
static constexpr hal::gpio::GPIO_pin PULLEY_SG_PIN = { GPIOF, 4 };
|
||||
static constexpr hal::gpio::GPIO_pin PULLEY_STEP_PIN = { GPIOB, 4 };
|
||||
static constexpr hal::gpio::GPIO_pin PULLEY_CS_PIN = { GPIOC, (1 << 6) };
|
||||
static constexpr hal::gpio::GPIO_pin PULLEY_SG_PIN = { GPIOF, (1 << 4) };
|
||||
static constexpr hal::gpio::GPIO_pin PULLEY_STEP_PIN = { GPIOB, (1 << 4) };
|
||||
|
||||
static constexpr hal::gpio::GPIO_pin SELECTOR_CS_PIN = { GPIOD, 7 };
|
||||
static constexpr hal::gpio::GPIO_pin SELECTOR_SG_PIN = { GPIOF, 1 };
|
||||
static constexpr hal::gpio::GPIO_pin SELECTOR_STEP_PIN = { GPIOD, 4 };
|
||||
static constexpr hal::gpio::GPIO_pin SELECTOR_CS_PIN = { GPIOD, (1 << 7) };
|
||||
static constexpr hal::gpio::GPIO_pin SELECTOR_SG_PIN = { GPIOF, (1 << 1) };
|
||||
static constexpr hal::gpio::GPIO_pin SELECTOR_STEP_PIN = { GPIOD, (1 << 4) };
|
||||
|
||||
static constexpr hal::gpio::GPIO_pin IDLER_CS_PIN = { GPIOB, 7 };
|
||||
static constexpr hal::gpio::GPIO_pin IDLER_SG_PIN = { GPIOF, 0 };
|
||||
static constexpr hal::gpio::GPIO_pin IDLER_STEP_PIN = { GPIOD, 6 };
|
||||
static constexpr hal::gpio::GPIO_pin IDLER_CS_PIN = { GPIOB, (1 << 7) };
|
||||
static constexpr hal::gpio::GPIO_pin IDLER_SG_PIN = { GPIOF, (1 << 0) };
|
||||
static constexpr hal::gpio::GPIO_pin IDLER_STEP_PIN = { GPIOD, (1 << 6) };
|
||||
|
||||
static constexpr hal::gpio::GPIO_pin FINDA_PIN = { GPIOF, 6 }; /// PF6 A1 ADC6/TDI
|
||||
static constexpr hal::gpio::GPIO_pin FINDA_PIN = { GPIOF, (1 << 6) }; /// PF6 A1 ADC6/TDI
|
||||
|
|
|
|||
|
|
@ -145,9 +145,9 @@
|
|||
| 0x0bh 11 | uint8 | extra_load_distance | 00h 0 | 1eh 30 | unit mm | Read / Write | M707 A0x0b | M708 A0x0b Xnn
|
||||
| 0x0ch 12 | uint8 | FSensor_unload_check_dist. | 00h 0 | 28h 30 | unit mm | Read / Write | M707 A0x0c | M708 A0x0c Xnn
|
||||
| 0x0dh 13 | uint16 | Pulley_unload_feedrate | 0000h 0 | 005fh 95 | unit mm/s | Read / Write | M707 A0x0d | M708 A0x0d Xnnnn
|
||||
| 0x0eh 14 | uint16 | Pulley_acceleration | 0000h 0 | 320h 800.0 | unit mm/s² | Read (Write) | M707 A0x0e | (M708 A0x0e Xnnnn)
|
||||
| 0x0fh 15 | uint16 | Selector_acceleration | 0000h 0 | 00c8h 200.0 | unit mm/s² | Read (Write) | M707 A0x0f | (M708 A0x0f Xnnnn)
|
||||
| 0x10h 16 | uint16 | Idler_acceleration | 0000h 0 | 01f4h 500.0 | unit deg/s² | Read (Write) | M707 A0x10 | (M708 A0x10 Xnnnn)
|
||||
| 0x0eh 14 | uint16 | Pulley_acceleration | 0000h 0 | 320h 800.0 | unit mm/s² | Read / Write | M707 A0x0e | M708 A0x0e Xnnnn
|
||||
| 0x0fh 15 | uint16 | Selector_acceleration | 0000h 0 | 00c8h 200.0 | unit mm/s² | Read / Write | M707 A0x0f | M708 A0x0f Xnnnn
|
||||
| 0x10h 16 | uint16 | Idler_acceleration | 0000h 0 | 01f4h 500.0 | unit deg/s² | Read / Write | M707 A0x10 | M708 A0x10 Xnnnn
|
||||
| 0x11h 17 | uint16 | Pulley_load_feedrate | 0000h 0 | 005fh 95 | unit mm/s | Read / Write | M707 A0x11 | M708 A0x11 Xnnnn
|
||||
| 0x12h 18 | uint16 | Selector_nominal_feedrate | 0000h 0 | 002dh 45 | unit mm/s | Read / Write | M707 A0x12 | M708 A0x12 Xnnnn
|
||||
| 0x13h 19 | uint16 | Idler_nominal_feedrate | 0000h 0 | 012ch 300 | unit deg/s | Read / Write | M707 A0x13 | M708 A0x13 Xnnnn
|
||||
|
|
@ -165,31 +165,18 @@
|
|||
| 0x1fh 31 | uint16 |Set/Get Selector iRun current| 0-31 | 1fh 31 | 31->530mA: see TMC2130 current conversion| Read / Write | M707 A0x1f | M708 A0x1f Xn
|
||||
| 0x20h 32 | uint16 | Set/Get Idler iRun current | 0-31 | 1fh 31 | 31->530mA: see TMC2130 current conversion| Read / Write | M707 A0x20 | M708 A0x20 Xn
|
||||
| 0x21h 33 | uint16 | Reserved for internal use | 225 | | N/A | N/A | N/A | N/A
|
||||
| 0x22h 34 | uint16 | Bowden length | 341-1000 | 168h 360 | unit mm | Read / Write Persistent | M707 A0x22 | M708 A0x22 Xn
|
||||
| 0x23h 35 | uint8 | Cut length | 0-255 | 8 | unit mm | Read / Write | M707 A0x23 | M708 A0x23 Xn
|
||||
*/
|
||||
|
||||
struct RegisterFlags {
|
||||
uint8_t writable : 1;
|
||||
uint8_t rwfuncs : 1; // 1: register needs special read and write functions
|
||||
uint8_t size : 2; // 0: 1 bit, 1: 1 byte, 2: 2 bytes
|
||||
constexpr RegisterFlags(bool writable, uint8_t size)
|
||||
: writable(writable)
|
||||
, rwfuncs(0)
|
||||
, size(size) {}
|
||||
constexpr RegisterFlags(bool writable, bool rwfuncs, uint8_t size)
|
||||
: writable(writable)
|
||||
, rwfuncs(rwfuncs)
|
||||
, size(size) {}
|
||||
};
|
||||
|
||||
using TReadFunc = uint16_t (*)();
|
||||
using TWriteFunc = void (*)(uint16_t);
|
||||
|
||||
// dummy zero register common to all empty registers
|
||||
static constexpr uint16_t dummyZero = 0;
|
||||
|
||||
struct RegisterRec {
|
||||
RegisterFlags flags;
|
||||
union U1 {
|
||||
struct __attribute__((packed)) RegisterRec {
|
||||
union __attribute__((packed)) U1 {
|
||||
void *addr;
|
||||
TReadFunc readFunc;
|
||||
constexpr explicit U1(const TReadFunc &r)
|
||||
|
|
@ -198,7 +185,7 @@ struct RegisterRec {
|
|||
: addr(a) {}
|
||||
} A1;
|
||||
|
||||
union U2 {
|
||||
union __attribute__((packed)) U2 {
|
||||
void *addr;
|
||||
TWriteFunc writeFunc;
|
||||
constexpr explicit U2(const TWriteFunc &w)
|
||||
|
|
@ -207,27 +194,26 @@ struct RegisterRec {
|
|||
: addr(a) {}
|
||||
} A2;
|
||||
|
||||
template <typename T>
|
||||
constexpr RegisterRec(bool writable, T *address)
|
||||
: flags(RegisterFlags(writable, sizeof(T)))
|
||||
, A1((void *)address)
|
||||
, A2((void *)nullptr) {}
|
||||
constexpr RegisterRec(const TReadFunc &readFunc, uint8_t bytes)
|
||||
: flags(RegisterFlags(false, true, bytes))
|
||||
, A1(readFunc)
|
||||
constexpr RegisterRec(const TReadFunc &readFunc)
|
||||
: A1(readFunc)
|
||||
, A2((void *)nullptr) {}
|
||||
|
||||
constexpr RegisterRec(const TReadFunc &readFunc, const TWriteFunc &writeFunc, uint8_t bytes)
|
||||
: flags(RegisterFlags(true, true, bytes))
|
||||
, A1(readFunc)
|
||||
constexpr RegisterRec(const TReadFunc &readFunc, const TWriteFunc &writeFunc)
|
||||
: A1(readFunc)
|
||||
, A2(writeFunc) {}
|
||||
|
||||
constexpr RegisterRec()
|
||||
: flags(RegisterFlags(false, false, 1))
|
||||
, A1((void *)&dummyZero)
|
||||
: A1((void *)&dummyZero)
|
||||
, A2((void *)nullptr) {}
|
||||
};
|
||||
|
||||
// Make sure the structure is tightly packed - necessary for unit tests.
|
||||
static_assert(sizeof(RegisterRec) == /*sizeof(uint8_t) +*/ sizeof(void *) + sizeof(void *));
|
||||
|
||||
// Beware: the size is expected to be 17B on an x86_64 and it requires the platform to be able to do unaligned reads.
|
||||
// That might be a problem when running unit tests on non-x86 platforms.
|
||||
// So far, no countermeasures have been taken to tackle this potential issue.
|
||||
|
||||
// @@TODO it is nice to see all the supported registers at one spot,
|
||||
// however it requires including all bunch of dependencies
|
||||
// which makes unit testing and separation of modules much harder.
|
||||
|
|
@ -242,230 +228,191 @@ struct RegisterRec {
|
|||
// sts <modules::globals::globals+0x4>, r24
|
||||
// ret
|
||||
//
|
||||
// @@TODO at the moment we are having problems compiling this array statically into PROGMEM.
|
||||
// In this project that's really not an issue since we have half of the RAM empty:
|
||||
// Data: 1531 bytes (59.8% Full)
|
||||
// But it would be nice to fix that in the future - might be hard to push the compiler to such a construct
|
||||
static const RegisterRec registers[] /*PROGMEM*/ = {
|
||||
// @@TODO
|
||||
// The "ret" instruction actually is a serious overhead since it is present in every lambda function.
|
||||
// The only way around is a giant C-style switch which screws up the beauty of this array of registers.
|
||||
// But it will save a few bytes.
|
||||
static const RegisterRec registers[] PROGMEM = {
|
||||
// 0x00
|
||||
RegisterRec(false, &project_major),
|
||||
RegisterRec([]() -> uint16_t { return project_major; }),
|
||||
// 0x01
|
||||
RegisterRec(false, &project_minor),
|
||||
RegisterRec([]() -> uint16_t { return project_minor; }),
|
||||
// 0x02
|
||||
RegisterRec(false, &project_revision),
|
||||
RegisterRec([]() -> uint16_t { return project_revision; }),
|
||||
// 0x03
|
||||
RegisterRec(false, &project_build_number),
|
||||
RegisterRec([]() -> uint16_t { return project_build_number; }),
|
||||
// 0x04
|
||||
RegisterRec( // MMU errors
|
||||
[]() -> uint16_t { return mg::globals.DriveErrors(); },
|
||||
[]() -> uint16_t { return mg::globals.DriveErrors(); } // compiles to: <{lambda()#1}::_FUN()>: jmp <modules::permanent_storage::DriveError::get()>
|
||||
// [](uint16_t) {}, // @@TODO think about setting/clearing the error counter from the outside
|
||||
2),
|
||||
),
|
||||
// 0x05
|
||||
RegisterRec([]() -> uint16_t { return application.CurrentProgressCode(); }, 1),
|
||||
RegisterRec([]() -> uint16_t { return application.CurrentProgressCode(); }),
|
||||
// 0x06
|
||||
RegisterRec([]() -> uint16_t { return application.CurrentErrorCode(); }, 2),
|
||||
RegisterRec([]() -> uint16_t { return application.CurrentErrorCode(); }),
|
||||
// 0x07 filamentState
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.FilamentLoaded(); },
|
||||
[](uint16_t v) { return mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), static_cast<mg::FilamentLoadState>(v)); },
|
||||
1),
|
||||
[](uint16_t v) { return mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), static_cast<mg::FilamentLoadState>(v)); }),
|
||||
// 0x08 FINDA
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return static_cast<uint16_t>(mf::finda.Pressed()); },
|
||||
1),
|
||||
[]() -> uint16_t { return static_cast<uint16_t>(mf::finda.Pressed()); }),
|
||||
// 09 fsensor
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return static_cast<uint16_t>(mfs::fsensor.Pressed()); },
|
||||
[](uint16_t v) { return mfs::fsensor.ProcessMessage(v != 0); },
|
||||
1),
|
||||
[](uint16_t v) { return mfs::fsensor.ProcessMessage(v != 0); }),
|
||||
// 0xa motor mode (stealth = 1/normal = 0)
|
||||
RegisterRec([]() -> uint16_t { return static_cast<uint16_t>(mg::globals.MotorsStealth()); }, 1),
|
||||
RegisterRec([]() -> uint16_t { return static_cast<uint16_t>(mg::globals.MotorsStealth()); }),
|
||||
// 0xb extra load distance after fsensor triggered (30mm default) [mm] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.FSensorToNozzle_mm().v; },
|
||||
[](uint16_t d) { mg::globals.SetFSensorToNozzle_mm(d); },
|
||||
1),
|
||||
[](uint16_t d) { mg::globals.SetFSensorToNozzle_mm(d); }),
|
||||
// 0x0c fsensor unload check distance (40mm default) [mm] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.FSensorUnloadCheck_mm().v; },
|
||||
[](uint16_t d) { mg::globals.SetFSensorUnloadCheck_mm(d); },
|
||||
1),
|
||||
[](uint16_t d) { mg::globals.SetFSensorUnloadCheck_mm(d); }),
|
||||
|
||||
// 0xd 2 Pulley unload feedrate [mm/s] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.PulleyUnloadFeedrate_mm_s().v; },
|
||||
[](uint16_t d) { mg::globals.SetPulleyUnloadFeedrate_mm_s(d); },
|
||||
2),
|
||||
[](uint16_t d) { mg::globals.SetPulleyUnloadFeedrate_mm_s(d); }),
|
||||
|
||||
// 0xe Pulley acceleration [mm/s2] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return config::pulleyLimits.accel.v; },
|
||||
//@@TODO please update documentation as well
|
||||
2),
|
||||
[]() -> uint16_t {
|
||||
mm::steps_t val = mm::motion.Acceleration(config::Pulley);
|
||||
return mm::axisUnitToTruncatedUnit<config::U_mm_s2>(mm::P_accel_t({ val }));
|
||||
},
|
||||
[](uint16_t d) { mm::motion.SetAcceleration(config::Pulley, mm::unitToSteps<mm::P_accel_t>(config::U_mm_s2({ (long double)d }))); }),
|
||||
// 0xf Selector acceleration [mm/s2] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return config::selectorLimits.accel.v; },
|
||||
//@@TODO please update documentation as well
|
||||
2),
|
||||
[]() -> uint16_t {
|
||||
mm::steps_t val = mm::motion.Acceleration(config::Selector);
|
||||
return mm::axisUnitToTruncatedUnit<config::U_mm_s2>(mm::S_accel_t({ val }));
|
||||
},
|
||||
[](uint16_t d) { (mm::motion.SetAcceleration(config::Selector, mm::unitToSteps<mm::S_accel_t>(config::U_mm_s2({ (long double)d })))); }),
|
||||
// 0x10 Idler acceleration [deg/s2] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return config::idlerLimits.accel.v; },
|
||||
//@@TODO please update documentation as well
|
||||
2),
|
||||
[]() -> uint16_t {
|
||||
mm::steps_t val = mm::motion.Acceleration(config::Idler);
|
||||
return mm::axisUnitToTruncatedUnit<config::U_deg_s2>(mm::I_accel_t({ val }));
|
||||
},
|
||||
[](uint16_t d) { mm::motion.SetAcceleration(config::Idler, mm::unitToSteps<mm::I_accel_t>(config::U_deg_s2({ (long double)d }))); }),
|
||||
|
||||
// 0x11 Pulley load feedrate [mm/s] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.PulleyLoadFeedrate_mm_s().v; },
|
||||
[](uint16_t d) { mg::globals.SetPulleyLoadFeedrate_mm_s(d); },
|
||||
2),
|
||||
[](uint16_t d) { mg::globals.SetPulleyLoadFeedrate_mm_s(d); }),
|
||||
// 0x12 Selector nominal feedrate [mm/s] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.SelectorFeedrate_mm_s().v; },
|
||||
[](uint16_t d) { mg::globals.SetSelectorFeedrate_mm_s(d); },
|
||||
2),
|
||||
[](uint16_t d) { mg::globals.SetSelectorFeedrate_mm_s(d); }),
|
||||
// 0x13 Idler nominal feedrate [deg/s] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.IdlerFeedrate_deg_s().v; },
|
||||
[](uint16_t d) { mg::globals.SetIdlerFeedrate_deg_s(d); },
|
||||
2),
|
||||
[](uint16_t d) { mg::globals.SetIdlerFeedrate_deg_s(d); }),
|
||||
|
||||
// 0x14 Pulley slow load to fsensor feedrate [mm/s] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.PulleySlowFeedrate_mm_s().v; },
|
||||
[](uint16_t d) { mg::globals.SetPulleySlowFeedrate_mm_s(d); },
|
||||
2),
|
||||
[](uint16_t d) { mg::globals.SetPulleySlowFeedrate_mm_s(d); }),
|
||||
// 0x15 Selector homing feedrate [mm/s] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.SelectorHomingFeedrate_mm_s().v; },
|
||||
[](uint16_t d) { mg::globals.SetSelectorHomingFeedrate_mm_s(d); },
|
||||
2),
|
||||
[](uint16_t d) { mg::globals.SetSelectorHomingFeedrate_mm_s(d); }),
|
||||
// 0x16 Idler homing feedrate [deg/s] RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.IdlerHomingFeedrate_deg_s().v; },
|
||||
[](uint16_t d) { mg::globals.SetIdlerHomingFeedrate_deg_s(d); },
|
||||
2),
|
||||
[](uint16_t d) { mg::globals.SetIdlerHomingFeedrate_deg_s(d); }),
|
||||
|
||||
// 0x17 Pulley sg_thrs threshold RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.StallGuardThreshold(config::Pulley); },
|
||||
[](uint16_t d) { mg::globals.SetStallGuardThreshold(config::Pulley, d); },
|
||||
1),
|
||||
[](uint16_t d) { mg::globals.SetStallGuardThreshold(config::Pulley, d); }),
|
||||
// 0x18 Selector sg_thrs RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.StallGuardThreshold(mm::Axis::Selector); },
|
||||
[](uint16_t d) { mg::globals.SetStallGuardThreshold(mm::Axis::Selector, d); },
|
||||
1),
|
||||
[](uint16_t d) { mg::globals.SetStallGuardThreshold(mm::Axis::Selector, d); }),
|
||||
// 0x19 Idler sg_thrs RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.StallGuardThreshold(mm::Axis::Idler); },
|
||||
[](uint16_t d) { mg::globals.SetStallGuardThreshold(mm::Axis::Idler, d); },
|
||||
1),
|
||||
[](uint16_t d) { mg::globals.SetStallGuardThreshold(mm::Axis::Idler, d); }),
|
||||
|
||||
// 0x1a Get Pulley position [mm] R
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mpu::pulley.CurrentPosition_mm(); },
|
||||
2),
|
||||
[]() -> uint16_t { return mpu::pulley.CurrentPosition_mm(); }),
|
||||
// 0x1b Set/Get Selector slot RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return ms::selector.Slot(); },
|
||||
[](uint16_t d) { ms::selector.MoveToSlot(d); },
|
||||
1),
|
||||
[](uint16_t d) { ms::selector.MoveToSlot(d); }),
|
||||
// 0x1c Set/Get Idler slot RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mi::idler.Slot(); },
|
||||
[](uint16_t d) { d >= config::toolCount ? mi::idler.Disengage() : mi::idler.Engage(d); },
|
||||
1),
|
||||
[](uint16_t d) { d >= config::toolCount ? mi::idler.Disengage() : mi::idler.Engage(d); }),
|
||||
// 0x1d Set/Get Selector cut iRun current level RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.CutIRunCurrent(); },
|
||||
[](uint16_t d) { mg::globals.SetCutIRunCurrent(d); },
|
||||
1),
|
||||
[](uint16_t d) { mg::globals.SetCutIRunCurrent(d); }),
|
||||
|
||||
// 0x1e Get/Set Pulley iRun current RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mm::motion.CurrentsForAxis(config::Pulley).iRun; },
|
||||
[](uint16_t d) { mm::motion.SetIRunForAxis(config::Pulley, d); },
|
||||
1),
|
||||
[](uint16_t d) { mm::motion.SetIRunForAxis(config::Pulley, d); }),
|
||||
// 0x1f Set/Get Selector iRun current RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mm::motion.CurrentsForAxis(config::Selector).iRun; },
|
||||
[](uint16_t d) { mm::motion.SetIRunForAxis(config::Selector, d); },
|
||||
1),
|
||||
[](uint16_t d) { mm::motion.SetIRunForAxis(config::Selector, d); }),
|
||||
// 0x20 Set/Get Idler iRun current RW
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mm::motion.CurrentsForAxis(config::Idler).iRun; },
|
||||
[](uint16_t d) { mm::motion.SetIRunForAxis(config::Idler, d); },
|
||||
1),
|
||||
[](uint16_t d) { mm::motion.SetIRunForAxis(config::Idler, d); }),
|
||||
// 0x21 Current VCC voltage level R
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return 225; /*mv::vcc.CurrentBandgapVoltage();*/ },
|
||||
2),
|
||||
[]() -> uint16_t { return 225; /*mv::vcc.CurrentBandgapVoltage();*/ }),
|
||||
|
||||
// 0x22 Detected bowden length R
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mps::BowdenLength::Get(); },
|
||||
[](uint16_t d) { mps::BowdenLength::Set(d); }),
|
||||
|
||||
// 0x23 Cut length
|
||||
RegisterRec(
|
||||
[]() -> uint16_t { return mg::globals.CutLength().v; },
|
||||
[](uint16_t d) { mg::globals.SetCutLength(d); }),
|
||||
};
|
||||
|
||||
static constexpr uint8_t registersSize = sizeof(registers) / sizeof(RegisterRec);
|
||||
static_assert(registersSize == 36);
|
||||
|
||||
bool ReadRegister(uint8_t address, uint16_t &value) {
|
||||
if (address >= registersSize) {
|
||||
return false;
|
||||
}
|
||||
value = 0;
|
||||
if (!registers[address].flags.rwfuncs) {
|
||||
switch (registers[address].flags.size) {
|
||||
case 0:
|
||||
case 1:
|
||||
value = *static_cast<uint8_t *>(registers[address].A1.addr);
|
||||
break;
|
||||
case 2:
|
||||
value = *static_cast<uint16_t *>(registers[address].A1.addr);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
switch (registers[address].flags.size) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
value = registers[address].A1.readFunc();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get pointer to register at address
|
||||
const uint8_t *addr = reinterpret_cast<const uint8_t *>(registers + address);
|
||||
|
||||
// beware - abusing the knowledge of RegisterRec memory layout to do lpm_reads
|
||||
const void *varAddr = addr;
|
||||
auto readFunc = hal::progmem::read_ptr<const TReadFunc>(varAddr);
|
||||
value = readFunc();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WriteRegister(uint8_t address, uint16_t value) {
|
||||
if (address >= registersSize) {
|
||||
return false;
|
||||
}
|
||||
if (!registers[address].flags.writable) {
|
||||
const uint8_t *addr = reinterpret_cast<const uint8_t *>(registers + address);
|
||||
|
||||
// beware - abusing the knowledge of RegisterRec memory layout to do lpm_reads
|
||||
// addr offset should be 2 on AVR, but 8 on x86_64, therefore "sizeof(void*)"
|
||||
const void *varAddr = addr + sizeof(RegisterRec::A1);
|
||||
auto writeFunc = hal::progmem::read_ptr<const TWriteFunc>(varAddr);
|
||||
if (writeFunc == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (!registers[address].flags.rwfuncs) {
|
||||
switch (registers[address].flags.size) {
|
||||
case 0:
|
||||
case 1:
|
||||
*static_cast<uint8_t *>(registers[address].A1.addr) = value;
|
||||
break;
|
||||
case 2:
|
||||
*static_cast<uint16_t *>(registers[address].A1.addr) = value;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
switch (registers[address].flags.size) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
registers[address].A2.writeFunc(value);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
writeFunc(value);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
#include <version.hpp>
|
||||
|
||||
|
||||
// Define structure at a fixed address in flash which contains information about the version of the firmware
|
||||
// This structure is read using the bootloader.
|
||||
struct Signatures {
|
||||
uint8_t project_major;
|
||||
uint8_t project_minor;
|
||||
uint16_t project_revision;
|
||||
uint16_t project_build_number;
|
||||
} static constexpr signatures __attribute__((section(".version"), used)) = {
|
||||
PROJECT_VERSION_MAJOR,
|
||||
PROJECT_VERSION_MINOR,
|
||||
PROJECT_VERSION_REV,
|
||||
PROJECT_BUILD_NUMBER,
|
||||
};
|
||||
|
|
@ -15,7 +15,7 @@ if(GCOV_ENABLE)
|
|||
COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_BINARY_DIR}/.ctest-finished
|
||||
)
|
||||
|
||||
set(ctest_test_args --timeout 30 --output-on-failure)
|
||||
set(ctest_test_args --timeout 180 --output-on-failure)
|
||||
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(N)
|
||||
|
|
@ -55,7 +55,8 @@ if(GCOV_ENABLE)
|
|||
COMMAND tar -zcvf Coverage.tar.gz Coverage
|
||||
# Cheat and compare a file to itself to check for existence. File-Not-Found is a failure
|
||||
# code.
|
||||
COMMAND ../../utils/gcovr.py -r . -e '../../tests' -e '../../lib/Catch2' | tee Summary.txt
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/utils/gcovr.py -r ${CMAKE_SOURCE_DIR} -e 'tests' -e 'lib/Catch2' |
|
||||
tee ${CMAKE_BINARY_DIR}/Summary.txt
|
||||
COMMAND ${CMAKE_COMMAND} -E compare_files ${PROJECT_BINARY_DIR}/.ctest-finished
|
||||
${PROJECT_BINARY_DIR}/.ctest-finished
|
||||
BYPRODUCTS ${PROJECT_BINARY_DIR}/Summary.txt ${PROJECT_BINARY_DIR}/Coverage.tar.gz
|
||||
|
|
|
|||
|
|
@ -132,6 +132,54 @@ TEST_CASE("circular_buffer::wrap_around", "[circular_buffer]") {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("circular_buffer::wrap_around_np2", "[circular_buffer]") {
|
||||
|
||||
// same as above, but using a non-power-of-two size
|
||||
static constexpr auto size = 3;
|
||||
using CB = CircularBuffer<uint8_t, uint8_t, size>;
|
||||
|
||||
// start with an empty buffer
|
||||
CB cb;
|
||||
REQUIRE(cb.empty());
|
||||
|
||||
// test inverse logic
|
||||
REQUIRE(!cb.full());
|
||||
|
||||
// add two elements to shift the internal offset
|
||||
uint8_t v;
|
||||
cb.push(size + 1);
|
||||
cb.pop(v);
|
||||
cb.push(size + 1);
|
||||
cb.pop(v);
|
||||
REQUIRE(cb.empty());
|
||||
|
||||
// loop to test the internal cursor wrap-around logic
|
||||
// the number of loops needs to be equal or greater than the index type
|
||||
for (auto loop = 0; loop != 256; ++loop) {
|
||||
INFO("loop " << loop);
|
||||
|
||||
// ensure we can fill the buffer
|
||||
for (auto i = 0; i != size; ++i) {
|
||||
CHECK(!cb.full());
|
||||
cb.push(i);
|
||||
CHECK(!cb.empty());
|
||||
CHECK(cb.count() == i + 1);
|
||||
}
|
||||
REQUIRE(cb.full());
|
||||
REQUIRE(!cb.empty());
|
||||
REQUIRE(cb.count() == size);
|
||||
|
||||
// retrieve all elements
|
||||
for (auto i = 0; i != size; ++i) {
|
||||
uint8_t v;
|
||||
CHECK(cb.pop(v));
|
||||
CHECK(v == i);
|
||||
CHECK(cb.count() == size - i - 1);
|
||||
}
|
||||
REQUIRE(cb.empty());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("circular_buffer::minimal_size", "[circular_buffer]") {
|
||||
|
||||
using CB = CircularBuffer<uint8_t, uint8_t, 1>;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ void FailingMovableUnload(hal::tmc2130::ErrorFlags ef, ErrorCode ec, config::Axi
|
|||
// UnloadFilament starts by engaging the idler (through the UnloadToFinda state machine)
|
||||
uf.Reset(0);
|
||||
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), 0, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), 0, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
|
||||
REQUIRE(WhileCondition(
|
||||
uf,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ TEST_CASE("feed_to_bondtech::feed_phase_unlimited", "[feed_to_bondtech]") {
|
|||
ForceReinitAllAutomata();
|
||||
REQUIRE(EnsureActiveSlotIndex(slot, mg::FilamentLoadState::AtPulley));
|
||||
|
||||
// reset bowden lenghts in EEPROM
|
||||
SetMinimalBowdenLength();
|
||||
// check bowden lengths
|
||||
REQUIRE(mps::BowdenLength::Get() == config::minimumBowdenLength.v);
|
||||
|
||||
FeedToBondtech fb;
|
||||
main_loop();
|
||||
|
||||
|
|
@ -57,20 +62,23 @@ TEST_CASE("feed_to_bondtech::feed_phase_unlimited", "[feed_to_bondtech]") {
|
|||
REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::green) == ml::blink0);
|
||||
|
||||
// fast load - no fsensor trigger
|
||||
// performs fast load for config::minimumBowdenLength distance
|
||||
REQUIRE(WhileCondition(
|
||||
fb,
|
||||
[&](uint32_t) { return fb.State() == FeedToBondtech::PushingFilamentFast; },
|
||||
mm::unitToSteps<mm::P_pos_t>(config::minimumBowdenLength) + 2));
|
||||
|
||||
// slow load - expecting fsensor trigger
|
||||
// This gets interesting with bowden length autotuning - we should trigger at the right step
|
||||
constexpr uint32_t additionalBowdenLengthTrigger = mm::unitToSteps<mm::P_pos_t>(config::defaultBowdenLength - config::minimumBowdenLength);
|
||||
REQUIRE(WhileCondition(
|
||||
fb,
|
||||
[&](uint32_t step) {
|
||||
if( step == 100 ){
|
||||
if( step == additionalBowdenLengthTrigger ){
|
||||
mfs::fsensor.ProcessMessage(true);
|
||||
}
|
||||
return fb.State() == FeedToBondtech::PushingFilamentToFSensor; },
|
||||
1500));
|
||||
additionalBowdenLengthTrigger + 5));
|
||||
|
||||
REQUIRE(mfs::fsensor.Pressed());
|
||||
|
||||
|
|
@ -107,5 +115,11 @@ TEST_CASE("feed_to_bondtech::feed_phase_unlimited", "[feed_to_bondtech]") {
|
|||
REQUIRE(fb.State() == FeedToBondtech::OK);
|
||||
REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::green));
|
||||
|
||||
// detected bowden length is expected still to be 341, not runtime detection available
|
||||
uint16_t bowdenLength = mps::BowdenLength::Get();
|
||||
CHECK(bowdenLength == 341);
|
||||
// must be within the specified tolerance of 10mm from the default bowden length
|
||||
REQUIRE(abs(bowdenLength - config::minimumBowdenLength.v) < 10);
|
||||
|
||||
REQUIRE(fb.Step() == true); // the automaton finished its work, any consecutive calls to Step must return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,13 @@ void LoadFilamentSuccessful(uint8_t slot, logic::LoadFilament &lf) {
|
|||
void LoadFilamentSuccessfulWithRehomeSelector(uint8_t slot, logic::LoadFilament &lf) {
|
||||
// Stage 2 - feeding to finda
|
||||
// make FINDA switch on
|
||||
// engaging idler
|
||||
|
||||
REQUIRE(WhileCondition(
|
||||
lf,
|
||||
[&](uint32_t) { return !mi::idler.Engaged(); },
|
||||
5000));
|
||||
|
||||
REQUIRE(WhileCondition(lf, std::bind(SimulateFeedToFINDA, _1, 100), 5000));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::RetractingFromFinda));
|
||||
|
||||
|
|
@ -176,8 +183,6 @@ void FailedLoadToFindaResolveTryAgain(uint8_t slot, logic::LoadFilament &lf) {
|
|||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, config::toolCount, slot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
|
||||
ClearButtons(lf);
|
||||
|
||||
SimulateIdlerHoming(lf);
|
||||
|
||||
LoadFilamentSuccessfulWithRehomeSelector(slot, lf);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include "../stubs/stub_motion.h"
|
||||
|
||||
#include "catch2/catch_test_macros.hpp"
|
||||
|
||||
void SimulateIdlerAndSelectorHoming(logic::CommandBase &cb) {
|
||||
#if 0
|
||||
// do 5 steps until we trigger the simulated StallGuard
|
||||
|
|
@ -58,6 +60,18 @@ void SimulateIdlerAndSelectorHoming(logic::CommandBase &cb) {
|
|||
|
||||
void SimulateIdlerHoming(logic::CommandBase &cb) {
|
||||
uint32_t idlerStepsFwd = mm::unitToSteps<mm::I_pos_t>(config::idlerLimits.lenght - 5.0_deg);
|
||||
|
||||
// Sometimes the initial idler state is Ready. Let's wait for the firmware to start
|
||||
// homing.
|
||||
REQUIRE(WhileCondition(
|
||||
cb,
|
||||
[&](uint32_t) { return mi::idler.State() == mm::MovableBase::Ready; },
|
||||
5000));
|
||||
|
||||
// At this point the idler should always be homing forward.
|
||||
REQUIRE((int)mi::idler.State() == (int)mm::MovableBase::HomeForward);
|
||||
|
||||
// Simulate the idler steps in one direction (forward)
|
||||
for (uint32_t i = 0; i < idlerStepsFwd; ++i) {
|
||||
main_loop();
|
||||
cb.Step();
|
||||
|
|
@ -68,6 +82,8 @@ void SimulateIdlerHoming(logic::CommandBase &cb) {
|
|||
cb.Step();
|
||||
mm::motion.StallGuardReset(mm::Idler);
|
||||
|
||||
REQUIRE((int)mi::idler.State() == (int)mm::MovableBase::HomeBack);
|
||||
|
||||
// now do a correct amount of steps of each axis towards the other end
|
||||
uint32_t idlerSteps = mm::unitToSteps<mm::I_pos_t>(config::idlerLimits.lenght);
|
||||
uint32_t maxSteps = idlerSteps + 1;
|
||||
|
|
@ -82,6 +98,9 @@ void SimulateIdlerHoming(logic::CommandBase &cb) {
|
|||
mm::motion.StallGuardReset(mm::Idler);
|
||||
}
|
||||
}
|
||||
|
||||
// If the homing has failed, the axis length was too short.
|
||||
REQUIRE(!((mi::idler.State() & mm::MovableBase::HomingFailed) == mm::MovableBase::HomingFailed));
|
||||
}
|
||||
|
||||
void SimulateIdlerWaitForHomingValid(logic::CommandBase &cb) {
|
||||
|
|
@ -185,33 +204,40 @@ bool SimulateFailedHomeSelectorPostfix(logic::CommandBase &cb) {
|
|||
}
|
||||
|
||||
bool SimulateFailedHomeFirstTime(logic::CommandBase &cb) {
|
||||
if (mi::idler.HomingValid())
|
||||
return false;
|
||||
if (ms::selector.HomingValid())
|
||||
return false;
|
||||
REQUIRE(!mi::idler.HomingValid());
|
||||
REQUIRE(!ms::selector.HomingValid());
|
||||
|
||||
// Idler homing is successful
|
||||
SimulateIdlerHoming(cb);
|
||||
SimulateIdlerWaitForHomingValid(cb);
|
||||
|
||||
// Selector homes once the idler homing is valid.
|
||||
REQUIRE(mi::idler.HomingValid());
|
||||
REQUIRE(!ms::selector.HomingValid());
|
||||
|
||||
// The selector will only rehome once the idler homing is valid. At that moment
|
||||
// the state will change to HomeForward.
|
||||
REQUIRE(WhileCondition(
|
||||
cb,
|
||||
[&](uint32_t) { return ms::selector.State() != mm::MovableBase::HomeForward; },
|
||||
5000));
|
||||
|
||||
constexpr uint32_t selectorSteps = mm::unitToSteps<mm::S_pos_t>(config::selectorLimits.lenght) + 1;
|
||||
{
|
||||
// do 5 steps until we trigger the simulated StallGuard
|
||||
constexpr uint32_t idlerStepsFwd = mm::unitToSteps<mm::I_pos_t>(config::idlerLimits.lenght - 5.0_deg);
|
||||
static_assert(idlerStepsFwd < selectorSteps); // beware, we expect that the Idler homes faster than Selector (less steps)
|
||||
for (uint32_t i = 0; i < idlerStepsFwd; ++i) {
|
||||
for (uint32_t i = 0; i < selectorSteps; ++i) {
|
||||
main_loop();
|
||||
cb.Step();
|
||||
}
|
||||
|
||||
mm::TriggerStallGuard(mm::Selector);
|
||||
mm::TriggerStallGuard(mm::Idler);
|
||||
main_loop();
|
||||
cb.Step();
|
||||
mm::motion.StallGuardReset(mm::Selector);
|
||||
mm::motion.StallGuardReset(mm::Idler);
|
||||
}
|
||||
// now do a correct amount of steps of each axis towards the other end
|
||||
constexpr uint32_t idlerSteps = mm::unitToSteps<mm::I_pos_t>(config::idlerLimits.lenght);
|
||||
// now do LESS steps than expected to simulate something is blocking the selector
|
||||
|
||||
constexpr uint32_t selectorTriggerShort = std::min(idlerSteps, selectorSteps) / 2;
|
||||
// now do LESS steps than expected to simulate something is blocking the selector
|
||||
constexpr uint32_t selectorTriggerShort = selectorSteps / 2;
|
||||
constexpr uint32_t maxSteps = selectorTriggerShort + 1;
|
||||
{
|
||||
for (uint32_t i = 0; i < maxSteps; ++i) {
|
||||
|
|
@ -225,17 +251,6 @@ bool SimulateFailedHomeFirstTime(logic::CommandBase &cb) {
|
|||
}
|
||||
}
|
||||
|
||||
// make sure the Idler finishes its homing procedure (makes further checks much easier)
|
||||
for (uint32_t i = maxSteps; i < idlerSteps + 1; ++i) {
|
||||
main_loop();
|
||||
cb.Step();
|
||||
if (i == idlerSteps) {
|
||||
mm::TriggerStallGuard(mm::Idler);
|
||||
} else {
|
||||
mm::motion.StallGuardReset(mm::Idler);
|
||||
}
|
||||
}
|
||||
|
||||
while (!(ms::selector.State() & mm::MovableBase::OnHold)) {
|
||||
main_loop();
|
||||
cb.Step();
|
||||
|
|
|
|||
|
|
@ -79,19 +79,27 @@ void ForceReinitAllAutomata() {
|
|||
mg::globals.Init();
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::AtPulley);
|
||||
}
|
||||
void HomeIdler() {
|
||||
logic::NoCommand nc; // just a dummy instance which has an empty Step()
|
||||
SimulateIdlerHoming(nc);
|
||||
SimulateIdlerWaitForHomingValid(nc);
|
||||
SimulateIdlerMoveToParkingPosition(nc);
|
||||
}
|
||||
|
||||
void HomeSelector() {
|
||||
logic::NoCommand nc; // just a dummy instance which has an empty Step()
|
||||
SimulateSelectorHoming(nc);
|
||||
SimulateSelectorWaitForHomingValid(nc);
|
||||
SimulateSelectorWaitForReadyState(nc);
|
||||
}
|
||||
|
||||
void HomeIdlerAndSelector() {
|
||||
mi::idler.InvalidateHoming();
|
||||
ms::selector.InvalidateHoming();
|
||||
logic::NoCommand nc; // just a dummy instance which has an empty Step()
|
||||
|
||||
SimulateIdlerHoming(nc);
|
||||
SimulateIdlerWaitForHomingValid(nc);
|
||||
SimulateIdlerMoveToParkingPosition(nc);
|
||||
HomeIdler();
|
||||
|
||||
SimulateSelectorHoming(nc);
|
||||
SimulateSelectorWaitForHomingValid(nc);
|
||||
SimulateSelectorWaitForReadyState(nc);
|
||||
HomeSelector();
|
||||
}
|
||||
|
||||
bool EnsureActiveSlotIndex(uint8_t slot, mg::FilamentLoadState loadState) {
|
||||
|
|
@ -165,6 +173,11 @@ void ClearButtons(logic::CommandBase &cb) {
|
|||
}
|
||||
}
|
||||
|
||||
void SetMinimalBowdenLength() {
|
||||
// reset bowdenLenght in EEPROM
|
||||
mps::BowdenLength::Set(config::minimumBowdenLength.v);
|
||||
}
|
||||
|
||||
void SetFSensorStateAndDebounce(bool press) {
|
||||
mfs::fsensor.ProcessMessage(press);
|
||||
for (uint8_t fs = 0; fs < config::fsensorDebounceMs + 1; ++fs) {
|
||||
|
|
@ -176,10 +189,10 @@ void SimulateErrDisengagingIdler(logic::CommandBase &cb, ErrorCode deferredEC) {
|
|||
REQUIRE(WhileCondition(
|
||||
cb, [&](uint32_t) {
|
||||
if (cb.TopLevelState() == ProgressCode::ERRDisengagingIdler) {
|
||||
REQUIRE(cb.Error() == ErrorCode::RUNNING); // ensure the error gets never set while disengaging the idler
|
||||
REQUIRE((cb.Error() == ErrorCode::RUNNING)); // ensure the error gets never set while disengaging the idler
|
||||
return true;
|
||||
} else {
|
||||
REQUIRE(cb.Error() == deferredEC);
|
||||
REQUIRE((cb.Error() == deferredEC));
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include "../../../../src/logic/command_base.h"
|
||||
#include "../../../../src/modules/globals.h"
|
||||
#include "../../../../src/modules/idler.h"
|
||||
|
||||
extern void main_loop();
|
||||
extern void ForceReinitAllAutomata();
|
||||
|
|
@ -32,6 +33,7 @@ bool SimulateRetractFromFINDA(uint32_t step, uint32_t findaOff);
|
|||
void PressButtonAndDebounce(logic::CommandBase &cb, uint8_t btnIndex, bool fromPrinter);
|
||||
void ClearButtons(logic::CommandBase &cb);
|
||||
|
||||
void SetMinimalBowdenLength();
|
||||
void SetFSensorStateAndDebounce(bool press);
|
||||
|
||||
// these are recommended max steps for simulated movement of the idler and selector
|
||||
|
|
@ -43,3 +45,21 @@ static constexpr uint32_t selectorMoveMaxSteps = 40000UL;
|
|||
void HomeIdlerAndSelector();
|
||||
|
||||
void SimulateErrDisengagingIdler(logic::CommandBase &cb, ErrorCode deferredEC);
|
||||
|
||||
template <typename T>
|
||||
bool SimulateEngageIdlerFully(T &cb) {
|
||||
return WhileCondition(
|
||||
cb,
|
||||
[&](uint32_t) { return !mi::idler.Engaged(); },
|
||||
5000);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool SimulateEngageIdlerPartially(T &cb) {
|
||||
return WhileCondition(
|
||||
cb,
|
||||
[&](uint32_t) { return !mi::idler.PartiallyDisengaged(); },
|
||||
5000);
|
||||
}
|
||||
|
||||
void HomeIdler();
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ bool SimulateUnloadFilament(uint32_t step, const logic::CommandBase *tc, uint32_
|
|||
|
||||
void ToolChange(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSlot) {
|
||||
ForceReinitAllAutomata();
|
||||
SetMinimalBowdenLength();
|
||||
|
||||
REQUIRE(EnsureActiveSlotIndex(fromSlot, mg::FilamentLoadState::InNozzle));
|
||||
SetFINDAStateAndDebounce(true);
|
||||
|
|
@ -104,6 +105,7 @@ void ToolChange(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSlot) {
|
|||
|
||||
void NoToolChange(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSlot) {
|
||||
ForceReinitAllAutomata();
|
||||
SetMinimalBowdenLength();
|
||||
|
||||
REQUIRE(EnsureActiveSlotIndex(fromSlot, mg::FilamentLoadState::InNozzle));
|
||||
// the filament is LOADED
|
||||
|
|
@ -123,6 +125,7 @@ void NoToolChange(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSlot) {
|
|||
void JustLoadFilament(logic::ToolChange &tc, uint8_t slot) {
|
||||
for (uint8_t startSelectorSlot = 0; startSelectorSlot < config::toolCount; ++startSelectorSlot) {
|
||||
ForceReinitAllAutomata();
|
||||
SetMinimalBowdenLength();
|
||||
// make sure all the modules are ready
|
||||
// MMU-196: Move selector to a "random" slot
|
||||
REQUIRE(EnsureActiveSlotIndex(startSelectorSlot, mg::FilamentLoadState::AtPulley));
|
||||
|
|
@ -188,6 +191,7 @@ TEST_CASE("tool_change::same_slot_just_unloaded_filament", "[tool_change]") {
|
|||
|
||||
void ToolChangeFailLoadToFinda(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSlot) {
|
||||
ForceReinitAllAutomata();
|
||||
SetMinimalBowdenLength();
|
||||
|
||||
REQUIRE(EnsureActiveSlotIndex(fromSlot, mg::FilamentLoadState::InNozzle));
|
||||
SetFINDAStateAndDebounce(true);
|
||||
|
|
@ -315,6 +319,7 @@ TEST_CASE("tool_change::load_fail_FINDA_resolve_btnM", "[tool_change]") {
|
|||
void ToolChangeFailFSensor(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSlot) {
|
||||
using namespace std::placeholders;
|
||||
ForceReinitAllAutomata();
|
||||
SetMinimalBowdenLength();
|
||||
|
||||
REQUIRE(EnsureActiveSlotIndex(fromSlot, mg::FilamentLoadState::InNozzle));
|
||||
SetFINDAStateAndDebounce(true);
|
||||
|
|
@ -323,13 +328,43 @@ void ToolChangeFailFSensor(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSl
|
|||
// restart the automaton
|
||||
tc.Reset(toSlot);
|
||||
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::idler.IdleSlotIndex(), fromSlot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
||||
// simulate unload to finda but fail the fsensor test
|
||||
REQUIRE(WhileCondition(tc, std::bind(SimulateUnloadToFINDA, _1, 500'000, 10'000), 200'000));
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), fromSlot, false, false, ml::off, ml::blink0, ErrorCode::FSENSOR_DIDNT_SWITCH_OFF, ProgressCode::UnloadingFilament));
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::idler.IdleSlotIndex(), fromSlot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
||||
|
||||
// now simulate unload to finda but fail the fsensor test - that means basically waiting for 4 seconds
|
||||
for (uint32_t ms = 0; ms < 4000; ++ms) {
|
||||
main_loop(); // increments 1ms each run
|
||||
tc.Step();
|
||||
}
|
||||
|
||||
// UnloadFilament.unl finds out, that fsensor didn't turn off in time
|
||||
main_loop();
|
||||
tc.Step();
|
||||
|
||||
// UnloadFilament starts error handling
|
||||
main_loop();
|
||||
tc.Step();
|
||||
|
||||
// wait for the Idler to be disengaged in error state
|
||||
REQUIRE(WhileCondition(
|
||||
tc, [&](uint32_t) {
|
||||
return tc.State() == ProgressCode::ERRDisengagingIdler;
|
||||
},
|
||||
idlerEngageDisengageMaxSteps));
|
||||
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::idler.IdleSlotIndex(), fromSlot, true, false, ml::off, ml::blink0, ErrorCode::FSENSOR_DIDNT_SWITCH_OFF, ProgressCode::UnloadingFilament));
|
||||
REQUIRE(tc.unl.State() == ProgressCode::ERRWaitingForUser);
|
||||
}
|
||||
|
||||
bool SimulateUnloadFilamentUntilSelectorRehoming(uint32_t step, const logic::ToolChange *tc, uint32_t unloadLengthSteps) {
|
||||
if (step == 20) { // on 20th step make FSensor switch off
|
||||
mfs::fsensor.ProcessMessage(false);
|
||||
} else if (step == unloadLengthSteps) {
|
||||
FINDAOnOff(false);
|
||||
}
|
||||
// end simulation at the DisengagingIdler stage, selector re-homing will take place later
|
||||
return tc->unl.State() != ProgressCode::DisengagingIdler;
|
||||
}
|
||||
|
||||
void ToolChangeFailFSensorMiddleBtn(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSlot) {
|
||||
using namespace std::placeholders;
|
||||
|
||||
|
|
@ -338,43 +373,31 @@ void ToolChangeFailFSensorMiddleBtn(logic::ToolChange &tc, uint8_t fromSlot, uin
|
|||
REQUIRE_FALSE(mui::userInput.AnyEvent());
|
||||
PressButtonAndDebounce(tc, mb::Middle, true);
|
||||
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), fromSlot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
||||
REQUIRE(tc.unl.State() == ProgressCode::FeedingToFinda); // MMU must find out where the filament is FS is OFF, FINDA is OFF
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::idler.IdleSlotIndex(), fromSlot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
||||
|
||||
// both movables should have their homing flag invalidated
|
||||
REQUIRE_FALSE(mi::idler.HomingValid());
|
||||
REQUIRE_FALSE(ms::selector.HomingValid());
|
||||
|
||||
// make FINDA trigger - Idler will rehome in this step, Selector must remain at its place
|
||||
SimulateIdlerHoming(tc);
|
||||
|
||||
REQUIRE_FALSE(mi::idler.HomingValid());
|
||||
REQUIRE_FALSE(ms::selector.HomingValid());
|
||||
|
||||
SimulateIdlerWaitForHomingValid(tc);
|
||||
|
||||
REQUIRE(mi::idler.HomingValid());
|
||||
REQUIRE_FALSE(ms::selector.HomingValid());
|
||||
|
||||
SimulateIdlerMoveToParkingPosition(tc);
|
||||
|
||||
// now trigger the FINDA
|
||||
REQUIRE(WhileCondition(tc, std::bind(SimulateFeedToFINDA, _1, 100), 5000));
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, fromSlot, fromSlot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
||||
REQUIRE(tc.unl.State() == ProgressCode::RetractingFromFinda);
|
||||
|
||||
// make FINDA switch off
|
||||
REQUIRE(WhileCondition(tc, std::bind(SimulateRetractFromFINDA, _1, 100), 5000));
|
||||
// perform a successful unload
|
||||
// During the last stage (DisengagingIdler), the Selector will start re-homing - needs special handling
|
||||
REQUIRE(WhileCondition(
|
||||
tc, [&](uint32_t) { return tc.unl.State() == ProgressCode::RetractingFromFinda; }, 50000));
|
||||
tc,
|
||||
std::bind(SimulateUnloadFilamentUntilSelectorRehoming, _1, &tc, mm::unitToSteps<mm::P_pos_t>(config::minimumBowdenLength)),
|
||||
200'000UL));
|
||||
|
||||
// Selector will start rehoming at this stage - that was the error this test was to find
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::AtPulley, fromSlot, config::toolCount, false, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
||||
REQUIRE(tc.unl.State() == ProgressCode::DisengagingIdler);
|
||||
SimulateSelectorHoming(tc);
|
||||
SimulateSelectorWaitForHomingValid(tc);
|
||||
|
||||
// Selector should be moving to the target slot to accomplish the unload phase
|
||||
REQUIRE(WhileTopState(tc, ProgressCode::UnloadingFilament, 50'000));
|
||||
|
||||
// Idler has probably engaged meanwhile, ignore its position check
|
||||
REQUIRE(WhileTopState(tc, ProgressCode::UnloadingFilament, 50000));
|
||||
REQUIRE(VerifyState2(tc, mg::FilamentLoadState::AtPulley, config::toolCount, fromSlot, false, false, toSlot, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
|
||||
|
||||
// after that, perform a normal load
|
||||
|
|
@ -397,6 +420,7 @@ TEST_CASE("tool_change::load_fail_FSensor_resolve_btnM", "[tool_change]") {
|
|||
|
||||
void ToolChangeWithFlickeringFINDA(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSlot, bool keepFindaPressed) {
|
||||
ForceReinitAllAutomata();
|
||||
SetMinimalBowdenLength();
|
||||
|
||||
REQUIRE(EnsureActiveSlotIndex(fromSlot, mg::FilamentLoadState::InNozzle));
|
||||
SetFINDAStateAndDebounce(true);
|
||||
|
|
@ -495,6 +519,7 @@ TEST_CASE("tool_change::test_flickering_FINDA_keepPressed", "[tool_change]") {
|
|||
|
||||
void ToolChangeFSENSOR_TOO_EARLY(logic::ToolChange &tc, uint8_t slot) {
|
||||
ForceReinitAllAutomata();
|
||||
SetMinimalBowdenLength();
|
||||
REQUIRE(EnsureActiveSlotIndex(slot, mg::FilamentLoadState::AtPulley));
|
||||
|
||||
// verify filament NOT loaded
|
||||
|
|
@ -521,7 +546,7 @@ void ToolChangeFSENSOR_TOO_EARLY(logic::ToolChange &tc, uint8_t slot) {
|
|||
|
||||
// make AutoRetry
|
||||
PressButtonAndDebounce(tc, mb::Middle, true);
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
||||
|
||||
SimulateIdlerHoming(tc);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,16 +53,10 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf, uint8_t en
|
|||
REQUIRE(VerifyState(uf, (mg::FilamentLoadState)(mg::FilamentLoadState::InNozzle | mg::FilamentLoadState::InSelector),
|
||||
entryIdlerSlotIndex, slot, true, true, entryGreenLED, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
|
||||
// run the automaton
|
||||
// Stage 1 - unloading to FINDA
|
||||
REQUIRE(WhileCondition(
|
||||
uf,
|
||||
[&](uint32_t step) -> bool {
|
||||
if(step == 100){ // on 100th step make FINDA trigger
|
||||
hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low);
|
||||
}
|
||||
return uf.TopLevelState() == ProgressCode::UnloadingToFinda; },
|
||||
50000));
|
||||
REQUIRE(WhileCondition(uf, std::bind(SimulateUnloadToFINDA, _1, 100, 2'000), 200'000));
|
||||
|
||||
main_loop();
|
||||
uf.Step();
|
||||
|
||||
// we still think we have filament loaded at this stage
|
||||
// idler should have been activated by the underlying automaton
|
||||
|
|
@ -100,7 +94,7 @@ TEST_CASE("unload_filament::regular_unload_from_slot_0-4", "[unload_filament]")
|
|||
for (uint8_t slot = 0; slot < config::toolCount; ++slot) {
|
||||
logic::UnloadFilament uf;
|
||||
RegularUnloadFromSlot04Init(slot, uf);
|
||||
RegularUnloadFromSlot04(slot, uf, mi::Idler::IdleSlotIndex(), false, ml::off);
|
||||
RegularUnloadFromSlot04(slot, uf, mi::Idler::IdleSlotIndex(), false, ml::blink0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +124,7 @@ void FindaDidntTriggerCommonSetup(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// FINDA triggered off
|
||||
// green LED should be off
|
||||
// no error so far
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
|
||||
// run the automaton
|
||||
// Stage 1 - unloading to FINDA - do NOT let it trigger - keep it pressed, the automaton should finish all moves with the pulley
|
||||
|
|
@ -177,7 +171,7 @@ void FindaDidntTriggerResolveTryAgain(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// no change in selector's position
|
||||
// FINDA still on
|
||||
// red LED should blink, green LED should be off
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
|
||||
ClearButtons(uf);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@
|
|||
#include "../../../../src/modules/motion.h"
|
||||
#include "../../../../src/modules/permanent_storage.h"
|
||||
#include "../../../../src/modules/selector.h"
|
||||
#include "../../../../src/modules/timebase.h"
|
||||
|
||||
#include "../../../../src/logic/unload_to_finda.h"
|
||||
|
||||
#include "../../modules/stubs/stub_adc.h"
|
||||
#include "../../modules/stubs/stub_timebase.h"
|
||||
|
||||
#include "../stubs/main_loop_stub.h"
|
||||
#include "../stubs/stub_motion.h"
|
||||
|
|
@ -24,7 +26,7 @@ using namespace std::placeholders;
|
|||
|
||||
namespace ha = hal::adc;
|
||||
|
||||
TEST_CASE("unload_to_finda::regular_unload", "[unload_to_finda]") {
|
||||
void UnloadToFindaCommonSetup(logic::UnloadToFinda &ff, uint8_t retryAttempts) {
|
||||
ForceReinitAllAutomata();
|
||||
REQUIRE(EnsureActiveSlotIndex(0, mg::FilamentLoadState::AtPulley));
|
||||
|
||||
|
|
@ -35,27 +37,41 @@ TEST_CASE("unload_to_finda::regular_unload", "[unload_to_finda]") {
|
|||
// and MMU "thinks" it has the filament loaded
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InNozzle);
|
||||
|
||||
logic::UnloadToFinda ff;
|
||||
|
||||
// restart the automaton - just 1 attempt
|
||||
ff.Reset(1);
|
||||
ff.Reset(retryAttempts);
|
||||
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::EngagingIdler);
|
||||
|
||||
// it should have instructed the selector and idler to move to slot 1
|
||||
// check if the idler and selector have the right command
|
||||
CHECK(mm::AxisNearestTargetPos(mm::Idler) == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::AxisNearestTargetPos(mm::Idler) == mi::Idler::IntermediateSlotPosition(0).v);
|
||||
CHECK(mm::AxisNearestTargetPos(mm::Selector) == ms::Selector::SlotPosition(0).v);
|
||||
|
||||
// engaging idler
|
||||
REQUIRE(WhileCondition(
|
||||
ff,
|
||||
[&](uint32_t) { return !mi::idler.Engaged(); },
|
||||
5000));
|
||||
REQUIRE(SimulateEngageIdlerPartially(ff));
|
||||
}
|
||||
|
||||
void UnloadToFindaCommonTurnOffFSensor(logic::UnloadToFinda &ff) {
|
||||
// turn off fsensor - the printer freed the filament from the gears
|
||||
SetFSensorStateAndDebounce(false);
|
||||
|
||||
// make sure we step ff to handle turned-off fsensor
|
||||
ff.Step();
|
||||
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::UnloadingToFinda);
|
||||
CHECK(mm::axes[mm::Pulley].enabled == true);
|
||||
CHECK(mm::AxisNearestTargetPos(mm::Idler) == mi::Idler::SlotPosition(0).v);
|
||||
|
||||
REQUIRE(SimulateEngageIdlerFully(ff));
|
||||
|
||||
// now pulling the filament until finda triggers
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::WaitingForFINDA);
|
||||
}
|
||||
|
||||
TEST_CASE("unload_to_finda::regular_unload", "[unload_to_finda]") {
|
||||
logic::UnloadToFinda ff;
|
||||
UnloadToFindaCommonSetup(ff, 1);
|
||||
UnloadToFindaCommonTurnOffFSensor(ff);
|
||||
|
||||
REQUIRE(WhileCondition(ff, std::bind(SimulateUnloadToFINDA, _1, 10, 1000), 1100));
|
||||
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::OK);
|
||||
|
|
@ -77,137 +93,81 @@ TEST_CASE("unload_to_finda::no_sense_FINDA_upon_start", "[unload_to_finda]") {
|
|||
}
|
||||
|
||||
TEST_CASE("unload_to_finda::unload_without_FINDA_trigger", "[unload_to_finda]") {
|
||||
ForceReinitAllAutomata();
|
||||
REQUIRE(EnsureActiveSlotIndex(0, mg::FilamentLoadState::AtPulley));
|
||||
|
||||
// we need finda ON
|
||||
SetFINDAStateAndDebounce(true);
|
||||
// fsensor should be ON
|
||||
SetFSensorStateAndDebounce(true);
|
||||
// and MMU "thinks" it has the filament loaded
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InNozzle);
|
||||
|
||||
logic::UnloadToFinda ff;
|
||||
|
||||
// restart the automaton - just 1 attempt
|
||||
ff.Reset(1);
|
||||
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::EngagingIdler);
|
||||
|
||||
// it should have instructed the selector and idler to move to slot 1
|
||||
// check if the idler and selector have the right command
|
||||
CHECK(mm::AxisNearestTargetPos(mm::Idler) == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::AxisNearestTargetPos(mm::Selector) == ms::Selector::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Idler].enabled == true);
|
||||
|
||||
// engaging idler
|
||||
REQUIRE(WhileCondition(
|
||||
ff,
|
||||
[&](uint32_t) { return !mi::idler.Engaged(); },
|
||||
5000));
|
||||
|
||||
// now pulling the filament until finda triggers
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::WaitingForFINDA);
|
||||
UnloadToFindaCommonSetup(ff, 1);
|
||||
UnloadToFindaCommonTurnOffFSensor(ff);
|
||||
|
||||
// no changes to FINDA during unload - we'll pretend it never triggers
|
||||
// but set FSensor correctly
|
||||
REQUIRE_FALSE(WhileCondition(ff, std::bind(SimulateUnloadToFINDA, _1, 10, 150000), 50000));
|
||||
uint32_t unlSteps = 10 + mm::unitToSteps<mm::P_pos_t>(config::maximumBowdenLength + config::feedToFinda + config::filamentMinLoadedToMMU);
|
||||
REQUIRE_FALSE(WhileCondition(ff, std::bind(SimulateUnloadToFINDA, _1, 10, 150000), unlSteps));
|
||||
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::FailedFINDA);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::InSelector);
|
||||
}
|
||||
|
||||
TEST_CASE("unload_to_finda::unload_without_FSensor_trigger", "[unload_to_finda]") {
|
||||
ForceReinitAllAutomata();
|
||||
REQUIRE(EnsureActiveSlotIndex(0, mg::FilamentLoadState::AtPulley));
|
||||
|
||||
// we need finda ON
|
||||
SetFINDAStateAndDebounce(true);
|
||||
// fsensor should be ON
|
||||
SetFSensorStateAndDebounce(true);
|
||||
// and MMU "thinks" it has the filament loaded
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InNozzle);
|
||||
|
||||
logic::UnloadToFinda ff;
|
||||
|
||||
// restart the automaton - just 1 attempt
|
||||
ff.Reset(1);
|
||||
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::EngagingIdler);
|
||||
|
||||
// it should have instructed the selector and idler to move to slot 1
|
||||
// check if the idler and selector have the right command
|
||||
CHECK(mm::AxisNearestTargetPos(mm::Idler) == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::AxisNearestTargetPos(mm::Selector) == ms::Selector::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Idler].enabled == true);
|
||||
|
||||
// engaging idler
|
||||
REQUIRE(WhileCondition(
|
||||
ff,
|
||||
[&](uint32_t) { return !mi::idler.Engaged(); },
|
||||
5000));
|
||||
|
||||
// now pulling the filament until finda triggers
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::WaitingForFINDA);
|
||||
UnloadToFindaCommonSetup(ff, 1);
|
||||
|
||||
// no changes to FSensor during unload - we'll pretend it never triggers
|
||||
// but set FINDA correctly
|
||||
REQUIRE(WhileCondition(ff, std::bind(SimulateUnloadToFINDA, _1, 150000, 10000), 50000));
|
||||
// time-out in 4 seconds
|
||||
mt::IncMillis(4000);
|
||||
|
||||
main_loop();
|
||||
ff.Step();
|
||||
|
||||
// no pulling actually starts, because the fsensor didn't turn off and the time-out elapsed
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::FailedFSensor);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::InSelector);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::InNozzle);
|
||||
}
|
||||
|
||||
TEST_CASE("unload_to_finda::unload_repeated", "[unload_to_finda]") {
|
||||
ForceReinitAllAutomata();
|
||||
REQUIRE(EnsureActiveSlotIndex(0, mg::FilamentLoadState::AtPulley));
|
||||
|
||||
// we need finda ON
|
||||
SetFINDAStateAndDebounce(true);
|
||||
// fsensor should be ON
|
||||
SetFSensorStateAndDebounce(true);
|
||||
// and MMU "thinks" it has the filament loaded
|
||||
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InNozzle);
|
||||
|
||||
logic::UnloadToFinda ff;
|
||||
UnloadToFindaCommonSetup(ff, 2);
|
||||
|
||||
// restart the automaton - 2 attempts
|
||||
ff.Reset(2);
|
||||
UnloadToFindaCommonTurnOffFSensor(ff);
|
||||
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::EngagingIdler);
|
||||
|
||||
// it should have instructed the selector and idler to move to slot 1
|
||||
// check if the idler and selector have the right command
|
||||
CHECK(mm::AxisNearestTargetPos(mm::Idler) == mi::Idler::SlotPosition(0).v);
|
||||
CHECK(mm::AxisNearestTargetPos(mm::Selector) == ms::Selector::SlotPosition(0).v);
|
||||
CHECK(mm::axes[mm::Idler].enabled == true);
|
||||
|
||||
// engaging idler
|
||||
REQUIRE(WhileCondition(
|
||||
ff,
|
||||
[&](uint32_t) { return !mi::idler.Engaged(); },
|
||||
5000));
|
||||
|
||||
// now pulling the filament until finda triggers
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::WaitingForFINDA);
|
||||
// remember raw Pulley pos for tweaking the steps below
|
||||
// because a 20mm (config::fsensorToNozzleAvoidGrindUnload)
|
||||
// move is being executed while the Idler is fully engaging
|
||||
// It is roughly -90 steps
|
||||
// int32_t pulleySteppedAlready = mm::axes[config::Pulley].pos;
|
||||
|
||||
// no changes to FINDA during unload - we'll pretend it never triggers
|
||||
// but set FSensor correctly
|
||||
// In this case it is vital to correctly compute the amount of steps
|
||||
// to make the unload state machine restart after the 1st attempt
|
||||
uint32_t unlSteps = 1 + mm::unitToSteps<mm::P_pos_t>(config::defaultBowdenLength + config::feedToFinda + config::filamentMinLoadedToMMU);
|
||||
// The number of steps must be more than what the state machine expects for FINDA to trigger.
|
||||
uint32_t unlSteps = 1 + mm::unitToSteps<mm::P_pos_t>(
|
||||
// standard fast move distance
|
||||
config::maximumBowdenLength + config::feedToFinda + config::filamentMinLoadedToMMU
|
||||
// slow start move distance
|
||||
+ config::fsensorToNozzleAvoidGrindUnload);
|
||||
// compensation
|
||||
// + pulleySteppedAlready;
|
||||
REQUIRE_FALSE(WhileCondition(ff, std::bind(SimulateUnloadToFINDA, _1, 10, 150000), unlSteps));
|
||||
|
||||
main_loop();
|
||||
ff.Step();
|
||||
|
||||
REQUIRE_FALSE(mi::idler.HomingValid());
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::EngagingIdler);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::InSelector);
|
||||
|
||||
HomeIdler();
|
||||
|
||||
main_loop();
|
||||
ff.Step();
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::UnloadingToFinda);
|
||||
|
||||
SimulateEngageIdlerPartially(ff);
|
||||
|
||||
main_loop();
|
||||
ff.Step();
|
||||
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::UnloadingToFinda);
|
||||
SimulateEngageIdlerFully(ff);
|
||||
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::InSelector);
|
||||
|
||||
// make arbitrary amount of steps
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
# define the test executable
|
||||
add_executable(
|
||||
leds_tests ${CMAKE_SOURCE_DIR}/src/modules/leds.cpp ${MODULES_STUBS_DIR}/stub_shr16.cpp
|
||||
${MODULES_STUBS_DIR}/stub_timebase.cpp test_leds.cpp
|
||||
leds_tests
|
||||
${CMAKE_SOURCE_DIR}/src/modules/leds.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/modules/globals.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/modules/permanent_storage.cpp
|
||||
${MODULES_STUBS_DIR}/stub_shr16.cpp
|
||||
${MODULES_STUBS_DIR}/stub_timebase.cpp
|
||||
${MODULES_STUBS_DIR}/stub_eeprom.cpp
|
||||
test_leds.cpp
|
||||
)
|
||||
|
||||
# define required search paths
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import tarfile
|
|||
import zipfile
|
||||
from argparse import ArgumentParser
|
||||
from pathlib import Path
|
||||
from tarfile import TarFile
|
||||
from urllib.request import urlretrieve
|
||||
project_root_dir = Path(__file__).resolve().parent.parent
|
||||
dependencies_dir = project_root_dir / '.dependencies'
|
||||
|
|
@ -28,11 +29,11 @@ dependencies_dir = project_root_dir / '.dependencies'
|
|||
# yapf: disable
|
||||
dependencies = {
|
||||
'ninja': {
|
||||
'version': '1.10.2',
|
||||
'version': '1.12.1',
|
||||
'url': {
|
||||
'Linux': 'https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip',
|
||||
'Windows': 'https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip',
|
||||
'Darwin': 'https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-mac.zip',
|
||||
'Linux': 'https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip',
|
||||
'Windows': 'https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-win.zip',
|
||||
'Darwin': 'https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-mac.zip',
|
||||
},
|
||||
},
|
||||
'cmake': {
|
||||
|
|
@ -99,7 +100,11 @@ def download_and_unzip(url: str, directory: Path):
|
|||
obj = tarfile.open(f)
|
||||
else:
|
||||
obj = zipfile.ZipFile(f, 'r')
|
||||
obj.extractall(path=str(extract_dir))
|
||||
|
||||
if isinstance(obj, TarFile):
|
||||
obj.extractall(path=str(extract_dir), filter='data')
|
||||
else: # Zip file
|
||||
obj.extractall(path=str(extract_dir))
|
||||
|
||||
subdir = find_single_subdir(extract_dir)
|
||||
shutil.move(str(subdir), str(directory))
|
||||
|
|
|
|||
|
|
@ -619,6 +619,10 @@ def process_gcov_data(data_fname, covdata, source_fname, options):
|
|||
is_code_statement = False
|
||||
if tmp[0] == '-' or (excluding and tmp[0] in "#=0123456789"):
|
||||
is_code_statement = True
|
||||
if len(segments) < 3:
|
||||
noncode.add(lineno)
|
||||
continue
|
||||
|
||||
code = segments[2].strip()
|
||||
# remember certain non-executed lines
|
||||
if excluding or is_non_code(segments[2]):
|
||||
|
|
@ -634,7 +638,7 @@ def process_gcov_data(data_fname, covdata, source_fname, options):
|
|||
uncovered_exceptional.add(lineno)
|
||||
elif tmp[0] in "0123456789":
|
||||
is_code_statement = True
|
||||
covered[lineno] = int(segments[0].strip())
|
||||
covered[lineno] = int(segments[0].strip().rstrip('*'))
|
||||
elif tmp.startswith('branch'):
|
||||
exclude_branch = False
|
||||
if options.exclude_unreachable_branches and \
|
||||
|
|
|
|||
|
|
@ -93,11 +93,11 @@ pipeline {
|
|||
steps {
|
||||
sh """
|
||||
python3 utils/bootstrap.py
|
||||
export PATH=\$PWD/.dependencies/cmake-3.22.5/bin:\$PWD/.dependencies/ninja-1.10.2:\$PATH
|
||||
export PATH=\$PWD/.dependencies/cmake-3.22.5/bin:\$PWD/.dependencies/ninja-1.12.1:\$PATH
|
||||
export CTEST_OUTPUT_ON_FAILURE=1
|
||||
mkdir -p build-test
|
||||
LD_LIBRARY_PATH=/usr/local/lib32 \$PWD/.dependencies/cmake-3.22.5/bin/ctest --build-and-test . build-test \
|
||||
-DCMAKE_MAKE_PROGRAM=\$PWD/.dependencies/ninja-1.10.2/ninja \
|
||||
-DCMAKE_MAKE_PROGRAM=\$PWD/.dependencies/ninja-1.12.1/ninja \
|
||||
--build-generator Ninja \
|
||||
--build-target tests \
|
||||
--test-command ctest
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ set(PROJECT_VERSION_MINOR
|
|||
CACHE STRING "Project minor version" FORCE
|
||||
)
|
||||
set(PROJECT_VERSION_REV
|
||||
0
|
||||
4
|
||||
CACHE STRING "Project revision" FORCE
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue