Merge pull request #6797 from Bob-the-Kuhn/M355-case-lightimprovements-(1.1.x)

M355 case light improvements (replaces PR #5685)
This commit is contained in:
Bob-the-Kuhn 2017-05-31 13:33:59 -05:00 committed by GitHub
commit 65bd4c8c94
28 changed files with 473 additions and 201 deletions

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -176,7 +176,7 @@
* M304 - Set bed PID parameters P I and D. (Requires PIDTEMPBED)
* M350 - Set microstepping mode. (Requires digital microstepping pins.)
* M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.)
* M355 - Turn the Case Light on/off and set its brightness. (Requires CASE_LIGHT_PIN)
* M355 - Set Case Light on/off and set brightness. (Requires CASE_LIGHT_PIN)
* M380 - Activate solenoid on active extruder. (Requires EXT_SOLENOID)
* M381 - Disable all solenoids. (Requires EXT_SOLENOID)
* M400 - Finish all moves.
@ -566,16 +566,6 @@ static uint8_t target_extruder;
;
#endif
#if HAS_CASE_LIGHT
bool case_light_on =
#if ENABLED(CASE_LIGHT_DEFAULT_ON)
true
#else
false
#endif
;
#endif
#if ENABLED(DELTA)
float delta[ABC],
@ -720,7 +710,8 @@ static void report_current_position();
SERIAL_ECHOPAIR(", ", z);
SERIAL_CHAR(')');
suffix ? serialprintPGM(suffix) : SERIAL_EOL;
if (suffix) {serialprintPGM(suffix);} //won't compile for Teensy with the previous construction
else SERIAL_EOL;
}
void print_xyz(const char* prefix, const char* suffix, const float xyz[]) {
@ -7678,11 +7669,18 @@ inline void gcode_M115() {
SERIAL_PROTOCOLLNPGM("Cap:SOFTWARE_POWER:0");
#endif
// TOGGLE_LIGHTS (M355)
// CASE LIGHTS (M355)
#if HAS_CASE_LIGHT
SERIAL_PROTOCOLLNPGM("Cap:TOGGLE_LIGHTS:1");
bool USEABLE_HARDWARE_PWM(uint8_t pin);
if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) {
SERIAL_PROTOCOLLNPGM("Cap:CASE_LIGHT_BRIGHTNESS:1");
}
else
SERIAL_PROTOCOLLNPGM("Cap:CASE_LIGHT_BRIGHTNESS:0");
#else
SERIAL_PROTOCOLLNPGM("Cap:TOGGLE_LIGHTS:0");
SERIAL_PROTOCOLLNPGM("Cap:CASE_LIGHT_BRIGHTNESS:0");
#endif
// EMERGENCY_PARSER (M108, M112, M410)
@ -9472,30 +9470,54 @@ inline void gcode_M907() {
#endif // HAS_MICROSTEPS
#if HAS_CASE_LIGHT
uint8_t case_light_brightness = 255;
#ifndef INVERT_CASE_LIGHT
#define INVERT_CASE_LIGHT false
#endif
int case_light_brightness; // LCD routine wants INT
bool case_light_on;
void update_case_light() {
WRITE(CASE_LIGHT_PIN, case_light_on != INVERT_CASE_LIGHT ? HIGH : LOW);
analogWrite(CASE_LIGHT_PIN, case_light_on != INVERT_CASE_LIGHT ? case_light_brightness : 0);
pinMode(CASE_LIGHT_PIN, OUTPUT); // digitalWrite doesn't set the port mode
uint8_t case_light_bright = (uint8_t)case_light_brightness;
if (case_light_on) {
if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) {
analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 - case_light_brightness : case_light_brightness );
}
else digitalWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? LOW : HIGH );
}
else digitalWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? HIGH : LOW);
}
#endif // HAS_CASE_LIGHT
/**
* M355: Turn case lights on/off and set brightness
* M355: Turn case light on/off and set brightness
*
* S<bool> Turn case light on or off
* P<byte> Set case light brightness (PWM pin required)
* P<byte> Set case light brightness (PWM pin required - ignored otherwise)
*
* S<bool> Set case light on/off
*
* When S turns on the light on a PWM pin then the current brightness level is used/restored
*
* M355 P200 S0 turns off the light & sets the brightness level
* M355 S1 turns on the light with a brightness of 200 (assuming a PWM pin)
*/
inline void gcode_M355() {
#if HAS_CASE_LIGHT
if (parser.seen('P')) case_light_brightness = parser.value_byte();
if (parser.seen('S')) case_light_on = parser.value_bool();
update_case_light();
uint8_t args = 0;
if (parser.seen('P')) ++args, case_light_brightness = parser.value_byte();
if (parser.seen('S')) ++args, case_light_on = parser.value_bool();
if (args) update_case_light();
// always report case light status
SERIAL_ECHO_START;
SERIAL_ECHOPGM("Case lights ");
case_light_on ? SERIAL_ECHOLNPGM("on") : SERIAL_ECHOLNPGM("off");
if (!case_light_on) {
SERIAL_ECHOLN("Case light: off");
}
else {
if (!USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) SERIAL_ECHOLN("Case light: on");
else SERIAL_ECHOLNPAIR("Case light: ", case_light_brightness);
}
#else
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_M355_NONE);
@ -10710,7 +10732,7 @@ void process_next_command() {
#endif // HAS_MICROSTEPS
case 355: // M355 Turn case lights on/off
case 355: // M355 set case light brightness
gcode_M355();
break;
@ -12459,6 +12481,8 @@ void setup() {
#endif
#if HAS_CASE_LIGHT
case_light_on = CASE_LIGHT_DEFAULT_ON;
case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
update_case_light();
#endif

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 35
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -233,12 +233,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -225,12 +225,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -220,12 +220,18 @@
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
// Define a pin to turn case light on/off
//#define CASE_LIGHT_PIN 4
#if PIN_EXISTS(CASE_LIGHT)
#define INVERT_CASE_LIGHT false // Set to true if HIGH is the OFF state (active low)
//#define CASE_LIGHT_DEFAULT_ON // Uncomment to set default state to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light On / Off entry in main menu
// M355 Case Light command
// Set case light brightness/on/off
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
#endif
//===========================================================================

View file

@ -30,6 +30,7 @@
#define _FASTIO_ARDUINO_H
#include <avr/io.h>
#include "macros.h"
/**
* Enable this option to use Teensy++ 2.0 assignments for AT90USB processors.
@ -238,4 +239,93 @@ typedef enum {
#define SET_FOCB(T,V) SET_FOC(T,B,V)
#define SET_FOCC(T,V) SET_FOC(T,C,V)
/**
* PWM availability macros
*/
#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__))
#define AVR_ATmega2560_FAMILY (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__))
#define AVR_ATmega2561_FAMILY (defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__))
#define AVR_ATmega328_FAMILY (defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328p__))
//find out which harware PWMs are already in use
#if PIN_EXISTS(CONTROLLER_FAN)
#define PWM_CHK_FAN_B(p) (p == CONTROLLER_FAN_PIN || p == E0_AUTO_FAN_PIN || p == E1_AUTO_FAN_PIN || p == E2_AUTO_FAN_PIN || p == E3_AUTO_FAN_PIN || p == E4_AUTO_FAN_PIN)
#else
#define PWM_CHK_FAN_B(p) (p == E0_AUTO_FAN_PIN || p == E1_AUTO_FAN_PIN || p == E2_AUTO_FAN_PIN || p == E3_AUTO_FAN_PIN || p == E4_AUTO_FAN_PIN)
#endif
#if PIN_EXISTS(FAN) || PIN_EXISTS(FAN1) || PIN_EXISTS(FAN2)
#if PIN_EXISTS(FAN2)
#define PWM_CHK_FAN_A(p) (p == FAN_PIN || p == FAN1_PIN || p == FAN2_PIN)
#elif PIN_EXISTS(FAN1)
#define PWM_CHK_FAN_A(p) (p == FAN_PIN || p == FAN1_PIN)
#else
#define PWM_CHK_FAN_A(p) p == FAN_PIN
#endif
#else
#define PWM_CHK_FAN_A(p) false
#endif
#if HAS_MOTOR_CURRENT_PWM
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
#define PWM_CHK_MOTOR_CURRENT(p) (p == MOTOR_CURRENT_PWM_E || p == MOTOR_CURRENT_PWM_Z || p == MOTOR_CURRENT_PWM_XY)
#elif PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
#define PWM_CHK_MOTOR_CURRENT(p) (p == MOTOR_CURRENT_PWM_E || p == MOTOR_CURRENT_PWM_Z)
#else
#define PWM_CHK_MOTOR_CURRENT(p) (p == MOTOR_CURRENT_PWM_E)
#endif
#else
#define PWM_CHK_MOTOR_CURRENT(p) false
#endif
#if defined(NUM_SERVOS)
#if AVR_ATmega2560_FAMILY
#define PWM_CHK_SERVO(p) ( p == 5 || NUM_SERVOS > 12 && p == 6 || NUM_SERVOS > 24 && p == 46) //PWMS 3A, 4A & 5A
#elif AVR_ATmega2561_FAMILY
#define PWM_CHK_SERVO(p) p == 5 //PWM3A
#elif AVR_ATmega1284_FAMILY
#define PWM_CHK_SERVO(p) false
#elif AVR_AT90USB1286_FAMILY
#define PWM_CHK_SERVO(p) p == 16 //PWM3A
#elif AVR_ATmega328_FAMILY
#define PWM_CHK_SERVO(p) false
#endif
#else
#define PWM_CHK_SERVO(p) false
#endif
#if ENABLED(BARICUDA)
#if HAS_HEATER_1 && HAS_HEATER_2
#define PWM_CHK_HEATER(p) (p == HEATER_1_PIN || p == HEATER_2_PIN)
#elif HAS_HEATER_1
#define PWM_CHK_HEATER(p) (p == HEATER_1_PIN)
#endif
#else
#define PWM_CHK_HEATER(p) false
#endif
#define PWM_CHK(p) (PWM_CHK_HEATER(p) || PWM_CHK_SERVO(p) || PWM_CHK_MOTOR_CURRENT(p)\
|| PWM_CHK_FAN_A(p) || PWM_CHK_FAN_B(p))
// define which hardware PWMs are available for the current CPU
// all timer 1 PWMS deleted from this list because they are never available
#if AVR_ATmega2560_FAMILY
#define PWM_PINS(p) ((p >= 2 && p <= 10 ) || p == 13 || p == 44 || p == 45 || p == 46 )
#elif AVR_ATmega2561_FAMILY
#define PWM_PINS(p) ((p >= 2 && p <= 6 ) || p == 9)
#elif AVR_ATmega1284_FAMILY
#define PWM_PINS(p) (p == 3 || p == 4 || p == 14 || p == 15)
#elif AVR_AT90USB1286_FAMILY
#define PWM_PINS(p) (p == 0 || p == 1 || p == 14 || p == 15 || p == 16 || p == 24)
#elif AVR_ATmega328_FAMILY
#define PWM_PINS(p) (p == 3 || p == 5 || p == 6 || p == 11)
#else
#error "unknown CPU"
#endif
// finally - the macro that tells us if a pin is an available hardware PWM
#define USEABLE_HARDWARE_PWM(p) (PWM_PINS(p) && !PWM_CHK(p))
#endif // _FASTIO_ARDUINO_H

View file

@ -706,7 +706,9 @@
#ifndef MSG_CASE_LIGHT
#define MSG_CASE_LIGHT _UxGT("Case light")
#endif
#ifndef MSG_CASE_LIGHT_BRIGHTNESS
#define MSG_CASE_LIGHT_BRIGHTNESS _UxGT("Light BRIGHTNESS")
#endif
#if LCD_WIDTH >= 20
#ifndef MSG_INFO_PRINT_COUNT
#define MSG_INFO_PRINT_COUNT _UxGT("Print Count")

View file

@ -60,6 +60,7 @@ int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2
uint8_t lcd_status_message_level;
char lcd_status_message[3 * (LCD_WIDTH) + 1] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1
#if ENABLED(STATUS_MESSAGE_SCROLLING)
uint8_t status_scroll_pos = 0;
#endif
@ -726,6 +727,24 @@ void kill_screen(const char* lcd_msg) {
#endif // SDSUPPORT
#if ENABLED(MENU_ITEM_CASE_LIGHT)
extern int case_light_brightness;
extern bool case_light_on;
extern void update_case_light();
void case_light_menu() {
START_MENU();
//
// ^ Main
//
MENU_BACK(MSG_MAIN);
MENU_ITEM_EDIT_CALLBACK(int3, MSG_CASE_LIGHT_BRIGHTNESS, &case_light_brightness, 0, 255, update_case_light, true);
MENU_ITEM_EDIT_CALLBACK(bool, MSG_CASE_LIGHT, (bool*)&case_light_on, update_case_light);
END_MENU();
}
#endif // MENU_ITEM_CASE_LIGHT
#if ENABLED(BLTOUCH)
/**
@ -847,11 +866,6 @@ void kill_screen(const char* lcd_msg) {
*
*/
#if ENABLED(MENU_ITEM_CASE_LIGHT)
extern bool case_light_on;
extern void update_case_light();
#endif
void lcd_main_menu() {
START_MENU();
MENU_BACK(MSG_WATCH);
@ -868,10 +882,14 @@ void kill_screen(const char* lcd_msg) {
#endif
//
// Switch case light on/off
// Set Case light on/off/brightness
//
#if ENABLED(MENU_ITEM_CASE_LIGHT)
MENU_ITEM_EDIT_CALLBACK(bool, MSG_CASE_LIGHT, &case_light_on, update_case_light);
if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) {
MENU_ITEM(submenu, MSG_CASE_LIGHT, case_light_menu);
}
else
MENU_ITEM_EDIT_CALLBACK(bool, MSG_CASE_LIGHT, (bool*)&case_light_on, update_case_light);
#endif
if (planner.movesplanned() || IS_SD_PRINTING) {
@ -2598,7 +2616,7 @@ void kill_screen(const char* lcd_msg) {
MENU_ITEM(submenu, MSG_FILAMENT, lcd_control_filament_menu);
#if HAS_LCD_CONTRAST
MENU_ITEM_EDIT_CALLBACK(int3, MSG_CONTRAST, &lcd_contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, lcd_callback_set_contrast, true);
MENU_ITEM_EDIT_CALLBACK(int3, MSG_CONTRAST, (int) &lcd_contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, lcd_callback_set_contrast, true);
#endif
#if ENABLED(FWRETRACT)
MENU_ITEM(submenu, MSG_RETRACT, lcd_control_retract_menu);

View file

@ -59,7 +59,7 @@
#if ENABLED(DOGLCD)
extern uint16_t lcd_contrast;
void set_lcd_contrast(uint16_t value);
void set_lcd_contrast(const uint16_t value);
#elif ENABLED(SHOW_BOOTSCREEN)
void bootscreen();
#endif