Skip to content

Commit

Permalink
misc. cleanup, style
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 5, 2022
1 parent 08d7b0d commit 3a16d57
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 35 deletions.
17 changes: 10 additions & 7 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -3251,18 +3251,19 @@
* luminance values can be set from 0 to 255.
* For NeoPixel LED an overall brightness parameter is also available.
*
* *** CAUTION ***
* === CAUTION ===
* LED Strips require a MOSFET Chip between PWM lines and LEDs,
* as the Arduino cannot handle the current the LEDs will require.
* Failure to follow this precaution can destroy your Arduino!
*
* NOTE: A separate 5V power supply is required! The NeoPixel LED needs
* more current than the Arduino 5V linear regulator can produce.
* *** CAUTION ***
*
* LED Type. Enable only one of the following two options.
* Require PWM frequency between 50 <> 100hz (Check hal or variant settings)
* Use FAST_PWM_FAN if possible, fans can be noisy.
* Requires PWM frequency between 50 <> 100Hz (Check HAL or variant)
* Use FAST_PWM_FAN, if possible, to reduce fan noise.
*/

// LED Type. Enable only one of the following two options:
//#define RGB_LED
//#define RGBW_LED

Expand All @@ -3271,8 +3272,10 @@
//#define RGB_LED_G_PIN 43
//#define RGB_LED_B_PIN 35
//#define RGB_LED_W_PIN -1
#define RGB_STARTUP_TEST // If pwm pins, fade between all colors if not only switch.
#define RGB_STARTUP_TEST_SLOWING_MS 10 // (ms) Reduce or increase fading speed.
//#define RGB_STARTUP_TEST // For PWM pins, fade between all colors
#if ENABLED(RGB_STARTUP_TEST)
#define RGB_STARTUP_TEST_INNER_MS 10 // (ms) Reduce or increase fading speed
#endif
#endif

// Support for Adafruit NeoPixel LED driver
Expand Down
4 changes: 1 addition & 3 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -870,12 +870,10 @@
#define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate)

//#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (linear=mm, rotational=°) Backoff from endstops after homing
//#define XY_COUNTERPART_BACKOFF_MM 0 // (mm) Backoff X after homing Y, and vice-versa

//#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
#if ENABLED(HOME_Y_BEFORE_X)
#define OPPOSITE_AXIS_BACKOFF_MM 10 // (linear=mm, rotational=°) Backoff X before Y homing or inverse (prevent colision with opposite axis endstop)
#endif
//#define HOME_Z_FIRST // Home Z first. Requires a Z-MIN endstop (not a probe).
//#define CODEPENDENT_XY_HOMING // If X/Y can't home without homing Y/X first

Expand Down
35 changes: 15 additions & 20 deletions Marlin/src/feature/leds/leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,27 @@ void LEDLights::setup() {
#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
#ifdef RGB_STARTUP_TEST
#if ENABLED(RGB_STARTUP_TEST)
int8_t led_pin_count = 0;
uint16_t led_pwm;
if (PWM_PIN(RGB_LED_R_PIN) && PWM_PIN(RGB_LED_G_PIN) && PWM_PIN(RGB_LED_B_PIN)) led_pin_count = 3;
if (PWM_PIN(RGB_LED_R_PIN) && PWM_PIN(RGB_LED_G_PIN) && PWM_PIN(RGB_LED_B_PIN)) led_pin_count = 3;
#if ENABLED(RGBW_LED)
if (PWM_PIN(RGB_LED_W_PIN) && led_pin_count) led_pin_count++;
#endif
//Startup animation
if (led_pin_count){
for (uint8_t i = 0; i < led_pin_count; i++) {
for (uint8_t b = 0; b < 201; b++) {
if (b <= 100) led_pwm = b;
if (b > 100) --led_pwm ;
LIMIT(led_pwm,0,100);
if (i == 0 && PWM_PIN(RGB_LED_R_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_R_PIN), led_pwm); else WRITE(RGB_LED_R_PIN, b < 100 ? HIGH : LOW);
if (i == 0 && PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), led_pwm); else WRITE(RGB_LED_G_PIN, b < 100 ? HIGH : LOW);
if (i == 0 && PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), led_pwm); else WRITE(RGB_LED_B_PIN, b < 100 ? HIGH : LOW);
#if ENABLED(RGBW_LED)
if (i == 0 && PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), led_pwm); else WRITE(RGB_LED_W_PIN, b < 100 ? HIGH : LOW);
#endif
delay(RGB_STARTUP_TEST_SLOWING_MS);
}
// Startup animation
LOOP_L_N(i, led_pin_count) {
LOOP_LE_N(b, 200) {
const uint16_t led_pwm = b <= 100 ? b : 200 - b;
if (i == 0 && PWM_PIN(RGB_LED_R_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_R_PIN), led_pwm); else WRITE(RGB_LED_R_PIN, b < 100 ? HIGH : LOW);
if (i == 0 && PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), led_pwm); else WRITE(RGB_LED_G_PIN, b < 100 ? HIGH : LOW);
if (i == 0 && PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), led_pwm); else WRITE(RGB_LED_B_PIN, b < 100 ? HIGH : LOW);
#if ENABLED(RGBW_LED)
if (i == 0 && PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), led_pwm); else WRITE(RGB_LED_W_PIN, b < 100 ? HIGH : LOW);
#endif
delay(RGB_STARTUP_TEST_INNER_MS);
}
delay(1000);
}
#endif//RGB_STARTUP_TEST
if (led_pin_count) delay(1000);
#endif // RGB_STARTUP_TEST
#endif
TERN_(NEOPIXEL_LED, neo.init());
TERN_(PCA9533, PCA9533_init());
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1997,11 +1997,11 @@ void prepare_line_to_destination() {
//
// Back away to prevent opposite endstop damage
//
#if !defined(SENSORLESS_BACKOFF_MM) && defined(OPPOSITE_AXIS_BACKOFF_MM)
if (axis == Y_AXIS || axis == X_AXIS ){
const AxisEnum opposite_axis = axis == Y_AXIS ? X_AXIS : Y_AXIS ;
const float backoff_length = -ABS(OPPOSITE_AXIS_BACKOFF_MM) * home_dir(opposite_axis);
do_homing_move(opposite_axis, backoff_length, homing_feedrate(opposite_axis));
#if !defined(SENSORLESS_BACKOFF_MM) && XY_COUNTERPART_BACKOFF_MM
if (axis == X_AXIS || axis == Y_AXIS) {
const AxisEnum opposite_axis = axis == X_AXIS ? Y_AXIS : X_AXIS;
const float backoff_length = -ABS(XY_COUNTERPART_BACKOFF_MM) * home_dir(opposite_axis);
do_homing_move(opposite_axis, backoff_length, homing_feedrate(opposite_axis));
}
#endif

Expand Down

0 comments on commit 3a16d57

Please sign in to comment.