From 74bbb1300847d56abff4ebbba02936ef9633b7c9 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Thu, 1 Nov 2018 20:38:45 +0100 Subject: [PATCH] Fix Mixer calculations for 32-bit processors (#12293) --- Marlin/src/feature/mixing.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Marlin/src/feature/mixing.h b/Marlin/src/feature/mixing.h index 1a675e4d79..a90c022c64 100644 --- a/Marlin/src/feature/mixing.h +++ b/Marlin/src/feature/mixing.h @@ -27,14 +27,15 @@ #define MIXER_ACCU_SIGNED typedef uint8_t mixer_color_t; typedef int8_t mixer_accu_t; + #define COLOR_A_MASK 0x80 + #define COLOR_MASK 0x7F #else typedef uint_fast16_t mixer_color_t; typedef uint_fast16_t mixer_accu_t; + #define COLOR_A_MASK 0x8000 + #define COLOR_MASK 0x7FFF #endif -#define COLOR_A_MASK _BV(sizeof(mixer_color_t) * 8 - 1) // 0x80 or 0x8000 -#define COLOR_MASK (COLOR_A_MASK - 1) // 0x7F or 0x7FFF - #ifndef MIXING_VIRTUAL_TOOLS #define MIXING_VIRTUAL_TOOLS 1 #endif @@ -42,8 +43,14 @@ #ifdef RETRACT_SYNC_MIXING #define NR_MIXING_VIRTUAL_TOOLS (MIXING_VIRTUAL_TOOLS + 1) #define MIXER_AUTORETRACT_TOOL MIXING_VIRTUAL_TOOLS + #if NR_MIXING_VIRTUAL_TOOLS > 255 + #error("MIXING_VIRTUAL_TOOLS must be <= 254!"); + #endif #else #define NR_MIXING_VIRTUAL_TOOLS (MIXING_VIRTUAL_TOOLS) + #if NR_MIXING_VIRTUAL_TOOLS > 255 + #error("MIXING_VIRTUAL_TOOLS must be <= 255!"); + #endif #endif #define MIXER_STEPPER_LOOP(VAR) \