From 6a9442d6ea6ce6e9215b221b298532bd379b02aa Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sat, 22 Aug 2020 13:44:09 -0500 Subject: [PATCH 01/58] seperate neopixel control with M151 sorry im not a programer but i did my best to get 2 seperated controls for extra visual indiaction from the LEDS by keeping the Printer Events on the main channel . --- Marlin/Configuration.h | 29 +++-- Marlin/Configuration_adv.h | 9 ++ Marlin/src/MarlinCore.cpp | 4 + Marlin/src/feature/leds/leds.cpp | 54 ++++++++ Marlin/src/feature/leds/leds.h | 170 +++++++++++++++++++++++++ Marlin/src/feature/leds/neopixel.cpp | 49 +++++++ Marlin/src/feature/leds/neopixel.h | 58 ++++++++- Marlin/src/gcode/feature/leds/M151.cpp | 64 ++++++++++ Marlin/src/gcode/gcode.cpp | 4 + Marlin/src/gcode/gcode.h | 5 + Marlin/src/inc/SanityCheck.h | 5 + 11 files changed, 435 insertions(+), 16 deletions(-) create mode 100644 Marlin/src/gcode/feature/leds/M151.cpp diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 2639bcd97b64..6bf5c418d3fc 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -128,7 +128,7 @@ // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_RAMPS_14_EFB + #define MOTHERBOARD BOARD_BTT_SKR_V1_4_TURBO #endif // Name displayed in the LCD "Ready" message and Info menu @@ -2353,21 +2353,28 @@ #endif // Support for Adafruit Neopixel LED driver -//#define NEOPIXEL_LED +#define NEOPIXEL_LED #if ENABLED(NEOPIXEL_LED) - #define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL_PIN 4 // LED driving pin - //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE - //#define NEOPIXEL2_PIN 5 - //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel - #define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used - #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. - #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) - //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup + #define NEOPIXEL_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) + #define NEOPIXEL_PIN P1_24 // LED driving pin + #define NEOPIXEL_PIXELS 12 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used + #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) + //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup + #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. // Use a single Neopixel LED for static (background) lighting //#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W + + // Support for second Adafruit Neopixel LED driver that is controlled with M151 + #define NEOPIXEL2 + #if ENABLED(NEOPIXEL2) + #define NEOPIXEL2_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) + #define NEOPIXEL2_PIN P1_26 // LED2 driving pin + #define NEOPIXEL2_PIXELS 12 // Number of LEDs in the second strip, larger of 2 strips if 2 neopixel strips are used + #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) + //#define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup on the seperate channel + #endif #endif /** diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 7d9182ad9bbc..8fc078e792fb 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1073,6 +1073,15 @@ #define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity //#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup #endif + + #if ENABLED(NEOPIXEL2) //Enables the Second NeoPixel Preset Color menu option + #define LED2_USER_PRESET_RED 255 // User defined RED value + #define LED2_USER_PRESET_GREEN 128 // User defined GREEN value + #define LED2_USER_PRESET_BLUE 0 // User defined BLUE value + #define LED2_USER_PRESET_WHITE 255 // User defined WHITE value + #define LED2_USER_PRESET_BRIGHTNESS 255 // User defined intensity + //#define LED2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip + #endif #endif #endif // HAS_LCD_MENU diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 3544a8840f63..06c14f247c82 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -991,6 +991,10 @@ void setup() { SETUP_RUN(leds.setup()); #endif +#if NEOPIXELX2 + SETUP_RUN(leds2.setup()); + #endif + #if ENABLED(USE_CONTROLLER_FAN) // Set up fan controller to initialize also the default configurations. SETUP_RUN(controllerFan.setup()); #endif diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index eec0cde630da..d6d283e02038 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -161,4 +161,58 @@ void LEDLights::set_color(const LEDColor &incol #endif +#if (NEOPIXELX2) + + +#if ENABLED(LED2_COLOR_PRESETS) + const LEDColor2 LEDLights2::defaultLEDColor2 = MakeLEDColor2( + LED2_USER_PRESET_RED, + LED2_USER_PRESET_GREEN, + LED2_USER_PRESET_BLUE, + LED2_USER_PRESET_WHITE, + LED2_USER_PRESET_BRIGHTNESS + ); +#endif + +#if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) + LEDColor2 LEDLights2::color; + bool LEDLights2::lights_on; +#endif + +LEDLights2 leds2; + +void LEDLights2::setup() { + #if EITHER(RGB_LED, RGBW_LED) + if (PWM_PIN(RGB_LED_R_PIN)) SET_PWM(RGB_LED_R_PIN); else SET_OUTPUT(RGB_LED_R_PIN); + if (PWM_PIN(RGB_LED_G_PIN)) SET_PWM(RGB_LED_G_PIN); else SET_OUTPUT(RGB_LED_G_PIN); + if (PWM_PIN(RGB_LED_B_PIN)) SET_PWM(RGB_LED_B_PIN); else SET_OUTPUT(RGB_LED_B_PIN); + #if ENABLED(RGBW_LED) + if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN); + #endif + #endif + TERN_(NEOPIXEL2, neo2.init()); + TERN_(PCA9533, PCA9533_init()); + TERN_(LED2_USER_PRESET_STARTUP, set_default()); +} + +void LEDLights2::set_color(const LEDColor2 &incol) { + + #if ENABLED(NEOPIXEL2) + + const uint32_t neocolor2 = LEDColorWhite2() == incol + ? neo2.Color(NEO_WHITE) + : neo2.Color(incol.r, incol.g, incol.b, incol.w); + + neo2.set_brightness(incol.i); + + + + neo2.set_color(neocolor2);} + + #endif + + + + #endif //NeoPixelX2 + #endif // HAS_COLOR_LEDS diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 577c94752ffd..3371264301bb 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -216,3 +216,173 @@ class LEDLights { }; extern LEDLights leds; + +#if NEOPIXELX2 + #include "neopixel.h" +#endif + +// A white component can be passed +#if EITHER(RGBW_LED, NEOPIXEL2) + #define HAS_WHITE_LED 1 +#endif + +/** + * LEDcolor2 type for use with leds2.set_color + */ +typedef struct LEDColor2 { + uint8_t r, g, b + #if HAS_WHITE_LED + , w + #if ENABLED(NEOPIXEL2) + , i + #endif + #endif + ; + + LEDColor2() : r(255), g(255), b(255) + #if HAS_WHITE_LED + , w(255) + #if ENABLED(NEOPIXEL2) + , i(NEOPIXEL2_BRIGHTNESS) + #endif + #endif + {} + + LEDColor2(uint8_t r, uint8_t g, uint8_t b + #if HAS_WHITE_LED + , uint8_t w=0 + #if ENABLED(NEOPIXEL2) + , uint8_t i=NEOPIXEL2_BRIGHTNESS + #endif + #endif + ) : r(r), g(g), b(b) + #if HAS_WHITE_LED + , w(w) + #if ENABLED(NEOPIXEL2) + , i(i) + #endif + #endif + {} + + LEDColor2(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2]) + #if HAS_WHITE_LED + , w(rgbw[3]) + #if ENABLED(NEOPIXEL2) + , i(NEOPIXEL2_BRIGHTNESS) + #endif + #endif + {} + + LEDColor2& operator=(const uint8_t (&rgbw)[4]) { + r = rgbw[0]; g = rgbw[1]; b = rgbw[2]; + TERN_(HAS_WHITE_LED, w = rgbw[3]); + return *this; + } + + LEDColor2& operator=(const LEDColor2 &right) { + if (this != &right) memcpy(this, &right, sizeof(LEDColor2)); + return *this; + } + + bool operator==(const LEDColor2 &right) { + if (this == &right) return true; + return 0 == memcmp(this, &right, sizeof(LEDColor2)); + } + + bool operator!=(const LEDColor2 &right) { return !operator==(right); } + + bool is_off() const { + return 3 > r + g + b + #if HAS_WHITE_LED + + w + #endif + ; + } +} LEDColor2; + +/** + * Color helpers and presets for second neopixel channel + */ +#if HAS_WHITE_LED + #if ENABLED(NEOPIXEL2) + #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B, W, I) + #else + #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B, W) + #endif +#else + #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B) +#endif + +#define LEDColorOff2() LEDColor2( 0, 0, 0) +#define LEDColorRed2() LEDColor2(255, 0, 0) +#if ENABLED(LED_COLORS_REDUCE_GREEN) + #define LEDColorOrange2() LEDColor2(255, 25, 0) + #define LEDColorYellow2() LEDColor2(255, 75, 0) +#else + #define LEDColorOrange2() LEDColor2(255, 80, 0) + #define LEDColorYellow2() LEDColor2(255, 255, 0) +#endif +#define LEDColorGreen2() LEDColor2( 0, 255, 0) +#define LEDColorBlue2() LEDColor2( 0, 0, 255) +#define LEDColorIndigo2() LEDColor2( 0, 255, 255) +#define LEDColorViolet2() LEDColor2(255, 0, 255) +#if HAS_WHITE_LED && DISABLED(RGB_LED) + #define LEDColorWhite2() LEDColor2( 0, 0, 0, 255) +#else + #define LEDColorWhite2() LEDColor2(255, 255, 255) +#endif + +class LEDLights2 { +public: + LEDLights2() {} // ctor + + static void setup(); // init() + + static void set_color(const LEDColor2 &color + + ); + + inline void set_color(uint8_t r, uint8_t g, uint8_t b + #if HAS_WHITE_LED + , uint8_t w=0 + #if ENABLED(NEOPIXEL2) + , uint8_t i=NEOPIXEL2_BRIGHTNESS + #endif + #endif + + ) { + set_color(MakeLEDColor2(r, g, b, w, i) + + ); + } + + static inline void set_off() { set_color(LEDColorOff2()); } + static inline void set_green() { set_color(LEDColorGreen2()); } + static inline void set_white() { set_color(LEDColorWhite2()); } + + #if ENABLED(LED2_COLOR_PRESETS) + static const LEDColor2 defaultLEDColor2; + static inline void set_default() { set_color(defaultLEDColor2); } + static inline void set_red() { set_color(LEDColorRed2()); } + static inline void set_orange() { set_color(LEDColorOrange2()); } + static inline void set_yellow() { set_color(LEDColorYellow2()); } + static inline void set_blue() { set_color(LEDColorBlue2()); } + static inline void set_indigo() { set_color(LEDColorIndigo2()); } + static inline void set_violet() { set_color(LEDColorViolet2()); } + #endif + + + #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) + static LEDColor2 color; // last non-off color + static bool lights_on; // the last set color was "on" + #endif + + #if ENABLED(LED_CONTROL_MENU) + static void toggle(); // swap "off" with color + static inline void update() { set_color(color); } + #endif + + +}; + +extern LEDLights2 leds2; diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 520d4d63b22f..615262188b5d 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -121,3 +121,52 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint #endif #endif // NEOPIXEL_LED + +#if NEOPIXELX2 + Marlin_NeoPixel2 neo2; + int8_t Marlin_NeoPixel2::neoindex2; + +Adafruit_NeoPixel Marlin_NeoPixel2::adaneo2(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); + +void Marlin_NeoPixel2::set_color(const uint32_t color) { + if (get_neo_index() >= 0) { + set_pixel_color(get_neo_index(), color); + set_neo_index(-1); + } + else { + for (uint16_t i = 0; i < pixels(); ++i) { + set_pixel_color(i, color); + } + } + show(); +} + +void Marlin_NeoPixel2::set_color_startup(const uint32_t color) { + for (uint16_t i = 0; i < pixels(); ++i) + set_pixel_color(i, color); + show(); +} + +void Marlin_NeoPixel2::init() { + set_neo_index(-1); // -1 .. NEOPIXEL2_PIXELS-1 range + set_brightness(NEOPIXEL2_BRIGHTNESS); // 0 .. 255 range + begin(); + show(); // initialize to all off + + #if ENABLED(NEOPIXEL2_STARTUP_TEST) + set_color_startup(adaneo2.Color(255, 0, 0, 0)); // red + safe_delay(1000); + set_color_startup(adaneo2.Color(0, 255, 0, 0)); // green + safe_delay(1000); + set_color_startup(adaneo2.Color(0, 0, 255, 0)); // blue + safe_delay(1000); + #endif + + + #if ENABLED(LED2_USER_PRESET_STARTUP) + set_color(adaneo2.Color(LED2_USER_PRESET_RED, LED2_USER_PRESET_GREEN, LED2_USER_PRESET_BLUE, LED2_USER_PRESET_WHITE)); + #else + set_color(adaneo2.Color(0, 0, 0, 0)); + #endif +} +#endif // NEOPIXELX2 \ No newline at end of file diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 0155785e9afb..2fbee2030ca3 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -38,11 +38,7 @@ // Defines // ------------------------ -#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE - #define MULTIPLE_NEOPIXEL_TYPES 1 -#endif - -#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR +#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR || NEOPIXEL2_TYPE == NEO_RGB || NEOPIXEL2_TYPE == NEO_RBG || NEOPIXEL2_TYPE == NEO_GRB || NEOPIXEL2_TYPE == NEO_GBR || NEOPIXEL2_TYPE == NEO_BRG || NEOPIXEL2_TYPE == NEO_BGR #define NEOPIXEL_IS_RGB 1 #else #define NEOPIXEL_IS_RGBW 1 @@ -134,3 +130,55 @@ class Marlin_NeoPixel { }; extern Marlin_NeoPixel neo; + +// Neo pixel channel 2 +#if NEOPIXELX2 +class Marlin_NeoPixel2 { +private: + static Adafruit_NeoPixel adaneo2; + + static int8_t neoindex2; + +public: + static void init(); + static void set_color_startup(const uint32_t c); + + static void set_color(const uint32_t c); + + FORCE_INLINE static void set_neo_index(const int8_t neoIndex2) { neoindex2 = neoIndex2; } + FORCE_INLINE static int8_t get_neo_index() { return neoindex2; } + + + static inline void begin() { + adaneo2.begin(); + + } + + static inline void set_pixel_color(const uint16_t n, const uint32_t c) { + adaneo2.setPixelColor(n, c); + + } + + static inline void set_brightness(const uint8_t b) { + adaneo2.setBrightness(b); + + } + +static inline void show() { + adaneo2.show(); + adaneo2.setPin(NEOPIXEL2_PIN); + } + #if 0 + bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p); + #endif + + // Accessors for NeoPixel2 + static inline uint16_t pixels() { return adaneo2.numPixels();} + static inline uint8_t brightness() { return adaneo2.getBrightness(); } + static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { + return adaneo2.Color(r, g, b, w); + } +}; + +extern Marlin_NeoPixel2 neo2; +#endif \ No newline at end of file diff --git a/Marlin/src/gcode/feature/leds/M151.cpp b/Marlin/src/gcode/feature/leds/M151.cpp new file mode 100644 index 000000000000..f76b4912d0ee --- /dev/null +++ b/Marlin/src/gcode/feature/leds/M151.cpp @@ -0,0 +1,64 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * 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 . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if NEOPIXELX2 + +#include "../../gcode.h" +#include "../../../feature/leds/leds.h" + +/** + * M151: Set Second LED Color - Use R-U-B-W for R-G-B-W + * and Brightness - Use P (for NEOPIXEL only) + * + * Always sets all 3 or 4 components. If a component is left out, set to 0. + * If brightness is left out, no value changed + * + * With NEOPIXEL2: + * I Set the Neopixel2 index to affect. Default: All + * + * Examples: + * + * M151 R255 ; Turn LED red + * M151 R255 U127 ; Turn LED orange (PWM only) + * M151 ; Turn LED off + * M151 R U B ; Turn LED white + * M151 W ; Turn LED white using a white LED + * M151 P127 ; Set LED 50% brightness + * M151 P ; Set LED full brightness + * M151 I1 R ; Set NEOPIXEL2 index 1 to red + */ +void GcodeSuite::M151() { + #if ENABLED(NEOPIXEL2) + neo2.set_neo_index(parser.intval('I', -1)); + #endif + leds2.set_color(MakeLEDColor2( + parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0, + parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0, + parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0, + parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0, + parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : neo2.brightness() + )); +} + +#endif // HAS_COLOR_LEDS diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index edbeca9c9279..99d596aa676c 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -571,6 +571,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 150: M150(); break; // M150: Set Status LED Color #endif + #if NEOPIXELX2 + case 151: M151(); break; // M151: Set Seperate LED Color to Neopixel2 pin + #endif + #if ENABLED(MIXING_EXTRUDER) case 163: M163(); break; // M163: Set a component weight for mixing extruder case 164: M164(); break; // M164: Save current mix as a virtual extruder diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index e04cd637eb92..5ece2c377f5d 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -156,6 +156,7 @@ * M145 - Set heatup values for materials on the LCD. H B F for S (0=PLA, 1=ABS) * M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT) * M150 - Set Status LED Color as R U B P. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632). + * M151 - Set the Neopixel color of the second Neopixel channel as R U B P I. Values 0-255. (Requires NEOPIXEL2). * M155 - Auto-report temperatures with interval of S. (Requires AUTO_REPORT_TEMPERATURES) * M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER) * M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER) @@ -628,6 +629,10 @@ class GcodeSuite { TERN_(HAS_COLOR_LEDS, static void M150()); + #if NEOPIXELX2 + TERN_(NEOPIXELX2, static void M151()); + #endif + #if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR) static void M155(); #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index ddefcc8b60ae..f2a0bf3afdf9 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2130,8 +2130,13 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #elif ENABLED(NEOPIXEL_LED) #if !(PIN_EXISTS(NEOPIXEL) && NEOPIXEL_PIXELS > 0) #error "NEOPIXEL_LED requires NEOPIXEL_PIN and NEOPIXEL_PIXELS." + #elif ENABLED(NEOPIXEL2) + #if !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) + #error "NEOPIXEL2 requires NEOPIXEL2_PIN and NEOPIXEL2_PIXELS." #endif #endif +#endif + #undef _RGB_TEST #if DISABLED(NO_COMPILE_TIME_PWM) From 53632761a8a821e6dc13ba350d46f83a2ec739b2 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sat, 22 Aug 2020 15:05:20 -0500 Subject: [PATCH 02/58] Update Configuration.h --- Marlin/Configuration.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 6bf5c418d3fc..205ba3046815 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -128,7 +128,7 @@ // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_BTT_SKR_V1_4_TURBO + #define MOTHERBOARD BOARD_RAMPS_14_EFB #endif // Name displayed in the LCD "Ready" message and Info menu @@ -2356,7 +2356,7 @@ #define NEOPIXEL_LED #if ENABLED(NEOPIXEL_LED) #define NEOPIXEL_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL_PIN P1_24 // LED driving pin + #define NEOPIXEL_PIN 4 // LED driving pin #define NEOPIXEL_PIXELS 12 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup @@ -2370,7 +2370,7 @@ #define NEOPIXEL2 #if ENABLED(NEOPIXEL2) #define NEOPIXEL2_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL2_PIN P1_26 // LED2 driving pin + #define NEOPIXEL2_PIN 5 // LED2 driving pin #define NEOPIXEL2_PIXELS 12 // Number of LEDs in the second strip, larger of 2 strips if 2 neopixel strips are used #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) //#define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup on the seperate channel From bd393378f8ec6127f982a38e42cde1b6757a17d0 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sat, 22 Aug 2020 15:18:04 -0500 Subject: [PATCH 03/58] further intergration --- Marlin/Configuration.h | 6 +++--- Marlin/src/inc/Conditionals_adv.h | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 6bf5c418d3fc..205ba3046815 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -128,7 +128,7 @@ // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_BTT_SKR_V1_4_TURBO + #define MOTHERBOARD BOARD_RAMPS_14_EFB #endif // Name displayed in the LCD "Ready" message and Info menu @@ -2356,7 +2356,7 @@ #define NEOPIXEL_LED #if ENABLED(NEOPIXEL_LED) #define NEOPIXEL_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL_PIN P1_24 // LED driving pin + #define NEOPIXEL_PIN 4 // LED driving pin #define NEOPIXEL_PIXELS 12 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup @@ -2370,7 +2370,7 @@ #define NEOPIXEL2 #if ENABLED(NEOPIXEL2) #define NEOPIXEL2_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL2_PIN P1_26 // LED2 driving pin + #define NEOPIXEL2_PIN 5 // LED2 driving pin #define NEOPIXEL2_PIXELS 12 // Number of LEDs in the second strip, larger of 2 strips if 2 neopixel strips are used #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) //#define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup on the seperate channel diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index fa4f0cd9b1f6..8a10e828ec58 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -116,6 +116,9 @@ #if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED) #define HAS_COLOR_LEDS 1 #endif +#if ENABLED(NEOPIXEL2) + #define NEOPIXELX2 1 +#endif #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT) #define HAS_LEDS_OFF_FLAG 1 #endif @@ -246,6 +249,29 @@ #endif #endif +//Set defaults for unspecified LED2 user colors +#if ENABLED(LED_CONTROL_MENU , NEOPIXELX2) + #ifndef LED2_USER_PRESET_RED + #define LED2_USER_PRESET_RED 255 + #endif + #ifndef LED2_USER_PRESET_GREEN + #define LED2_USER_PRESET_GREEN 255 + #endif + #ifndef LED2_USER_PRESET_BLUE + #define LED2_USER_PRESET_BLUE 255 + #endif + #ifndef LED2_USER_PRESET_WHITE + #define LED2_USER_PRESET_WHITE 0 + #endif + #ifndef LED2_USER_PRESET_BRIGHTNESS + #ifdef NEOPIXEL2_BRIGHTNESS + #define LED2_USER_PRESET_BRIGHTNESS NEOPIXEL2_BRIGHTNESS + #else + #define LED2_USER_PRESET_BRIGHTNESS 255 + #endif + #endif +#endif + // If platform requires early initialization of watchdog to properly boot #if ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM) #define EARLY_WATCHDOG 1 From 465092b5c45bff12a77b4db7b04553c1e12e8d5c Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sat, 22 Aug 2020 15:41:00 -0500 Subject: [PATCH 04/58] -Fixed TYPO for the Smart effector Originally labeled as DUET_SMART_EFFECTOR but this is incorrect as MarlinCore looks for SMART_EFFECTOR and not DUET_SMART_EFFECTOR --- Marlin/Configuration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 205ba3046815..dfd19274dd02 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -946,8 +946,8 @@ // Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J // When the pin is defined you can use M672 to set/reset the probe sensivity. -//#define DUET_SMART_EFFECTOR -#if ENABLED(DUET_SMART_EFFECTOR) +//#define SMART_EFFECTOR +#if ENABLED(SMART_EFFECTOR) #define SMART_EFFECTOR_MOD_PIN -1 // Connect a GPIO pin to the Smart Effector MOD pin #endif From 970005f9255c2a8370644e63d1383691409c6b75 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sat, 22 Aug 2020 21:18:19 -0500 Subject: [PATCH 05/58] better intergration --- Marlin/Configuration.h | 24 +++++---- Marlin/Configuration_adv.h | 20 ++++---- Marlin/src/feature/leds/leds.cpp | 26 +++++----- Marlin/src/feature/leds/leds.h | 25 ++++----- Marlin/src/feature/leds/neopixel.cpp | 33 ++++++------ Marlin/src/feature/leds/neopixel.h | 51 +++++-------------- Marlin/src/feature/password/password.cpp | 2 +- Marlin/src/feature/password/password.h | 2 +- Marlin/src/gcode/feature/leds/M151.cpp | 12 ++--- .../src/gcode/feature/password/M510-M512.cpp | 2 +- Marlin/src/inc/Conditionals_adv.h | 2 +- Marlin/src/inc/SanityCheck.h | 6 +-- 12 files changed, 88 insertions(+), 117 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index dfd19274dd02..2f7ad51f6690 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2353,28 +2353,30 @@ #endif // Support for Adafruit Neopixel LED driver -#define NEOPIXEL_LED +//#define NEOPIXEL_LED #if ENABLED(NEOPIXEL_LED) #define NEOPIXEL_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL_PIN 4 // LED driving pin + #define NEOPIXEL_PIN 4 // LED driving pin #define NEOPIXEL_PIXELS 12 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. + #define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel + #define NEOPIXEL2_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) + #define NEOPIXEL2_PIN 5 // Neopixel2 driving pin + + // Support for second Adafruit Neopixel LED driver that is controlled with M151 +#define NEOPIXEL2_SEPERATE +#if ENABLED(NEOPIXEL2_SEPERATE) + #define NEOPIXEL2_PIXELS 12 // Number of LEDs in the second strip, larger of 2 strips if 2 neopixel strips are used + #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) + //#define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup on the seperate channel +#endif // Use a single Neopixel LED for static (background) lighting //#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W - // Support for second Adafruit Neopixel LED driver that is controlled with M151 - #define NEOPIXEL2 - #if ENABLED(NEOPIXEL2) - #define NEOPIXEL2_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL2_PIN 5 // LED2 driving pin - #define NEOPIXEL2_PIXELS 12 // Number of LEDs in the second strip, larger of 2 strips if 2 neopixel strips are used - #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) - //#define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup on the seperate channel - #endif #endif /** diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 8fc078e792fb..6c8b1955c297 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1064,7 +1064,8 @@ */ //#define LED_CONTROL_MENU #if ENABLED(LED_CONTROL_MENU) - #define LED_COLOR_PRESETS // Enable the Preset Color menu option + // #define LED_COLOR_PRESETS // Enable the Preset Color menu option + //#define NEO2_COLOR_PRESETS //Enables the Second NeoPixel Preset Color menu option #if ENABLED(LED_COLOR_PRESETS) #define LED_USER_PRESET_RED 255 // User defined RED value #define LED_USER_PRESET_GREEN 128 // User defined GREEN value @@ -1073,17 +1074,16 @@ #define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity //#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup #endif - - #if ENABLED(NEOPIXEL2) //Enables the Second NeoPixel Preset Color menu option - #define LED2_USER_PRESET_RED 255 // User defined RED value - #define LED2_USER_PRESET_GREEN 128 // User defined GREEN value - #define LED2_USER_PRESET_BLUE 0 // User defined BLUE value - #define LED2_USER_PRESET_WHITE 255 // User defined WHITE value - #define LED2_USER_PRESET_BRIGHTNESS 255 // User defined intensity - //#define LED2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip + #if ENABLED(NEO2_COLOR_PRESETS) + #define NEO2_USER_PRESET_RED 255 // User defined RED value + #define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value + #define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value + #define NEO2_USER_PRESET_WHITE 255 // User defined WHITE value + #define NEO2_USER_PRESET_BRIGHTNESS 255 // User defined intensity + //#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip #endif #endif - + #endif // HAS_LCD_MENU // Scroll a longer status message into view diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index d6d283e02038..efd9213b0282 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -164,17 +164,17 @@ void LEDLights::set_color(const LEDColor &incol #if (NEOPIXELX2) -#if ENABLED(LED2_COLOR_PRESETS) +#if ENABLED(NEO2_COLOR_PRESETS) const LEDColor2 LEDLights2::defaultLEDColor2 = MakeLEDColor2( - LED2_USER_PRESET_RED, - LED2_USER_PRESET_GREEN, - LED2_USER_PRESET_BLUE, - LED2_USER_PRESET_WHITE, - LED2_USER_PRESET_BRIGHTNESS + NEO2_USER_PRESET_RED, + NEO2_USER_PRESET_GREEN, + NEO2_USER_PRESET_BLUE, + NEO2_USER_PRESET_WHITE, + NEO2_USER_PRESET_BRIGHTNESS ); #endif -#if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) +#if ENABLED(LED_CONTROL_MENU) LEDColor2 LEDLights2::color; bool LEDLights2::lights_on; #endif @@ -190,14 +190,13 @@ void LEDLights2::setup() { if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN); #endif #endif - TERN_(NEOPIXEL2, neo2.init()); - TERN_(PCA9533, PCA9533_init()); - TERN_(LED2_USER_PRESET_STARTUP, set_default()); + TERN_(NEOPIXEL2_SEPERATE, neo2.init()); + TERN_(NEO2_USER_PRESET_STARTUP, set_default()); } void LEDLights2::set_color(const LEDColor2 &incol) { - #if ENABLED(NEOPIXEL2) + #if ENABLED(NEOPIXEL2_SEPERATE) const uint32_t neocolor2 = LEDColorWhite2() == incol ? neo2.Color(NEO_WHITE) @@ -213,6 +212,5 @@ void LEDLights2::set_color(const LEDColor2 &incol) { - #endif //NeoPixelX2 - -#endif // HAS_COLOR_LEDS + #endif //NEOPIXELX2 +#endif //HAS_LEDS diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 3371264301bb..a9c7567f0938 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -216,15 +216,9 @@ class LEDLights { }; extern LEDLights leds; - +//NEOPIXEL2_SEPERATE_SEPERATE setup #if NEOPIXELX2 - #include "neopixel.h" -#endif -// A white component can be passed -#if EITHER(RGBW_LED, NEOPIXEL2) - #define HAS_WHITE_LED 1 -#endif /** * LEDcolor2 type for use with leds2.set_color @@ -233,7 +227,7 @@ typedef struct LEDColor2 { uint8_t r, g, b #if HAS_WHITE_LED , w - #if ENABLED(NEOPIXEL2) + #if ENABLED(NEOPIXEL2_SEPERATE_SEPERATE) , i #endif #endif @@ -242,7 +236,7 @@ typedef struct LEDColor2 { LEDColor2() : r(255), g(255), b(255) #if HAS_WHITE_LED , w(255) - #if ENABLED(NEOPIXEL2) + #if ENABLED(NEOPIXEL2_SEPERATE) , i(NEOPIXEL2_BRIGHTNESS) #endif #endif @@ -251,14 +245,14 @@ typedef struct LEDColor2 { LEDColor2(uint8_t r, uint8_t g, uint8_t b #if HAS_WHITE_LED , uint8_t w=0 - #if ENABLED(NEOPIXEL2) + #if ENABLED(NEOPIXEL2_SEPERATE) , uint8_t i=NEOPIXEL2_BRIGHTNESS #endif #endif ) : r(r), g(g), b(b) #if HAS_WHITE_LED , w(w) - #if ENABLED(NEOPIXEL2) + #if ENABLED(NEOPIXEL2_SEPERATE) , i(i) #endif #endif @@ -267,7 +261,7 @@ typedef struct LEDColor2 { LEDColor2(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2]) #if HAS_WHITE_LED , w(rgbw[3]) - #if ENABLED(NEOPIXEL2) + #if ENABLED(NEOPIXEL2_SEPERATE) , i(NEOPIXEL2_BRIGHTNESS) #endif #endif @@ -304,7 +298,7 @@ typedef struct LEDColor2 { * Color helpers and presets for second neopixel channel */ #if HAS_WHITE_LED - #if ENABLED(NEOPIXEL2) + #if ENABLED(NEOPIXEL2_SEPERATE) #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B, W, I) #else #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B, W) @@ -345,7 +339,7 @@ class LEDLights2 { inline void set_color(uint8_t r, uint8_t g, uint8_t b #if HAS_WHITE_LED , uint8_t w=0 - #if ENABLED(NEOPIXEL2) + #if ENABLED(NEOPIXEL2_SEPERATE) , uint8_t i=NEOPIXEL2_BRIGHTNESS #endif #endif @@ -360,7 +354,7 @@ class LEDLights2 { static inline void set_green() { set_color(LEDColorGreen2()); } static inline void set_white() { set_color(LEDColorWhite2()); } - #if ENABLED(LED2_COLOR_PRESETS) + #if ENABLED(NEO2_COLOR_PRESETS) static const LEDColor2 defaultLEDColor2; static inline void set_default() { set_color(defaultLEDColor2); } static inline void set_red() { set_color(LEDColorRed2()); } @@ -386,3 +380,4 @@ class LEDLights2 { }; extern LEDLights2 leds2; +#endif // NEOPIXELX2 diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 615262188b5d..3f45d9b9c65b 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -37,11 +37,10 @@ Marlin_NeoPixel neo; int8_t Marlin_NeoPixel::neoindex; -Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800) - #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) - , Marlin_NeoPixel::adaneo2(NEOPIXEL_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE + NEO_KHZ800) - #endif -; +Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800); + + + #ifdef NEOPIXEL_BKGD_LED_INDEX @@ -120,15 +119,13 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint } #endif -#endif // NEOPIXEL_LED - #if NEOPIXELX2 - Marlin_NeoPixel2 neo2; - int8_t Marlin_NeoPixel2::neoindex2; + Marlin_NEOPIXEL2 neo2; + int8_t Marlin_NEOPIXEL2_SEPERATE::neoindex2; -Adafruit_NeoPixel Marlin_NeoPixel2::adaneo2(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); +Adafruit_NeoPixel Marlin_NEOPIXEL2::adaneo2(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); -void Marlin_NeoPixel2::set_color(const uint32_t color) { +void Marlin_NEOPIXEL2::set_color(const uint32_t color) { if (get_neo_index() >= 0) { set_pixel_color(get_neo_index(), color); set_neo_index(-1); @@ -141,15 +138,15 @@ void Marlin_NeoPixel2::set_color(const uint32_t color) { show(); } -void Marlin_NeoPixel2::set_color_startup(const uint32_t color) { +void Marlin_NEOPIXEL2::set_color_startup(const uint32_t color) { for (uint16_t i = 0; i < pixels(); ++i) set_pixel_color(i, color); show(); } -void Marlin_NeoPixel2::init() { +void Marlin_NEOPIXEL2::init() { set_neo_index(-1); // -1 .. NEOPIXEL2_PIXELS-1 range - set_brightness(NEOPIXEL2_BRIGHTNESS); // 0 .. 255 range + set_brightness(NEOPIXEL2_SEPERATE_BRIGHTNESS); // 0 .. 255 range begin(); show(); // initialize to all off @@ -163,10 +160,12 @@ void Marlin_NeoPixel2::init() { #endif - #if ENABLED(LED2_USER_PRESET_STARTUP) - set_color(adaneo2.Color(LED2_USER_PRESET_RED, LED2_USER_PRESET_GREEN, LED2_USER_PRESET_BLUE, LED2_USER_PRESET_WHITE)); + #if ENABLED(NEO2_USER_PRESET_STARTUP) + set_color(adaneo2.Color(NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, NEO2_USER_PRESET_WHITE)); #else set_color(adaneo2.Color(0, 0, 0, 0)); #endif } -#endif // NEOPIXELX2 \ No newline at end of file +#endif // NEOPIXELX2 + +#endif // NEOPIXEL_LED diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 2fbee2030ca3..2bab989d7a37 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -38,6 +38,10 @@ // Defines // ------------------------ +#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE + #define MULTIPLE_NEOPIXEL_TYPES 1 +#endif + #if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR || NEOPIXEL2_TYPE == NEO_RGB || NEOPIXEL2_TYPE == NEO_RBG || NEOPIXEL2_TYPE == NEO_GRB || NEOPIXEL2_TYPE == NEO_GBR || NEOPIXEL2_TYPE == NEO_BRG || NEOPIXEL2_TYPE == NEO_BGR #define NEOPIXEL_IS_RGB 1 #else @@ -56,11 +60,7 @@ class Marlin_NeoPixel { private: - static Adafruit_NeoPixel adaneo1 - #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) - , adaneo2 - #endif - ; + static Adafruit_NeoPixel adaneo1; static int8_t neoindex; public: @@ -78,51 +78,27 @@ class Marlin_NeoPixel { static inline void begin() { adaneo1.begin(); - #if ENABLED(NEOPIXEL2_INSERIES) - adaneo2.begin(); - #else - TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.begin()); - #endif } static inline void set_pixel_color(const uint16_t n, const uint32_t c) { - #if ENABLED(NEOPIXEL2_INSERIES) - if (n >= NEOPIXEL_PIXELS) adaneo2.setPixelColor(n - (NEOPIXEL_PIXELS), c); - else adaneo1.setPixelColor(n, c); - #else - adaneo1.setPixelColor(n, c); - TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c)); - #endif + adaneo1.setPixelColor(n, c); } static inline void set_brightness(const uint8_t b) { adaneo1.setBrightness(b); - #if ENABLED(NEOPIXEL2_INSERIES) - adaneo2.setBrightness(b); - #else - TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setBrightness(b)); - #endif } - static inline void show() { - adaneo1.show(); - #if PIN_EXISTS(NEOPIXEL2) - #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) - adaneo2.show(); - #else - adaneo1.setPin(NEOPIXEL2_PIN); - adaneo1.show(); - adaneo1.setPin(NEOPIXEL_PIN); - #endif - #endif - } +static inline void show() { + adaneo1.show(); + adaneo1.setPin(NEOPIXEL_PIN); + } #if 0 bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p); #endif // Accessors - static inline uint16_t pixels() { TERN(NEOPIXEL2_INSERIES, return adaneo1.numPixels() * 2, return adaneo1.numPixels()); } + static inline uint16_t pixels() { return adaneo1.numPixels(); } static inline uint8_t brightness() { return adaneo1.getBrightness(); } static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { return adaneo1.Color(r, g, b, w); @@ -131,6 +107,7 @@ class Marlin_NeoPixel { extern Marlin_NeoPixel neo; + // Neo pixel channel 2 #if NEOPIXELX2 class Marlin_NeoPixel2 { @@ -172,7 +149,7 @@ static inline void show() { bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p); #endif - // Accessors for NeoPixel2 + // Accessors for NEOPIXELX2 static inline uint16_t pixels() { return adaneo2.numPixels();} static inline uint8_t brightness() { return adaneo2.getBrightness(); } static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { @@ -181,4 +158,4 @@ static inline void show() { }; extern Marlin_NeoPixel2 neo2; -#endif \ No newline at end of file +#endif // NEOPIXELX2 diff --git a/Marlin/src/feature/password/password.cpp b/Marlin/src/feature/password/password.cpp index c519ee7c9c46..90bb647118b5 100644 --- a/Marlin/src/feature/password/password.cpp +++ b/Marlin/src/feature/password/password.cpp @@ -16,7 +16,7 @@ * 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 . + * along with this program. If not, see . * */ diff --git a/Marlin/src/feature/password/password.h b/Marlin/src/feature/password/password.h index 66f1c70ba314..3ed584b29d5e 100644 --- a/Marlin/src/feature/password/password.h +++ b/Marlin/src/feature/password/password.h @@ -16,7 +16,7 @@ * 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 . + * along with this program. If not, see . * */ #pragma once diff --git a/Marlin/src/gcode/feature/leds/M151.cpp b/Marlin/src/gcode/feature/leds/M151.cpp index f76b4912d0ee..8edfae4f9f0b 100644 --- a/Marlin/src/gcode/feature/leds/M151.cpp +++ b/Marlin/src/gcode/feature/leds/M151.cpp @@ -16,7 +16,7 @@ * 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 . + * along with this program. If not, see . * */ @@ -34,8 +34,8 @@ * Always sets all 3 or 4 components. If a component is left out, set to 0. * If brightness is left out, no value changed * - * With NEOPIXEL2: - * I Set the Neopixel2 index to affect. Default: All + * With NEOPIXEL2_SEPERATE: + * I Set the NEOPIXEL2_SEPERATE index to affect. Default: All * * Examples: * @@ -46,10 +46,10 @@ * M151 W ; Turn LED white using a white LED * M151 P127 ; Set LED 50% brightness * M151 P ; Set LED full brightness - * M151 I1 R ; Set NEOPIXEL2 index 1 to red + * M151 I1 R ; Set NEOPIXEL2_SEPERATE index 1 to red */ void GcodeSuite::M151() { - #if ENABLED(NEOPIXEL2) + #if ENABLED(NEOPIXEL2_SEPERATE) neo2.set_neo_index(parser.intval('I', -1)); #endif leds2.set_color(MakeLEDColor2( @@ -61,4 +61,4 @@ void GcodeSuite::M151() { )); } -#endif // HAS_COLOR_LEDS +#endif // NEOPIXELX2 diff --git a/Marlin/src/gcode/feature/password/M510-M512.cpp b/Marlin/src/gcode/feature/password/M510-M512.cpp index f26fb75fdada..79f1da065b3c 100644 --- a/Marlin/src/gcode/feature/password/M510-M512.cpp +++ b/Marlin/src/gcode/feature/password/M510-M512.cpp @@ -16,7 +16,7 @@ * 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 . + * along with this program. If not, see . * */ diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 8a10e828ec58..e42203f95720 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -116,7 +116,7 @@ #if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED) #define HAS_COLOR_LEDS 1 #endif -#if ENABLED(NEOPIXEL2) +#if ENABLED(NEOPIXEL2_SEPERATE) #define NEOPIXELX2 1 #endif #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f2a0bf3afdf9..6c59caf8065c 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2130,12 +2130,12 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #elif ENABLED(NEOPIXEL_LED) #if !(PIN_EXISTS(NEOPIXEL) && NEOPIXEL_PIXELS > 0) #error "NEOPIXEL_LED requires NEOPIXEL_PIN and NEOPIXEL_PIXELS." - #elif ENABLED(NEOPIXEL2) - #if !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) + #endif + #elif ENABLED(NEOPIXEL2_SEPERATE) + #if !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) #error "NEOPIXEL2 requires NEOPIXEL2_PIN and NEOPIXEL2_PIXELS." #endif #endif -#endif #undef _RGB_TEST From 7243dd10b64533b700e4df386ea42a710f9b8aa4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 02:41:17 -0500 Subject: [PATCH 06/58] Neo 2 initial cleanup --- Marlin/Configuration.h | 40 ++++++------- Marlin/src/MarlinCore.cpp | 4 +- Marlin/src/feature/leds/leds.cpp | 81 +++++++++++-------------- Marlin/src/feature/leds/leds.h | 32 ++++------ Marlin/src/feature/leds/neopixel.cpp | 83 +++++++++++++------------- Marlin/src/feature/leds/neopixel.h | 82 +++++++++++++------------ Marlin/src/gcode/feature/leds/M151.cpp | 12 ++-- Marlin/src/gcode/gcode.cpp | 6 +- Marlin/src/gcode/gcode.h | 7 +-- Marlin/src/inc/Conditionals_adv.h | 6 +- Marlin/src/inc/SanityCheck.h | 2 +- 11 files changed, 162 insertions(+), 193 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index ae5cb4c1f329..62066e457e9c 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -945,9 +945,9 @@ #endif // Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J -// When the pin is defined you can use M672 to set/reset the probe sensivity. -//#define SMART_EFFECTOR -#if ENABLED(SMART_EFFECTOR) +// When the pin is defined you can use M672 to set/reset the probe sensitivity. +//#define DUET_SMART_EFFECTOR +#if ENABLED(DUET_SMART_EFFECTOR) #define SMART_EFFECTOR_MOD_PIN -1 // Connect a GPIO pin to the Smart Effector MOD pin #endif @@ -2358,23 +2358,23 @@ // Support for Adafruit Neopixel LED driver //#define NEOPIXEL_LED #if ENABLED(NEOPIXEL_LED) - #define NEOPIXEL_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL_PIN 4 // LED driving pin - #define NEOPIXEL_PIXELS 12 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used - #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) - //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup - #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. - #define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel - #define NEOPIXEL2_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL2_PIN 5 // Neopixel2 driving pin - - // Support for second Adafruit Neopixel LED driver that is controlled with M151 -#define NEOPIXEL2_SEPERATE -#if ENABLED(NEOPIXEL2_SEPERATE) - #define NEOPIXEL2_PIXELS 12 // Number of LEDs in the second strip, larger of 2 strips if 2 neopixel strips are used - #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) - //#define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup on the seperate channel -#endif + #define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) + #define NEOPIXEL_PIN 4 // LED driving pin + //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE + //#define NEOPIXEL2_PIN 5 + //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel + #define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used + #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. + #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) + //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup + + // Support for second Adafruit Neopixel LED driver controlled with M151 + #define NEOPIXEL2_SEPARATE + #if ENABLED(NEOPIXEL2_SEPARATE) + #define NEOPIXEL2_PIXELS 12 // Number of LEDs in the second strip, larger of 2 strips if 2 neopixel strips are used + #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) + //#define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup on the separate channel + #endif // Use a single Neopixel LED for static (background) lighting //#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index f0adcd613500..ea42d7b4c9d0 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -991,10 +991,10 @@ void setup() { SETUP_RUN(leds.setup()); #endif -#if NEOPIXELX2 + #if ENABLED(NEOPIXEL2_SEPARATE) SETUP_RUN(leds2.setup()); #endif - + #if ENABLED(USE_CONTROLLER_FAN) // Set up fan controller to initialize also the default configurations. SETUP_RUN(controllerFan.setup()); #endif diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index efd9213b0282..1b58be560a72 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -129,11 +129,8 @@ void LEDLights::set_color(const LEDColor &incol #endif - #if ENABLED(PCA9632) - // Update I2C LED driver - pca9632_set_led_color(incol); - #endif - + // Update I2C LED driver + TERN_(PCA9632, pca9632_set_led_color(incol)); TERN_(PCA9533, PCA9533_setColor(incol.r, incol.g, incol.b)); #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) @@ -161,56 +158,46 @@ void LEDLights::set_color(const LEDColor &incol #endif -#if (NEOPIXELX2) +#if ENABLED(NEOPIXEL2_SEPARATE) + #if ENABLED(NEO2_COLOR_PRESETS) + const LEDColor2 LEDLights2::defaultLEDColor2 = MakeLEDColor2( + NEO2_USER_PRESET_RED, + NEO2_USER_PRESET_GREEN, + NEO2_USER_PRESET_BLUE, + NEO2_USER_PRESET_WHITE, + NEO2_USER_PRESET_BRIGHTNESS + ); + #endif -#if ENABLED(NEO2_COLOR_PRESETS) - const LEDColor2 LEDLights2::defaultLEDColor2 = MakeLEDColor2( - NEO2_USER_PRESET_RED, - NEO2_USER_PRESET_GREEN, - NEO2_USER_PRESET_BLUE, - NEO2_USER_PRESET_WHITE, - NEO2_USER_PRESET_BRIGHTNESS - ); -#endif - -#if ENABLED(LED_CONTROL_MENU) - LEDColor2 LEDLights2::color; - bool LEDLights2::lights_on; -#endif - -LEDLights2 leds2; - -void LEDLights2::setup() { - #if EITHER(RGB_LED, RGBW_LED) - if (PWM_PIN(RGB_LED_R_PIN)) SET_PWM(RGB_LED_R_PIN); else SET_OUTPUT(RGB_LED_R_PIN); - if (PWM_PIN(RGB_LED_G_PIN)) SET_PWM(RGB_LED_G_PIN); else SET_OUTPUT(RGB_LED_G_PIN); - if (PWM_PIN(RGB_LED_B_PIN)) SET_PWM(RGB_LED_B_PIN); else SET_OUTPUT(RGB_LED_B_PIN); - #if ENABLED(RGBW_LED) - if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN); - #endif + #if ENABLED(LED_CONTROL_MENU) + LEDColor2 LEDLights2::color; + bool LEDLights2::lights_on; #endif - TERN_(NEOPIXEL2_SEPERATE, neo2.init()); - TERN_(NEO2_USER_PRESET_STARTUP, set_default()); -} -void LEDLights2::set_color(const LEDColor2 &incol) { + LEDLights2 leds2; - #if ENABLED(NEOPIXEL2_SEPERATE) + void LEDLights2::setup() { + #if EITHER(RGB_LED, RGBW_LED) + if (PWM_PIN(RGB_LED_R_PIN)) SET_PWM(RGB_LED_R_PIN); else SET_OUTPUT(RGB_LED_R_PIN); + if (PWM_PIN(RGB_LED_G_PIN)) SET_PWM(RGB_LED_G_PIN); else SET_OUTPUT(RGB_LED_G_PIN); + if (PWM_PIN(RGB_LED_B_PIN)) SET_PWM(RGB_LED_B_PIN); else SET_OUTPUT(RGB_LED_B_PIN); + #if ENABLED(RGBW_LED) + if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN); + #endif + #endif + neo2.init(); + TERN_(NEO2_USER_PRESET_STARTUP, set_default()); + } + void LEDLights2::set_color(const LEDColor2 &incol) { const uint32_t neocolor2 = LEDColorWhite2() == incol ? neo2.Color(NEO_WHITE) : neo2.Color(incol.r, incol.g, incol.b, incol.w); - - neo2.set_brightness(incol.i); - - - - neo2.set_color(neocolor2);} - - #endif - + neo2.set_brightness(incol.i); + neo2.set_color(neocolor2); + } +#endif // NEOPIXEL2_SEPARATE - #endif //NEOPIXELX2 -#endif //HAS_LEDS +#endif // HAS_COLOR_LEDS diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index a9c7567f0938..68b081d99e5e 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -216,9 +216,9 @@ class LEDLights { }; extern LEDLights leds; -//NEOPIXEL2_SEPERATE_SEPERATE setup -#if NEOPIXELX2 +// NEOPIXEL2_SEPARATE setup +#if ENABLED(NEOPIXEL2_SEPARATE) /** * LEDcolor2 type for use with leds2.set_color @@ -227,7 +227,7 @@ typedef struct LEDColor2 { uint8_t r, g, b #if HAS_WHITE_LED , w - #if ENABLED(NEOPIXEL2_SEPERATE_SEPERATE) + #if ENABLED(NEOPIXEL2_SEPARATE) , i #endif #endif @@ -236,7 +236,7 @@ typedef struct LEDColor2 { LEDColor2() : r(255), g(255), b(255) #if HAS_WHITE_LED , w(255) - #if ENABLED(NEOPIXEL2_SEPERATE) + #if ENABLED(NEOPIXEL2_SEPARATE) , i(NEOPIXEL2_BRIGHTNESS) #endif #endif @@ -245,14 +245,14 @@ typedef struct LEDColor2 { LEDColor2(uint8_t r, uint8_t g, uint8_t b #if HAS_WHITE_LED , uint8_t w=0 - #if ENABLED(NEOPIXEL2_SEPERATE) + #if ENABLED(NEOPIXEL2_SEPARATE) , uint8_t i=NEOPIXEL2_BRIGHTNESS #endif #endif ) : r(r), g(g), b(b) #if HAS_WHITE_LED , w(w) - #if ENABLED(NEOPIXEL2_SEPERATE) + #if ENABLED(NEOPIXEL2_SEPARATE) , i(i) #endif #endif @@ -261,7 +261,7 @@ typedef struct LEDColor2 { LEDColor2(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2]) #if HAS_WHITE_LED , w(rgbw[3]) - #if ENABLED(NEOPIXEL2_SEPERATE) + #if ENABLED(NEOPIXEL2_SEPARATE) , i(NEOPIXEL2_BRIGHTNESS) #endif #endif @@ -298,7 +298,7 @@ typedef struct LEDColor2 { * Color helpers and presets for second neopixel channel */ #if HAS_WHITE_LED - #if ENABLED(NEOPIXEL2_SEPERATE) + #if ENABLED(NEOPIXEL2_SEPARATE) #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B, W, I) #else #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B, W) @@ -332,22 +332,18 @@ class LEDLights2 { static void setup(); // init() - static void set_color(const LEDColor2 &color - - ); + static void set_color(const LEDColor2 &color); inline void set_color(uint8_t r, uint8_t g, uint8_t b #if HAS_WHITE_LED , uint8_t w=0 - #if ENABLED(NEOPIXEL2_SEPERATE) + #if ENABLED(NEOPIXEL2_SEPARATE) , uint8_t i=NEOPIXEL2_BRIGHTNESS #endif #endif ) { - set_color(MakeLEDColor2(r, g, b, w, i) - - ); + set_color(MakeLEDColor2(r, g, b, w, i)); } static inline void set_off() { set_color(LEDColorOff2()); } @@ -365,7 +361,6 @@ class LEDLights2 { static inline void set_violet() { set_color(LEDColorViolet2()); } #endif - #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) static LEDColor2 color; // last non-off color static bool lights_on; // the last set color was "on" @@ -375,9 +370,8 @@ class LEDLights2 { static void toggle(); // swap "off" with color static inline void update() { set_color(color); } #endif - - }; extern LEDLights2 leds2; -#endif // NEOPIXELX2 + +#endif // NEOPIXEL2_SEPARATE diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 3f45d9b9c65b..6eb8aa95d47a 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -39,9 +39,6 @@ int8_t Marlin_NeoPixel::neoindex; Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800); - - - #ifdef NEOPIXEL_BKGD_LED_INDEX void Marlin_NeoPixel::set_color_background() { @@ -119,53 +116,53 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint } #endif -#if NEOPIXELX2 +#if ENABLED(NEOPIXEL2_SEPARATE) + Marlin_NEOPIXEL2 neo2; - int8_t Marlin_NEOPIXEL2_SEPERATE::neoindex2; + int8_t Marlin_NEOPIXEL2_SEPARATE::neoindex2; -Adafruit_NeoPixel Marlin_NEOPIXEL2::adaneo2(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); + Adafruit_NeoPixel Marlin_NEOPIXEL2::adaneo2(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); -void Marlin_NEOPIXEL2::set_color(const uint32_t color) { - if (get_neo_index() >= 0) { - set_pixel_color(get_neo_index(), color); - set_neo_index(-1); - } - else { - for (uint16_t i = 0; i < pixels(); ++i) { - set_pixel_color(i, color); + void Marlin_NEOPIXEL2::set_color(const uint32_t color) { + if (get_neo_index() >= 0) { + set_pixel_color(get_neo_index(), color); + set_neo_index(-1); } + else { + for (uint16_t i = 0; i < pixels(); ++i) + set_pixel_color(i, color); + } + show(); } - show(); -} - -void Marlin_NEOPIXEL2::set_color_startup(const uint32_t color) { - for (uint16_t i = 0; i < pixels(); ++i) - set_pixel_color(i, color); - show(); -} -void Marlin_NEOPIXEL2::init() { - set_neo_index(-1); // -1 .. NEOPIXEL2_PIXELS-1 range - set_brightness(NEOPIXEL2_SEPERATE_BRIGHTNESS); // 0 .. 255 range - begin(); - show(); // initialize to all off + void Marlin_NEOPIXEL2::set_color_startup(const uint32_t color) { + for (uint16_t i = 0; i < pixels(); ++i) + set_pixel_color(i, color); + show(); + } - #if ENABLED(NEOPIXEL2_STARTUP_TEST) - set_color_startup(adaneo2.Color(255, 0, 0, 0)); // red - safe_delay(1000); - set_color_startup(adaneo2.Color(0, 255, 0, 0)); // green - safe_delay(1000); - set_color_startup(adaneo2.Color(0, 0, 255, 0)); // blue - safe_delay(1000); - #endif + void Marlin_NEOPIXEL2::init() { + set_neo_index(-1); // -1 .. NEOPIXEL2_PIXELS-1 range + set_brightness(NEOPIXEL2_SEPARATE_BRIGHTNESS); // 0 .. 255 range + begin(); + show(); // initialize to all off + + #if ENABLED(NEOPIXEL2_STARTUP_TEST) + set_color_startup(adaneo2.Color(255, 0, 0, 0)); // red + safe_delay(1000); + set_color_startup(adaneo2.Color(0, 255, 0, 0)); // green + safe_delay(1000); + set_color_startup(adaneo2.Color(0, 0, 255, 0)); // blue + safe_delay(1000); + #endif + + #if ENABLED(NEO2_USER_PRESET_STARTUP) + set_color(adaneo2.Color(NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, NEO2_USER_PRESET_WHITE)); + #else + set_color(adaneo2.Color(0, 0, 0, 0)); + #endif + } - - #if ENABLED(NEO2_USER_PRESET_STARTUP) - set_color(adaneo2.Color(NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, NEO2_USER_PRESET_WHITE)); - #else - set_color(adaneo2.Color(0, 0, 0, 0)); - #endif -} -#endif // NEOPIXELX2 +#endif // NEOPIXEL2_SEPARATE #endif // NEOPIXEL_LED diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 2bab989d7a37..6554896553a4 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -89,9 +89,9 @@ class Marlin_NeoPixel { } -static inline void show() { +static inline void show() { adaneo1.show(); - adaneo1.setPin(NEOPIXEL_PIN); + adaneo1.setPin(NEOPIXEL_PIN); } #if 0 bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p); @@ -107,55 +107,53 @@ static inline void show() { extern Marlin_NeoPixel neo; +// Neo pixel channel 2 +#if ENABLED(NEOPIXEL2_SEPARATE) -// Neo pixel channel 2 -#if NEOPIXELX2 -class Marlin_NeoPixel2 { -private: - static Adafruit_NeoPixel adaneo2; - - static int8_t neoindex2; + class Marlin_NeoPixel2 { + private: + static Adafruit_NeoPixel adaneo2; -public: - static void init(); - static void set_color_startup(const uint32_t c); + static int8_t neoindex2; - static void set_color(const uint32_t c); + public: + static void init(); + static void set_color_startup(const uint32_t c); - FORCE_INLINE static void set_neo_index(const int8_t neoIndex2) { neoindex2 = neoIndex2; } - FORCE_INLINE static int8_t get_neo_index() { return neoindex2; } + static void set_color(const uint32_t c); + FORCE_INLINE static void set_neo_index(const int8_t neoIndex2) { neoindex2 = neoIndex2; } + FORCE_INLINE static int8_t get_neo_index() { return neoindex2; } - static inline void begin() { - adaneo2.begin(); - - } + static inline void begin() { + adaneo2.begin(); + } - static inline void set_pixel_color(const uint16_t n, const uint32_t c) { - adaneo2.setPixelColor(n, c); - - } + static inline void set_pixel_color(const uint16_t n, const uint32_t c) { + adaneo2.setPixelColor(n, c); + } - static inline void set_brightness(const uint8_t b) { - adaneo2.setBrightness(b); - - } + static inline void set_brightness(const uint8_t b) { + adaneo2.setBrightness(b); + } -static inline void show() { + static inline void show() { adaneo2.show(); - adaneo2.setPin(NEOPIXEL2_PIN); - } - #if 0 - bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p); - #endif + adaneo2.setPin(NEOPIXEL2_PIN); + } - // Accessors for NEOPIXELX2 - static inline uint16_t pixels() { return adaneo2.numPixels();} - static inline uint8_t brightness() { return adaneo2.getBrightness(); } - static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - return adaneo2.Color(r, g, b, w); - } -}; + #if 0 + bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p); + #endif + + // Accessors for NEOPIXEL2_SEPARATE + static inline uint16_t pixels() { return adaneo2.numPixels();} + static inline uint8_t brightness() { return adaneo2.getBrightness(); } + static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { + return adaneo2.Color(r, g, b, w); + } + }; + + extern Marlin_NeoPixel2 neo2; -extern Marlin_NeoPixel2 neo2; -#endif // NEOPIXELX2 +#endif // NEOPIXEL2_SEPARATE diff --git a/Marlin/src/gcode/feature/leds/M151.cpp b/Marlin/src/gcode/feature/leds/M151.cpp index 8edfae4f9f0b..e365150dcbb3 100644 --- a/Marlin/src/gcode/feature/leds/M151.cpp +++ b/Marlin/src/gcode/feature/leds/M151.cpp @@ -22,7 +22,7 @@ #include "../../../inc/MarlinConfig.h" -#if NEOPIXELX2 +#if ENABLED(NEOPIXEL2_SEPARATE) #include "../../gcode.h" #include "../../../feature/leds/leds.h" @@ -34,8 +34,8 @@ * Always sets all 3 or 4 components. If a component is left out, set to 0. * If brightness is left out, no value changed * - * With NEOPIXEL2_SEPERATE: - * I Set the NEOPIXEL2_SEPERATE index to affect. Default: All + * With NEOPIXEL2_SEPARATE: + * I Set the NEOPIXEL2_SEPARATE index to affect. Default: All * * Examples: * @@ -46,10 +46,10 @@ * M151 W ; Turn LED white using a white LED * M151 P127 ; Set LED 50% brightness * M151 P ; Set LED full brightness - * M151 I1 R ; Set NEOPIXEL2_SEPERATE index 1 to red + * M151 I1 R ; Set NEOPIXEL2_SEPARATE index 1 to red */ void GcodeSuite::M151() { - #if ENABLED(NEOPIXEL2_SEPERATE) + #if ENABLED(NEOPIXEL2_SEPARATE) neo2.set_neo_index(parser.intval('I', -1)); #endif leds2.set_color(MakeLEDColor2( @@ -61,4 +61,4 @@ void GcodeSuite::M151() { )); } -#endif // NEOPIXELX2 +#endif // NEOPIXEL2_SEPARATE diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index f7b668a4b1b6..83e882d83611 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -571,10 +571,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 150: M150(); break; // M150: Set Status LED Color #endif - #if NEOPIXELX2 - case 151: M151(); break; // M151: Set Seperate LED Color to Neopixel2 pin + #if ENABLED(NEOPIXEL2_SEPARATE) + case 151: M151(); break; // M151: Set Seperate LED Color to Neopixel2 pin #endif - + #if ENABLED(MIXING_EXTRUDER) case 163: M163(); break; // M163: Set a component weight for mixing extruder case 164: M164(); break; // M164: Save current mix as a virtual extruder diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index fdd647d15af9..f3b624eabc31 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -627,11 +627,8 @@ class GcodeSuite { TERN_(TEMPERATURE_UNITS_SUPPORT, static void M149()); - TERN_(HAS_COLOR_LEDS, static void M150()); - - #if NEOPIXELX2 - TERN_(NEOPIXELX2, static void M151()); - #endif + TERN_(HAS_COLOR_LEDS, static void M150()); + TERN_(NEOPIXEL2_SEPARATE, static void M151()); #if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR) static void M155(); diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index e42203f95720..35542f9412ab 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -116,9 +116,6 @@ #if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED) #define HAS_COLOR_LEDS 1 #endif -#if ENABLED(NEOPIXEL2_SEPERATE) - #define NEOPIXELX2 1 -#endif #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT) #define HAS_LEDS_OFF_FLAG 1 #endif @@ -249,8 +246,7 @@ #endif #endif -//Set defaults for unspecified LED2 user colors -#if ENABLED(LED_CONTROL_MENU , NEOPIXELX2) +#if BOTH(LED_CONTROL_MENU, NEOPIXEL2_SEPARATE) #ifndef LED2_USER_PRESET_RED #define LED2_USER_PRESET_RED 255 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 1f00489469c2..cd94710304b3 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2131,7 +2131,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if !(PIN_EXISTS(NEOPIXEL) && NEOPIXEL_PIXELS > 0) #error "NEOPIXEL_LED requires NEOPIXEL_PIN and NEOPIXEL_PIXELS." #endif - #elif ENABLED(NEOPIXEL2_SEPERATE) + #elif ENABLED(NEOPIXEL2_SEPARATE) #if !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) #error "NEOPIXEL2 requires NEOPIXEL2_PIN and NEOPIXEL2_PIXELS." #endif From 0a97a4c6af9732a879fe279eab6d9b63e434fcb8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 03:12:33 -0500 Subject: [PATCH 07/58] Clean up, extend M150 --- Marlin/Configuration.h | 1 - Marlin/Configuration_adv.h | 8 +- Marlin/src/feature/leds/leds.h | 102 +++++++++---------------- Marlin/src/gcode/feature/leds/M150.cpp | 19 ++++- Marlin/src/gcode/feature/leds/M151.cpp | 64 ---------------- Marlin/src/gcode/gcode.cpp | 4 - Marlin/src/gcode/gcode.h | 6 +- 7 files changed, 59 insertions(+), 145 deletions(-) delete mode 100644 Marlin/src/gcode/feature/leds/M151.cpp diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 62066e457e9c..5dda4f5c0800 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2379,7 +2379,6 @@ // Use a single Neopixel LED for static (background) lighting //#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W - #endif /** diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6c8b1955c297..f91af974e5d0 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1064,8 +1064,8 @@ */ //#define LED_CONTROL_MENU #if ENABLED(LED_CONTROL_MENU) - // #define LED_COLOR_PRESETS // Enable the Preset Color menu option - //#define NEO2_COLOR_PRESETS //Enables the Second NeoPixel Preset Color menu option + //#define LED_COLOR_PRESETS // Enable the Preset Color menu option + //#define NEO2_COLOR_PRESETS // Enable a second NeoPixel Preset Color menu option #if ENABLED(LED_COLOR_PRESETS) #define LED_USER_PRESET_RED 255 // User defined RED value #define LED_USER_PRESET_GREEN 128 // User defined GREEN value @@ -1074,7 +1074,7 @@ #define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity //#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup #endif - #if ENABLED(NEO2_COLOR_PRESETS) + #if ENABLED(NEO2_COLOR_PRESETS) #define NEO2_USER_PRESET_RED 255 // User defined RED value #define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value #define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value @@ -1083,7 +1083,7 @@ //#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip #endif #endif - + #endif // HAS_LCD_MENU // Scroll a longer status message into view diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 68b081d99e5e..d652b9f08712 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -104,11 +104,7 @@ typedef struct LEDColor { bool operator!=(const LEDColor &right) { return !operator==(right); } bool is_off() const { - return 3 > r + g + b - #if HAS_WHITE_LED - + w - #endif - ; + return 3 > r + g + b + TERN0(HAS_WHITE_LED, w); } } LEDColor; @@ -217,94 +213,75 @@ class LEDLights { extern LEDLights leds; -// NEOPIXEL2_SEPARATE setup #if ENABLED(NEOPIXEL2_SEPARATE) -/** - * LEDcolor2 type for use with leds2.set_color - */ -typedef struct LEDColor2 { - uint8_t r, g, b - #if HAS_WHITE_LED + /** + * LEDcolor2 type for use with leds2.set_color + */ + typedef struct LEDColor2 { + uint8_t r, g, b , w #if ENABLED(NEOPIXEL2_SEPARATE) , i #endif - #endif - ; + ; - LEDColor2() : r(255), g(255), b(255) - #if HAS_WHITE_LED + LEDColor2() : r(255), g(255), b(255) , w(255) #if ENABLED(NEOPIXEL2_SEPARATE) , i(NEOPIXEL2_BRIGHTNESS) #endif - #endif - {} + {} - LEDColor2(uint8_t r, uint8_t g, uint8_t b - #if HAS_WHITE_LED + LEDColor2(uint8_t r, uint8_t g, uint8_t b , uint8_t w=0 #if ENABLED(NEOPIXEL2_SEPARATE) , uint8_t i=NEOPIXEL2_BRIGHTNESS #endif - #endif - ) : r(r), g(g), b(b) - #if HAS_WHITE_LED + ) : r(r), g(g), b(b) , w(w) #if ENABLED(NEOPIXEL2_SEPARATE) , i(i) #endif - #endif - {} + {} - LEDColor2(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2]) - #if HAS_WHITE_LED + LEDColor2(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2]) , w(rgbw[3]) #if ENABLED(NEOPIXEL2_SEPARATE) , i(NEOPIXEL2_BRIGHTNESS) #endif - #endif - {} + {} - LEDColor2& operator=(const uint8_t (&rgbw)[4]) { - r = rgbw[0]; g = rgbw[1]; b = rgbw[2]; - TERN_(HAS_WHITE_LED, w = rgbw[3]); - return *this; - } + LEDColor2& operator=(const uint8_t (&rgbw)[4]) { + r = rgbw[0]; g = rgbw[1]; b = rgbw[2]; w = rgbw[3]; + return *this; + } - LEDColor2& operator=(const LEDColor2 &right) { - if (this != &right) memcpy(this, &right, sizeof(LEDColor2)); - return *this; - } + LEDColor2& operator=(const LEDColor2 &right) { + if (this != &right) memcpy(this, &right, sizeof(LEDColor2)); + return *this; + } - bool operator==(const LEDColor2 &right) { - if (this == &right) return true; - return 0 == memcmp(this, &right, sizeof(LEDColor2)); - } + bool operator==(const LEDColor2 &right) { + if (this == &right) return true; + return 0 == memcmp(this, &right, sizeof(LEDColor2)); + } - bool operator!=(const LEDColor2 &right) { return !operator==(right); } + bool operator!=(const LEDColor2 &right) { return !operator==(right); } - bool is_off() const { - return 3 > r + g + b - #if HAS_WHITE_LED - + w - #endif - ; - } -} LEDColor2; + bool is_off() const { + return 3 > r + g + b + w; + } + } LEDColor2; -/** - * Color helpers and presets for second neopixel channel - */ -#if HAS_WHITE_LED + /** + * Color helpers and presets for second neopixel channel + */ #if ENABLED(NEOPIXEL2_SEPARATE) #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B, W, I) #else #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B, W) #endif -#else - #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B) #endif #define LEDColorOff2() LEDColor2( 0, 0, 0) @@ -320,7 +297,7 @@ typedef struct LEDColor2 { #define LEDColorBlue2() LEDColor2( 0, 0, 255) #define LEDColorIndigo2() LEDColor2( 0, 255, 255) #define LEDColorViolet2() LEDColor2(255, 0, 255) -#if HAS_WHITE_LED && DISABLED(RGB_LED) +#if DISABLED(RGB_LED) #define LEDColorWhite2() LEDColor2( 0, 0, 0, 255) #else #define LEDColorWhite2() LEDColor2(255, 255, 255) @@ -335,13 +312,10 @@ class LEDLights2 { static void set_color(const LEDColor2 &color); inline void set_color(uint8_t r, uint8_t g, uint8_t b - #if HAS_WHITE_LED - , uint8_t w=0 - #if ENABLED(NEOPIXEL2_SEPARATE) - , uint8_t i=NEOPIXEL2_BRIGHTNESS - #endif + , uint8_t w=0 + #if ENABLED(NEOPIXEL2_SEPARATE) + , uint8_t i=NEOPIXEL2_BRIGHTNESS #endif - ) { set_color(MakeLEDColor2(r, g, b, w, i)); } diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 88f02951add2..97d5fca2f15f 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -35,7 +35,10 @@ * If brightness is left out, no value changed * * With NEOPIXEL_LED: - * I Set the Neopixel index to affect. Default: All + * I Set the NeoPixel index to affect. Default: All + * + * With NEOPIXEL2_SEPARATE: + * S The neopixel strip to set. Default is index 0. * * Examples: * @@ -49,15 +52,23 @@ * M150 I1 R ; Set NEOPIXEL index 1 to red */ void GcodeSuite::M150() { + LEDLights &the_leds = leds; #if ENABLED(NEOPIXEL_LED) - neo.set_neo_index(parser.intval('I', -1)); + Marlin_NeoPixel &the_neo = neo; + #if ENABLED(NEOPIXEL2_SEPARATE) + if (parser.intval('S') == 1) { + the_neo = neo2; + the_leds = leds2; + } + #endif + the_neo.set_neo_index(parser.intval('I', -1)); #endif - leds.set_color(MakeLEDColor( + the_leds.set_color(MakeLEDColor( parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0, parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0, parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : neo.brightness() + parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : the_neo.brightness() )); } diff --git a/Marlin/src/gcode/feature/leds/M151.cpp b/Marlin/src/gcode/feature/leds/M151.cpp deleted file mode 100644 index e365150dcbb3..000000000000 --- a/Marlin/src/gcode/feature/leds/M151.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * 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 . - * - */ - -#include "../../../inc/MarlinConfig.h" - -#if ENABLED(NEOPIXEL2_SEPARATE) - -#include "../../gcode.h" -#include "../../../feature/leds/leds.h" - -/** - * M151: Set Second LED Color - Use R-U-B-W for R-G-B-W - * and Brightness - Use P (for NEOPIXEL only) - * - * Always sets all 3 or 4 components. If a component is left out, set to 0. - * If brightness is left out, no value changed - * - * With NEOPIXEL2_SEPARATE: - * I Set the NEOPIXEL2_SEPARATE index to affect. Default: All - * - * Examples: - * - * M151 R255 ; Turn LED red - * M151 R255 U127 ; Turn LED orange (PWM only) - * M151 ; Turn LED off - * M151 R U B ; Turn LED white - * M151 W ; Turn LED white using a white LED - * M151 P127 ; Set LED 50% brightness - * M151 P ; Set LED full brightness - * M151 I1 R ; Set NEOPIXEL2_SEPARATE index 1 to red - */ -void GcodeSuite::M151() { - #if ENABLED(NEOPIXEL2_SEPARATE) - neo2.set_neo_index(parser.intval('I', -1)); - #endif - leds2.set_color(MakeLEDColor2( - parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : neo2.brightness() - )); -} - -#endif // NEOPIXEL2_SEPARATE diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 83e882d83611..c0a795025fc7 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -571,10 +571,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 150: M150(); break; // M150: Set Status LED Color #endif - #if ENABLED(NEOPIXEL2_SEPARATE) - case 151: M151(); break; // M151: Set Seperate LED Color to Neopixel2 pin - #endif - #if ENABLED(MIXING_EXTRUDER) case 163: M163(); break; // M163: Set a component weight for mixing extruder case 164: M164(); break; // M164: Save current mix as a virtual extruder diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index f3b624eabc31..23bf2c0ce5b1 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -155,8 +155,7 @@ * M141 - Set heated chamber target temp. S (Requires a chamber heater) * M145 - Set heatup values for materials on the LCD. H B F for S (0=PLA, 1=ABS) * M149 - Set temperature units. (Requires TEMPERATURE_UNITS_SUPPORT) - * M150 - Set Status LED Color as R U B P. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632). - * M151 - Set the Neopixel color of the second Neopixel channel as R U B P I. Values 0-255. (Requires NEOPIXEL2). + * M150 - Set Status LED Color as R U B W P. Values 0-255. (Requires BLINKM, RGB_LED, RGBW_LED, NEOPIXEL_LED, PCA9533, or PCA9632). * M155 - Auto-report temperatures with interval of S. (Requires AUTO_REPORT_TEMPERATURES) * M163 - Set a single proportion for a mixing extruder. (Requires MIXING_EXTRUDER) * M164 - Commit the mix and save to a virtual tool (current, or as specified by 'S'). (Requires MIXING_EXTRUDER) @@ -627,8 +626,7 @@ class GcodeSuite { TERN_(TEMPERATURE_UNITS_SUPPORT, static void M149()); - TERN_(HAS_COLOR_LEDS, static void M150()); - TERN_(NEOPIXEL2_SEPARATE, static void M151()); + TERN_(HAS_COLOR_LEDS, static void M150()); #if BOTH(AUTO_REPORT_TEMPERATURES, HAS_TEMP_SENSOR) static void M155(); From 42150e391e7774b312d34fe04673263cf80b810b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 04:57:15 -0500 Subject: [PATCH 08/58] Rename some pca9632 functions --- Marlin/src/feature/leds/leds.cpp | 4 ++-- Marlin/src/feature/leds/pca9533.cpp | 2 +- Marlin/src/feature/leds/pca9533.h | 2 +- Marlin/src/feature/leds/pca9632.cpp | 4 ++-- Marlin/src/feature/leds/pca9632.h | 4 ++-- Marlin/src/lcd/ultralcd.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 1b58be560a72..6c759fa353db 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -130,8 +130,8 @@ void LEDLights::set_color(const LEDColor &incol #endif // Update I2C LED driver - TERN_(PCA9632, pca9632_set_led_color(incol)); - TERN_(PCA9533, PCA9533_setColor(incol.r, incol.g, incol.b)); + TERN_(PCA9632, PCA9632_set_led_color(incol)); + TERN_(PCA9533, PCA9533_set_rgb(incol.r, incol.g, incol.b)); #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) // Don't update the color when OFF diff --git a/Marlin/src/feature/leds/pca9533.cpp b/Marlin/src/feature/leds/pca9533.cpp index bcc4bc50a474..0fd4d6675771 100644 --- a/Marlin/src/feature/leds/pca9533.cpp +++ b/Marlin/src/feature/leds/pca9533.cpp @@ -62,7 +62,7 @@ void PCA9533_setOff() { PCA9533_writeRegister(PCA9533_REG_SEL, 0); } -void PCA9533_setColor(uint8_t red, uint8_t green, uint8_t blue) { +void PCA9533_set_rgb(uint8_t red, uint8_t green, uint8_t blue) { uint8_t r_pwm0 = 0; // Register data - PWM value uint8_t r_pwm1 = 0; // Register data - PWM value diff --git a/Marlin/src/feature/leds/pca9533.h b/Marlin/src/feature/leds/pca9533.h index 899418ff232c..431058c49136 100644 --- a/Marlin/src/feature/leds/pca9533.h +++ b/Marlin/src/feature/leds/pca9533.h @@ -55,5 +55,5 @@ void PCA9533_init(); void PCA9533_reset(); -void PCA9533_setColor(uint8_t red, uint8_t green, uint8_t blue); +void PCA9533_set_rgb(uint8_t red, uint8_t green, uint8_t blue); void PCA9533_setOff(); diff --git a/Marlin/src/feature/leds/pca9632.cpp b/Marlin/src/feature/leds/pca9632.cpp index df991ded36cc..d8af31cb6ce4 100644 --- a/Marlin/src/feature/leds/pca9632.cpp +++ b/Marlin/src/feature/leds/pca9632.cpp @@ -120,7 +120,7 @@ static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const } #endif -void pca9632_set_led_color(const LEDColor &color) { +void PCA9632_set_led_color(const LEDColor &color) { Wire.begin(); if (!PCA_init) { PCA_init = 1; @@ -138,7 +138,7 @@ void pca9632_set_led_color(const LEDColor &color) { #if ENABLED(PCA9632_BUZZER) - void pca9632_buzz(const long, const uint16_t) { + void PCA9632_buzz(const long, const uint16_t) { uint8_t data[] = PCA9632_BUZZER_DATA; Wire.beginTransmission(I2C_ADDRESS(PCA9632_ADDRESS)); Wire.write(data, sizeof(data)); diff --git a/Marlin/src/feature/leds/pca9632.h b/Marlin/src/feature/leds/pca9632.h index 34aceb31d6e3..fb59a8c18479 100644 --- a/Marlin/src/feature/leds/pca9632.h +++ b/Marlin/src/feature/leds/pca9632.h @@ -29,9 +29,9 @@ struct LEDColor; typedef LEDColor LEDColor; -void pca9632_set_led_color(const LEDColor &color); +void PCA9632_set_led_color(const LEDColor &color); #if ENABLED(PCA9632_BUZZER) #include - void pca9632_buzz(const long, const uint16_t); + void PCA9632_buzz(const long, const uint16_t); #endif diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index f30d9c68cff7..09767c72aaab 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -81,7 +81,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif void MarlinUI::buzz(const long duration, const uint16_t freq) { #if ENABLED(PCA9632_BUZZER) - pca9632_buzz(duration, freq); + PCA9632_buzz(duration, freq); #elif USE_BEEPER buzzer.tone(duration, freq); #endif From 356715db48ecd566c17221f5f5a417f70b9606fc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 05:01:29 -0500 Subject: [PATCH 09/58] Rename adaneo# and other vars --- Marlin/src/feature/leds/leds.cpp | 6 ++-- Marlin/src/feature/leds/neopixel.cpp | 44 +++++++++++++------------- Marlin/src/feature/leds/neopixel.h | 47 ++++++++++++++-------------- 3 files changed, 48 insertions(+), 49 deletions(-) diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 6c759fa353db..a34ddc08ca81 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -190,12 +190,12 @@ void LEDLights::set_color(const LEDColor &incol TERN_(NEO2_USER_PRESET_STARTUP, set_default()); } - void LEDLights2::set_color(const LEDColor2 &incol) { - const uint32_t neocolor2 = LEDColorWhite2() == incol + void LEDLights2::set_color(const LEDColor &incol) { + const uint32_t neocolor = LEDColorWhite() == incol ? neo2.Color(NEO_WHITE) : neo2.Color(incol.r, incol.g, incol.b, incol.w); neo2.set_brightness(incol.i); - neo2.set_color(neocolor2); + neo2.set_color(neocolor); } #endif // NEOPIXEL2_SEPARATE diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 6eb8aa95d47a..d761fa3a8b45 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -37,13 +37,13 @@ Marlin_NeoPixel neo; int8_t Marlin_NeoPixel::neoindex; -Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800); +Adafruit_NeoPixel Marlin_NeoPixel::adaneo(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800); #ifdef NEOPIXEL_BKGD_LED_INDEX void Marlin_NeoPixel::set_color_background() { uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR; - set_pixel_color(NEOPIXEL_BKGD_LED_INDEX, adaneo1.Color(background_color[0], background_color[1], background_color[2], background_color[3])); + set_pixel_color(NEOPIXEL_BKGD_LED_INDEX, adaneo.Color(background_color[0], background_color[1], background_color[2], background_color[3])); } #endif @@ -80,12 +80,12 @@ void Marlin_NeoPixel::init() { show(); // initialize to all off #if ENABLED(NEOPIXEL_STARTUP_TEST) - set_color_startup(adaneo1.Color(255, 0, 0, 0)); // red - safe_delay(1000); - set_color_startup(adaneo1.Color(0, 255, 0, 0)); // green - safe_delay(1000); - set_color_startup(adaneo1.Color(0, 0, 255, 0)); // blue - safe_delay(1000); + set_color_startup(adaneo.Color(255, 0, 0, 0)); // red + safe_delay(500); + set_color_startup(adaneo.Color(0, 255, 0, 0)); // green + safe_delay(500); + set_color_startup(adaneo.Color(0, 0, 255, 0)); // blue + safe_delay(500); #endif #ifdef NEOPIXEL_BKGD_LED_INDEX @@ -93,15 +93,15 @@ void Marlin_NeoPixel::init() { #endif #if ENABLED(LED_USER_PRESET_STARTUP) - set_color(adaneo1.Color(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE)); + set_color(adaneo.Color(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE)); #else - set_color(adaneo1.Color(0, 0, 0, 0)); + set_color(adaneo.Color(0, 0, 0, 0)); #endif } #if 0 bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p) { - const uint32_t color = adaneo1.Color(r, g, b, w); + const uint32_t color = adaneo.Color(r, g, b, w); set_brightness(p); #if DISABLED(NEOPIXEL_IS_SEQUENTIAL) set_color(color); @@ -119,9 +119,9 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint #if ENABLED(NEOPIXEL2_SEPARATE) Marlin_NEOPIXEL2 neo2; - int8_t Marlin_NEOPIXEL2_SEPARATE::neoindex2; - Adafruit_NeoPixel Marlin_NEOPIXEL2::adaneo2(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); + int8_t Marlin_NEOPIXEL2::neoindex; + Adafruit_NeoPixel Marlin_NEOPIXEL2::adaneo(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); void Marlin_NEOPIXEL2::set_color(const uint32_t color) { if (get_neo_index() >= 0) { @@ -148,21 +148,21 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint show(); // initialize to all off #if ENABLED(NEOPIXEL2_STARTUP_TEST) - set_color_startup(adaneo2.Color(255, 0, 0, 0)); // red - safe_delay(1000); - set_color_startup(adaneo2.Color(0, 255, 0, 0)); // green - safe_delay(1000); - set_color_startup(adaneo2.Color(0, 0, 255, 0)); // blue - safe_delay(1000); + set_color_startup(adaneo.Color(255, 0, 0, 0)); // red + safe_delay(500); + set_color_startup(adaneo.Color(0, 255, 0, 0)); // green + safe_delay(500); + set_color_startup(adaneo.Color(0, 0, 255, 0)); // blue + safe_delay(500); #endif #if ENABLED(NEO2_USER_PRESET_STARTUP) - set_color(adaneo2.Color(NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, NEO2_USER_PRESET_WHITE)); + set_color(adaneo.Color(NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, NEO2_USER_PRESET_WHITE)); #else - set_color(adaneo2.Color(0, 0, 0, 0)); + set_color(adaneo.Color(0, 0, 0, 0)); #endif } -#endif // NEOPIXEL2_SEPARATE +#endif // NEOPIXEL2_SEPARATE #endif // NEOPIXEL_LED diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 619a4f72ed6d..c0c77ca8fd58 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -60,7 +60,7 @@ class Marlin_NeoPixel { private: - static Adafruit_NeoPixel adaneo1; + static Adafruit_NeoPixel adaneo; static int8_t neoindex; public: @@ -77,31 +77,31 @@ class Marlin_NeoPixel { #endif static inline void begin() { - adaneo1.begin(); + adaneo.begin(); } static inline void set_pixel_color(const uint16_t n, const uint32_t c) { - adaneo1.setPixelColor(n, c); + adaneo.setPixelColor(n, c); } static inline void set_brightness(const uint8_t b) { - adaneo1.setBrightness(b); + adaneo.setBrightness(b); } - -static inline void show() { - adaneo1.show(); - adaneo1.setPin(NEOPIXEL_PIN); + static inline void show() { + adaneo.show(); + adaneo.setPin(NEOPIXEL_PIN); } + #if 0 bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p); #endif // Accessors - static inline uint16_t pixels() { return adaneo1.numPixels(); } - static inline uint8_t brightness() { return adaneo1.getBrightness(); } + static inline uint16_t pixels() { return adaneo.numPixels(); } + static inline uint8_t brightness() { return adaneo.getBrightness(); } static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - return adaneo1.Color(r, g, b, w); + return adaneo.Color(r, g, b, w); } }; @@ -112,9 +112,8 @@ extern Marlin_NeoPixel neo; class Marlin_NeoPixel2 { private: - static Adafruit_NeoPixel adaneo2; - - static int8_t neoindex2; + static Adafruit_NeoPixel adaneo; + static int8_t neoindex; public: static void init(); @@ -122,24 +121,24 @@ extern Marlin_NeoPixel neo; static void set_color(const uint32_t c); - FORCE_INLINE static void set_neo_index(const int8_t neoIndex2) { neoindex2 = neoIndex2; } - FORCE_INLINE static int8_t get_neo_index() { return neoindex2; } + FORCE_INLINE static void set_neo_index(const int8_t neoIndex) { neoindex = neoIndex; } + FORCE_INLINE static int8_t get_neo_index() { return neoindex; } static inline void begin() { - adaneo2.begin(); + adaneo.begin(); } static inline void set_pixel_color(const uint16_t n, const uint32_t c) { - adaneo2.setPixelColor(n, c); + adaneo.setPixelColor(n, c); } static inline void set_brightness(const uint8_t b) { - adaneo2.setBrightness(b); + adaneo.setBrightness(b); } static inline void show() { - adaneo2.show(); - adaneo2.setPin(NEOPIXEL2_PIN); + adaneo.show(); + adaneo.setPin(NEOPIXEL2_PIN); } #if 0 @@ -147,10 +146,10 @@ extern Marlin_NeoPixel neo; #endif // Accessors for NEOPIXEL2_SEPARATE - static inline uint16_t pixels() { return adaneo2.numPixels();} - static inline uint8_t brightness() { return adaneo2.getBrightness(); } + static inline uint16_t pixels() { return adaneo.numPixels();} + static inline uint8_t brightness() { return adaneo.getBrightness(); } static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - return adaneo2.Color(r, g, b, w); + return adaneo.Color(r, g, b, w); } }; From cd9d80d0c2721cafd294745ba3bd668c683c8a4d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 05:04:05 -0500 Subject: [PATCH 10/58] Re-use LEDColor --- Marlin/src/feature/leds/leds.cpp | 4 +- Marlin/src/feature/leds/leds.h | 88 -------------------------------- 2 files changed, 2 insertions(+), 90 deletions(-) diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index a34ddc08ca81..1ae2dd204302 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -161,7 +161,7 @@ void LEDLights::set_color(const LEDColor &incol #if ENABLED(NEOPIXEL2_SEPARATE) #if ENABLED(NEO2_COLOR_PRESETS) - const LEDColor2 LEDLights2::defaultLEDColor2 = MakeLEDColor2( + const LEDColor LEDLights2::defaultLEDColor = MakeLEDColor( NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, @@ -171,7 +171,7 @@ void LEDLights::set_color(const LEDColor &incol #endif #if ENABLED(LED_CONTROL_MENU) - LEDColor2 LEDLights2::color; + LEDColor LEDLights2::color; bool LEDLights2::lights_on; #endif diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index d652b9f08712..02cc6f9d6288 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -215,94 +215,6 @@ extern LEDLights leds; #if ENABLED(NEOPIXEL2_SEPARATE) - /** - * LEDcolor2 type for use with leds2.set_color - */ - typedef struct LEDColor2 { - uint8_t r, g, b - , w - #if ENABLED(NEOPIXEL2_SEPARATE) - , i - #endif - ; - - LEDColor2() : r(255), g(255), b(255) - , w(255) - #if ENABLED(NEOPIXEL2_SEPARATE) - , i(NEOPIXEL2_BRIGHTNESS) - #endif - {} - - LEDColor2(uint8_t r, uint8_t g, uint8_t b - , uint8_t w=0 - #if ENABLED(NEOPIXEL2_SEPARATE) - , uint8_t i=NEOPIXEL2_BRIGHTNESS - #endif - ) : r(r), g(g), b(b) - , w(w) - #if ENABLED(NEOPIXEL2_SEPARATE) - , i(i) - #endif - {} - - LEDColor2(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2]) - , w(rgbw[3]) - #if ENABLED(NEOPIXEL2_SEPARATE) - , i(NEOPIXEL2_BRIGHTNESS) - #endif - {} - - LEDColor2& operator=(const uint8_t (&rgbw)[4]) { - r = rgbw[0]; g = rgbw[1]; b = rgbw[2]; w = rgbw[3]; - return *this; - } - - LEDColor2& operator=(const LEDColor2 &right) { - if (this != &right) memcpy(this, &right, sizeof(LEDColor2)); - return *this; - } - - bool operator==(const LEDColor2 &right) { - if (this == &right) return true; - return 0 == memcmp(this, &right, sizeof(LEDColor2)); - } - - bool operator!=(const LEDColor2 &right) { return !operator==(right); } - - bool is_off() const { - return 3 > r + g + b + w; - } - } LEDColor2; - - /** - * Color helpers and presets for second neopixel channel - */ - #if ENABLED(NEOPIXEL2_SEPARATE) - #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B, W, I) - #else - #define MakeLEDColor2(R,G,B,W,I) LEDColor2(R, G, B, W) - #endif -#endif - -#define LEDColorOff2() LEDColor2( 0, 0, 0) -#define LEDColorRed2() LEDColor2(255, 0, 0) -#if ENABLED(LED_COLORS_REDUCE_GREEN) - #define LEDColorOrange2() LEDColor2(255, 25, 0) - #define LEDColorYellow2() LEDColor2(255, 75, 0) -#else - #define LEDColorOrange2() LEDColor2(255, 80, 0) - #define LEDColorYellow2() LEDColor2(255, 255, 0) -#endif -#define LEDColorGreen2() LEDColor2( 0, 255, 0) -#define LEDColorBlue2() LEDColor2( 0, 0, 255) -#define LEDColorIndigo2() LEDColor2( 0, 255, 255) -#define LEDColorViolet2() LEDColor2(255, 0, 255) -#if DISABLED(RGB_LED) - #define LEDColorWhite2() LEDColor2( 0, 0, 0, 255) -#else - #define LEDColorWhite2() LEDColor2(255, 255, 255) -#endif - class LEDLights2 { public: LEDLights2() {} // ctor From 0dbe7ff5201c64fb87e87a22b279b9d69abb6ffd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 05:05:37 -0500 Subject: [PATCH 11/58] Misc. cleanup --- Marlin/Configuration_adv.h | 2 +- Marlin/src/feature/leds/leds.cpp | 8 -------- Marlin/src/lcd/menu/menu_led.cpp | 15 ++++++++------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 15183e2a4d0f..44fe44a2f682 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1064,7 +1064,7 @@ */ //#define LED_CONTROL_MENU #if ENABLED(LED_CONTROL_MENU) - //#define LED_COLOR_PRESETS // Enable the Preset Color menu option + #define LED_COLOR_PRESETS // Enable the Preset Color menu option //#define NEO2_COLOR_PRESETS // Enable a second NeoPixel Preset Color menu option #if ENABLED(LED_COLOR_PRESETS) #define LED_USER_PRESET_RED 255 // User defined RED value diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 1ae2dd204302..9d51c701ec52 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -178,14 +178,6 @@ void LEDLights::set_color(const LEDColor &incol LEDLights2 leds2; void LEDLights2::setup() { - #if EITHER(RGB_LED, RGBW_LED) - if (PWM_PIN(RGB_LED_R_PIN)) SET_PWM(RGB_LED_R_PIN); else SET_OUTPUT(RGB_LED_R_PIN); - if (PWM_PIN(RGB_LED_G_PIN)) SET_PWM(RGB_LED_G_PIN); else SET_OUTPUT(RGB_LED_G_PIN); - if (PWM_PIN(RGB_LED_B_PIN)) SET_PWM(RGB_LED_B_PIN); else SET_OUTPUT(RGB_LED_B_PIN); - #if ENABLED(RGBW_LED) - if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN); - #endif - #endif neo2.init(); TERN_(NEO2_USER_PRESET_STARTUP, set_default()); } diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 61ffbfd66399..290b0ddf63cd 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -34,18 +34,19 @@ #include "../../feature/leds/leds.h" #if ENABLED(LED_COLOR_PRESETS) + void menu_led_presets() { START_MENU(); #if LCD_HEIGHT > 2 STATIC_ITEM(MSG_LED_PRESETS, SS_DEFAULT|SS_INVERT); #endif BACK_ITEM(MSG_LED_CONTROL); - ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white); - ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red); + ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white); + ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red); ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds.set_orange); - ACTION_ITEM(MSG_SET_LEDS_YELLOW,leds.set_yellow); - ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green); - ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue); + ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds.set_yellow); + ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green); + ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue); ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo); ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds.set_violet); END_MENU(); @@ -83,11 +84,10 @@ #endif #endif - - void menu_led() { START_MENU(); BACK_ITEM(MSG_MAIN); + #if ENABLED(LED_CONTROL_MENU) bool led_on = leds.lights_on; EDIT_ITEM(bool, MSG_LEDS, &led_on, leds.toggle); @@ -97,6 +97,7 @@ void menu_led() { #endif SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom); #endif + // // Set Case light on/off/brightness // From ffb781c9cab7c459d22f639e14f1b9a55eb99153 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 05:05:59 -0500 Subject: [PATCH 12/58] Fix set_color binding --- Marlin/src/feature/leds/leds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 02cc6f9d6288..15c8a6c5a907 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -152,7 +152,7 @@ class LEDLights { #endif ); - inline void set_color(uint8_t r, uint8_t g, uint8_t b + static inline void set_color(uint8_t r, uint8_t g, uint8_t b #if HAS_WHITE_LED , uint8_t w=0 #if ENABLED(NEOPIXEL_LED) From bdb472221ed4f53184258d939cae81fe5535c36b Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sun, 23 Aug 2020 10:57:27 -0500 Subject: [PATCH 13/58] Adding conflict protection with other neopixel features --- Marlin/Configuration.h | 2 +- Marlin/src/feature/leds/neopixel.h | 46 ++++++++++++++++++++++++------ 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 2f7ad51f6690..3712c146ee21 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2361,9 +2361,9 @@ #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. - #define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel #define NEOPIXEL2_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) #define NEOPIXEL2_PIN 5 // Neopixel2 driving pin + //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel // Support for second Adafruit Neopixel LED driver that is controlled with M151 #define NEOPIXEL2_SEPERATE diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 2bab989d7a37..cbdcd8a6ae63 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -38,11 +38,11 @@ // Defines // ------------------------ -#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE +#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE || !NEOPIXELX2 #define MULTIPLE_NEOPIXEL_TYPES 1 #endif -#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR || NEOPIXEL2_TYPE == NEO_RGB || NEOPIXEL2_TYPE == NEO_RBG || NEOPIXEL2_TYPE == NEO_GRB || NEOPIXEL2_TYPE == NEO_GBR || NEOPIXEL2_TYPE == NEO_BRG || NEOPIXEL2_TYPE == NEO_BGR +#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR #define NEOPIXEL_IS_RGB 1 #else #define NEOPIXEL_IS_RGBW 1 @@ -60,7 +60,11 @@ class Marlin_NeoPixel { private: - static Adafruit_NeoPixel adaneo1; + static Adafruit_NeoPixel adaneo1 + #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) + , adaneo2 + #endif + ; static int8_t neoindex; public: @@ -78,27 +82,51 @@ class Marlin_NeoPixel { static inline void begin() { adaneo1.begin(); + #if ENABLED(NEOPIXEL2_INSERIES) + adaneo2.begin(); + #else + TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.begin()); + #endif } static inline void set_pixel_color(const uint16_t n, const uint32_t c) { - adaneo1.setPixelColor(n, c); + #if ENABLED(NEOPIXEL2_INSERIES) + if (n >= NEOPIXEL_PIXELS) adaneo2.setPixelColor(n - (NEOPIXEL_PIXELS), c); + else adaneo1.setPixelColor(n, c); + #else + adaneo1.setPixelColor(n, c); + TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c)); + #endif } static inline void set_brightness(const uint8_t b) { adaneo1.setBrightness(b); + #if ENABLED(NEOPIXEL2_INSERIES) + adaneo2.setBrightness(b); + #else + TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setBrightness(b)); + #endif } - -static inline void show() { - adaneo1.show(); - adaneo1.setPin(NEOPIXEL_PIN); + static inline void show() { + adaneo1.show(); + #if PIN_EXISTS(NEOPIXEL2) + #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) + adaneo2.show(); + #else + adaneo1.setPin(NEOPIXEL2_PIN); + adaneo1.show(); + adaneo1.setPin(NEOPIXEL_PIN); + #endif + #endif } + #if 0 bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p); #endif // Accessors - static inline uint16_t pixels() { return adaneo1.numPixels(); } + static inline uint16_t pixels() { TERN(NEOPIXEL2_INSERIES, return adaneo1.numPixels() * 2, return adaneo1.numPixels()); } static inline uint8_t brightness() { return adaneo1.getBrightness(); } static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { return adaneo1.Color(r, g, b, w); From 4434b889511146b19a090f211e6de70ff986173a Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sun, 23 Aug 2020 12:09:12 -0500 Subject: [PATCH 14/58] reverting change --- Marlin/src/feature/leds/neopixel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 2d1530cbda07..78266038d639 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -38,7 +38,7 @@ // Defines // ------------------------ -#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE || !NEOPIXELX2 +#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE #define MULTIPLE_NEOPIXEL_TYPES 1 #endif From 1abbb8ce65403727165b04b951f333322fe02443 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sun, 23 Aug 2020 19:44:23 -0500 Subject: [PATCH 15/58] fixed compiling Error with the LPC1769 --- Marlin/Configuration.h | 290 ++++++++++++++++--------- Marlin/Configuration_adv.h | 59 ++--- Marlin/src/feature/leds/leds.h | 26 +-- Marlin/src/feature/leds/neopixel.cpp | 30 +-- Marlin/src/feature/leds/neopixel.h | 2 +- Marlin/src/gcode/feature/leds/M150.cpp | 2 + platformio.ini | 2 +- 7 files changed, 245 insertions(+), 166 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 4c279f8870e2..585b05072220 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -110,7 +110,7 @@ * Select a secondary serial port on the board to use for communication with the host. * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ -//#define SERIAL_PORT_2 -1 +#define SERIAL_PORT_2 -1 /** * This setting determines the communication speed of the printer. @@ -128,7 +128,7 @@ // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_RAMPS_14_EFB + #define MOTHERBOARD BOARD_BTT_SKR_V1_4_TURBO #endif // Name displayed in the LCD "Ready" message and Info menu @@ -416,7 +416,7 @@ * 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below. * 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below. */ -#define TEMP_SENSOR_0 1 +#define TEMP_SENSOR_0 5 #define TEMP_SENSOR_1 0 #define TEMP_SENSOR_2 0 #define TEMP_SENSOR_3 0 @@ -424,7 +424,7 @@ #define TEMP_SENSOR_5 0 #define TEMP_SENSOR_6 0 #define TEMP_SENSOR_7 0 -#define TEMP_SENSOR_BED 0 +#define TEMP_SENSOR_BED 5 #define TEMP_SENSOR_PROBE 0 #define TEMP_SENSOR_CHAMBER 0 @@ -435,13 +435,13 @@ // Use temp sensor 1 as a redundant sensor with sensor 0. If the readings // from the two sensors differ too much the print will be aborted. //#define TEMP_SENSOR_1_AS_REDUNDANT -#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10 +#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 5 #define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109 #define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer #define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target -#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190 +#define TEMP_BED_RESIDENCY_TIME 1 // (seconds) Time to wait for bed to "settle" in M190 #define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer #define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target @@ -460,7 +460,7 @@ // Above this temperature the heater will be switched off. // This can protect components from overheating, but NOT from shorts and failures. // (Use MINTEMP for thermistor short/failure protection.) -#define HEATER_0_MAXTEMP 275 +#define HEATER_0_MAXTEMP 300 #define HEATER_1_MAXTEMP 275 #define HEATER_2_MAXTEMP 275 #define HEATER_3_MAXTEMP 275 @@ -468,7 +468,7 @@ #define HEATER_5_MAXTEMP 275 #define HEATER_6_MAXTEMP 275 #define HEATER_7_MAXTEMP 275 -#define BED_MAXTEMP 150 +#define BED_MAXTEMP 115 //=========================================================================== //============================= PID Settings ================================ @@ -482,17 +482,21 @@ #define PID_K1 0.95 // Smoothing factor within any PID loop #if ENABLED(PIDTEMP) - //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) - //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) + #define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) + #define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with gcode: M301 E[extruder number, 0-2] // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it + // E3D V6 30mm Fan + #define DEFAULT_Kp 21.21 + #define DEFAULT_Ki 1.78 + #define DEFAULT_Kd 63.23 // Ultimaker - #define DEFAULT_Kp 22.2 - #define DEFAULT_Ki 1.08 - #define DEFAULT_Kd 114 + //#define DEFAULT_Kp 22.2 + //#define DEFAULT_Ki 1.08 + //#define DEFAULT_Kd 114 // MakerGear //#define DEFAULT_Kp 7.0 @@ -541,9 +545,9 @@ //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) - #define DEFAULT_bedKp 10.00 - #define DEFAULT_bedKi .023 - #define DEFAULT_bedKd 305.4 + //#define DEFAULT_bedKp 10.00 + //#define DEFAULT_bedKi .023 + //#define DEFAULT_bedKd 305.4 //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //from pidautotune @@ -551,6 +555,10 @@ //#define DEFAULT_bedKi 1.41 //#define DEFAULT_bedKd 1675.16 +//D-force + #define DEFAULT_bedKp 22.97 + #define DEFAULT_bedKi 3.76 + #define DEFAULT_bedKd 29.2 // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. #endif // PIDTEMPBED @@ -600,7 +608,7 @@ #define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders #define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed -#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber +//#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber //=========================================================================== //============================= Mechanical Settings ========================= @@ -617,6 +625,67 @@ //#define COREZX //#define COREZY +//=========================================================================== +//============================== Delta Settings ============================= +//=========================================================================== +// Enable DELTA kinematics and most of the default configuration for Deltas +#define DELTA + +#if ENABLED(DELTA) + + // Make delta curves from many straight lines (linear interpolation). + // This is a trade-off between visible corners (not enough segments) + // and processor overload (too many expensive sqrt calls). + #define DELTA_SEGMENTS_PER_SECOND 200 + + // After homing move down to a height where XY movement is unconstrained + //#define DELTA_HOME_TO_SAFE_ZONE + + // Delta calibration menu + // uncomment to add three points calibration menu option. + // See http://minow.blogspot.com/index.html#4918805519571907051 + #define DELTA_CALIBRATION_MENU + + // uncomment to add G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results) + #define DELTA_AUTO_CALIBRATION + + // NOTE NB all values for DELTA_* values MUST be floating point, so always have a decimal point in them + + #if ENABLED(DELTA_AUTO_CALIBRATION) + // set the default number of probe points : n*n (1 -> 7) + #define DELTA_CALIBRATION_DEFAULT_POINTS 4.0 + #endif + + #if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU) + // Set the steprate for papertest probing + #define PROBE_MANUALLY_STEP 0.05 // (mm) + #endif + + // Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers). + #define DELTA_PRINTABLE_RADIUS 120.0 // (mm) + + // Center-to-center distance of the holes in the diagonal push rods. + #define DELTA_DIAGONAL_ROD 304.14 // (mm) + + // Distance between bed and nozzle Z home position + #define DELTA_HEIGHT 199.61 // (mm) Get this value from G33 auto calibrate + + #define DELTA_ENDSTOP_ADJ { 0.0, -2.30, -1.89 } // Get these values from G33 auto calibrate + + // Horizontal distance bridged by diagonal push rods when effector is centered. + #define DELTA_RADIUS 145.94 // (mm) Get this value from G33 auto calibrate + + // Trim adjustments for individual towers + // tower angle corrections for X and Y tower / rotate XYZ so Z tower angle = 0 + // measured in degrees anticlockwise looking from above the printer + #define DELTA_TOWER_ANGLE_TRIM {0.17, -0.21, 0.04} // Get these values from G33 auto calibrate + + // Delta radius and diagonal rod adjustments (mm) + //#define DELTA_RADIUS_TRIM_TOWER { 0.0, 0.0, 0.0 } + //#define DELTA_DIAGONAL_ROD_TRIM_TOWER { 0.0, 0.0, 0.0 } + +#endif + //=========================================================================== //============================== Endstop Settings =========================== //=========================================================================== @@ -626,12 +695,12 @@ // Specify here all the endstop connectors that are connected to any endstop or probe. // Almost all printers will be using one per axis. Probes will use one or more of the // extra connectors. Leave undefined any used for non-endstop and non-probe purposes. -#define USE_XMIN_PLUG -#define USE_YMIN_PLUG -#define USE_ZMIN_PLUG -//#define USE_XMAX_PLUG -//#define USE_YMAX_PLUG -//#define USE_ZMAX_PLUG +//#define USE_XMIN_PLUG +//#define USE_YMIN_PLUG +//#define USE_ZMIN_PLUG // a Z probe +#define USE_XMAX_PLUG +#define USE_YMAX_PLUG +#define USE_ZMAX_PLUG // Enable pullup for all endstops to prevent a floating state #define ENDSTOPPULLUPS @@ -663,9 +732,9 @@ #define X_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Y_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Z_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define X_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define Y_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define Z_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. +#define X_MAX_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop. +#define Y_MAX_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop. +#define Z_MAX_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop. #define Z_MIN_PROBE_ENDSTOP_INVERTING false // Set to true to invert the logic of the probe. /** @@ -684,15 +753,15 @@ * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] */ -//#define X_DRIVER_TYPE A4988 -//#define Y_DRIVER_TYPE A4988 -//#define Z_DRIVER_TYPE A4988 +#define X_DRIVER_TYPE TMC2209 +#define Y_DRIVER_TYPE TMC2209 +#define Z_DRIVER_TYPE TMC2209 //#define X2_DRIVER_TYPE A4988 //#define Y2_DRIVER_TYPE A4988 //#define Z2_DRIVER_TYPE A4988 //#define Z3_DRIVER_TYPE A4988 //#define Z4_DRIVER_TYPE A4988 -//#define E0_DRIVER_TYPE A4988 +#define E0_DRIVER_TYPE TMC2209 //#define E1_DRIVER_TYPE A4988 //#define E2_DRIVER_TYPE A4988 //#define E3_DRIVER_TYPE A4988 @@ -747,14 +816,23 @@ * Override with M92 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 4000, 500 } + +// variables to calculate steps +#define XYZ_FULL_STEPS_PER_ROTATION 200 +#define XYZ_MICROSTEPS 16 +#define XYZ_BELT_PITCH 2 +#define XYZ_PULLEY_TEETH 16 + +// delta speeds must be the same on xyz +#define DEFAULT_XYZ_STEPS_PER_UNIT ((XYZ_FULL_STEPS_PER_ROTATION) * (XYZ_MICROSTEPS) / double(XYZ_BELT_PITCH) / double(XYZ_PULLEY_TEETH)) +#define DEFAULT_AXIS_STEPS_PER_UNIT { DEFAULT_XYZ_STEPS_PER_UNIT, DEFAULT_XYZ_STEPS_PER_UNIT, DEFAULT_XYZ_STEPS_PER_UNIT, 139 } // default steps per unit for Kossel (GT2, 20 tooth) /** * Default Max Feed Rate (mm/s) * Override with M203 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_FEEDRATE { 300, 300, 5, 25 } +#define DEFAULT_MAX_FEEDRATE { 200, 200, 200, 25 } //#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2 #if ENABLED(LIMITED_MAX_FR_EDITING) @@ -767,7 +845,7 @@ * Override with M201 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 10000 } +#define DEFAULT_MAX_ACCELERATION { 4000, 4000, 4000, 4000 } //#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 #if ENABLED(LIMITED_MAX_ACCEL_EDITING) @@ -794,11 +872,11 @@ * When changing speed and direction, if the difference is less than the * value set here, it may happen instantaneously. */ -//#define CLASSIC_JERK +#define CLASSIC_JERK #if ENABLED(CLASSIC_JERK) #define DEFAULT_XJERK 10.0 - #define DEFAULT_YJERK 10.0 - #define DEFAULT_ZJERK 0.3 + #define DEFAULT_YJERK DEFAULT_XJERK + #define DEFAULT_ZJERK DEFAULT_XJERK // Must be same as XY for delta //#define TRAVEL_EXTRA_XYJERK 0.0 // Additional jerk allowance for all travel moves @@ -831,7 +909,7 @@ * * See https://github.com/synthetos/TinyG/wiki/Jerk-Controlled-Motion-Explained */ -//#define S_CURVE_ACCELERATION +#define S_CURVE_ACCELERATION //=========================================================================== //============================= Z Probe Options ============================= @@ -847,7 +925,7 @@ * The probe replaces the Z-MIN endstop and is used for Z homing. * (Automatically enables USE_PROBE_FOR_Z_HOMING.) */ -#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN +//#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN // Force the use of the probe for Z-axis homing //#define USE_PROBE_FOR_Z_HOMING @@ -868,7 +946,7 @@ * - normally-open switches to 5V and D32. * */ -//#define Z_MIN_PROBE_PIN 32 // Pin 32 is the RAMPS default +#define Z_MIN_PROBE_PIN P0_10 // Pin 32 is the RAMPS default /** * Probe Type @@ -895,7 +973,7 @@ * Use the nozzle as the probe, as with a conductive * nozzle system or a piezo-electric smart effector. */ -//#define NOZZLE_AS_PROBE +#define NOZZLE_AS_PROBE /** * Z Servo Probe, such as an endstop switch on a rotating arm. @@ -946,9 +1024,9 @@ // Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J // When the pin is defined you can use M672 to set/reset the probe sensitivity. -//#define DUET_SMART_EFFECTOR +#define DUET_SMART_EFFECTOR #if ENABLED(DUET_SMART_EFFECTOR) - #define SMART_EFFECTOR_MOD_PIN -1 // Connect a GPIO pin to the Smart Effector MOD pin + #define SMART_EFFECTOR_MOD_PIN P2_00 // Connect a GPIO pin to the Smart Effector MOD pin #endif /** @@ -993,20 +1071,20 @@ * | [-] | * O-- FRONT --+ */ -#define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 } +#define NOZZLE_TO_PROBE_OFFSET { 0.0, 0.0, 0.11 } // Most probes should stay away from the edges of the bed, but // with NOZZLE_AS_PROBE this can be negative for a wider probing area. #define PROBING_MARGIN 10 // X and Y axis travel speed (mm/min) between probes -#define XY_PROBE_SPEED (133*60) +#define XY_PROBE_SPEED 1200 // Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2) -#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z +#define Z_PROBE_SPEED_FAST 1200 // Feedrate (mm/min) for the "accurate" probe of each point -#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2) +#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 1) /** * Multiple Probing @@ -1034,10 +1112,10 @@ * Example: `M851 Z-5` with a CLEARANCE of 4 => 9mm from bed to nozzle. * But: `M851 Z+1` with a CLEARANCE of 2 => 2mm from bed to nozzle. */ -#define Z_CLEARANCE_DEPLOY_PROBE 10 // Z Clearance for Deploy/Stow -#define Z_CLEARANCE_BETWEEN_PROBES 5 // Z Clearance between probe points +#define Z_CLEARANCE_DEPLOY_PROBE 5 // Z Clearance for Deploy/Stow +#define Z_CLEARANCE_BETWEEN_PROBES 2 // Z Clearance between probe points #define Z_CLEARANCE_MULTI_PROBE 5 // Z Clearance between multiple probes -//#define Z_AFTER_PROBING 5 // Z position after probing is done +//#define Z_AFTER_PROBING 10 // Z position after probing is done #define Z_PROBE_LOW_POINT -2 // Farthest distance below the trigger-point to go before stopping @@ -1046,7 +1124,7 @@ #define Z_PROBE_OFFSET_RANGE_MAX 20 // Enable the M48 repeatability test to test probe accuracy -//#define Z_MIN_PROBE_REPEATABILITY_TEST +#define Z_MIN_PROBE_REPEATABILITY_TEST // Before deploy/stow pause for user confirmation //#define PAUSE_BEFORE_DEPLOY_STOW @@ -1067,7 +1145,7 @@ #endif //#define PROBING_FANS_OFF // Turn fans off when probing //#define PROBING_STEPPERS_OFF // Turn steppers off (unless needed to hold position) when probing -//#define DELAY_BEFORE_PROBING 200 // (ms) To prevent vibrations from triggering piezo sensors +#define DELAY_BEFORE_PROBING 400 // (ms) To prevent vibrations from triggering piezo sensors // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 // :{ 0:'Low', 1:'High' } @@ -1094,13 +1172,13 @@ // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. #define INVERT_X_DIR false -#define INVERT_Y_DIR true +#define INVERT_Y_DIR false #define INVERT_Z_DIR false // @section extruder // For direct drive extruder v9 set to true, for geared extruder set to false. -#define INVERT_E0_DIR false +#define INVERT_E0_DIR true #define INVERT_E1_DIR false #define INVERT_E2_DIR false #define INVERT_E3_DIR false @@ -1122,23 +1200,22 @@ // Direction of endstops when homing; 1=MAX, -1=MIN // :[-1,1] -#define X_HOME_DIR -1 -#define Y_HOME_DIR -1 -#define Z_HOME_DIR -1 +#define X_HOME_DIR 1 // deltas always home to max +#define Y_HOME_DIR 1 +#define Z_HOME_DIR 1 // @section machine // The size of the print bed -#define X_BED_SIZE 200 -#define Y_BED_SIZE 200 - +#define X_BED_SIZE ((DELTA_PRINTABLE_RADIUS) * 2) +#define Y_BED_SIZE ((DELTA_PRINTABLE_RADIUS) * 2) // Travel limits (mm) after homing, corresponding to endstop positions. -#define X_MIN_POS 0 -#define Y_MIN_POS 0 +#define X_MIN_POS -(DELTA_PRINTABLE_RADIUS) +#define Y_MIN_POS -(DELTA_PRINTABLE_RADIUS) #define Z_MIN_POS 0 -#define X_MAX_POS X_BED_SIZE -#define Y_MAX_POS Y_BED_SIZE -#define Z_MAX_POS 200 +#define X_MAX_POS DELTA_PRINTABLE_RADIUS +#define Y_MAX_POS DELTA_PRINTABLE_RADIUS +#define Z_MAX_POS MANUAL_Z_HOME_POS /** * Software Endstops @@ -1242,21 +1319,21 @@ //#define AUTO_BED_LEVELING_3POINT //#define AUTO_BED_LEVELING_LINEAR //#define AUTO_BED_LEVELING_BILINEAR -//#define AUTO_BED_LEVELING_UBL +#define AUTO_BED_LEVELING_UBL //#define MESH_BED_LEVELING /** * Normally G28 leaves leveling disabled on completion. Enable * this option to have G28 restore the prior leveling state. */ -//#define RESTORE_LEVELING_AFTER_G28 +#define RESTORE_LEVELING_AFTER_G28 /** * Enable detailed logging of G28, G29, M48, etc. * Turn on with the command 'M111 S32'. * NOTE: Requires a lot of PROGMEM! */ -//#define DEBUG_LEVELING_FEATURE +#define DEBUG_LEVELING_FEATURE #if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL) // Gradually reduce leveling correction until a set height is reached, @@ -1273,7 +1350,7 @@ /** * Enable the G26 Mesh Validation Pattern tool. */ - //#define G26_MESH_VALIDATION + #define G26_MESH_VALIDATION #if ENABLED(G26_MESH_VALIDATION) #define MESH_TEST_NOZZLE_SIZE 0.4 // (mm) Diameter of primary nozzle. #define MESH_TEST_LAYER_HEIGHT 0.2 // (mm) Default layer height for the G26 Mesh Validation Tool. @@ -1288,7 +1365,7 @@ #if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR) // Set the number of grid points per dimension. - #define GRID_MAX_POINTS_X 3 + #define GRID_MAX_POINTS_X 11 #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X // Probe along the Y axis, advancing X after each column @@ -1304,7 +1381,7 @@ // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. // - //#define ABL_BILINEAR_SUBDIVISION + #define ABL_BILINEAR_SUBDIVISION #if ENABLED(ABL_BILINEAR_SUBDIVISION) // Number of subdivisions between probe points #define BILINEAR_SUBDIVISIONS 3 @@ -1320,11 +1397,11 @@ //#define MESH_EDIT_GFX_OVERLAY // Display a graphics overlay while editing the mesh - #define MESH_INSET 1 // Set Mesh bounds as an inset region of the bed - #define GRID_MAX_POINTS_X 10 // Don't use more than 15 points per axis, implementation limited. + #define MESH_INSET 0 // Set Mesh bounds as an inset region of the bed + #define GRID_MAX_POINTS_X 11 // Don't use more than 15 points per axis, implementation limited. #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X - #define UBL_MESH_EDIT_MOVES_Z // Sophisticated users prefer no movement of nozzle + //#define UBL_MESH_EDIT_MOVES_Z // Sophisticated users prefer no movement of nozzle #define UBL_SAVE_ACTIVE_ON_M500 // Save the currently active mesh in the current slot on M500 //#define UBL_Z_RAISE_WHEN_OFF_MESH 2.5 // When the nozzle is off the mesh, this value is used @@ -1348,12 +1425,12 @@ * Add a bed leveling sub-menu for ABL or MBL. * Include a guided procedure if manual probing is enabled. */ -//#define LCD_BED_LEVELING +#define LCD_BED_LEVELING #if ENABLED(LCD_BED_LEVELING) #define MESH_EDIT_Z_STEP 0.025 // (mm) Step size while manually probing Z axis. #define LCD_PROBE_Z_RANGE 4 // (mm) Z Range centered on Z_MIN_POS for LCD Z adjustment - //#define MESH_EDIT_MENU // Add a menu to edit mesh points + #define MESH_EDIT_MENU // Add a menu to edit mesh points #endif // Add a menu item to move between bed corners for manual bed adjustment @@ -1375,13 +1452,13 @@ // @section homing // The center of the bed is at (X=0, Y=0) -//#define BED_CENTER_AT_0_0 +#define BED_CENTER_AT_0_0 // Manually set the home position. Leave these undefined for automatic settings. // For DELTA this is the top-center of the Cartesian print volume. //#define MANUAL_X_HOME_POS 0 //#define MANUAL_Y_HOME_POS 0 -//#define MANUAL_Z_HOME_POS 0 +#define MANUAL_Z_HOME_POS DELTA_HEIGHT // Distance between the nozzle to printbed after homing // Use "Z Safe Homing" to avoid homing with a Z probe outside the bed area. // @@ -1399,9 +1476,8 @@ #define Z_SAFE_HOMING_Y_POINT Y_CENTER // Y point for Z homing #endif -// Homing speeds (mm/min) -#define HOMING_FEEDRATE_XY (50*60) -#define HOMING_FEEDRATE_Z (4*60) +// Delta only homes to Z +#define HOMING_FEEDRATE_Z (100*15) // Validate that endstops are triggered on homing moves #define VALIDATE_HOMING_ENDSTOPS @@ -1478,7 +1554,7 @@ * M501 - Read settings from EEPROM. (i.e., Throw away unsaved changes) * M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.) */ -//#define EEPROM_SETTINGS // Persistent storage with M500 and M501 +#define EEPROM_SETTINGS // Persistent storage with M500 and M501 //#define DISABLE_M503 // Saves ~2700 bytes of PROGMEM. Disable for release! #define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM. #define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load @@ -1493,7 +1569,7 @@ // every couple of seconds when it can't accept commands. // #define HOST_KEEPALIVE_FEATURE // Disable this if your host doesn't like keepalive messages -#define DEFAULT_KEEPALIVE_INTERVAL 2 // Number of seconds between "busy" messages. Set with M113. +#define DEFAULT_KEEPALIVE_INTERVAL 3 // Number of seconds between "busy" messages. Set with M113. #define BUSY_WHILE_HEATING // Some hosts require "busy" messages even during heating // @@ -1717,7 +1793,7 @@ * * :['JAPANESE', 'WESTERN', 'CYRILLIC'] */ -#define DISPLAY_CHARSET_HD44780 JAPANESE +#define DISPLAY_CHARSET_HD44780 WESTERN /** * Info Screen Style (0:Classic, 1:Prusa) @@ -1733,7 +1809,7 @@ * you must uncomment the following option or it won't work. * */ -//#define SDSUPPORT +#define SDSUPPORT /** * SD CARD: SPI SPEED @@ -1750,7 +1826,7 @@ * * Use CRC checks and retries on the SD communication. */ -//#define SD_CHECK_AND_RETRY +#define SD_CHECK_AND_RETRY /** * LCD Menu Items @@ -1798,7 +1874,7 @@ // If CLOCKWISE normally moves DOWN this makes it go UP. // If CLOCKWISE normally moves UP this makes it go DOWN. // -//#define REVERSE_MENU_DIRECTION +#define REVERSE_MENU_DIRECTION // // This option reverses the encoder direction for Select Screen. @@ -1821,7 +1897,7 @@ // If you have a speaker that can produce tones, enable it here. // By default Marlin assumes you have a buzzer with a fixed frequency. // -//#define SPEAKER +#define SPEAKER // // The duration and frequency for the UI feedback sound. @@ -1844,7 +1920,7 @@ // // Note: Usually sold with a white PCB. // -//#define REPRAP_DISCOUNT_SMART_CONTROLLER +#define REPRAP_DISCOUNT_SMART_CONTROLLER // // Original RADDS LCD Display+Encoder+SDCardReader @@ -2356,25 +2432,25 @@ #endif // Support for Adafruit NeoPixel LED driver -//#define NEOPIXEL_LED +#define NEOPIXEL_LED #if ENABLED(NEOPIXEL_LED) - #define NEOPIXEL_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL_PIN 4 // LED driving pin - #define NEOPIXEL_PIXELS 12 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used - #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) - //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup - #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. - #define NEOPIXEL2_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL2_PIN 5 // Neopixel2 driving pin - //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel - - // Support for second Adafruit Neopixel LED driver that is controlled with M151 -#define NEOPIXEL2_SEPERATE -#if ENABLED(NEOPIXEL2_SEPERATE) - #define NEOPIXEL2_PIXELS 12 // Number of LEDs in the second strip, larger of 2 strips if 2 neopixel strips are used - #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) - //#define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup on the seperate channel -#endif + #define NEOPIXEL_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) + #define NEOPIXEL_PIN P1_24 // LED driving pin + #define NEOPIXEL2_TYPE NEO_GRB + #define NEOPIXEL2_PIN P1_25 + //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel + #define NEOPIXEL_PIXELS 9 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used + #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. + #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) + #define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup + + // Support for second Adafruit NeoPixel LED driver controlled with M150 S1 ... + #define NEOPIXEL2_SEPARATE + #if ENABLED(NEOPIXEL2_SEPARATE) + #define NEOPIXEL2_PIXELS 15 // Number of LEDs in the second strip, larger of 2 strips if 2 neopixel strips are used + #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) + #define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup on the separate channel + #endif // Use a single NeoPixel LED for static (background) lighting //#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use @@ -2413,7 +2489,7 @@ // (ms) Delay before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -#define SERVO_DELAY { 300 } +//#define SERVO_DELAY { 300 } // Only power servos during movement, otherwise leave off to prevent jitter //#define DEACTIVATE_SERVOS_AFTER_MOVE diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 44fe44a2f682..e388ba47170e 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -481,7 +481,7 @@ */ //#define CASE_LIGHT_ENABLE #if ENABLED(CASE_LIGHT_ENABLE) - //#define CASE_LIGHT_PIN 4 // Override the default pin if needed + //#define CASE_LIGHT_PIN P1_25 // Override the default pin if needed #define INVERT_CASE_LIGHT false // Set true if Case Light is ON when pin is LOW #define CASE_LIGHT_DEFAULT_ON true // Set default power-up state on #define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // Set default power-up brightness (0-255, requires PWM pin) @@ -629,10 +629,10 @@ //#define SENSORLESS_BACKOFF_MM { 2, 2 } // (mm) Backoff from endstops before sensorless homing -#define HOMING_BUMP_MM { 5, 5, 2 } // (mm) Backoff from endstops after first bump -#define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate) +#define HOMING_BUMP_MM { 5, 5, 5 } // (mm) Backoff from endstops after first bump +#define HOMING_BUMP_DIVISOR { 5, 5, 5 } // Re-Bump Speed Divisor (Divides the Homing Feedrate) -//#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm) Backoff from endstops after homing +#define HOMING_BACKOFF_POST_MM { 5, 5, 5 } // (mm) Backoff from endstops after homing //#define QUICK_HOME // If G28 contains XY do a diagonal move first //#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X @@ -834,7 +834,7 @@ // Slow down the machine if the lookahead buffer is (by default) half full. // Increase the slowdown divisor for larger buffer sizes. -#define SLOWDOWN +//#define SLOWDOWN #if ENABLED(SLOWDOWN) #define SLOWDOWN_DIVISOR 2 #endif @@ -1025,7 +1025,8 @@ // @section lcd #if EITHER(ULTIPANEL, EXTENSIBLE_UI) - #define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 2*60 } // (mm/min) Feedrates for manual moves along X, Y, Z, E from panel + #define MANUAL_FEEDRATE_XYZ 50*60 + #define MANUAL_FEEDRATE { MANUAL_FEEDRATE_XYZ, MANUAL_FEEDRATE_XYZ, MANUAL_FEEDRATE_XYZ, 60 } // Feedrates for manual moves along X, Y, Z, E from panel #define SHORT_MANUAL_Z_MOVE 0.025 // (mm) Smallest manual Z move (< 0.1mm) #if ENABLED(ULTIPANEL) #define MANUAL_E_MOVES_RELATIVE // Display extruder move distance rather than "position" @@ -1065,7 +1066,7 @@ //#define LED_CONTROL_MENU #if ENABLED(LED_CONTROL_MENU) #define LED_COLOR_PRESETS // Enable the Preset Color menu option - //#define NEO2_COLOR_PRESETS // Enable a second NeoPixel Preset Color menu option + #define NEO2_COLOR_PRESETS // Enable a second NeoPixel Preset Color menu option #if ENABLED(LED_COLOR_PRESETS) #define LED_USER_PRESET_RED 255 // User defined RED value #define LED_USER_PRESET_GREEN 128 // User defined GREEN value @@ -1087,7 +1088,7 @@ #endif // HAS_LCD_MENU // Scroll a longer status message into view -//#define STATUS_MESSAGE_SCROLLING +#define STATUS_MESSAGE_SCROLLING // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY @@ -1146,7 +1147,7 @@ //#define MENU_ADDAUTOSTART // Add a menu option to run auto#.g files - #define EVENT_GCODE_SD_ABORT "G28XY" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27") + #define EVENT_GCODE_SD_ABORT "G28" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27") #if ENABLED(PRINTER_EVENT_LEDS) #define PE_LEDS_COMPLETED_TIME (30*60) // (seconds) Time to keep the LED "done" color before restoring normal illumination @@ -1215,10 +1216,10 @@ #endif // This allows hosts to request long names for files and folders with M33 - //#define LONG_FILENAME_HOST_SUPPORT + #define LONG_FILENAME_HOST_SUPPORT // Enable this option to scroll long filenames in the SD card menu - //#define SCROLL_LONG_FILENAMES + #define SCROLL_LONG_FILENAMES // Leave the heaters on after Stop Print (not recommended!) //#define SD_ABORT_NO_COOLDOWN @@ -1302,7 +1303,7 @@ * * :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ] */ - //#define SDCARD_CONNECTION LCD + #define SDCARD_CONNECTION LCD, ONBOARD #endif // SDSUPPORT @@ -1379,14 +1380,14 @@ #define STATUS_HOTEND_INVERTED // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM) #define STATUS_HOTEND_ANIM // Use a second bitmap to indicate hotend heating #define STATUS_BED_ANIM // Use a second bitmap to indicate bed heating - #define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating + //#define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating //#define STATUS_CUTTER_ANIM // Use a second bitmap to indicate spindle / laser active //#define STATUS_ALT_BED_BITMAP // Use the alternative bed bitmap //#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap //#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames //#define STATUS_HEAT_PERCENT // Show heating in a progress bar //#define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving 399 bytes of flash) - //#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~‭3260 (or ~940) bytes of PROGMEM. + #define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~‭3260 (or ~940) bytes of PROGMEM. // Frivolous Game Options //#define MARLIN_BRICKOUT @@ -1615,12 +1616,12 @@ * * See https://marlinfw.org/docs/features/lin_advance.html for full instructions. */ -//#define LIN_ADVANCE +#define LIN_ADVANCE #if ENABLED(LIN_ADVANCE) //#define EXTRA_LIN_ADVANCE_K // Enable for second linear advance constants - #define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed + #define LIN_ADVANCE_K 0.53 // Unit: mm compression per 1mm/s extruder speed //#define LA_DEBUG // If enabled, this will generate debug information output over USB. - //#define EXPERIMENTAL_SCURVE // Enable this option to permit S-Curve Acceleration + #define EXPERIMENTAL_SCURVE // Enable this option to permit S-Curve Acceleration #endif // @section leveling @@ -1751,7 +1752,7 @@ // // G60/G61 Position Save and Return // -//#define SAVED_POSITIONS 1 // Each saved position slot costs 12 bytes +#define SAVED_POSITIONS 1 // Each saved position slot costs 12 bytes // // G2/G3 Arc Support @@ -1794,7 +1795,7 @@ #endif // Moves (or segments) with fewer steps than this will be joined with the next move -#define MIN_STEPS_PER_SEGMENT 6 +#define MIN_STEPS_PER_SEGMENT 1 /** * Minimum delay before and after setting the stepper DIR (in ns) @@ -1908,7 +1909,7 @@ * Currently handles M108, M112, M410, M876 * NOTE: Not yet implemented for all platforms. */ -//#define EMERGENCY_PARSER +#define EMERGENCY_PARSER // Bad Serial-connections can miss a received command by sending an 'ok' // Therefore some clients abort after 30 seconds in a timeout. @@ -1952,9 +1953,9 @@ * Note that M207 / M208 / M209 settings are saved to EEPROM. * */ -//#define FWRETRACT +#define FWRETRACT #if ENABLED(FWRETRACT) - #define FWRETRACT_AUTORETRACT // Override slicer retractions + //#define FWRETRACT_AUTORETRACT // Override slicer retractions #if ENABLED(FWRETRACT_AUTORETRACT) #define MIN_AUTORETRACT 0.1 // (mm) Don't convert E moves under this length #define MAX_AUTORETRACT 10.0 // (mm) Don't convert E moves over this length @@ -2452,7 +2453,7 @@ * M912 - Clear stepper driver overtemperature pre-warn condition flag. * M122 - Report driver parameters (Requires TMC_DEBUG) */ - //#define MONITOR_DRIVER_STATUS + #define MONITOR_DRIVER_STATUS #if ENABLED(MONITOR_DRIVER_STATUS) #define CURRENT_STEP_DOWN 50 // [mA] @@ -2541,13 +2542,13 @@ * Beta feature! * Create a 50/50 square wave step pulse optimal for stepper drivers. */ - //#define SQUARE_WAVE_STEPPING + #define SQUARE_WAVE_STEPPING /** * Enable M122 debugging command for TMC stepper drivers. * M122 S0/1 will enable continous reporting. */ - //#define TMC_DEBUG + #define TMC_DEBUG /** * You can set your own advanced settings by filling in predefined functions. @@ -3146,7 +3147,7 @@ //#define GCODE_QUOTED_STRINGS // Support for quoted string parameters #endif -//#define GCODE_CASE_INSENSITIVE // Accept G-code sent to the firmware in lowercase +#define GCODE_CASE_INSENSITIVE // Accept G-code sent to the firmware in lowercase //#define REPETIER_GCODE_M360 // Add commands originally from Repetier FW @@ -3224,9 +3225,9 @@ * Host Prompt Support enables Marlin to use the host for user prompts so * filament runout and other processes can be managed from the host side. */ -//#define HOST_ACTION_COMMANDS +#define HOST_ACTION_COMMANDS #if ENABLED(HOST_ACTION_COMMANDS) - //#define HOST_PROMPT_SUPPORT + #define HOST_PROMPT_SUPPORT #endif /** @@ -3520,7 +3521,7 @@ // // M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe // -//#define PINS_DEBUGGING +#define PINS_DEBUGGING // Enable Marlin dev mode which adds some special commands //#define MARLIN_DEV_MODE diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 15c8a6c5a907..5c6596f6202f 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -221,7 +221,7 @@ class LEDLights2 { static void setup(); // init() - static void set_color(const LEDColor2 &color); + static void set_color(const LEDColor &color); inline void set_color(uint8_t r, uint8_t g, uint8_t b , uint8_t w=0 @@ -229,26 +229,26 @@ class LEDLights2 { , uint8_t i=NEOPIXEL2_BRIGHTNESS #endif ) { - set_color(MakeLEDColor2(r, g, b, w, i)); + set_color(MakeLEDColor(r, g, b, w, i)); } - static inline void set_off() { set_color(LEDColorOff2()); } - static inline void set_green() { set_color(LEDColorGreen2()); } - static inline void set_white() { set_color(LEDColorWhite2()); } + static inline void set_off() { set_color(LEDColorOff()); } + static inline void set_green() { set_color(LEDColorGreen()); } + static inline void set_white() { set_color(LEDColorWhite()); } #if ENABLED(NEO2_COLOR_PRESETS) static const LEDColor2 defaultLEDColor2; - static inline void set_default() { set_color(defaultLEDColor2); } - static inline void set_red() { set_color(LEDColorRed2()); } - static inline void set_orange() { set_color(LEDColorOrange2()); } - static inline void set_yellow() { set_color(LEDColorYellow2()); } - static inline void set_blue() { set_color(LEDColorBlue2()); } - static inline void set_indigo() { set_color(LEDColorIndigo2()); } - static inline void set_violet() { set_color(LEDColorViolet2()); } + static inline void set_default() { set_color(defaultLEDColor); } + static inline void set_red() { set_color(LEDColorRed()); } + static inline void set_orange() { set_color(LEDColorOrange()); } + static inline void set_yellow() { set_color(LEDColorYellow()); } + static inline void set_blue() { set_color(LEDColorBlue()); } + static inline void set_indigo() { set_color(LEDColorIndigo()); } + static inline void set_violet() { set_color(LEDColorViolet()); } #endif #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) - static LEDColor2 color; // last non-off color + static LEDColor color; // last non-off color static bool lights_on; // the last set color was "on" #endif diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index d761fa3a8b45..ca67d3e8f4b8 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -37,13 +37,13 @@ Marlin_NeoPixel neo; int8_t Marlin_NeoPixel::neoindex; -Adafruit_NeoPixel Marlin_NeoPixel::adaneo(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800); +Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800); #ifdef NEOPIXEL_BKGD_LED_INDEX void Marlin_NeoPixel::set_color_background() { uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR; - set_pixel_color(NEOPIXEL_BKGD_LED_INDEX, adaneo.Color(background_color[0], background_color[1], background_color[2], background_color[3])); + set_pixel_color(NEOPIXEL_BKGD_LED_INDEX, adaneo1.Color(background_color[0], background_color[1], background_color[2], background_color[3])); } #endif @@ -80,11 +80,11 @@ void Marlin_NeoPixel::init() { show(); // initialize to all off #if ENABLED(NEOPIXEL_STARTUP_TEST) - set_color_startup(adaneo.Color(255, 0, 0, 0)); // red + set_color_startup(adaneo1.Color(255, 0, 0, 0)); // red safe_delay(500); - set_color_startup(adaneo.Color(0, 255, 0, 0)); // green + set_color_startup(adaneo1.Color(0, 255, 0, 0)); // green safe_delay(500); - set_color_startup(adaneo.Color(0, 0, 255, 0)); // blue + set_color_startup(adaneo1.Color(0, 0, 255, 0)); // blue safe_delay(500); #endif @@ -93,15 +93,15 @@ void Marlin_NeoPixel::init() { #endif #if ENABLED(LED_USER_PRESET_STARTUP) - set_color(adaneo.Color(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE)); + set_color(adaneo1.Color(LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE)); #else - set_color(adaneo.Color(0, 0, 0, 0)); + set_color(adaneo1.Color(0, 0, 0, 0)); #endif } #if 0 bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p) { - const uint32_t color = adaneo.Color(r, g, b, w); + const uint32_t color = adaneo1.Color(r, g, b, w); set_brightness(p); #if DISABLED(NEOPIXEL_IS_SEQUENTIAL) set_color(color); @@ -118,12 +118,12 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint #if ENABLED(NEOPIXEL2_SEPARATE) - Marlin_NEOPIXEL2 neo2; + Marlin_NeoPixel2 neo2; - int8_t Marlin_NEOPIXEL2::neoindex; - Adafruit_NeoPixel Marlin_NEOPIXEL2::adaneo(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); + int8_t Marlin_NeoPixel2::neoindex; + Adafruit_NeoPixel Marlin_NeoPixel2::adaneo(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); - void Marlin_NEOPIXEL2::set_color(const uint32_t color) { + void Marlin_NeoPixel2::set_color(const uint32_t color) { if (get_neo_index() >= 0) { set_pixel_color(get_neo_index(), color); set_neo_index(-1); @@ -135,15 +135,15 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint show(); } - void Marlin_NEOPIXEL2::set_color_startup(const uint32_t color) { + void Marlin_NeoPixel2::set_color_startup(const uint32_t color) { for (uint16_t i = 0; i < pixels(); ++i) set_pixel_color(i, color); show(); } - void Marlin_NEOPIXEL2::init() { + void Marlin_NeoPixel2::init() { set_neo_index(-1); // -1 .. NEOPIXEL2_PIXELS-1 range - set_brightness(NEOPIXEL2_SEPARATE_BRIGHTNESS); // 0 .. 255 range + set_brightness(NEOPIXEL2_BRIGHTNESS); // 0 .. 255 range begin(); show(); // initialize to all off diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 78266038d639..f87241202636 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -129,7 +129,7 @@ class Marlin_NeoPixel { static inline uint16_t pixels() { TERN(NEOPIXEL2_INSERIES, return adaneo1.numPixels() * 2, return adaneo1.numPixels()); } static inline uint8_t brightness() { return adaneo1.getBrightness(); } static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - return adaneo.Color(r, g, b, w); + return adaneo1.Color(r, g, b, w); } }; diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index ae4076523e41..1b856a0a071f 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -57,6 +57,8 @@ void GcodeSuite::M150() { Marlin_NeoPixel &the_neo = neo; #if ENABLED(NEOPIXEL2_SEPARATE) if (parser.intval('S') == 1) { + Marlin_NeoPixel2 &the_neo = neo2; + LEDLights2 &the_leds = leds2; the_neo = neo2; the_leds = leds2; } diff --git a/platformio.ini b/platformio.ini index e3ff6c152634..a9bfccf9ef63 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,7 +18,7 @@ [platformio] src_dir = Marlin boards_dir = buildroot/share/PlatformIO/boards -default_envs = mega2560 +default_envs = LPC1769 include_dir = Marlin # From 3ffa4ca91dfa26a1fdfe1b0753c6b5e5f5c0574e Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sun, 23 Aug 2020 20:09:25 -0500 Subject: [PATCH 16/58] second index to stop M150 from bleeding into the second neopixel channel --- Marlin/src/feature/leds/neopixel.cpp | 2 +- Marlin/src/feature/leds/neopixel.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index ca67d3e8f4b8..37d2bad18802 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -120,7 +120,7 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint Marlin_NeoPixel2 neo2; - int8_t Marlin_NeoPixel2::neoindex; + int8_t Marlin_NeoPixel2::neoindex2; Adafruit_NeoPixel Marlin_NeoPixel2::adaneo(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); void Marlin_NeoPixel2::set_color(const uint32_t color) { diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index f87241202636..68c653397422 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -141,7 +141,7 @@ extern Marlin_NeoPixel neo; class Marlin_NeoPixel2 { private: static Adafruit_NeoPixel adaneo; - static int8_t neoindex; + static int8_t neoindex2; public: static void init(); @@ -149,8 +149,8 @@ extern Marlin_NeoPixel neo; static void set_color(const uint32_t c); - FORCE_INLINE static void set_neo_index(const int8_t neoIndex) { neoindex = neoIndex; } - FORCE_INLINE static int8_t get_neo_index() { return neoindex; } + FORCE_INLINE static void set_neo_index(const int8_t neoIndex2) { neoindex2 = neoIndex2; } + FORCE_INLINE static int8_t get_neo_index() { return neoindex2; } static inline void begin() { adaneo.begin(); From ca79f2b5364da6fb9ea3c8e28bbb4a043bff4532 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 22:40:10 -0500 Subject: [PATCH 17/58] Who needs accessors? --- Marlin/src/feature/leds/neopixel.cpp | 18 +++++++++--------- Marlin/src/feature/leds/neopixel.h | 19 ++++--------------- Marlin/src/gcode/feature/leds/M150.cpp | 4 +--- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 37d2bad18802..28878ae30981 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -49,9 +49,9 @@ Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIX #endif void Marlin_NeoPixel::set_color(const uint32_t color) { - if (get_neo_index() >= 0) { - set_pixel_color(get_neo_index(), color); - set_neo_index(-1); + if (neoindex >= 0) { + set_pixel_color(neoindex, color); + neoindex = -1; } else { for (uint16_t i = 0; i < pixels(); ++i) { @@ -74,7 +74,7 @@ void Marlin_NeoPixel::set_color_startup(const uint32_t color) { } void Marlin_NeoPixel::init() { - set_neo_index(-1); // -1 .. NEOPIXEL_PIXELS-1 range + neoindex = -1; // -1 .. NEOPIXEL_PIXELS-1 range set_brightness(NEOPIXEL_BRIGHTNESS); // 0 .. 255 range begin(); show(); // initialize to all off @@ -120,13 +120,13 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint Marlin_NeoPixel2 neo2; - int8_t Marlin_NeoPixel2::neoindex2; + int8_t Marlin_NeoPixel2::neoindex; Adafruit_NeoPixel Marlin_NeoPixel2::adaneo(NEOPIXEL2_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE); void Marlin_NeoPixel2::set_color(const uint32_t color) { - if (get_neo_index() >= 0) { - set_pixel_color(get_neo_index(), color); - set_neo_index(-1); + if (neoindex >= 0) { + set_pixel_color(neoindex, color); + neoindex = -1; } else { for (uint16_t i = 0; i < pixels(); ++i) @@ -142,7 +142,7 @@ bool Marlin_NeoPixel::set_led_color(const uint8_t r, const uint8_t g, const uint } void Marlin_NeoPixel2::init() { - set_neo_index(-1); // -1 .. NEOPIXEL2_PIXELS-1 range + neoindex = -1; // -1 .. NEOPIXEL2_PIXELS-1 range set_brightness(NEOPIXEL2_BRIGHTNESS); // 0 .. 255 range begin(); show(); // initialize to all off diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 68c653397422..e30fbf1ce738 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -38,7 +38,7 @@ // Defines // ------------------------ -#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE +#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE #define MULTIPLE_NEOPIXEL_TYPES 1 #endif @@ -73,19 +73,14 @@ class Marlin_NeoPixel { static void set_color(const uint32_t c); - FORCE_INLINE static void set_neo_index(const int8_t neoIndex) { neoindex = neoIndex; } - FORCE_INLINE static int8_t get_neo_index() { return neoindex; } - #ifdef NEOPIXEL_BKGD_LED_INDEX static void set_color_background(); #endif static inline void begin() { adaneo1.begin(); - #if ENABLED(NEOPIXEL2_INSERIES) + #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) adaneo2.begin(); - #else - TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.begin()); #endif } @@ -101,10 +96,8 @@ class Marlin_NeoPixel { static inline void set_brightness(const uint8_t b) { adaneo1.setBrightness(b); - #if ENABLED(NEOPIXEL2_INSERIES) + #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) adaneo2.setBrightness(b); - #else - TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setBrightness(b)); #endif } @@ -141,7 +134,7 @@ extern Marlin_NeoPixel neo; class Marlin_NeoPixel2 { private: static Adafruit_NeoPixel adaneo; - static int8_t neoindex2; + static int8_t neoindex; public: static void init(); @@ -149,9 +142,6 @@ extern Marlin_NeoPixel neo; static void set_color(const uint32_t c); - FORCE_INLINE static void set_neo_index(const int8_t neoIndex2) { neoindex2 = neoIndex2; } - FORCE_INLINE static int8_t get_neo_index() { return neoindex2; } - static inline void begin() { adaneo.begin(); } @@ -166,7 +156,6 @@ extern Marlin_NeoPixel neo; static inline void show() { adaneo.show(); - adaneo.setPin(NEOPIXEL2_PIN); } #if 0 diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 1b856a0a071f..fe8747323137 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -57,13 +57,11 @@ void GcodeSuite::M150() { Marlin_NeoPixel &the_neo = neo; #if ENABLED(NEOPIXEL2_SEPARATE) if (parser.intval('S') == 1) { - Marlin_NeoPixel2 &the_neo = neo2; - LEDLights2 &the_leds = leds2; the_neo = neo2; the_leds = leds2; } #endif - the_neo.set_neo_index(parser.intval('I', -1)); + the_neo.neoindex = parser.intval('I', -1); #endif the_leds.set_color(MakeLEDColor( parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0, From c60bea4649853dfd2660b7edc8c667c048ca1811 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 22:50:06 -0500 Subject: [PATCH 18/58] Thanks but no thanks for your configs --- Marlin/Configuration.h | 278 +++++++----------- Marlin/Configuration_adv.h | 65 ++-- .../src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h | 2 +- platformio.ini | 2 +- 4 files changed, 135 insertions(+), 212 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 585b05072220..610b1bd5e26a 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -110,7 +110,7 @@ * Select a secondary serial port on the board to use for communication with the host. * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ -#define SERIAL_PORT_2 -1 +//#define SERIAL_PORT_2 -1 /** * This setting determines the communication speed of the printer. @@ -128,7 +128,7 @@ // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_BTT_SKR_V1_4_TURBO + #define MOTHERBOARD BOARD_RAMPS_14_EFB #endif // Name displayed in the LCD "Ready" message and Info menu @@ -416,7 +416,7 @@ * 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below. * 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below. */ -#define TEMP_SENSOR_0 5 +#define TEMP_SENSOR_0 1 #define TEMP_SENSOR_1 0 #define TEMP_SENSOR_2 0 #define TEMP_SENSOR_3 0 @@ -424,7 +424,7 @@ #define TEMP_SENSOR_5 0 #define TEMP_SENSOR_6 0 #define TEMP_SENSOR_7 0 -#define TEMP_SENSOR_BED 5 +#define TEMP_SENSOR_BED 0 #define TEMP_SENSOR_PROBE 0 #define TEMP_SENSOR_CHAMBER 0 @@ -435,13 +435,13 @@ // Use temp sensor 1 as a redundant sensor with sensor 0. If the readings // from the two sensors differ too much the print will be aborted. //#define TEMP_SENSOR_1_AS_REDUNDANT -#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 5 +#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10 #define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109 #define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer #define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target -#define TEMP_BED_RESIDENCY_TIME 1 // (seconds) Time to wait for bed to "settle" in M190 +#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190 #define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer #define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target @@ -460,7 +460,7 @@ // Above this temperature the heater will be switched off. // This can protect components from overheating, but NOT from shorts and failures. // (Use MINTEMP for thermistor short/failure protection.) -#define HEATER_0_MAXTEMP 300 +#define HEATER_0_MAXTEMP 275 #define HEATER_1_MAXTEMP 275 #define HEATER_2_MAXTEMP 275 #define HEATER_3_MAXTEMP 275 @@ -468,7 +468,7 @@ #define HEATER_5_MAXTEMP 275 #define HEATER_6_MAXTEMP 275 #define HEATER_7_MAXTEMP 275 -#define BED_MAXTEMP 115 +#define BED_MAXTEMP 150 //=========================================================================== //============================= PID Settings ================================ @@ -482,21 +482,17 @@ #define PID_K1 0.95 // Smoothing factor within any PID loop #if ENABLED(PIDTEMP) - #define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) - #define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) + //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) + //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with gcode: M301 E[extruder number, 0-2] // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it - // E3D V6 30mm Fan - #define DEFAULT_Kp 21.21 - #define DEFAULT_Ki 1.78 - #define DEFAULT_Kd 63.23 // Ultimaker - //#define DEFAULT_Kp 22.2 - //#define DEFAULT_Ki 1.08 - //#define DEFAULT_Kd 114 + #define DEFAULT_Kp 22.2 + #define DEFAULT_Ki 1.08 + #define DEFAULT_Kd 114 // MakerGear //#define DEFAULT_Kp 7.0 @@ -545,9 +541,9 @@ //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) - //#define DEFAULT_bedKp 10.00 - //#define DEFAULT_bedKi .023 - //#define DEFAULT_bedKd 305.4 + #define DEFAULT_bedKp 10.00 + #define DEFAULT_bedKi .023 + #define DEFAULT_bedKd 305.4 //120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //from pidautotune @@ -555,10 +551,6 @@ //#define DEFAULT_bedKi 1.41 //#define DEFAULT_bedKd 1675.16 -//D-force - #define DEFAULT_bedKp 22.97 - #define DEFAULT_bedKi 3.76 - #define DEFAULT_bedKd 29.2 // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. #endif // PIDTEMPBED @@ -608,7 +600,7 @@ #define THERMAL_PROTECTION_HOTENDS // Enable thermal protection for all extruders #define THERMAL_PROTECTION_BED // Enable thermal protection for the heated bed -//#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber +#define THERMAL_PROTECTION_CHAMBER // Enable thermal protection for the heated chamber //=========================================================================== //============================= Mechanical Settings ========================= @@ -625,67 +617,6 @@ //#define COREZX //#define COREZY -//=========================================================================== -//============================== Delta Settings ============================= -//=========================================================================== -// Enable DELTA kinematics and most of the default configuration for Deltas -#define DELTA - -#if ENABLED(DELTA) - - // Make delta curves from many straight lines (linear interpolation). - // This is a trade-off between visible corners (not enough segments) - // and processor overload (too many expensive sqrt calls). - #define DELTA_SEGMENTS_PER_SECOND 200 - - // After homing move down to a height where XY movement is unconstrained - //#define DELTA_HOME_TO_SAFE_ZONE - - // Delta calibration menu - // uncomment to add three points calibration menu option. - // See http://minow.blogspot.com/index.html#4918805519571907051 - #define DELTA_CALIBRATION_MENU - - // uncomment to add G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results) - #define DELTA_AUTO_CALIBRATION - - // NOTE NB all values for DELTA_* values MUST be floating point, so always have a decimal point in them - - #if ENABLED(DELTA_AUTO_CALIBRATION) - // set the default number of probe points : n*n (1 -> 7) - #define DELTA_CALIBRATION_DEFAULT_POINTS 4.0 - #endif - - #if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU) - // Set the steprate for papertest probing - #define PROBE_MANUALLY_STEP 0.05 // (mm) - #endif - - // Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers). - #define DELTA_PRINTABLE_RADIUS 120.0 // (mm) - - // Center-to-center distance of the holes in the diagonal push rods. - #define DELTA_DIAGONAL_ROD 304.14 // (mm) - - // Distance between bed and nozzle Z home position - #define DELTA_HEIGHT 199.61 // (mm) Get this value from G33 auto calibrate - - #define DELTA_ENDSTOP_ADJ { 0.0, -2.30, -1.89 } // Get these values from G33 auto calibrate - - // Horizontal distance bridged by diagonal push rods when effector is centered. - #define DELTA_RADIUS 145.94 // (mm) Get this value from G33 auto calibrate - - // Trim adjustments for individual towers - // tower angle corrections for X and Y tower / rotate XYZ so Z tower angle = 0 - // measured in degrees anticlockwise looking from above the printer - #define DELTA_TOWER_ANGLE_TRIM {0.17, -0.21, 0.04} // Get these values from G33 auto calibrate - - // Delta radius and diagonal rod adjustments (mm) - //#define DELTA_RADIUS_TRIM_TOWER { 0.0, 0.0, 0.0 } - //#define DELTA_DIAGONAL_ROD_TRIM_TOWER { 0.0, 0.0, 0.0 } - -#endif - //=========================================================================== //============================== Endstop Settings =========================== //=========================================================================== @@ -695,12 +626,12 @@ // Specify here all the endstop connectors that are connected to any endstop or probe. // Almost all printers will be using one per axis. Probes will use one or more of the // extra connectors. Leave undefined any used for non-endstop and non-probe purposes. -//#define USE_XMIN_PLUG -//#define USE_YMIN_PLUG -//#define USE_ZMIN_PLUG // a Z probe -#define USE_XMAX_PLUG -#define USE_YMAX_PLUG -#define USE_ZMAX_PLUG +#define USE_XMIN_PLUG +#define USE_YMIN_PLUG +#define USE_ZMIN_PLUG +//#define USE_XMAX_PLUG +//#define USE_YMAX_PLUG +//#define USE_ZMAX_PLUG // Enable pullup for all endstops to prevent a floating state #define ENDSTOPPULLUPS @@ -732,9 +663,9 @@ #define X_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Y_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Z_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. -#define X_MAX_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop. -#define Y_MAX_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop. -#define Z_MAX_ENDSTOP_INVERTING true // Set to true to invert the logic of the endstop. +#define X_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. +#define Y_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. +#define Z_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Z_MIN_PROBE_ENDSTOP_INVERTING false // Set to true to invert the logic of the probe. /** @@ -753,15 +684,15 @@ * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] */ -#define X_DRIVER_TYPE TMC2209 -#define Y_DRIVER_TYPE TMC2209 -#define Z_DRIVER_TYPE TMC2209 +//#define X_DRIVER_TYPE A4988 +//#define Y_DRIVER_TYPE A4988 +//#define Z_DRIVER_TYPE A4988 //#define X2_DRIVER_TYPE A4988 //#define Y2_DRIVER_TYPE A4988 //#define Z2_DRIVER_TYPE A4988 //#define Z3_DRIVER_TYPE A4988 //#define Z4_DRIVER_TYPE A4988 -#define E0_DRIVER_TYPE TMC2209 +//#define E0_DRIVER_TYPE A4988 //#define E1_DRIVER_TYPE A4988 //#define E2_DRIVER_TYPE A4988 //#define E3_DRIVER_TYPE A4988 @@ -816,23 +747,14 @@ * Override with M92 * X, Y, Z, E0 [, E1[, E2...]] */ - -// variables to calculate steps -#define XYZ_FULL_STEPS_PER_ROTATION 200 -#define XYZ_MICROSTEPS 16 -#define XYZ_BELT_PITCH 2 -#define XYZ_PULLEY_TEETH 16 - -// delta speeds must be the same on xyz -#define DEFAULT_XYZ_STEPS_PER_UNIT ((XYZ_FULL_STEPS_PER_ROTATION) * (XYZ_MICROSTEPS) / double(XYZ_BELT_PITCH) / double(XYZ_PULLEY_TEETH)) -#define DEFAULT_AXIS_STEPS_PER_UNIT { DEFAULT_XYZ_STEPS_PER_UNIT, DEFAULT_XYZ_STEPS_PER_UNIT, DEFAULT_XYZ_STEPS_PER_UNIT, 139 } // default steps per unit for Kossel (GT2, 20 tooth) +#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 4000, 500 } /** * Default Max Feed Rate (mm/s) * Override with M203 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_FEEDRATE { 200, 200, 200, 25 } +#define DEFAULT_MAX_FEEDRATE { 300, 300, 5, 25 } //#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2 #if ENABLED(LIMITED_MAX_FR_EDITING) @@ -845,7 +767,7 @@ * Override with M201 * X, Y, Z, E0 [, E1[, E2...]] */ -#define DEFAULT_MAX_ACCELERATION { 4000, 4000, 4000, 4000 } +#define DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 10000 } //#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2 #if ENABLED(LIMITED_MAX_ACCEL_EDITING) @@ -872,11 +794,11 @@ * When changing speed and direction, if the difference is less than the * value set here, it may happen instantaneously. */ -#define CLASSIC_JERK +//#define CLASSIC_JERK #if ENABLED(CLASSIC_JERK) #define DEFAULT_XJERK 10.0 - #define DEFAULT_YJERK DEFAULT_XJERK - #define DEFAULT_ZJERK DEFAULT_XJERK // Must be same as XY for delta + #define DEFAULT_YJERK 10.0 + #define DEFAULT_ZJERK 0.3 //#define TRAVEL_EXTRA_XYJERK 0.0 // Additional jerk allowance for all travel moves @@ -909,7 +831,7 @@ * * See https://github.com/synthetos/TinyG/wiki/Jerk-Controlled-Motion-Explained */ -#define S_CURVE_ACCELERATION +//#define S_CURVE_ACCELERATION //=========================================================================== //============================= Z Probe Options ============================= @@ -925,7 +847,7 @@ * The probe replaces the Z-MIN endstop and is used for Z homing. * (Automatically enables USE_PROBE_FOR_Z_HOMING.) */ -//#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN +#define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN // Force the use of the probe for Z-axis homing //#define USE_PROBE_FOR_Z_HOMING @@ -946,7 +868,7 @@ * - normally-open switches to 5V and D32. * */ -#define Z_MIN_PROBE_PIN P0_10 // Pin 32 is the RAMPS default +//#define Z_MIN_PROBE_PIN 32 // Pin 32 is the RAMPS default /** * Probe Type @@ -973,7 +895,7 @@ * Use the nozzle as the probe, as with a conductive * nozzle system or a piezo-electric smart effector. */ -#define NOZZLE_AS_PROBE +//#define NOZZLE_AS_PROBE /** * Z Servo Probe, such as an endstop switch on a rotating arm. @@ -1023,10 +945,10 @@ #endif // Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J -// When the pin is defined you can use M672 to set/reset the probe sensitivity. -#define DUET_SMART_EFFECTOR +// When the pin is defined you can use M672 to set/reset the probe sensivity. +//#define DUET_SMART_EFFECTOR #if ENABLED(DUET_SMART_EFFECTOR) - #define SMART_EFFECTOR_MOD_PIN P2_00 // Connect a GPIO pin to the Smart Effector MOD pin + #define SMART_EFFECTOR_MOD_PIN -1 // Connect a GPIO pin to the Smart Effector MOD pin #endif /** @@ -1071,20 +993,20 @@ * | [-] | * O-- FRONT --+ */ -#define NOZZLE_TO_PROBE_OFFSET { 0.0, 0.0, 0.11 } +#define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 } // Most probes should stay away from the edges of the bed, but // with NOZZLE_AS_PROBE this can be negative for a wider probing area. #define PROBING_MARGIN 10 // X and Y axis travel speed (mm/min) between probes -#define XY_PROBE_SPEED 1200 +#define XY_PROBE_SPEED (133*60) // Feedrate (mm/min) for the first approach when double-probing (MULTIPLE_PROBING == 2) -#define Z_PROBE_SPEED_FAST 1200 +#define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z // Feedrate (mm/min) for the "accurate" probe of each point -#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 1) +#define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2) /** * Multiple Probing @@ -1112,10 +1034,10 @@ * Example: `M851 Z-5` with a CLEARANCE of 4 => 9mm from bed to nozzle. * But: `M851 Z+1` with a CLEARANCE of 2 => 2mm from bed to nozzle. */ -#define Z_CLEARANCE_DEPLOY_PROBE 5 // Z Clearance for Deploy/Stow -#define Z_CLEARANCE_BETWEEN_PROBES 2 // Z Clearance between probe points +#define Z_CLEARANCE_DEPLOY_PROBE 10 // Z Clearance for Deploy/Stow +#define Z_CLEARANCE_BETWEEN_PROBES 5 // Z Clearance between probe points #define Z_CLEARANCE_MULTI_PROBE 5 // Z Clearance between multiple probes -//#define Z_AFTER_PROBING 10 // Z position after probing is done +//#define Z_AFTER_PROBING 5 // Z position after probing is done #define Z_PROBE_LOW_POINT -2 // Farthest distance below the trigger-point to go before stopping @@ -1124,7 +1046,7 @@ #define Z_PROBE_OFFSET_RANGE_MAX 20 // Enable the M48 repeatability test to test probe accuracy -#define Z_MIN_PROBE_REPEATABILITY_TEST +//#define Z_MIN_PROBE_REPEATABILITY_TEST // Before deploy/stow pause for user confirmation //#define PAUSE_BEFORE_DEPLOY_STOW @@ -1145,7 +1067,7 @@ #endif //#define PROBING_FANS_OFF // Turn fans off when probing //#define PROBING_STEPPERS_OFF // Turn steppers off (unless needed to hold position) when probing -#define DELAY_BEFORE_PROBING 400 // (ms) To prevent vibrations from triggering piezo sensors +//#define DELAY_BEFORE_PROBING 200 // (ms) To prevent vibrations from triggering piezo sensors // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1 // :{ 0:'Low', 1:'High' } @@ -1172,13 +1094,13 @@ // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. #define INVERT_X_DIR false -#define INVERT_Y_DIR false +#define INVERT_Y_DIR true #define INVERT_Z_DIR false // @section extruder // For direct drive extruder v9 set to true, for geared extruder set to false. -#define INVERT_E0_DIR true +#define INVERT_E0_DIR false #define INVERT_E1_DIR false #define INVERT_E2_DIR false #define INVERT_E3_DIR false @@ -1200,22 +1122,23 @@ // Direction of endstops when homing; 1=MAX, -1=MIN // :[-1,1] -#define X_HOME_DIR 1 // deltas always home to max -#define Y_HOME_DIR 1 -#define Z_HOME_DIR 1 +#define X_HOME_DIR -1 +#define Y_HOME_DIR -1 +#define Z_HOME_DIR -1 // @section machine // The size of the print bed -#define X_BED_SIZE ((DELTA_PRINTABLE_RADIUS) * 2) -#define Y_BED_SIZE ((DELTA_PRINTABLE_RADIUS) * 2) +#define X_BED_SIZE 200 +#define Y_BED_SIZE 200 + // Travel limits (mm) after homing, corresponding to endstop positions. -#define X_MIN_POS -(DELTA_PRINTABLE_RADIUS) -#define Y_MIN_POS -(DELTA_PRINTABLE_RADIUS) +#define X_MIN_POS 0 +#define Y_MIN_POS 0 #define Z_MIN_POS 0 -#define X_MAX_POS DELTA_PRINTABLE_RADIUS -#define Y_MAX_POS DELTA_PRINTABLE_RADIUS -#define Z_MAX_POS MANUAL_Z_HOME_POS +#define X_MAX_POS X_BED_SIZE +#define Y_MAX_POS Y_BED_SIZE +#define Z_MAX_POS 200 /** * Software Endstops @@ -1319,21 +1242,21 @@ //#define AUTO_BED_LEVELING_3POINT //#define AUTO_BED_LEVELING_LINEAR //#define AUTO_BED_LEVELING_BILINEAR -#define AUTO_BED_LEVELING_UBL +//#define AUTO_BED_LEVELING_UBL //#define MESH_BED_LEVELING /** * Normally G28 leaves leveling disabled on completion. Enable * this option to have G28 restore the prior leveling state. */ -#define RESTORE_LEVELING_AFTER_G28 +//#define RESTORE_LEVELING_AFTER_G28 /** * Enable detailed logging of G28, G29, M48, etc. * Turn on with the command 'M111 S32'. * NOTE: Requires a lot of PROGMEM! */ -#define DEBUG_LEVELING_FEATURE +//#define DEBUG_LEVELING_FEATURE #if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL) // Gradually reduce leveling correction until a set height is reached, @@ -1350,7 +1273,7 @@ /** * Enable the G26 Mesh Validation Pattern tool. */ - #define G26_MESH_VALIDATION + //#define G26_MESH_VALIDATION #if ENABLED(G26_MESH_VALIDATION) #define MESH_TEST_NOZZLE_SIZE 0.4 // (mm) Diameter of primary nozzle. #define MESH_TEST_LAYER_HEIGHT 0.2 // (mm) Default layer height for the G26 Mesh Validation Tool. @@ -1365,7 +1288,7 @@ #if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR) // Set the number of grid points per dimension. - #define GRID_MAX_POINTS_X 11 + #define GRID_MAX_POINTS_X 3 #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X // Probe along the Y axis, advancing X after each column @@ -1381,7 +1304,7 @@ // Experimental Subdivision of the grid by Catmull-Rom method. // Synthesizes intermediate points to produce a more detailed mesh. // - #define ABL_BILINEAR_SUBDIVISION + //#define ABL_BILINEAR_SUBDIVISION #if ENABLED(ABL_BILINEAR_SUBDIVISION) // Number of subdivisions between probe points #define BILINEAR_SUBDIVISIONS 3 @@ -1397,11 +1320,11 @@ //#define MESH_EDIT_GFX_OVERLAY // Display a graphics overlay while editing the mesh - #define MESH_INSET 0 // Set Mesh bounds as an inset region of the bed - #define GRID_MAX_POINTS_X 11 // Don't use more than 15 points per axis, implementation limited. + #define MESH_INSET 1 // Set Mesh bounds as an inset region of the bed + #define GRID_MAX_POINTS_X 10 // Don't use more than 15 points per axis, implementation limited. #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X - //#define UBL_MESH_EDIT_MOVES_Z // Sophisticated users prefer no movement of nozzle + #define UBL_MESH_EDIT_MOVES_Z // Sophisticated users prefer no movement of nozzle #define UBL_SAVE_ACTIVE_ON_M500 // Save the currently active mesh in the current slot on M500 //#define UBL_Z_RAISE_WHEN_OFF_MESH 2.5 // When the nozzle is off the mesh, this value is used @@ -1425,12 +1348,12 @@ * Add a bed leveling sub-menu for ABL or MBL. * Include a guided procedure if manual probing is enabled. */ -#define LCD_BED_LEVELING +//#define LCD_BED_LEVELING #if ENABLED(LCD_BED_LEVELING) #define MESH_EDIT_Z_STEP 0.025 // (mm) Step size while manually probing Z axis. #define LCD_PROBE_Z_RANGE 4 // (mm) Z Range centered on Z_MIN_POS for LCD Z adjustment - #define MESH_EDIT_MENU // Add a menu to edit mesh points + //#define MESH_EDIT_MENU // Add a menu to edit mesh points #endif // Add a menu item to move between bed corners for manual bed adjustment @@ -1452,13 +1375,13 @@ // @section homing // The center of the bed is at (X=0, Y=0) -#define BED_CENTER_AT_0_0 +//#define BED_CENTER_AT_0_0 // Manually set the home position. Leave these undefined for automatic settings. // For DELTA this is the top-center of the Cartesian print volume. //#define MANUAL_X_HOME_POS 0 //#define MANUAL_Y_HOME_POS 0 -#define MANUAL_Z_HOME_POS DELTA_HEIGHT // Distance between the nozzle to printbed after homing +//#define MANUAL_Z_HOME_POS 0 // Use "Z Safe Homing" to avoid homing with a Z probe outside the bed area. // @@ -1476,8 +1399,9 @@ #define Z_SAFE_HOMING_Y_POINT Y_CENTER // Y point for Z homing #endif -// Delta only homes to Z -#define HOMING_FEEDRATE_Z (100*15) +// Homing speeds (mm/min) +#define HOMING_FEEDRATE_XY (50*60) +#define HOMING_FEEDRATE_Z (4*60) // Validate that endstops are triggered on homing moves #define VALIDATE_HOMING_ENDSTOPS @@ -1554,7 +1478,7 @@ * M501 - Read settings from EEPROM. (i.e., Throw away unsaved changes) * M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.) */ -#define EEPROM_SETTINGS // Persistent storage with M500 and M501 +//#define EEPROM_SETTINGS // Persistent storage with M500 and M501 //#define DISABLE_M503 // Saves ~2700 bytes of PROGMEM. Disable for release! #define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM. #define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load @@ -1569,7 +1493,7 @@ // every couple of seconds when it can't accept commands. // #define HOST_KEEPALIVE_FEATURE // Disable this if your host doesn't like keepalive messages -#define DEFAULT_KEEPALIVE_INTERVAL 3 // Number of seconds between "busy" messages. Set with M113. +#define DEFAULT_KEEPALIVE_INTERVAL 2 // Number of seconds between "busy" messages. Set with M113. #define BUSY_WHILE_HEATING // Some hosts require "busy" messages even during heating // @@ -1793,7 +1717,7 @@ * * :['JAPANESE', 'WESTERN', 'CYRILLIC'] */ -#define DISPLAY_CHARSET_HD44780 WESTERN +#define DISPLAY_CHARSET_HD44780 JAPANESE /** * Info Screen Style (0:Classic, 1:Prusa) @@ -1809,7 +1733,7 @@ * you must uncomment the following option or it won't work. * */ -#define SDSUPPORT +//#define SDSUPPORT /** * SD CARD: SPI SPEED @@ -1826,7 +1750,7 @@ * * Use CRC checks and retries on the SD communication. */ -#define SD_CHECK_AND_RETRY +//#define SD_CHECK_AND_RETRY /** * LCD Menu Items @@ -1874,7 +1798,7 @@ // If CLOCKWISE normally moves DOWN this makes it go UP. // If CLOCKWISE normally moves UP this makes it go DOWN. // -#define REVERSE_MENU_DIRECTION +//#define REVERSE_MENU_DIRECTION // // This option reverses the encoder direction for Select Screen. @@ -1897,7 +1821,7 @@ // If you have a speaker that can produce tones, enable it here. // By default Marlin assumes you have a buzzer with a fixed frequency. // -#define SPEAKER +//#define SPEAKER // // The duration and frequency for the UI feedback sound. @@ -1920,7 +1844,7 @@ // // Note: Usually sold with a white PCB. // -#define REPRAP_DISCOUNT_SMART_CONTROLLER +//#define REPRAP_DISCOUNT_SMART_CONTROLLER // // Original RADDS LCD Display+Encoder+SDCardReader @@ -2432,24 +2356,24 @@ #endif // Support for Adafruit NeoPixel LED driver -#define NEOPIXEL_LED +//#define NEOPIXEL_LED #if ENABLED(NEOPIXEL_LED) - #define NEOPIXEL_TYPE NEO_GRB // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - #define NEOPIXEL_PIN P1_24 // LED driving pin - #define NEOPIXEL2_TYPE NEO_GRB - #define NEOPIXEL2_PIN P1_25 + #define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) + #define NEOPIXEL_PIN 4 // LED driving pin + //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE + //#define NEOPIXEL2_PIN 5 //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel - #define NEOPIXEL_PIXELS 9 // Number of LEDs in the strip, larger of 2 strips if 2 neopixel strips are used + #define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip. (Longest strip when NEOPIXEL2_SEPARATE is disabled.) #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) - #define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup + //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup // Support for second Adafruit NeoPixel LED driver controlled with M150 S1 ... - #define NEOPIXEL2_SEPARATE + //#define NEOPIXEL2_SEPARATE #if ENABLED(NEOPIXEL2_SEPARATE) - #define NEOPIXEL2_PIXELS 15 // Number of LEDs in the second strip, larger of 2 strips if 2 neopixel strips are used - #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) - #define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup on the separate channel + #define NEOPIXEL2_PIXELS 15 // Number of LEDs in the second strip + #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) + #define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup #endif // Use a single NeoPixel LED for static (background) lighting @@ -2489,7 +2413,7 @@ // (ms) Delay before the next move will start, to give the servo time to reach its target angle. // 300ms is a good value but you can try less delay. // If the servo can't reach the requested position, increase it. -//#define SERVO_DELAY { 300 } +#define SERVO_DELAY { 300 } // Only power servos during movement, otherwise leave off to prevent jitter //#define DEACTIVATE_SERVOS_AFTER_MOVE diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e388ba47170e..cf89b4da8ac3 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -481,7 +481,7 @@ */ //#define CASE_LIGHT_ENABLE #if ENABLED(CASE_LIGHT_ENABLE) - //#define CASE_LIGHT_PIN P1_25 // Override the default pin if needed + //#define CASE_LIGHT_PIN 4 // Override the default pin if needed #define INVERT_CASE_LIGHT false // Set true if Case Light is ON when pin is LOW #define CASE_LIGHT_DEFAULT_ON true // Set default power-up state on #define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // Set default power-up brightness (0-255, requires PWM pin) @@ -629,10 +629,10 @@ //#define SENSORLESS_BACKOFF_MM { 2, 2 } // (mm) Backoff from endstops before sensorless homing -#define HOMING_BUMP_MM { 5, 5, 5 } // (mm) Backoff from endstops after first bump -#define HOMING_BUMP_DIVISOR { 5, 5, 5 } // Re-Bump Speed Divisor (Divides the Homing Feedrate) +#define HOMING_BUMP_MM { 5, 5, 2 } // (mm) Backoff from endstops after first bump +#define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate) -#define HOMING_BACKOFF_POST_MM { 5, 5, 5 } // (mm) Backoff from endstops after homing +//#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm) Backoff from endstops after homing //#define QUICK_HOME // If G28 contains XY do a diagonal move first //#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X @@ -834,7 +834,7 @@ // Slow down the machine if the lookahead buffer is (by default) half full. // Increase the slowdown divisor for larger buffer sizes. -//#define SLOWDOWN +#define SLOWDOWN #if ENABLED(SLOWDOWN) #define SLOWDOWN_DIVISOR 2 #endif @@ -909,9 +909,9 @@ #define CALIBRATION_MEASUREMENT_RESOLUTION 0.01 // mm - #define CALIBRATION_FEEDRATE_SLOW 60 // mm/m - #define CALIBRATION_FEEDRATE_FAST 1200 // mm/m - #define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/m + #define CALIBRATION_FEEDRATE_SLOW 60 // mm/min + #define CALIBRATION_FEEDRATE_FAST 1200 // mm/min + #define CALIBRATION_FEEDRATE_TRAVEL 3000 // mm/min // The following parameters refer to the conical section of the nozzle tip. #define CALIBRATION_NOZZLE_TIP_HEIGHT 1.0 // mm @@ -1025,8 +1025,7 @@ // @section lcd #if EITHER(ULTIPANEL, EXTENSIBLE_UI) - #define MANUAL_FEEDRATE_XYZ 50*60 - #define MANUAL_FEEDRATE { MANUAL_FEEDRATE_XYZ, MANUAL_FEEDRATE_XYZ, MANUAL_FEEDRATE_XYZ, 60 } // Feedrates for manual moves along X, Y, Z, E from panel + #define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 2*60 } // (mm/min) Feedrates for manual moves along X, Y, Z, E from panel #define SHORT_MANUAL_Z_MOVE 0.025 // (mm) Smallest manual Z move (< 0.1mm) #if ENABLED(ULTIPANEL) #define MANUAL_E_MOVES_RELATIVE // Display extruder move distance rather than "position" @@ -1066,7 +1065,7 @@ //#define LED_CONTROL_MENU #if ENABLED(LED_CONTROL_MENU) #define LED_COLOR_PRESETS // Enable the Preset Color menu option - #define NEO2_COLOR_PRESETS // Enable a second NeoPixel Preset Color menu option + //#define NEO2_COLOR_PRESETS // Enable a second NeoPixel Preset Color menu option #if ENABLED(LED_COLOR_PRESETS) #define LED_USER_PRESET_RED 255 // User defined RED value #define LED_USER_PRESET_GREEN 128 // User defined GREEN value @@ -1088,7 +1087,7 @@ #endif // HAS_LCD_MENU // Scroll a longer status message into view -#define STATUS_MESSAGE_SCROLLING +//#define STATUS_MESSAGE_SCROLLING // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY @@ -1147,7 +1146,7 @@ //#define MENU_ADDAUTOSTART // Add a menu option to run auto#.g files - #define EVENT_GCODE_SD_ABORT "G28" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27") + #define EVENT_GCODE_SD_ABORT "G28XY" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27") #if ENABLED(PRINTER_EVENT_LEDS) #define PE_LEDS_COMPLETED_TIME (30*60) // (seconds) Time to keep the LED "done" color before restoring normal illumination @@ -1216,10 +1215,10 @@ #endif // This allows hosts to request long names for files and folders with M33 - #define LONG_FILENAME_HOST_SUPPORT + //#define LONG_FILENAME_HOST_SUPPORT // Enable this option to scroll long filenames in the SD card menu - #define SCROLL_LONG_FILENAMES + //#define SCROLL_LONG_FILENAMES // Leave the heaters on after Stop Print (not recommended!) //#define SD_ABORT_NO_COOLDOWN @@ -1303,7 +1302,7 @@ * * :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ] */ - #define SDCARD_CONNECTION LCD, ONBOARD + //#define SDCARD_CONNECTION LCD #endif // SDSUPPORT @@ -1380,14 +1379,14 @@ #define STATUS_HOTEND_INVERTED // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM) #define STATUS_HOTEND_ANIM // Use a second bitmap to indicate hotend heating #define STATUS_BED_ANIM // Use a second bitmap to indicate bed heating - //#define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating + #define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating //#define STATUS_CUTTER_ANIM // Use a second bitmap to indicate spindle / laser active //#define STATUS_ALT_BED_BITMAP // Use the alternative bed bitmap //#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap //#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames //#define STATUS_HEAT_PERCENT // Show heating in a progress bar //#define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving 399 bytes of flash) - #define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~‭3260 (or ~940) bytes of PROGMEM. + //#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~‭3260 (or ~940) bytes of PROGMEM. // Frivolous Game Options //#define MARLIN_BRICKOUT @@ -1616,12 +1615,12 @@ * * See https://marlinfw.org/docs/features/lin_advance.html for full instructions. */ -#define LIN_ADVANCE +//#define LIN_ADVANCE #if ENABLED(LIN_ADVANCE) //#define EXTRA_LIN_ADVANCE_K // Enable for second linear advance constants - #define LIN_ADVANCE_K 0.53 // Unit: mm compression per 1mm/s extruder speed + #define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed //#define LA_DEBUG // If enabled, this will generate debug information output over USB. - #define EXPERIMENTAL_SCURVE // Enable this option to permit S-Curve Acceleration + //#define EXPERIMENTAL_SCURVE // Enable this option to permit S-Curve Acceleration #endif // @section leveling @@ -1752,7 +1751,7 @@ // // G60/G61 Position Save and Return // -#define SAVED_POSITIONS 1 // Each saved position slot costs 12 bytes +//#define SAVED_POSITIONS 1 // Each saved position slot costs 12 bytes // // G2/G3 Arc Support @@ -1795,7 +1794,7 @@ #endif // Moves (or segments) with fewer steps than this will be joined with the next move -#define MIN_STEPS_PER_SEGMENT 1 +#define MIN_STEPS_PER_SEGMENT 6 /** * Minimum delay before and after setting the stepper DIR (in ns) @@ -1909,7 +1908,7 @@ * Currently handles M108, M112, M410, M876 * NOTE: Not yet implemented for all platforms. */ -#define EMERGENCY_PARSER +//#define EMERGENCY_PARSER // Bad Serial-connections can miss a received command by sending an 'ok' // Therefore some clients abort after 30 seconds in a timeout. @@ -1953,9 +1952,9 @@ * Note that M207 / M208 / M209 settings are saved to EEPROM. * */ -#define FWRETRACT +//#define FWRETRACT #if ENABLED(FWRETRACT) - //#define FWRETRACT_AUTORETRACT // Override slicer retractions + #define FWRETRACT_AUTORETRACT // Override slicer retractions #if ENABLED(FWRETRACT_AUTORETRACT) #define MIN_AUTORETRACT 0.1 // (mm) Don't convert E moves under this length #define MAX_AUTORETRACT 10.0 // (mm) Don't convert E moves over this length @@ -2453,7 +2452,7 @@ * M912 - Clear stepper driver overtemperature pre-warn condition flag. * M122 - Report driver parameters (Requires TMC_DEBUG) */ - #define MONITOR_DRIVER_STATUS + //#define MONITOR_DRIVER_STATUS #if ENABLED(MONITOR_DRIVER_STATUS) #define CURRENT_STEP_DOWN 50 // [mA] @@ -2542,13 +2541,13 @@ * Beta feature! * Create a 50/50 square wave step pulse optimal for stepper drivers. */ - #define SQUARE_WAVE_STEPPING + //#define SQUARE_WAVE_STEPPING /** * Enable M122 debugging command for TMC stepper drivers. * M122 S0/1 will enable continous reporting. */ - #define TMC_DEBUG + //#define TMC_DEBUG /** * You can set your own advanced settings by filling in predefined functions. @@ -3147,7 +3146,7 @@ //#define GCODE_QUOTED_STRINGS // Support for quoted string parameters #endif -#define GCODE_CASE_INSENSITIVE // Accept G-code sent to the firmware in lowercase +//#define GCODE_CASE_INSENSITIVE // Accept G-code sent to the firmware in lowercase //#define REPETIER_GCODE_M360 // Add commands originally from Repetier FW @@ -3225,9 +3224,9 @@ * Host Prompt Support enables Marlin to use the host for user prompts so * filament runout and other processes can be managed from the host side. */ -#define HOST_ACTION_COMMANDS +//#define HOST_ACTION_COMMANDS #if ENABLED(HOST_ACTION_COMMANDS) - #define HOST_PROMPT_SUPPORT + //#define HOST_PROMPT_SUPPORT #endif /** @@ -3521,7 +3520,7 @@ // // M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe // -#define PINS_DEBUGGING +//#define PINS_DEBUGGING // Enable Marlin dev mode which adds some special commands //#define MARLIN_DEV_MODE diff --git a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index af1e4c114518..b63acf516f57 100644 --- a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -113,7 +113,7 @@ #define FAN1_PIN PA8 // FAN (fan0 on board) e0 cool fan #define FAN2_PIN PB9 // FAN (fan1 on board) controller cool fan -// One neopixel onboard and a connector for other neopixels +// One NeoPixel onboard and a connector for other neopixels #define NEOPIXEL_PIN PC7 // The NEOPIXEL LED driving pin /** diff --git a/platformio.ini b/platformio.ini index a9bfccf9ef63..e3ff6c152634 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,7 +18,7 @@ [platformio] src_dir = Marlin boards_dir = buildroot/share/PlatformIO/boards -default_envs = LPC1769 +default_envs = mega2560 include_dir = Marlin # From b41a73305ac7c05cba6bfa275fae2d5e6a5af7c5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 23:35:35 -0500 Subject: [PATCH 19/58] Condition for conjoined strips --- Marlin/Configuration.h | 3 ++- Marlin/src/feature/leds/neopixel.cpp | 6 +++++- Marlin/src/feature/leds/neopixel.h | 12 ++++-------- Marlin/src/inc/Conditionals_LCD.h | 4 ++++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 610b1bd5e26a..3d8e8933f2a1 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2362,7 +2362,6 @@ #define NEOPIXEL_PIN 4 // LED driving pin //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE //#define NEOPIXEL2_PIN 5 - //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel #define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip. (Longest strip when NEOPIXEL2_SEPARATE is disabled.) #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) @@ -2374,6 +2373,8 @@ #define NEOPIXEL2_PIXELS 15 // Number of LEDs in the second strip #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) #define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup + #else + //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel #endif // Use a single NeoPixel LED for static (background) lighting diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 28878ae30981..f3fab53146d7 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -37,7 +37,11 @@ Marlin_NeoPixel neo; int8_t Marlin_NeoPixel::neoindex; -Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800); +Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIXEL_TYPE + NEO_KHZ800) + #if CONJOINED_NEOPIXEL + , Marlin_NeoPixel::adaneo2(NEOPIXEL_PIXELS, NEOPIXEL2_PIN, NEOPIXEL2_TYPE + NEO_KHZ800) + #endif +; #ifdef NEOPIXEL_BKGD_LED_INDEX diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index e30fbf1ce738..cccfba830fe2 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -61,7 +61,7 @@ class Marlin_NeoPixel { private: static Adafruit_NeoPixel adaneo1 - #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) + #if CONJOINED_NEOPIXEL , adaneo2 #endif ; @@ -79,9 +79,7 @@ class Marlin_NeoPixel { static inline void begin() { adaneo1.begin(); - #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) - adaneo2.begin(); - #endif + TERN_(CONJOINED_NEOPIXEL, adaneo2.begin()); } static inline void set_pixel_color(const uint16_t n, const uint32_t c) { @@ -96,15 +94,13 @@ class Marlin_NeoPixel { static inline void set_brightness(const uint8_t b) { adaneo1.setBrightness(b); - #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) - adaneo2.setBrightness(b); - #endif + TERN_(CONJOINED_NEOPIXEL, adaneo2.setBrightness(b)); } static inline void show() { adaneo1.show(); #if PIN_EXISTS(NEOPIXEL2) - #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) + #if CONJOINED_NEOPIXEL adaneo2.show(); #else adaneo1.setPin(NEOPIXEL2_PIN); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index ccafd413cfcb..cabbed76229d 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -780,3 +780,7 @@ #ifndef EXTRUDE_MINTEMP #define EXTRUDE_MINTEMP 170 #endif + +#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) && DISABLED(NEOPIXEL2_SEPARATE) + #define CONJOINED_NEOPIXEL 1 +#endif From 85b0a48a980963fd0e3b6e30eb907f8724e5f9d7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 23:12:16 -0500 Subject: [PATCH 20/58] Fix M150 to fit current design --- Marlin/src/feature/leds/leds.h | 74 +++++++++++++------------- Marlin/src/gcode/feature/leds/M150.cpp | 28 ++++++---- 2 files changed, 55 insertions(+), 47 deletions(-) diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 5c6596f6202f..534f0bd8a2c7 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -215,49 +215,49 @@ extern LEDLights leds; #if ENABLED(NEOPIXEL2_SEPARATE) -class LEDLights2 { -public: - LEDLights2() {} // ctor + class LEDLights2 { + public: + LEDLights2() {} // ctor - static void setup(); // init() + static void setup(); // init() - static void set_color(const LEDColor &color); + static void set_color(const LEDColor &color); - inline void set_color(uint8_t r, uint8_t g, uint8_t b - , uint8_t w=0 - #if ENABLED(NEOPIXEL2_SEPARATE) - , uint8_t i=NEOPIXEL2_BRIGHTNESS + inline void set_color(uint8_t r, uint8_t g, uint8_t b + , uint8_t w=0 + #if ENABLED(NEOPIXEL2_SEPARATE) + , uint8_t i=NEOPIXEL2_BRIGHTNESS + #endif + ) { + set_color(MakeLEDColor(r, g, b, w, i)); + } + + static inline void set_off() { set_color(LEDColorOff()); } + static inline void set_green() { set_color(LEDColorGreen()); } + static inline void set_white() { set_color(LEDColorWhite()); } + + #if ENABLED(NEO2_COLOR_PRESETS) + static const LEDColor2 defaultLEDColor2; + static inline void set_default() { set_color(defaultLEDColor); } + static inline void set_red() { set_color(LEDColorRed()); } + static inline void set_orange() { set_color(LEDColorOrange()); } + static inline void set_yellow() { set_color(LEDColorYellow()); } + static inline void set_blue() { set_color(LEDColorBlue()); } + static inline void set_indigo() { set_color(LEDColorIndigo()); } + static inline void set_violet() { set_color(LEDColorViolet()); } #endif - ) { - set_color(MakeLEDColor(r, g, b, w, i)); - } - - static inline void set_off() { set_color(LEDColorOff()); } - static inline void set_green() { set_color(LEDColorGreen()); } - static inline void set_white() { set_color(LEDColorWhite()); } - - #if ENABLED(NEO2_COLOR_PRESETS) - static const LEDColor2 defaultLEDColor2; - static inline void set_default() { set_color(defaultLEDColor); } - static inline void set_red() { set_color(LEDColorRed()); } - static inline void set_orange() { set_color(LEDColorOrange()); } - static inline void set_yellow() { set_color(LEDColorYellow()); } - static inline void set_blue() { set_color(LEDColorBlue()); } - static inline void set_indigo() { set_color(LEDColorIndigo()); } - static inline void set_violet() { set_color(LEDColorViolet()); } - #endif - #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) - static LEDColor color; // last non-off color - static bool lights_on; // the last set color was "on" - #endif + #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) + static LEDColor color; // last non-off color + static bool lights_on; // the last set color was "on" + #endif - #if ENABLED(LED_CONTROL_MENU) - static void toggle(); // swap "off" with color - static inline void update() { set_color(color); } - #endif -}; + #if ENABLED(LED_CONTROL_MENU) + static void toggle(); // swap "off" with color + static inline void update() { set_color(color); } + #endif + }; -extern LEDLights2 leds2; + extern LEDLights2 leds2; #endif // NEOPIXEL2_SEPARATE diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index fe8747323137..48aaea5fa5c5 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -52,24 +52,32 @@ * M150 I1 R ; Set NEOPIXEL index 1 to red */ void GcodeSuite::M150() { - LEDLights &the_leds = leds; + const bool unit = ENABLED(NEOPIXEL2_SEPARATE) ? parser.intval('S') : 0; + #if ENABLED(NEOPIXEL_LED) - Marlin_NeoPixel &the_neo = neo; + const uint8_t index = parser.intval('I', -1); #if ENABLED(NEOPIXEL2_SEPARATE) - if (parser.intval('S') == 1) { - the_neo = neo2; - the_leds = leds2; - } + const uint8_t brightness = unit ? neo2.brightness() : neo.brightness(); + *(unit ? &neo2.neoindex : &neo.neoindex) = index; + #else + const uint8_t brightness = neo.brightness(); + neo.neoindex = index; #endif - the_neo.neoindex = parser.intval('I', -1); #endif - the_leds.set_color(MakeLEDColor( + + const LEDColor color = MakeLEDColor( parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0, parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0, parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : the_neo.brightness() - )); + parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : brightness + ); + + #if ENABLED(NEOPIXEL2_SEPARATE) + if (unit == 1) { leds2.set_color(color); return; } + #endif + + leds.set_color(color); } #endif // HAS_COLOR_LEDS From 7d57af2bd93d9a28ec4b2713893841273adbbcaf Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Aug 2020 23:42:02 -0500 Subject: [PATCH 21/58] Patch neoindex --- Marlin/src/feature/leds/neopixel.h | 31 ++++++++------------------ Marlin/src/gcode/feature/leds/M150.cpp | 5 ++--- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index cccfba830fe2..fda2fed63e86 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -65,9 +65,10 @@ class Marlin_NeoPixel { , adaneo2 #endif ; - static int8_t neoindex; public: + static int8_t neoindex; + static void init(); static void set_color_startup(const uint32_t c); @@ -130,35 +131,21 @@ extern Marlin_NeoPixel neo; class Marlin_NeoPixel2 { private: static Adafruit_NeoPixel adaneo; - static int8_t neoindex; public: + static int8_t neoindex; + static void init(); static void set_color_startup(const uint32_t c); static void set_color(const uint32_t c); - static inline void begin() { - adaneo.begin(); - } - - static inline void set_pixel_color(const uint16_t n, const uint32_t c) { - adaneo.setPixelColor(n, c); - } - - static inline void set_brightness(const uint8_t b) { - adaneo.setBrightness(b); - } - - static inline void show() { - adaneo.show(); - } - - #if 0 - bool set_led_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w, const uint8_t p); - #endif + static inline void begin() { adaneo.begin(); } + static inline void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); } + static inline void set_brightness(const uint8_t b) { adaneo.setBrightness(b); } + static inline void show() { adaneo.show(); } - // Accessors for NEOPIXEL2_SEPARATE + // Accessors static inline uint16_t pixels() { return adaneo.numPixels();} static inline uint8_t brightness() { return adaneo.getBrightness(); } static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 48aaea5fa5c5..b13aa7f0d9f2 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -52,12 +52,11 @@ * M150 I1 R ; Set NEOPIXEL index 1 to red */ void GcodeSuite::M150() { - const bool unit = ENABLED(NEOPIXEL2_SEPARATE) ? parser.intval('S') : 0; - #if ENABLED(NEOPIXEL_LED) const uint8_t index = parser.intval('I', -1); #if ENABLED(NEOPIXEL2_SEPARATE) - const uint8_t brightness = unit ? neo2.brightness() : neo.brightness(); + const uint8_t unit = parser.intval('S'), + brightness = unit ? neo2.brightness() : neo.brightness(); *(unit ? &neo2.neoindex : &neo.neoindex) = index; #else const uint8_t brightness = neo.brightness(); From 0cf88aafd20bf7b497417027de2d051a7ff2eb2e Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Mon, 24 Aug 2020 13:03:28 -0500 Subject: [PATCH 22/58] dont know how i lost this config for some reason NEOPIXEL_SEPERATE ended up missing in config --- Marlin/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 3d8e8933f2a1..727005782942 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2420,4 +2420,4 @@ //#define DEACTIVATE_SERVOS_AFTER_MOVE // Allow servo angle to be edited and saved to EEPROM -//#define EDITABLE_SERVO_ANGLES +//#define EDITABLE_SERVO_ANGLES \ No newline at end of file From 8a355740707c0e9a17fab44a89ae1a1cebb998d6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 24 Aug 2020 13:24:19 -0500 Subject: [PATCH 23/58] Update Configuration.h --- Marlin/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 727005782942..3d8e8933f2a1 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2420,4 +2420,4 @@ //#define DEACTIVATE_SERVOS_AFTER_MOVE // Allow servo angle to be edited and saved to EEPROM -//#define EDITABLE_SERVO_ANGLES \ No newline at end of file +//#define EDITABLE_SERVO_ANGLES From 971e1301c7a8e61f4eb116f898fe132875288131 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Tue, 25 Aug 2020 10:40:44 -0500 Subject: [PATCH 24/58] Update leds.h trying out stuffs --- Marlin/src/feature/leds/leds.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 534f0bd8a2c7..a41beb41e4f8 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -247,15 +247,13 @@ extern LEDLights leds; static inline void set_violet() { set_color(LEDColorViolet()); } #endif - #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) + #if ENABLED(LED_CONTROL_MENU) static LEDColor color; // last non-off color static bool lights_on; // the last set color was "on" - #endif - - #if ENABLED(LED_CONTROL_MENU) static void toggle(); // swap "off" with color static inline void update() { set_color(color); } #endif + }; extern LEDLights2 leds2; From 563029d50108d66d9934a67cdc683cf6cdc3ff02 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Tue, 25 Aug 2020 11:52:38 -0500 Subject: [PATCH 25/58] Update neopixel.h with NeoPixel2_separate enabled there isnt a conflict if they are different Neo type --- Marlin/src/feature/leds/neopixel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index fda2fed63e86..269ee658a2fa 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -38,11 +38,11 @@ // Defines // ------------------------ -#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE +#if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE && DISABLED(NEOPIXEL2_SEPARATE) #define MULTIPLE_NEOPIXEL_TYPES 1 #endif -#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR +#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR || NEOPIXEL2_TYPE == NEO_RGB || NEOPIXEL2_TYPE == NEO_RBG || NEOPIXEL2_TYPE == NEO_GRB || NEOPIXEL2_TYPE == NEO_GBR || NEOPIXEL2_TYPE == NEO_BRG || NEOPIXEL2_TYPE == NEO_BGR #define NEOPIXEL_IS_RGB 1 #else #define NEOPIXEL_IS_RGBW 1 From 066ac3dfd2e6436eb936916da00f0b2a3d762bc9 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Tue, 25 Aug 2020 12:15:57 -0500 Subject: [PATCH 26/58] not needed i dont know why i thought this was needed if neopixel is't enabled then there wont be a neopixel2 --- Marlin/src/feature/leds/neopixel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 269ee658a2fa..51fa1e753d84 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -42,7 +42,7 @@ #define MULTIPLE_NEOPIXEL_TYPES 1 #endif -#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR || NEOPIXEL2_TYPE == NEO_RGB || NEOPIXEL2_TYPE == NEO_RBG || NEOPIXEL2_TYPE == NEO_GRB || NEOPIXEL2_TYPE == NEO_GBR || NEOPIXEL2_TYPE == NEO_BRG || NEOPIXEL2_TYPE == NEO_BGR +#if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR #define NEOPIXEL_IS_RGB 1 #else #define NEOPIXEL_IS_RGBW 1 From dfa25dc2f6871ed6c79385687ec4d4785de63d75 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Tue, 25 Aug 2020 12:31:30 -0500 Subject: [PATCH 27/58] add an extra example to M150 for Sn M150 S1 I1 R ; Set SEPARATE index 1 to red --- Marlin/src/gcode/feature/leds/M150.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index b13aa7f0d9f2..cf09bf14ead7 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -50,7 +50,9 @@ * M150 P127 ; Set LED 50% brightness * M150 P ; Set LED full brightness * M150 I1 R ; Set NEOPIXEL index 1 to red + * M150 S1 I1 R ; Set SEPARATE index 1 to red */ + void GcodeSuite::M150() { #if ENABLED(NEOPIXEL_LED) const uint8_t index = parser.intval('I', -1); From b540b00c3df4e59afa77c1fa0cab170cfebff9ec Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Tue, 25 Aug 2020 13:10:13 -0500 Subject: [PATCH 28/58] Fixed Typo for Neo2 color presets --- Marlin/src/feature/leds/leds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index a41beb41e4f8..061595a61b87 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -237,7 +237,7 @@ extern LEDLights leds; static inline void set_white() { set_color(LEDColorWhite()); } #if ENABLED(NEO2_COLOR_PRESETS) - static const LEDColor2 defaultLEDColor2; + static const LEDColor defaultLEDColor; static inline void set_default() { set_color(defaultLEDColor); } static inline void set_red() { set_color(LEDColorRed()); } static inline void set_orange() { set_color(LEDColorOrange()); } From 9b3a4a13757055d860ad2e93d37706aba7dbed7d Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Wed, 26 Aug 2020 12:36:21 -0500 Subject: [PATCH 29/58] tinkering I dont know why but in Conditionals_LCD.h MULTIPLE_NEOPIXEL_TYPES isn't carried over from its definition in neopixel.h --- Marlin/src/feature/leds/neopixel.cpp | 2 +- Marlin/src/feature/leds/neopixel.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index f3fab53146d7..27bbeb348c5d 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -30,7 +30,7 @@ #include "neopixel.h" -#if ENABLED(NEOPIXEL_STARTUP_TEST) +#if EITHER(NEOPIXEL_STARTUP_TEST, NEOPIXEL2_STARTUP_TEST) #include "../../core/utility.h" #endif diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 51fa1e753d84..b7bc90d42bee 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -40,6 +40,7 @@ #if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE && DISABLED(NEOPIXEL2_SEPARATE) #define MULTIPLE_NEOPIXEL_TYPES 1 + #define CONJOINED_NEOPIXEL 1 #endif #if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR @@ -80,7 +81,9 @@ class Marlin_NeoPixel { static inline void begin() { adaneo1.begin(); + #if CONJOINED_NEOPIXEL TERN_(CONJOINED_NEOPIXEL, adaneo2.begin()); + #endif } static inline void set_pixel_color(const uint16_t n, const uint32_t c) { @@ -89,13 +92,17 @@ class Marlin_NeoPixel { else adaneo1.setPixelColor(n, c); #else adaneo1.setPixelColor(n, c); + #if CONJOINED_NEOPIXEL TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c)); + #endif #endif } static inline void set_brightness(const uint8_t b) { adaneo1.setBrightness(b); + #if CONJOINED_NEOPIXEL TERN_(CONJOINED_NEOPIXEL, adaneo2.setBrightness(b)); + #endif } static inline void show() { @@ -127,7 +134,7 @@ extern Marlin_NeoPixel neo; // Neo pixel channel 2 #if ENABLED(NEOPIXEL2_SEPARATE) - + class Marlin_NeoPixel2 { private: static Adafruit_NeoPixel adaneo; From 88f050d25c0d30159a827ca465ce166484b3e7fd Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Thu, 27 Aug 2020 12:37:55 -0500 Subject: [PATCH 30/58] NEOPIXEL_SEPERATE to run diferent neopixel types moved the CONJOINED_NEOPIXEL from Conditionals_LCD.h to neopixel.h because MULTIPLE_NEOPIXEL_TYPE wouldnt trip the trigger in conditionals --- Marlin/src/feature/leds/leds.cpp | 2 +- Marlin/src/feature/leds/neopixel.h | 15 +++++++++++++++ Marlin/src/inc/Conditionals_LCD.h | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 9d51c701ec52..72e24d6d730e 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -184,7 +184,7 @@ void LEDLights::set_color(const LEDColor &incol void LEDLights2::set_color(const LEDColor &incol) { const uint32_t neocolor = LEDColorWhite() == incol - ? neo2.Color(NEO_WHITE) + ? neo2.Color(NEO2_WHITE) : neo2.Color(incol.r, incol.g, incol.b, incol.w); neo2.set_brightness(incol.i); neo2.set_color(neocolor); diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index b7bc90d42bee..d2f31d8a53b2 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -40,6 +40,9 @@ #if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE && DISABLED(NEOPIXEL2_SEPARATE) #define MULTIPLE_NEOPIXEL_TYPES 1 +#endif + +#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) #define CONJOINED_NEOPIXEL 1 #endif @@ -135,6 +138,18 @@ extern Marlin_NeoPixel neo; // Neo pixel channel 2 #if ENABLED(NEOPIXEL2_SEPARATE) + #if NEOPIXEL2_TYPE == NEO_RGB || NEOPIXEL2_TYPE == NEO_RBG || NEOPIXEL2_TYPE == NEO_GRB || NEOPIXEL2_TYPE == NEO_GBR || NEOPIXEL2_TYPE == NEO_BRG || NEOPIXEL2_TYPE == NEO_BGR + #define NEOPIXEL2_IS_RGB 1 + #else + #define NEOPIXEL2_IS_RGBW 1 + #endif + + #if NEOPIXEL2_IS_RGB + #define NEO2_WHITE 255, 255, 255, 0 + #else + #define NEO2_WHITE 0, 0, 0, 255 + #endif + class Marlin_NeoPixel2 { private: static Adafruit_NeoPixel adaneo; diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index cabbed76229d..e00dcab84d78 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -781,6 +781,7 @@ #define EXTRUDE_MINTEMP 170 #endif -#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) && DISABLED(NEOPIXEL2_SEPARATE) +// This flag indicates if Neopixel pins are shared or seperated +#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) #define CONJOINED_NEOPIXEL 1 #endif From 8b12f7bd58359add47bd4a501bb9bea9e80c424f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 27 Aug 2020 12:49:13 -0500 Subject: [PATCH 31/58] ffs --- Marlin/src/inc/Conditionals_LCD.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index e00dcab84d78..3efd32841b46 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -781,7 +781,7 @@ #define EXTRUDE_MINTEMP 170 #endif -// This flag indicates if Neopixel pins are shared or seperated +// This flag indicates if Neopixel pins are shared or separated #if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) #define CONJOINED_NEOPIXEL 1 #endif From dc7e16963784f534dc5f5b14ac33695a9a60872a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 27 Aug 2020 12:54:12 -0500 Subject: [PATCH 32/58] Update neopixel.h --- Marlin/src/feature/leds/neopixel.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index d2f31d8a53b2..f1f1d42530c2 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -84,9 +84,7 @@ class Marlin_NeoPixel { static inline void begin() { adaneo1.begin(); - #if CONJOINED_NEOPIXEL TERN_(CONJOINED_NEOPIXEL, adaneo2.begin()); - #endif } static inline void set_pixel_color(const uint16_t n, const uint32_t c) { @@ -95,17 +93,15 @@ class Marlin_NeoPixel { else adaneo1.setPixelColor(n, c); #else adaneo1.setPixelColor(n, c); - #if CONJOINED_NEOPIXEL - TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c)); - #endif + #if BOTH(CONJOINED_NEOPIXEL, MULTIPLE_NEOPIXEL_TYPES) + adaneo2.setPixelColor(n, c); + #endif #endif } static inline void set_brightness(const uint8_t b) { adaneo1.setBrightness(b); - #if CONJOINED_NEOPIXEL TERN_(CONJOINED_NEOPIXEL, adaneo2.setBrightness(b)); - #endif } static inline void show() { @@ -141,7 +137,7 @@ extern Marlin_NeoPixel neo; #if NEOPIXEL2_TYPE == NEO_RGB || NEOPIXEL2_TYPE == NEO_RBG || NEOPIXEL2_TYPE == NEO_GRB || NEOPIXEL2_TYPE == NEO_GBR || NEOPIXEL2_TYPE == NEO_BRG || NEOPIXEL2_TYPE == NEO_BGR #define NEOPIXEL2_IS_RGB 1 #else - #define NEOPIXEL2_IS_RGBW 1 + #define NEOPIXEL2_IS_RGBW 1 #endif #if NEOPIXEL2_IS_RGB From 5f0fd8c117a3cbfdf0ee1de0661fe827429c6a83 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 27 Aug 2020 12:58:31 -0500 Subject: [PATCH 33/58] Update leds.h --- Marlin/src/feature/leds/leds.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 061595a61b87..2aa18e1bdf6a 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -217,18 +217,13 @@ extern LEDLights leds; class LEDLights2 { public: - LEDLights2() {} // ctor + LEDLights2() {} static void setup(); // init() static void set_color(const LEDColor &color); - inline void set_color(uint8_t r, uint8_t g, uint8_t b - , uint8_t w=0 - #if ENABLED(NEOPIXEL2_SEPARATE) - , uint8_t i=NEOPIXEL2_BRIGHTNESS - #endif - ) { + inline void set_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w=0, uint8_t i=NEOPIXEL2_BRIGHTNESS) { set_color(MakeLEDColor(r, g, b, w, i)); } @@ -253,7 +248,6 @@ extern LEDLights leds; static void toggle(); // swap "off" with color static inline void update() { set_color(color); } #endif - }; extern LEDLights2 leds2; From b201138bf4e6b527475e3441614ec5f5f46c1bb1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 27 Aug 2020 13:02:10 -0500 Subject: [PATCH 34/58] Update leds.h --- Marlin/src/feature/leds/leds.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 2aa18e1bdf6a..a13f960a3bb2 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -155,11 +155,9 @@ class LEDLights { static inline void set_color(uint8_t r, uint8_t g, uint8_t b #if HAS_WHITE_LED , uint8_t w=0 - #if ENABLED(NEOPIXEL_LED) - , uint8_t i=NEOPIXEL_BRIGHTNESS - #endif #endif #if ENABLED(NEOPIXEL_LED) + , uint8_t i=NEOPIXEL_BRIGHTNESS , bool isSequence=false #endif ) { From ceeea2ff57f9f1a63b230562aac02939cafc4cc9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 27 Aug 2020 14:10:47 -0500 Subject: [PATCH 35/58] Update neopixel.h --- Marlin/src/feature/leds/neopixel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index f1f1d42530c2..81a0a8b1c660 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -93,7 +93,7 @@ class Marlin_NeoPixel { else adaneo1.setPixelColor(n, c); #else adaneo1.setPixelColor(n, c); - #if BOTH(CONJOINED_NEOPIXEL, MULTIPLE_NEOPIXEL_TYPES) + #if MULTIPLE_NEOPIXEL_TYPES adaneo2.setPixelColor(n, c); #endif #endif From dd9bb5251da9230fd5b0d3faeef9f2ca921bc46f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 27 Aug 2020 14:17:27 -0500 Subject: [PATCH 36/58] Update leds.cpp --- Marlin/src/feature/leds/leds.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 72e24d6d730e..01bca809260e 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -44,11 +44,8 @@ #if ENABLED(LED_COLOR_PRESETS) const LEDColor LEDLights::defaultLEDColor = MakeLEDColor( - LED_USER_PRESET_RED, - LED_USER_PRESET_GREEN, - LED_USER_PRESET_BLUE, - LED_USER_PRESET_WHITE, - LED_USER_PRESET_BRIGHTNESS + LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, + LED_USER_PRESET_WHITE, LED_USER_PRESET_BRIGHTNESS ); #endif @@ -117,12 +114,13 @@ void LEDLights::set_color(const LEDColor &incol // This variant uses 3-4 separate pins for the RGB(W) components. // If the pins can do PWM then their intensity will be set. - #define UPDATE_RGBW(C,c) do { if (PWM_PIN(RGB_LED_##C##_PIN)) \ + #define UPDATE_RGBW(C,c) do { \ + if (PWM_PIN(RGB_LED_##C##_PIN)) \ analogWrite(pin_t(RGB_LED_##C##_PIN), incol.c); \ - else WRITE(RGB_LED_##C##_PIN, incol.c ? HIGH : LOW); }while(0) - UPDATE_RGBW(R,r); - UPDATE_RGBW(G,g); - UPDATE_RGBW(B,b); + else \ + WRITE(RGB_LED_##C##_PIN, incol.c ? HIGH : LOW); \ + }while(0) + UPDATE_RGBW(R,r); UPDATE_RGBW(G,g); UPDATE_RGBW(B,b); #if ENABLED(RGBW_LED) UPDATE_RGBW(W,w); #endif @@ -162,11 +160,8 @@ void LEDLights::set_color(const LEDColor &incol #if ENABLED(NEO2_COLOR_PRESETS) const LEDColor LEDLights2::defaultLEDColor = MakeLEDColor( - NEO2_USER_PRESET_RED, - NEO2_USER_PRESET_GREEN, - NEO2_USER_PRESET_BLUE, - NEO2_USER_PRESET_WHITE, - NEO2_USER_PRESET_BRIGHTNESS + NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, + NEO2_USER_PRESET_WHITE, NEO2_USER_PRESET_BRIGHTNESS ); #endif From 19a20df7f779830f59c06cdbac10efd427921ad9 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Fri, 28 Aug 2020 15:23:41 -0500 Subject: [PATCH 37/58] Bugfix for Neopixel_separate adaneo1 still was set to NEOPIXEL2_PIN and was bleeding into the separated neopixel bank during start up and regular M150 commands found that adaneo never set a pin once NEOPIXEL2_SEPARATE is enabled --- Marlin/src/feature/leds/neopixel.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 81a0a8b1c660..20f10797869f 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -110,7 +110,9 @@ class Marlin_NeoPixel { #if CONJOINED_NEOPIXEL adaneo2.show(); #else + #if DISABLED(NEOPIXEL2_SEPARATE) adaneo1.setPin(NEOPIXEL2_PIN); + #endif adaneo1.show(); adaneo1.setPin(NEOPIXEL_PIN); #endif @@ -161,7 +163,10 @@ extern Marlin_NeoPixel neo; static inline void begin() { adaneo.begin(); } static inline void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); } static inline void set_brightness(const uint8_t b) { adaneo.setBrightness(b); } - static inline void show() { adaneo.show(); } + static inline void show() { + adaneo.show(); + adaneo.setPin(NEOPIXEL2_PIN); + } // Accessors static inline uint16_t pixels() { return adaneo.numPixels();} From 23080302ea49a46ec504005ff515745ec738dc63 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 31 Aug 2020 01:43:15 -0500 Subject: [PATCH 38/58] adjust --- Marlin/src/feature/leds/neopixel.h | 4 +--- Marlin/src/inc/Conditionals_LCD.h | 5 ----- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 6e1ba25c2b74..09a5cf8b39be 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -110,9 +110,7 @@ class Marlin_NeoPixel { #if CONJOINED_NEOPIXEL adaneo2.show(); #else - #if DISABLED(NEOPIXEL2_SEPARATE) - adaneo1.setPin(NEOPIXEL2_PIN); - #endif + TERN_(NEOPIXEL2_SEPARATE,,adaneo1.setPin(NEOPIXEL2_PIN)); adaneo1.show(); adaneo1.setPin(NEOPIXEL_PIN); #endif diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index bbe89b7c5042..112ff93a0e0e 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -780,8 +780,3 @@ #ifndef EXTRUDE_MINTEMP #define EXTRUDE_MINTEMP 170 #endif - -// This flag indicates if Neopixel pins are shared or separated -#if EITHER(MULTIPLE_NEOPIXEL_TYPES, NEOPIXEL2_INSERIES) - #define CONJOINED_NEOPIXEL 1 -#endif From 654e6a97dda5b8d504405abb462ef27379112b5e Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Tue, 1 Sep 2020 12:21:19 -0500 Subject: [PATCH 39/58] Update neopixel.h TERN_(NEOPIXEL2_SEPARATE,,adaneo1.setPin(NEOPIXEL2_PIN)); dosent compile as is. i believe it has an extra comma in it --- Marlin/src/feature/leds/neopixel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 09a5cf8b39be..f8300c4d988c 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -110,7 +110,7 @@ class Marlin_NeoPixel { #if CONJOINED_NEOPIXEL adaneo2.show(); #else - TERN_(NEOPIXEL2_SEPARATE,,adaneo1.setPin(NEOPIXEL2_PIN)); + TERN_(NEOPIXEL2_SEPARATE,adaneo1.setPin(NEOPIXEL2_PIN)); adaneo1.show(); adaneo1.setPin(NEOPIXEL_PIN); #endif From 435ef1034e51e0961f39b645ecc6654ff76e9578 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Thu, 3 Sep 2020 09:45:00 -0500 Subject: [PATCH 40/58] Update neopixel.h TERN_(NEOPIXEL2_SEPARATE,adaneo1.setPin(NEOPIXEL2_PIN)); stops NEOPIXEL2_SEPARATE From working as intended it bleeds into the separate channel #if Disabled(NEOPIXEL2_SEPARATE) Works like its supposed to is there a different macro than TERN_(NEOPIXEL2_SEPARATE,adaneo1.setPin(NEOPIXEL2_PIN)); becuase it dosnet have the desired effect --- Marlin/src/feature/leds/neopixel.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index f8300c4d988c..dd2397cfda39 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -110,7 +110,9 @@ class Marlin_NeoPixel { #if CONJOINED_NEOPIXEL adaneo2.show(); #else - TERN_(NEOPIXEL2_SEPARATE,adaneo1.setPin(NEOPIXEL2_PIN)); + #if DISABLED(NEOPIXEL2_SEPARATE) + adaneo1.setPin(NEOPIXEL2_PIN); + #endif adaneo1.show(); adaneo1.setPin(NEOPIXEL_PIN); #endif From 9880be5aee0d187d8606b8233d219b1c09d98b2f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 3 Sep 2020 17:42:19 -0500 Subject: [PATCH 41/58] Update neopixel.h --- Marlin/src/feature/leds/neopixel.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index dd2397cfda39..42046fa5638f 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -110,9 +110,7 @@ class Marlin_NeoPixel { #if CONJOINED_NEOPIXEL adaneo2.show(); #else - #if DISABLED(NEOPIXEL2_SEPARATE) - adaneo1.setPin(NEOPIXEL2_PIN); - #endif + TERN(NEOPIXEL2_SEPARATE,,adaneo1.setPin(NEOPIXEL2_PIN)); adaneo1.show(); adaneo1.setPin(NEOPIXEL_PIN); #endif From 0ed32328325bc1715911c121520444cf9143b993 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sat, 5 Sep 2020 20:35:24 -0500 Subject: [PATCH 42/58] Added menu support for NEOPIXLE2_SEPARATE --- Marlin/src/feature/leds/leds.cpp | 12 ++++++++- Marlin/src/feature/leds/leds.h | 2 +- Marlin/src/lcd/language/language_en.h | 15 ++++++++++- Marlin/src/lcd/menu/menu_led.cpp | 39 ++++++++++++++++++++++++++- 4 files changed, 64 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 01bca809260e..cbfdd7e2f0d1 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -157,7 +157,7 @@ void LEDLights::set_color(const LEDColor &incol #endif #if ENABLED(NEOPIXEL2_SEPARATE) - + #if ENABLED(NEO2_COLOR_PRESETS) const LEDColor LEDLights2::defaultLEDColor = MakeLEDColor( NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, @@ -183,7 +183,17 @@ void LEDLights::set_color(const LEDColor &incol : neo2.Color(incol.r, incol.g, incol.b, incol.w); neo2.set_brightness(incol.i); neo2.set_color(neocolor); + + #if ENABLED(LED_CONTROL_MENU) + // Don't update the color when OFF + lights_on = !incol.is_off(); + if (lights_on) color = incol; + #endif } + + #if ENABLED(LED_CONTROL_MENU) + void LEDLights2::toggle() { if (lights_on) set_off(); else update(); } + #endif #endif // NEOPIXEL2_SEPARATE diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index a13f960a3bb2..055ea0df37ad 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -240,7 +240,7 @@ extern LEDLights leds; static inline void set_violet() { set_color(LEDColorViolet()); } #endif - #if ENABLED(LED_CONTROL_MENU) + #if ENABLED(NEOPIXEL2_SEPARATE) static LEDColor color; // last non-off color static bool lights_on; // the last set color was "on" static void toggle(); // swap "off" with color diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 39bb85d37815..f14acf395a5c 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -222,13 +222,26 @@ namespace Language_en { PROGMEM Language_Str MSG_SET_LEDS_VIOLET = _UxGT("Violet"); PROGMEM Language_Str MSG_SET_LEDS_WHITE = _UxGT("White"); PROGMEM Language_Str MSG_SET_LEDS_DEFAULT = _UxGT("Default"); + PROGMEM Language_Str MSG_LED_CHANNEL2 = _UxGT("Channel 2"); + PROGMEM Language_Str MSG_LEDS2 = _UxGT("Lights #2"); + PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Light #2 Presets"); + PROGMEM Language_Str MSG_SET_NEO2_RED = _UxGT("Red"); + PROGMEM Language_Str MSG_SET_NEO2_ORANGE = _UxGT("Orange"); + PROGMEM Language_Str MSG_SET_NEO2_YELLOW = _UxGT("Yellow"); + PROGMEM Language_Str MSG_SET_NEO2_GREEN = _UxGT("Green"); + PROGMEM Language_Str MSG_SET_NEO2_BLUE = _UxGT("Blue"); + PROGMEM Language_Str MSG_SET_NEO2_INDIGO = _UxGT("Indigo"); + PROGMEM Language_Str MSG_SET_NEO2_VIOLET = _UxGT("Violet"); + PROGMEM Language_Str MSG_SET_NEO2_WHITE = _UxGT("White"); + PROGMEM Language_Str MSG_SET_NEO2_DEFAULT = _UxGT("Default"); + PROGMEM Language_Str MSG_NEO2_BRIGHTNESS = _UxGT("Brightness"); PROGMEM Language_Str MSG_CUSTOM_LEDS = _UxGT("Custom Lights"); PROGMEM Language_Str MSG_INTENSITY_R = _UxGT("Red Intensity"); PROGMEM Language_Str MSG_INTENSITY_G = _UxGT("Green Intensity"); PROGMEM Language_Str MSG_INTENSITY_B = _UxGT("Blue Intensity"); PROGMEM Language_Str MSG_INTENSITY_W = _UxGT("White Intensity"); PROGMEM Language_Str MSG_LED_BRIGHTNESS = _UxGT("Brightness"); - + PROGMEM Language_Str MSG_MOVING = _UxGT("Moving..."); PROGMEM Language_Str MSG_FREE_XY = _UxGT("Free XY"); PROGMEM Language_Str MSG_MOVE_X = _UxGT("Move X"); diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 290b0ddf63cd..f004d9ddfc42 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU) +#if HAS_LCD_MENU && ANY(LED_CONTROL_MENU ,NEO2_CONTROL_MENU, CASE_LIGHT_MENU) #include "menu_item.h" @@ -54,6 +54,27 @@ #endif + #if ENABLED(NEO2_COLOR_PRESETS) + + void menu_leds2_presets() { + START_MENU(); + #if LCD_HEIGHT > 2 + STATIC_ITEM(MSG_NEO2_PRESETS, SS_DEFAULT|SS_INVERT); + #endif + BACK_ITEM(MSG_LED_CONTROL); + ACTION_ITEM(MSG_SET_NEO2_WHITE, leds2.set_white); + ACTION_ITEM(MSG_SET_NEO2_RED, leds2.set_red); + ACTION_ITEM(MSG_SET_NEO2_ORANGE, leds2.set_orange); + ACTION_ITEM(MSG_SET_NEO2_YELLOW, leds2.set_yellow); + ACTION_ITEM(MSG_SET_NEO2_GREEN, leds2.set_green); + ACTION_ITEM(MSG_SET_NEO2_BLUE, leds2.set_blue); + ACTION_ITEM(MSG_SET_NEO2_INDIGO, leds2.set_indigo); + ACTION_ITEM(MSG_SET_NEO2_VIOLET, leds2.set_violet); + END_MENU(); + } + + #endif + void menu_led_custom() { START_MENU(); BACK_ITEM(MSG_LED_CONTROL); @@ -65,6 +86,14 @@ #if ENABLED(NEOPIXEL_LED) EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true); #endif + #if ENABLED(NEOPIXEL2_SEPARATE) + STATIC_ITEM(MSG_LED_CHANNEL2, SS_DEFAULT|SS_INVERT); + EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true); + #endif #endif END_MENU(); } @@ -92,9 +121,17 @@ void menu_led() { bool led_on = leds.lights_on; EDIT_ITEM(bool, MSG_LEDS, &led_on, leds.toggle); ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default); + #if ENABLED(NEOPIXEL2_SEPARATE) + bool led2_on = leds2.lights_on; + EDIT_ITEM(bool, MSG_LEDS2, &led2_on, leds2.toggle); + ACTION_ITEM(MSG_SET_NEO2_DEFAULT, leds2.set_default); + #endif #if ENABLED(LED_COLOR_PRESETS) SUBMENU(MSG_LED_PRESETS, menu_led_presets); #endif + #if ENABLED(NEO2_COLOR_PRESETS) + SUBMENU(MSG_NEO2_PRESETS, menu_leds2_presets); + #endif SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom); #endif From 8aee8ed6fef67d71812eb587b08adef89130b153 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sat, 5 Sep 2020 20:43:59 -0500 Subject: [PATCH 43/58] Update menu_led.cpp --- Marlin/src/lcd/menu/menu_led.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index f004d9ddfc42..48dbac24f326 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU && ANY(LED_CONTROL_MENU ,NEO2_CONTROL_MENU, CASE_LIGHT_MENU) +#if HAS_LCD_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU) #include "menu_item.h" From 0cd232a544d656b79f372c126714196fd6aeadc6 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sun, 6 Sep 2020 14:14:38 -0500 Subject: [PATCH 44/58] refinement --- Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/menu/menu_led.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index f14acf395a5c..1554d84a5141 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -222,6 +222,7 @@ namespace Language_en { PROGMEM Language_Str MSG_SET_LEDS_VIOLET = _UxGT("Violet"); PROGMEM Language_Str MSG_SET_LEDS_WHITE = _UxGT("White"); PROGMEM Language_Str MSG_SET_LEDS_DEFAULT = _UxGT("Default"); + PROGMEM Language_Str MSG_LED_CHANNEL1 = _UxGT("Channel 1"); PROGMEM Language_Str MSG_LED_CHANNEL2 = _UxGT("Channel 2"); PROGMEM Language_Str MSG_LEDS2 = _UxGT("Lights #2"); PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Light #2 Presets"); diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 48dbac24f326..97d0c3057ba1 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -78,6 +78,7 @@ void menu_led_custom() { START_MENU(); BACK_ITEM(MSG_LED_CONTROL); + TERN(NEOPIXEL2_SEPARATE,,STATIC_ITEM(MSG_LED_CHANNEL1, SS_DEFAULT|SS_INVERT)); EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true); From 02dd0a1fb4bf7d8f1a831e4264e97e682c16e3ad Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sun, 6 Sep 2020 14:33:37 -0500 Subject: [PATCH 45/58] Update menu_led.cpp --- Marlin/src/lcd/menu/menu_led.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 97d0c3057ba1..01440b681aef 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -78,7 +78,7 @@ void menu_led_custom() { START_MENU(); BACK_ITEM(MSG_LED_CONTROL); - TERN(NEOPIXEL2_SEPARATE,,STATIC_ITEM(MSG_LED_CHANNEL1, SS_DEFAULT|SS_INVERT)); + TERN_(NEOPIXEL2_SEPARATE,STATIC_ITEM(MSG_LED_CHANNEL1, SS_DEFAULT|SS_INVERT)); EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true); From c32f5681710c7253453a05584c88014e5b5ab159 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sun, 6 Sep 2020 14:47:33 -0500 Subject: [PATCH 46/58] Update SanityCheck.h makes sure there is a need --- Marlin/src/inc/SanityCheck.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index da5ddc1c2ddb..f266d744dec0 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1843,6 +1843,9 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if ENABLED(LED_CONTROL_MENU) && !HAS_COLOR_LEDS #error "LED_CONTROL_MENU requires BLINKM, RGB_LED, RGBW_LED, PCA9533, PCA9632, or NEOPIXEL_LED." #endif +#if ENABLED(LED_CONTROL_MENU) && !NOEPIXEL2_SEPARATE + #error "NEO2_COLOR_PRESETS requires NEOPIXEL2_SEPARATE to be enabled." +#endif /** * LED Backlight Timeout From 73c7e74ef217d0077a867674b67e2d6a181d259d Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Sun, 6 Sep 2020 18:57:35 -0500 Subject: [PATCH 47/58] Update SanityCheck.h added a check for the neopixel2 pin when neopixel separate is enabled --- Marlin/src/inc/SanityCheck.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f266d744dec0..052c0cfe3fab 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2123,12 +2123,12 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if !(PIN_EXISTS(NEOPIXEL) && NEOPIXEL_PIXELS > 0) #error "NEOPIXEL_LED requires NEOPIXEL_PIN and NEOPIXEL_PIXELS." #endif - #elif ENABLED(NEOPIXEL2_SEPARATE) - #if !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) - #error "NEOPIXEL2 requires NEOPIXEL2_PIN and NEOPIXEL2_PIXELS." + #if ENABLED(NEOPIXEL2_SEPARATE) && !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) && NEOPIXEL2_PIN + #error "NEOPIXEL2_SEPARATE requires NEOPIXEL2_PIN, NEOPIXEL2_TYPE and NEOPIXEL2_PIXELS." #endif #endif + #undef _RGB_TEST #if DISABLED(NO_COMPILE_TIME_PWM) From 0d9b30bf3e2656f8396d19efd2a0027699861750 Mon Sep 17 00:00:00 2001 From: Zachary Annand Date: Sun, 6 Sep 2020 19:26:31 -0500 Subject: [PATCH 48/58] Update SanityCheck.h --- Marlin/src/inc/SanityCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 052c0cfe3fab..cc3ea542989b 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2123,7 +2123,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if !(PIN_EXISTS(NEOPIXEL) && NEOPIXEL_PIXELS > 0) #error "NEOPIXEL_LED requires NEOPIXEL_PIN and NEOPIXEL_PIXELS." #endif - #if ENABLED(NEOPIXEL2_SEPARATE) && !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) && NEOPIXEL2_PIN + #if ENABLED(NEOPIXEL2_SEPARATE) && !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) && NEOPIXEL2_TYPE #error "NEOPIXEL2_SEPARATE requires NEOPIXEL2_PIN, NEOPIXEL2_TYPE and NEOPIXEL2_PIXELS." #endif #endif From 9d554ddb1fa0f7aa22e0af6a2ddf9fa2355e6fd1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 6 Sep 2020 19:32:15 -0500 Subject: [PATCH 49/58] Update menu_led.cpp --- Marlin/src/lcd/menu/menu_led.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 01440b681aef..1f1de874dfd4 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -78,7 +78,9 @@ void menu_led_custom() { START_MENU(); BACK_ITEM(MSG_LED_CONTROL); - TERN_(NEOPIXEL2_SEPARATE,STATIC_ITEM(MSG_LED_CHANNEL1, SS_DEFAULT|SS_INVERT)); + #if ENABLED(NEOPIXEL2_SEPARATE) + STATIC_ITEM(MSG_LED_CHANNEL1, SS_DEFAULT|SS_INVERT); + #endif EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true); @@ -87,14 +89,14 @@ #if ENABLED(NEOPIXEL_LED) EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true); #endif - #if ENABLED(NEOPIXEL2_SEPARATE) - STATIC_ITEM(MSG_LED_CHANNEL2, SS_DEFAULT|SS_INVERT); - EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true); - EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true); - EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true); - EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true); - EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true); - #endif + #endif + #if ENABLED(NEOPIXEL2_SEPARATE) + STATIC_ITEM(MSG_LED_CHANNEL2, SS_DEFAULT|SS_INVERT); + EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds2.color.w, 0, 255, leds2.update, true); + EDIT_ITEM(uint8, MSG_NEO2_BRIGHTNESS, &leds2.color.i, 0, 255, leds2.update, true); #endif END_MENU(); } From 9a90653b9bc19673e40b5358d57b4c388fb554ac Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 6 Sep 2020 19:33:03 -0500 Subject: [PATCH 50/58] Update language_en.h --- Marlin/src/lcd/language/language_en.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 1554d84a5141..bfdeda42fe58 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -242,7 +242,7 @@ namespace Language_en { PROGMEM Language_Str MSG_INTENSITY_B = _UxGT("Blue Intensity"); PROGMEM Language_Str MSG_INTENSITY_W = _UxGT("White Intensity"); PROGMEM Language_Str MSG_LED_BRIGHTNESS = _UxGT("Brightness"); - + PROGMEM Language_Str MSG_MOVING = _UxGT("Moving..."); PROGMEM Language_Str MSG_FREE_XY = _UxGT("Free XY"); PROGMEM Language_Str MSG_MOVE_X = _UxGT("Move X"); From fd978789a49cf8e72e216fdb42c23164dedf4258 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 6 Sep 2020 19:35:53 -0500 Subject: [PATCH 51/58] Fix insanity check --- Marlin/src/inc/SanityCheck.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 8f455be3c609..8203b6a93303 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1846,9 +1846,6 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if ENABLED(LED_CONTROL_MENU) && !HAS_COLOR_LEDS #error "LED_CONTROL_MENU requires BLINKM, RGB_LED, RGBW_LED, PCA9533, PCA9632, or NEOPIXEL_LED." #endif -#if ENABLED(LED_CONTROL_MENU) && !NOEPIXEL2_SEPARATE - #error "NEO2_COLOR_PRESETS requires NEOPIXEL2_SEPARATE to be enabled." -#endif /** * LED Backlight Timeout @@ -2131,6 +2128,9 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #endif #endif +#if ENABLED(NEO2_COLOR_PRESETS) && DISABLED(NEOPIXEL2_SEPARATE) + #error "NEO2_COLOR_PRESETS requires NEOPIXEL2_SEPARATE to be enabled." +#endif #undef _RGB_TEST From a1f4ecc85b503629f536b1321175ed2e55e3d597 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 6 Sep 2020 19:43:19 -0500 Subject: [PATCH 52/58] Update SanityCheck.h --- Marlin/src/inc/SanityCheck.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 8203b6a93303..0c79ead37387 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2119,21 +2119,20 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if !(_RGB_TEST && PIN_EXISTS(RGB_LED_W)) #error "RGBW_LED requires RGB_LED_R_PIN, RGB_LED_G_PIN, RGB_LED_B_PIN, and RGB_LED_W_PIN." #endif -#elif ENABLED(NEOPIXEL_LED) - #if !(PIN_EXISTS(NEOPIXEL) && NEOPIXEL_PIXELS > 0) +#endif +#undef _RGB_TEST + +// NeoPixel requirements +#if ENABLED(NEOPIXEL_LED) + #if !PIN_EXISTS(NEOPIXEL) || NEOPIXEL_PIXELS == 0 #error "NEOPIXEL_LED requires NEOPIXEL_PIN and NEOPIXEL_PIXELS." - #endif - #if ENABLED(NEOPIXEL2_SEPARATE) && !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) && NEOPIXEL2_TYPE + #elif ENABLED(NEOPIXEL2_SEPARATE) && !(NEOPIXEL2_TYPE && PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) #error "NEOPIXEL2_SEPARATE requires NEOPIXEL2_PIN, NEOPIXEL2_TYPE and NEOPIXEL2_PIXELS." + #elif ENABLED(NEO2_COLOR_PRESETS) && DISABLED(NEOPIXEL2_SEPARATE) + #error "NEO2_COLOR_PRESETS requires NEOPIXEL2_SEPARATE to be enabled." #endif #endif -#if ENABLED(NEO2_COLOR_PRESETS) && DISABLED(NEOPIXEL2_SEPARATE) - #error "NEO2_COLOR_PRESETS requires NEOPIXEL2_SEPARATE to be enabled." -#endif - -#undef _RGB_TEST - #if DISABLED(NO_COMPILE_TIME_PWM) #define _TEST_PWM(P) PWM_PIN(P) #else From 086e37f8b5f8dd4edb6ad1df0333c089eb07f895 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 6 Sep 2020 19:45:49 -0500 Subject: [PATCH 53/58] Update leds.cpp --- Marlin/src/feature/leds/leds.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index cbfdd7e2f0d1..28a6814b4397 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -157,7 +157,7 @@ void LEDLights::set_color(const LEDColor &incol #endif #if ENABLED(NEOPIXEL2_SEPARATE) - + #if ENABLED(NEO2_COLOR_PRESETS) const LEDColor LEDLights2::defaultLEDColor = MakeLEDColor( NEO2_USER_PRESET_RED, NEO2_USER_PRESET_GREEN, NEO2_USER_PRESET_BLUE, @@ -184,11 +184,11 @@ void LEDLights::set_color(const LEDColor &incol neo2.set_brightness(incol.i); neo2.set_color(neocolor); - #if ENABLED(LED_CONTROL_MENU) - // Don't update the color when OFF - lights_on = !incol.is_off(); - if (lights_on) color = incol; - #endif + #if ENABLED(LED_CONTROL_MENU) + // Don't update the color when OFF + lights_on = !incol.is_off(); + if (lights_on) color = incol; + #endif } #if ENABLED(LED_CONTROL_MENU) From 6e64423a5d620e70d3c6efdbcd4008f991776762 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 6 Sep 2020 19:49:07 -0500 Subject: [PATCH 54/58] Reduce strings --- Marlin/src/lcd/language/language_en.h | 9 --------- Marlin/src/lcd/menu/menu_led.cpp | 18 +++++++++--------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index bfdeda42fe58..3bd9da09f81b 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -226,15 +226,6 @@ namespace Language_en { PROGMEM Language_Str MSG_LED_CHANNEL2 = _UxGT("Channel 2"); PROGMEM Language_Str MSG_LEDS2 = _UxGT("Lights #2"); PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Light #2 Presets"); - PROGMEM Language_Str MSG_SET_NEO2_RED = _UxGT("Red"); - PROGMEM Language_Str MSG_SET_NEO2_ORANGE = _UxGT("Orange"); - PROGMEM Language_Str MSG_SET_NEO2_YELLOW = _UxGT("Yellow"); - PROGMEM Language_Str MSG_SET_NEO2_GREEN = _UxGT("Green"); - PROGMEM Language_Str MSG_SET_NEO2_BLUE = _UxGT("Blue"); - PROGMEM Language_Str MSG_SET_NEO2_INDIGO = _UxGT("Indigo"); - PROGMEM Language_Str MSG_SET_NEO2_VIOLET = _UxGT("Violet"); - PROGMEM Language_Str MSG_SET_NEO2_WHITE = _UxGT("White"); - PROGMEM Language_Str MSG_SET_NEO2_DEFAULT = _UxGT("Default"); PROGMEM Language_Str MSG_NEO2_BRIGHTNESS = _UxGT("Brightness"); PROGMEM Language_Str MSG_CUSTOM_LEDS = _UxGT("Custom Lights"); PROGMEM Language_Str MSG_INTENSITY_R = _UxGT("Red Intensity"); diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 1f1de874dfd4..84416c44d443 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -62,14 +62,14 @@ STATIC_ITEM(MSG_NEO2_PRESETS, SS_DEFAULT|SS_INVERT); #endif BACK_ITEM(MSG_LED_CONTROL); - ACTION_ITEM(MSG_SET_NEO2_WHITE, leds2.set_white); - ACTION_ITEM(MSG_SET_NEO2_RED, leds2.set_red); - ACTION_ITEM(MSG_SET_NEO2_ORANGE, leds2.set_orange); - ACTION_ITEM(MSG_SET_NEO2_YELLOW, leds2.set_yellow); - ACTION_ITEM(MSG_SET_NEO2_GREEN, leds2.set_green); - ACTION_ITEM(MSG_SET_NEO2_BLUE, leds2.set_blue); - ACTION_ITEM(MSG_SET_NEO2_INDIGO, leds2.set_indigo); - ACTION_ITEM(MSG_SET_NEO2_VIOLET, leds2.set_violet); + ACTION_ITEM(MSG_SET_LEDS_WHITE, leds2.set_white); + ACTION_ITEM(MSG_SET_LEDS_RED, leds2.set_red); + ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds2.set_orange); + ACTION_ITEM(MSG_SET_LEDS_YELLOW, leds2.set_yellow); + ACTION_ITEM(MSG_SET_LEDS_GREEN, leds2.set_green); + ACTION_ITEM(MSG_SET_LEDS_BLUE, leds2.set_blue); + ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds2.set_indigo); + ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds2.set_violet); END_MENU(); } @@ -127,7 +127,7 @@ void menu_led() { #if ENABLED(NEOPIXEL2_SEPARATE) bool led2_on = leds2.lights_on; EDIT_ITEM(bool, MSG_LEDS2, &led2_on, leds2.toggle); - ACTION_ITEM(MSG_SET_NEO2_DEFAULT, leds2.set_default); + ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds2.set_default); #endif #if ENABLED(LED_COLOR_PRESETS) SUBMENU(MSG_LED_PRESETS, menu_led_presets); From 676c1e72f762fb1b845fdb47734a9b765209a79d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 6 Sep 2020 19:52:31 -0500 Subject: [PATCH 55/58] Maybe save bytes --- Marlin/src/lcd/language/language_en.h | 3 +-- Marlin/src/lcd/menu/menu_led.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 3bd9da09f81b..8ae40304bdf3 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -222,8 +222,7 @@ namespace Language_en { PROGMEM Language_Str MSG_SET_LEDS_VIOLET = _UxGT("Violet"); PROGMEM Language_Str MSG_SET_LEDS_WHITE = _UxGT("White"); PROGMEM Language_Str MSG_SET_LEDS_DEFAULT = _UxGT("Default"); - PROGMEM Language_Str MSG_LED_CHANNEL1 = _UxGT("Channel 1"); - PROGMEM Language_Str MSG_LED_CHANNEL2 = _UxGT("Channel 2"); + PROGMEM Language_Str MSG_LED_CHANNEL_N = _UxGT("Channel ="); PROGMEM Language_Str MSG_LEDS2 = _UxGT("Lights #2"); PROGMEM Language_Str MSG_NEO2_PRESETS = _UxGT("Light #2 Presets"); PROGMEM Language_Str MSG_NEO2_BRIGHTNESS = _UxGT("Brightness"); diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 84416c44d443..311484b6ed78 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -79,7 +79,7 @@ START_MENU(); BACK_ITEM(MSG_LED_CONTROL); #if ENABLED(NEOPIXEL2_SEPARATE) - STATIC_ITEM(MSG_LED_CHANNEL1, SS_DEFAULT|SS_INVERT); + STATIC_ITEM_N(MSG_LED_CHANNEL_N, 1, SS_DEFAULT|SS_INVERT); #endif EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true); @@ -91,7 +91,7 @@ #endif #endif #if ENABLED(NEOPIXEL2_SEPARATE) - STATIC_ITEM(MSG_LED_CHANNEL2, SS_DEFAULT|SS_INVERT); + STATIC_ITEM_N(MSG_LED_CHANNEL_N, 2, SS_DEFAULT|SS_INVERT); EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true); From 324d8db32f129cfbdc2bf2ccc8c2eb78c015e68e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 6 Sep 2020 19:55:46 -0500 Subject: [PATCH 56/58] 'editable' better than stack? --- Marlin/src/lcd/menu/menu_led.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 311484b6ed78..386a4d799aa2 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -121,12 +121,12 @@ void menu_led() { BACK_ITEM(MSG_MAIN); #if ENABLED(LED_CONTROL_MENU) - bool led_on = leds.lights_on; - EDIT_ITEM(bool, MSG_LEDS, &led_on, leds.toggle); + editable.state = leds.lights_on; + EDIT_ITEM(bool, MSG_LEDS, &editable.state, leds.toggle); ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default); #if ENABLED(NEOPIXEL2_SEPARATE) - bool led2_on = leds2.lights_on; - EDIT_ITEM(bool, MSG_LEDS2, &led2_on, leds2.toggle); + editable.state = leds2.lights_on; + EDIT_ITEM(bool, MSG_LEDS2, &editable.state, leds2.toggle); ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds2.set_default); #endif #if ENABLED(LED_COLOR_PRESETS) From ce70d8946dc00b4b831181f860bb448efca93433 Mon Sep 17 00:00:00 2001 From: Bacon-Fixation Date: Mon, 7 Sep 2020 00:24:30 -0500 Subject: [PATCH 57/58] Update SanityCheck.h still problems with #elif ENABLED(NEOPIXEL2_SEPARATE) && !(NEOPIXEL2_TYPE && PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) Error is a;ways flagged --- Marlin/src/inc/SanityCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 0c79ead37387..8a1744c9cce4 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2126,7 +2126,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #if ENABLED(NEOPIXEL_LED) #if !PIN_EXISTS(NEOPIXEL) || NEOPIXEL_PIXELS == 0 #error "NEOPIXEL_LED requires NEOPIXEL_PIN and NEOPIXEL_PIXELS." - #elif ENABLED(NEOPIXEL2_SEPARATE) && !(NEOPIXEL2_TYPE && PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) + #elif ENABLED(NEOPIXEL2_SEPARATE) && !(PIN_EXISTS(NEOPIXEL2) && NEOPIXEL2_PIXELS > 0) #error "NEOPIXEL2_SEPARATE requires NEOPIXEL2_PIN, NEOPIXEL2_TYPE and NEOPIXEL2_PIXELS." #elif ENABLED(NEO2_COLOR_PRESETS) && DISABLED(NEOPIXEL2_SEPARATE) #error "NEO2_COLOR_PRESETS requires NEOPIXEL2_SEPARATE to be enabled." From 47d7e33c61728cf8b2e9173e03136e35210e0707 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 7 Sep 2020 02:58:05 -0500 Subject: [PATCH 58/58] Fix bad merge --- Marlin/src/feature/leds/leds.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 69fbddd5ded9..ef9099fb2093 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -190,10 +190,6 @@ void LEDLights::set_color(const LEDColor &incol if (lights_on) color = incol; #endif } - - #if ENABLED(LED_CONTROL_MENU) - void LEDLights2::toggle() { if (lights_on) set_off(); else update(); } - #endif #if ENABLED(LED_CONTROL_MENU) void LEDLights2::toggle() { if (lights_on) set_off(); else update(); }