M355 S0, S1 fixes & faster LCD, SD card
fix Travis error
This commit is contained in:
committed by
Bob-the-Kuhn
parent
8c622a59cf
commit
bea3ec2724
@ -27,19 +27,38 @@
|
||||
uint8_t case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
|
||||
bool case_light_on = CASE_LIGHT_DEFAULT_ON;
|
||||
|
||||
/**
|
||||
* 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 arguement type
|
||||
|
||||
#ifndef INVERT_CASE_LIGHT
|
||||
#define INVERT_CASE_LIGHT false
|
||||
#endif
|
||||
|
||||
void update_case_light() {
|
||||
SET_OUTPUT(CASE_LIGHT_PIN);
|
||||
|
||||
if (!(case_light_arg_flag && !case_light_on))
|
||||
case_light_brightness_sav = case_light_brightness; // save brightness except if this is an S0 arguement
|
||||
if (case_light_arg_flag && case_light_on)
|
||||
case_light_brightness = case_light_brightness_sav; // restore last brightens if this is an S1 arguement
|
||||
|
||||
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 WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? LOW : HIGH);
|
||||
}
|
||||
else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? HIGH : LOW);
|
||||
else {
|
||||
if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN))
|
||||
analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 : 0 ); // turn the light off
|
||||
WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? HIGH : LOW);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAS_CASE_LIGHT
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
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 arguement type
|
||||
|
||||
void update_case_light();
|
||||
|
||||
|
Reference in New Issue
Block a user