Optimize G-code / feature dependencies (#18919)
This commit is contained in:
@ -25,7 +25,7 @@
|
||||
#if ENABLED(BINARY_FILE_TRANSFER)
|
||||
|
||||
#include "../sd/cardreader.h"
|
||||
#include "binary_protocol.h"
|
||||
#include "binary_stream.h"
|
||||
|
||||
char* SDFileTransferProtocol::Packet::Open::data = nullptr;
|
||||
size_t SDFileTransferProtocol::data_waiting, SDFileTransferProtocol::transfer_timeout, SDFileTransferProtocol::idle_timeout;
|
||||
@ -33,4 +33,4 @@ bool SDFileTransferProtocol::transfer_active, SDFileTransferProtocol::dummy_tran
|
||||
|
||||
BinaryStream binaryStream[NUM_SERIAL];
|
||||
|
||||
#endif // BINARY_FILE_TRANSFER
|
||||
#endif
|
@ -22,14 +22,17 @@
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_CASE_LIGHT
|
||||
#if ENABLED(CASE_LIGHT_ENABLE)
|
||||
|
||||
uint8_t case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
|
||||
bool case_light_on = CASE_LIGHT_DEFAULT_ON;
|
||||
#include "caselight.h"
|
||||
|
||||
CaseLight caselight;
|
||||
|
||||
uint8_t CaseLight::brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
|
||||
bool CaseLight::on = CASE_LIGHT_DEFAULT_ON;
|
||||
|
||||
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
|
||||
#include "leds/leds.h"
|
||||
LEDColor case_light_color =
|
||||
LEDColor CaseLight::color =
|
||||
#ifdef CASE_LIGHT_NEOPIXEL_COLOR
|
||||
CASE_LIGHT_NEOPIXEL_COLOR
|
||||
#else
|
||||
@ -38,34 +41,33 @@ bool case_light_on = CASE_LIGHT_DEFAULT_ON;
|
||||
;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The following are needed because ARM chips ignore a "WRITE(CASE_LIGHT_PIN,x)" command to the pins that
|
||||
* are directly controlled by the PWM module. In order to turn them off the brightness level needs to be
|
||||
* set to off. Since we can't use the pwm register to save the last brightness level we need a variable
|
||||
* to save it.
|
||||
*/
|
||||
uint8_t case_light_brightness_sav; // saves brighness info so can restore when "M355 S1" received
|
||||
bool case_light_arg_flag; // flag to notify if S or P argument type
|
||||
|
||||
#ifndef INVERT_CASE_LIGHT
|
||||
#define INVERT_CASE_LIGHT false
|
||||
#endif
|
||||
|
||||
void update_case_light() {
|
||||
void CaseLight::update(const bool sflag) {
|
||||
/**
|
||||
* The brightness_sav (and sflag) is needed because ARM chips ignore
|
||||
* a "WRITE(CASE_LIGHT_PIN,x)" command to the pins that are directly
|
||||
* controlled by the PWM module. In order to turn them off the brightness
|
||||
* level needs to be set to OFF. Since we can't use the PWM register to
|
||||
* save the last brightness level we need a variable to save it.
|
||||
*/
|
||||
static uint8_t brightness_sav; // Save brightness info for restore on "M355 S1"
|
||||
|
||||
if (!(case_light_arg_flag && !case_light_on))
|
||||
case_light_brightness_sav = case_light_brightness; // save brightness except if this is an S0 argument
|
||||
if (case_light_arg_flag && case_light_on)
|
||||
case_light_brightness = case_light_brightness_sav; // restore last brightens if this is an S1 argument
|
||||
if (on || !sflag)
|
||||
brightness_sav = brightness; // Save brightness except for M355 S0
|
||||
if (sflag && on)
|
||||
brightness = brightness_sav; // Restore last brightness for M355 S1
|
||||
|
||||
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL) || DISABLED(CASE_LIGHT_NO_BRIGHTNESS)
|
||||
const uint8_t i = case_light_on ? case_light_brightness : 0, n10ct = INVERT_CASE_LIGHT ? 255 - i : i;
|
||||
const uint8_t i = on ? brightness : 0, n10ct = INVERT_CASE_LIGHT ? 255 - i : i;
|
||||
#endif
|
||||
|
||||
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
|
||||
|
||||
leds.set_color(
|
||||
MakeLEDColor(case_light_color.r, case_light_color.g, case_light_color.b, case_light_color.w, n10ct),
|
||||
MakeLEDColor(color.r, color.g, color.b, color.w, n10ct),
|
||||
false
|
||||
);
|
||||
|
||||
@ -83,11 +85,11 @@ void update_case_light() {
|
||||
else
|
||||
#endif
|
||||
{
|
||||
const bool s = case_light_on ? !INVERT_CASE_LIGHT : INVERT_CASE_LIGHT;
|
||||
const bool s = on ? !INVERT_CASE_LIGHT : INVERT_CASE_LIGHT;
|
||||
WRITE(CASE_LIGHT_PIN, s ? HIGH : LOW);
|
||||
}
|
||||
|
||||
#endif // !CASE_LIGHT_USE_NEOPIXEL
|
||||
}
|
||||
|
||||
#endif // HAS_CASE_LIGHT
|
||||
#endif // CASE_LIGHT_ENABLE
|
||||
|
@ -21,9 +21,25 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
extern uint8_t case_light_brightness;
|
||||
extern bool case_light_on;
|
||||
extern uint8_t case_light_brightness_sav; // saves brighness info when case_light_on is false
|
||||
extern bool case_light_arg_flag; // flag to notify if S or P argument type
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
|
||||
void update_case_light();
|
||||
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
|
||||
#include "leds/leds.h"
|
||||
#endif
|
||||
|
||||
class CaseLight {
|
||||
public:
|
||||
static uint8_t brightness;
|
||||
static bool on;
|
||||
|
||||
static void update(const bool sflag);
|
||||
static inline void update_brightness() { update(false); }
|
||||
static inline void update_enabled() { update(true); }
|
||||
|
||||
private:
|
||||
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
|
||||
static LEDColor color;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern CaseLight caselight;
|
||||
|
@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* emergency_parser.cpp - Intercept special commands directly in the serial stream
|
||||
* e_parser.cpp - Intercept special commands directly in the serial stream
|
||||
*/
|
||||
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
|
@ -22,7 +22,7 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* emergency_parser.h - Intercept special commands directly in the serial stream
|
||||
* e_parser.h - Intercept special commands directly in the serial stream
|
||||
*/
|
||||
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
|
Reference in New Issue
Block a user