Skip to content

Commit 687ed2d

Browse files
committed
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marlin into feature/bugfix-2.1.x
* 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marlin: (252 commits) 🐛 Fix Anet ET4 SD_SS_PIN (MarlinFirmware#25492) [cron] Bump distribution date (2023-03-11) ✨ BTT Octopus Max EZ 1.0, SKR 3.0 / 3.0 EZ (MarlinFirmware#25387) [cron] Bump distribution date (2023-03-10) ✨ Z_SAFE_HOMING_POINT_ABSOLUTE (MarlinFirmware#23069) [cron] Bump distribution date (2023-03-09) 🔨 VSCode + Devcontainer support (MarlinFirmware#22420) 🔧 Update some config.ini options ✨ Extra Z Servo Probe options (MarlinFirmware#21427) [cron] Bump distribution date (2023-03-08) 🔧 Add DGUS_LCD_UI RELOADED conditions 🌐 DGUS Reloaded non-accented French (MarlinFirmware#25443) [cron] Bump distribution date (2023-03-07) 🌐 Update Turkish language 🧑‍💻 Script to make non-accented languages [cron] Bump distribution date (2023-03-06) 🌐 Update Turkish language (MarlinFirmware#25447) 🐛 Fix Flash EEPROM for STM32G0B1CB (MarlinFirmware#25469) 🐛 Fix apply_power for SPINDLE_SERVO (MarlinFirmware#25465) [cron] Bump distribution date (2023-03-05) ... Signed-off-by: Nick Snyder <nick@nicksnyder.is> # Conflicts: # config/ncksnydr/narungol/2.1/Configuration_adv.h
2 parents 34679ac + 3e12934 commit 687ed2d

File tree

569 files changed

+46643
-9371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

569 files changed

+46643
-9371
lines changed

.devcontainer/Dockerfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/python-3/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
4+
ARG VARIANT="3.9.0-buster"
5+
FROM python:${VARIANT}
6+
7+
# [Option] Install Node.js
8+
ARG INSTALL_NODE="true"
9+
ARG NODE_VERSION="lts/*"
10+
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
11+
12+
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
13+
# COPY requirements.txt /tmp/pip-tmp/
14+
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
15+
# && rm -rf /tmp/pip-tmp
16+
17+
# [Optional] Uncomment this section to install additional OS packages.
18+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
19+
# && apt-get -y install --no-install-recommends <your-package-list-here>
20+
21+
# [Optional] Uncomment this line to install global node packages.
22+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
23+
24+
25+
RUN pip install -U https://github.com/platformio/platformio-core/archive/develop.zip
26+
RUN platformio update
27+
# To get the test platforms
28+
RUN pip install PyYaml
29+
#ENV PATH /code/buildroot/bin/:/code/buildroot/tests/:${PATH}

.devcontainer/devcontainer.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/python-3
3+
{
4+
"name": "Python 3",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"context": "..",
8+
"args": {
9+
// Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9
10+
"VARIANT": "3.9.0-buster",
11+
// Options
12+
"INSTALL_NODE": "false",
13+
"NODE_VERSION": "lts/*"
14+
}
15+
},
16+
17+
// Set *default* container specific settings.json values on container create.
18+
"settings": {
19+
"python.pythonPath": "/usr/local/bin/python",
20+
"python.languageServer": "Pylance",
21+
"python.linting.enabled": true,
22+
"python.linting.pylintEnabled": true,
23+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
24+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
25+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
26+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
27+
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
28+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
29+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
30+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
31+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
32+
},
33+
34+
// Add the IDs of extensions you want installed when the container is created.
35+
"extensions": [
36+
"ms-python.python",
37+
"ms-python.vscode-pylance",
38+
"platformio.platformio-ide",
39+
"marlinfirmware.auto-build",
40+
"editorconfig.editorconfig"
41+
],
42+
43+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
44+
// "forwardPorts": [],
45+
46+
// Use 'postCreateCommand' to run commands after the container is created.
47+
// "postCreateCommand": "pip3 install --user -r requirements.txt",
48+
49+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
50+
// "remoteUser": "vscode"
51+
}

.github/workflows/check-pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ jobs:
2929
3030
Please redo this PR starting with the `bugfix-2.1.x` branch and be careful to target `bugfix-2.1.x` when resubmitting the PR. Patches may also target `bugfix-2.0.x` if they are specifically for 2.0.9.x.
3131
32-
It may help to set your fork's default branch to `bugfix-2.0.x`.
32+
It may help to set your fork's default branch to `bugfix-2.1.x`.
3333
3434
See [this page](https://marlinfw.org/docs/development/getting_started_pull_requests.html) for full instructions.

.github/workflows/test-builds.yml

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
- teensy31
4545
- teensy35
4646
- teensy41
47+
- SAMD21_minitronics20
4748
- SAMD51_grandcentral_m4
4849
- PANDA_PI_V29
4950

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Marlin/_Statusscreen.h
2828

2929
# Generated files
3030
_Version.h
31-
bdf2u8g
31+
bdf2u8g.exe
32+
genpages.exe
3233
marlin_config.json
3334
mczip.h
3435
*.gen

Marlin/Version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* here we define this default string as the date where the latest release
4242
* version was tagged.
4343
*/
44-
//#define STRING_DISTRIBUTION_DATE "2022-12-05"
44+
//#define STRING_DISTRIBUTION_DATE "2023-03-11"
4545

4646
/**
4747
* Defines a generic printer name to be output to the LCD after booting Marlin.

Marlin/config.ini

+5-5
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ invert_y_dir = true
9595
invert_z_dir = false
9696
invert_e0_dir = false
9797

98-
invert_e_step_pin = false
99-
invert_x_step_pin = false
100-
invert_y_step_pin = false
101-
invert_z_step_pin = false
98+
step_state_e = HIGH
99+
step_state_x = HIGH
100+
step_state_y = HIGH
101+
step_state_z = HIGH
102102

103103
disable_x = false
104104
disable_y = false
@@ -178,7 +178,7 @@ autotemp_oldweight = 0.98
178178
bed_check_interval = 5000
179179
default_stepper_deactive_time = 120
180180
default_volumetric_extruder_limit = 0.00
181-
disable_inactive_e = true
181+
disable_inactive_extruder = true
182182
disable_inactive_x = true
183183
disable_inactive_y = true
184184
disable_inactive_z = true

Marlin/src/HAL/AVR/MarlinSerial.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <WString.h>
3535

3636
#include "../../inc/MarlinConfigPre.h"
37+
#include "../../core/types.h"
3738
#include "../../core/serial_hook.h"
3839

3940
#ifndef SERIAL_PORT
@@ -138,10 +139,6 @@
138139

139140
#define BYTE 0
140141

141-
// Templated type selector
142-
template<bool b, typename T, typename F> struct TypeSelector { typedef T type;} ;
143-
template<typename T, typename F> struct TypeSelector<false, T, F> { typedef F type; };
144-
145142
template<typename Cfg>
146143
class MarlinSerial {
147144
protected:
@@ -164,7 +161,7 @@
164161
static constexpr B_U2Xx<Cfg::PORT> B_U2X = 0;
165162

166163
// Base size of type on buffer size
167-
typedef typename TypeSelector<(Cfg::RX_SIZE>256), uint16_t, uint8_t>::type ring_buffer_pos_t;
164+
typedef uvalue_t(Cfg::RX_SIZE - 1) ring_buffer_pos_t;
168165

169166
struct ring_buffer_r {
170167
volatile ring_buffer_pos_t head, tail;

Marlin/src/HAL/AVR/fast_pwm.cpp

+22-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323

2424
#include "../../inc/MarlinConfig.h"
2525

26+
//#define DEBUG_AVR_FAST_PWM
27+
#define DEBUG_OUT ENABLED(DEBUG_AVR_FAST_PWM)
28+
#include "../../core/debug_out.h"
29+
2630
struct Timer {
2731
volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer
2832
volatile uint16_t* OCRnQ[3]; // max 3 OCR registers per timer
@@ -108,36 +112,45 @@ const Timer get_pwm_timer(const pin_t pin) {
108112
}
109113

110114
void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
115+
DEBUG_ECHOLNPGM("set_pwm_frequency(pin=", pin, ", freq=", f_desired, ")");
111116
const Timer timer = get_pwm_timer(pin);
112117
if (timer.isProtected || !timer.isPWM) return; // Don't proceed if protected timer or not recognized
113118

114119
const bool is_timer2 = timer.n == 2;
115120
const uint16_t maxtop = is_timer2 ? 0xFF : 0xFFFF;
116121

122+
DEBUG_ECHOLNPGM("maxtop=", maxtop);
123+
117124
uint16_t res = 0xFF; // resolution (TOP value)
118125
uint8_t j = CS_NONE; // prescaler index
119126
uint8_t wgm = WGM_PWM_PC_8; // waveform generation mode
120127

121128
// Calculating the prescaler and resolution to use to achieve closest frequency
122129
if (f_desired != 0) {
123130
constexpr uint16_t prescaler[] = { 1, 8, (32), 64, (128), 256, 1024 }; // (*) are Timer 2 only
124-
uint16_t f = (F_CPU) / (2 * 1024 * maxtop) + 1; // Start with the lowest non-zero frequency achievable (1 or 31)
131+
uint16_t f = (F_CPU) / (uint32_t(maxtop) << 11) + 1; // Start with the lowest non-zero frequency achievable (for 16MHz, 1 or 31)
125132

133+
DEBUG_ECHOLNPGM("f=", f);
134+
DEBUG_ECHOLNPGM("(prescaler loop)");
126135
LOOP_L_N(i, COUNT(prescaler)) { // Loop through all prescaler values
127-
const uint16_t p = prescaler[i];
136+
const uint32_t p = prescaler[i]; // Extend to 32 bits for calculations
137+
DEBUG_ECHOLNPGM("prescaler[", i, "]=", p);
128138
uint16_t res_fast_temp, res_pc_temp;
129139
if (is_timer2) {
130140
#if ENABLED(USE_OCR2A_AS_TOP) // No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP
131141
const uint16_t rft = (F_CPU) / (p * f_desired);
132142
res_fast_temp = rft - 1;
133143
res_pc_temp = rft / 2;
144+
DEBUG_ECHOLNPGM("(Timer2) res_fast_temp=", res_fast_temp, " res_pc_temp=", res_pc_temp);
134145
#else
135146
res_fast_temp = res_pc_temp = maxtop;
147+
DEBUG_ECHOLNPGM("(Timer2) res_fast_temp=", maxtop, " res_pc_temp=", maxtop);
136148
#endif
137149
}
138150
else {
139151
if (p == 32 || p == 128) continue; // Skip TIMER2 specific prescalers when not TIMER2
140152
const uint16_t rft = (F_CPU) / (p * f_desired);
153+
DEBUG_ECHOLNPGM("(Not Timer 2) F_CPU=" STRINGIFY(F_CPU), " prescaler=", p, " f_desired=", f_desired);
141154
res_fast_temp = rft - 1;
142155
res_pc_temp = rft / 2;
143156
}
@@ -147,23 +160,27 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
147160

148161
// Calculate frequencies of test prescaler and resolution values
149162
const uint16_t f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)),
150-
f_pc_temp = (F_CPU) / (2 * p * res_pc_temp);
151-
const int f_diff = _MAX(f, f_desired) - _MIN(f, f_desired),
163+
f_pc_temp = (F_CPU) / ((p * res_pc_temp) << 1),
164+
f_diff = _MAX(f, f_desired) - _MIN(f, f_desired),
152165
f_fast_diff = _MAX(f_fast_temp, f_desired) - _MIN(f_fast_temp, f_desired),
153166
f_pc_diff = _MAX(f_pc_temp, f_desired) - _MIN(f_pc_temp, f_desired);
154167

168+
DEBUG_ECHOLNPGM("f_fast_temp=", f_fast_temp, " f_pc_temp=", f_pc_temp, " f_diff=", f_diff, " f_fast_diff=", f_fast_diff, " f_pc_diff=", f_pc_diff);
169+
155170
if (f_fast_diff < f_diff && f_fast_diff <= f_pc_diff) { // FAST values are closest to desired f
156171
// Set the Wave Generation Mode to FAST PWM
157172
wgm = is_timer2 ? uint8_t(TERN(USE_OCR2A_AS_TOP, WGM2_FAST_PWM_OCR2A, WGM2_FAST_PWM)) : uint8_t(WGM_FAST_PWM_ICRn);
158173
// Remember this combination
159174
f = f_fast_temp; res = res_fast_temp; j = i + 1;
175+
DEBUG_ECHOLNPGM("(FAST) updated f=", f);
160176
}
161177
else if (f_pc_diff < f_diff) { // PHASE CORRECT values are closes to desired f
162178
// Set the Wave Generation Mode to PWM PHASE CORRECT
163179
wgm = is_timer2 ? uint8_t(TERN(USE_OCR2A_AS_TOP, WGM2_PWM_PC_OCR2A, WGM2_PWM_PC)) : uint8_t(WGM_PWM_PC_ICRn);
164180
f = f_pc_temp; res = res_pc_temp; j = i + 1;
181+
DEBUG_ECHOLNPGM("(PHASE) updated f=", f);
165182
}
166-
}
183+
} // prescaler loop
167184
}
168185

169186
_SET_WGMnQ(timer, wgm);

Marlin/src/HAL/AVR/fastio.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ enum ClockSource2 : uint8_t {
293293

294294
#if HAS_MOTOR_CURRENT_PWM
295295
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
296-
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1 || P == MOTOR_CURRENT_PWM_Z || P == MOTOR_CURRENT_PWM_XY)
296+
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E_PIN || P == MOTOR_CURRENT_PWM_E0_PIN || P == MOTOR_CURRENT_PWM_E1_PIN || P == MOTOR_CURRENT_PWM_Z_PIN || P == MOTOR_CURRENT_PWM_XY_PIN)
297297
#elif PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
298-
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1 || P == MOTOR_CURRENT_PWM_Z)
298+
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E_PIN || P == MOTOR_CURRENT_PWM_E0_PIN || P == MOTOR_CURRENT_PWM_E1_PIN || P == MOTOR_CURRENT_PWM_Z_PIN)
299299
#else
300-
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1)
300+
#define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E_PIN || P == MOTOR_CURRENT_PWM_E0_PIN || P == MOTOR_CURRENT_PWM_E1_PIN)
301301
#endif
302302
#else
303303
#define PWM_CHK_MOTOR_CURRENT(P) false

Marlin/src/HAL/AVR/math.h

+21-19
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727

2828
// intRes = longIn1 * longIn2 >> 24
2929
// uses:
30-
// A[tmp] to store 0
31-
// B[tmp] to store bits 16-23 of the 48bit result. The top bit is used to round the two byte result.
32-
// note that the lower two bytes and the upper byte of the 48bit result are not calculated.
33-
// this can cause the result to be out by one as the lower bytes may cause carries into the upper ones.
34-
// B A are bits 24-39 and are the returned value
35-
// C B A is longIn1
36-
// D C B A is longIn2
30+
// r1, r0 for the result of mul.
31+
// [tmp1] to store 0.
32+
// [tmp2] to store bits 16-23 of the 56 bit result. The top bit of [tmp2] is used for rounding.
33+
// Note that the lower two bytes and the upper two bytes of the 56 bit result are not calculated.
34+
// This can cause the result to be out by one as the lower bytes may cause carries into the upper ones.
35+
// [intRes] (A B) is bits 24-39 and is the returned value.
36+
// [longIn1] (C B A) is a 24 bit parameter.
37+
// [longIn2] (D C B A) is a 32 bit parameter.
3738
//
3839
FORCE_INLINE static uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2) {
3940
uint8_t tmp1;
@@ -66,11 +67,9 @@ FORCE_INLINE static uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2
6667
A("add %[tmp2], r1")
6768
A("adc %A[intRes], %[tmp1]")
6869
A("adc %B[intRes], %[tmp1]")
69-
A("lsr %[tmp2]")
70-
A("adc %A[intRes], %[tmp1]")
71-
A("adc %B[intRes], %[tmp1]")
7270
A("mul %D[longIn2], %A[longIn1]")
73-
A("add %A[intRes], r0")
71+
A("lsl %[tmp2]")
72+
A("adc %A[intRes], r0")
7473
A("adc %B[intRes], r1")
7574
A("mul %D[longIn2], %B[longIn1]")
7675
A("add %B[intRes], r0")
@@ -85,22 +84,25 @@ FORCE_INLINE static uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2
8584
return intRes;
8685
}
8786

88-
// intRes = intIn1 * intIn2 >> 16
87+
// intRes = intIn1 * intIn2 >> 8
8988
// uses:
90-
// r26 to store 0
91-
// r27 to store the byte 1 of the 24 bit result
92-
FORCE_INLINE static uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) {
89+
// r1, r0 for the result of mul. After the second mul, r0 holds bits 0-7 of the 24 bit result and
90+
// the top bit of r0 is used for rounding.
91+
// [tmp] to store 0.
92+
// [intRes] (A B) is bits 8-15 and is the returned value.
93+
// [charIn1] is an 8 bit parameter.
94+
// [intIn2] (B A) is a 16 bit parameter.
95+
//
96+
FORCE_INLINE static uint16_t MultiU8X16toH16(uint8_t charIn1, uint16_t intIn2) {
9397
uint8_t tmp;
9498
uint16_t intRes;
9599
__asm__ __volatile__ (
96100
A("clr %[tmp]")
97101
A("mul %[charIn1], %B[intIn2]")
98102
A("movw %A[intRes], r0")
99103
A("mul %[charIn1], %A[intIn2]")
100-
A("add %A[intRes], r1")
101-
A("adc %B[intRes], %[tmp]")
102-
A("lsr r0")
103-
A("adc %A[intRes], %[tmp]")
104+
A("lsl r0")
105+
A("adc %A[intRes], r1")
104106
A("adc %B[intRes], %[tmp]")
105107
A("clr r1")
106108
: [intRes] "=&r" (intRes),

Marlin/src/HAL/DUE/MarlinSerial.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <WString.h>
3131

3232
#include "../../inc/MarlinConfigPre.h"
33+
#include "../../core/types.h"
3334
#include "../../core/serial_hook.h"
3435

3536
// Define constants and variables for buffering incoming serial data. We're
@@ -52,10 +53,6 @@
5253
// #error "TX_BUFFER_SIZE must be 0, a power of 2 greater than 1, and no greater than 256."
5354
//#endif
5455

55-
// Templated type selector
56-
template<bool b, typename T, typename F> struct TypeSelector { typedef T type;} ;
57-
template<typename T, typename F> struct TypeSelector<false, T, F> { typedef F type; };
58-
5956
// Templated structure wrapper
6057
template<typename S, unsigned int addr> struct StructWrapper {
6158
constexpr StructWrapper(int) {}
@@ -76,7 +73,7 @@ class MarlinSerial {
7673
static constexpr int HWUART_IRQ_ID = IRQ_IDS[Cfg::PORT];
7774

7875
// Base size of type on buffer size
79-
typedef typename TypeSelector<(Cfg::RX_SIZE>256), uint16_t, uint8_t>::type ring_buffer_pos_t;
76+
typedef uvalue_t(Cfg::RX_SIZE - 1) ring_buffer_pos_t;
8077

8178
struct ring_buffer_r {
8279
volatile ring_buffer_pos_t head, tail;

0 commit comments

Comments
 (0)