Skip to content

Commit 4e19c59

Browse files
committed
Miscellaneous cleanup
1 parent 9cf5b96 commit 4e19c59

File tree

4 files changed

+50
-86
lines changed

4 files changed

+50
-86
lines changed

Marlin/Marlin_main.cpp

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8942,8 +8942,8 @@ inline void gcode_M205() {
89428942
set_home_offset((AxisEnum)i, parser.value_linear_units());
89438943

89448944
#if ENABLED(MORGAN_SCARA)
8945-
if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_linear_units()); // Theta
8946-
if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_linear_units()); // Psi
8945+
if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_float()); // Theta
8946+
if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi
89478947
#endif
89488948

89498949
report_current_position();
@@ -9319,14 +9319,14 @@ inline void gcode_M226() {
93199319
#if ENABLED(BABYSTEP_XY)
93209320
for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
93219321
if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
9322-
const float offs = constrain(parser.value_axis_units(a), -2, 2);
9322+
const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
93239323
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
93249324
if (a == Z_AXIS) {
93259325
zprobe_zoffset += offs;
93269326
refresh_zprobe_zoffset(true); // 'true' to not babystep
93279327
}
93289328
#endif
9329-
thermalManager.babystep_axis(a, offs * planner.axis_steps_per_mm[a]);
9329+
thermalManager.babystep_axis((AxisEnum)a, offs * planner.axis_steps_per_mm[a]);
93309330
}
93319331
#else
93329332
if (parser.seenval('Z') || parser.seenval('S')) {
@@ -13318,48 +13318,27 @@ void prepare_move_to_destination() {
1331813318
#if !AVR_AT90USB1286_FAMILY
1331913319
case TIMER0A:
1332013320
#endif
13321-
case TIMER0B:
13322-
//_SET_CS(0, val);
13323-
break;
13321+
case TIMER0B: //_SET_CS(0, val);
13322+
break;
1332413323
#endif
13325-
#ifdef TCCR1A
13326-
case TIMER1A:
13327-
case TIMER1B:
13328-
//_SET_CS(1, val);
13329-
break;
13324+
#ifdef TCCR1A
13325+
case TIMER1A: case TIMER1B: //_SET_CS(1, val);
13326+
break;
1333013327
#endif
13331-
#ifdef TCCR2
13332-
case TIMER2:
13333-
case TIMER2:
13334-
_SET_CS(2, val);
13335-
break;
13328+
#ifdef TCCR2
13329+
case TIMER2: case TIMER2: _SET_CS(2, val); break;
1333613330
#endif
13337-
#ifdef TCCR2A
13338-
case TIMER2A:
13339-
case TIMER2B:
13340-
_SET_CS(2, val);
13341-
break;
13331+
#ifdef TCCR2A
13332+
case TIMER2A: case TIMER2B: _SET_CS(2, val); break;
1334213333
#endif
13343-
#ifdef TCCR3A
13344-
case TIMER3A:
13345-
case TIMER3B:
13346-
case TIMER3C:
13347-
_SET_CS(3, val);
13348-
break;
13334+
#ifdef TCCR3A
13335+
case TIMER3A: case TIMER3B: case TIMER3C: _SET_CS(3, val); break;
1334913336
#endif
13350-
#ifdef TCCR4A
13351-
case TIMER4A:
13352-
case TIMER4B:
13353-
case TIMER4C:
13354-
_SET_CS(4, val);
13355-
break;
13337+
#ifdef TCCR4A
13338+
case TIMER4A: case TIMER4B: case TIMER4C: _SET_CS(4, val); break;
1335613339
#endif
13357-
#ifdef TCCR5A
13358-
case TIMER5A:
13359-
case TIMER5B:
13360-
case TIMER5C:
13361-
_SET_CS(5, val);
13362-
break;
13340+
#ifdef TCCR5A
13341+
case TIMER5A: case TIMER5B: case TIMER5C: _SET_CS(5, val); break;
1336313342
#endif
1336413343
}
1336513344
}

Marlin/Max7219_Debug_LEDs.cpp

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -63,54 +63,41 @@
6363

6464
static uint8_t LEDs[8] = { 0 };
6565

66+
#ifdef CPU_32_BIT
67+
#define MS_DELAY() delayMicroseconds(5) // 32-bit processors need a delay to stabilize the signal
68+
#else
69+
#define MS_DELAY() NOOP
70+
#endif
71+
6672
void Max7219_PutByte(uint8_t data) {
6773
CRITICAL_SECTION_START
6874
for (uint8_t i = 8; i--;) {
69-
#ifdef CPU_32_BIT // The 32-bit processors are so fast, a small delay in the code is needed
70-
delayMicroseconds(5); // to let the signal wires stabilize.
71-
WRITE(MAX7219_CLK_PIN, LOW); // tick
72-
delayMicroseconds(5);
73-
WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW); // send 1 or 0 based on data bit
74-
delayMicroseconds(5);
75-
WRITE(MAX7219_CLK_PIN, HIGH); // tock
76-
delayMicroseconds(5);
77-
#else
78-
WRITE(MAX7219_CLK_PIN, LOW); // tick
79-
WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW); // send 1 or 0 based on data bit
80-
WRITE(MAX7219_CLK_PIN, HIGH); // tock
81-
#endif
82-
75+
MS_DELAY();
76+
WRITE(MAX7219_CLK_PIN, LOW); // tick
77+
MS_DELAY();
78+
WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW); // send 1 or 0 based on data bit
79+
MS_DELAY();
80+
WRITE(MAX7219_CLK_PIN, HIGH); // tock
81+
MS_DELAY();
8382
data <<= 1;
8483
}
8584
CRITICAL_SECTION_END
8685
}
8786

8887
void Max7219(const uint8_t reg, const uint8_t data) {
89-
#ifdef CPU_32_BIT
90-
delayMicroseconds(5);
91-
#endif
88+
MS_DELAY();
9289
CRITICAL_SECTION_START
9390
WRITE(MAX7219_LOAD_PIN, LOW); // begin
94-
#ifdef CPU_32_BIT // The 32-bit processors are so fast, a small delay in the code is needed
95-
delayMicroseconds(5); // to let the signal wires stabilize.
96-
#endif
91+
MS_DELAY();
9792
Max7219_PutByte(reg); // specify register
98-
#ifdef CPU_32_BIT
99-
delayMicroseconds(5);
100-
#endif
93+
MS_DELAY();
10194
Max7219_PutByte(data); // put data
102-
#ifdef CPU_32_BIT
103-
delayMicroseconds(5);
104-
#endif
95+
MS_DELAY();
10596
WRITE(MAX7219_LOAD_PIN, LOW); // and tell the chip to load the data
106-
#ifdef CPU_32_BIT
107-
delayMicroseconds(5);
108-
#endif
97+
MS_DELAY();
10998
WRITE(MAX7219_LOAD_PIN, HIGH);
11099
CRITICAL_SECTION_END
111-
#ifdef CPU_32_BIT
112-
delayMicroseconds(5);
113-
#endif
100+
MS_DELAY();
114101
}
115102

116103
void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) {
@@ -329,23 +316,22 @@ void Max7219_idle_tasks() {
329316

330317
#if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE)
331318
static millis_t next_blink = 0;
332-
333319
if (ELAPSED(millis(), next_blink)) {
334-
Max7219_LED_Toggle(7, 7);
335-
next_blink = millis() + 750;
320+
Max7219_LED_Toggle(7, 7);
321+
next_blink = millis() + 750;
336322
}
337323
#endif
338324

339325
#ifdef MAX7219_DEBUG_STEPPER_HEAD
340326
static int16_t last_head_cnt=0;
341327
if (last_head_cnt != head) {
342-
if ( last_head_cnt < 8)
328+
if (last_head_cnt < 8)
343329
Max7219_LED_Off( last_head_cnt, MAX7219_DEBUG_STEPPER_HEAD);
344330
else
345331
Max7219_LED_Off( last_head_cnt-8, MAX7219_DEBUG_STEPPER_HEAD+1);
346332

347333
last_head_cnt = head;
348-
if ( head < 8)
334+
if (head < 8)
349335
Max7219_LED_On(head, MAX7219_DEBUG_STEPPER_HEAD);
350336
else
351337
Max7219_LED_On(head-8, MAX7219_DEBUG_STEPPER_HEAD+1);
@@ -355,13 +341,13 @@ void Max7219_idle_tasks() {
355341
#ifdef MAX7219_DEBUG_STEPPER_TAIL
356342
static int16_t last_tail_cnt=0;
357343
if (last_tail_cnt != tail) {
358-
if ( last_tail_cnt < 8)
344+
if (last_tail_cnt < 8)
359345
Max7219_LED_Off( last_tail_cnt, MAX7219_DEBUG_STEPPER_TAIL);
360346
else
361347
Max7219_LED_Off( last_tail_cnt-8, MAX7219_DEBUG_STEPPER_TAIL+1);
362348

363349
last_tail_cnt = tail;
364-
if ( tail < 8)
350+
if (tail < 8)
365351
Max7219_LED_On(tail, MAX7219_DEBUG_STEPPER_TAIL);
366352
else
367353
Max7219_LED_On(tail-8, MAX7219_DEBUG_STEPPER_TAIL+1);
@@ -381,10 +367,10 @@ void Max7219_idle_tasks() {
381367
en = max(current_depth, last_depth);
382368
if (current_depth < last_depth)
383369
for (uint8_t i = st; i <= en; i++) // clear the highest order LEDs
384-
Max7219_LED_Off(i/2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
370+
Max7219_LED_Off(i/2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
385371
else
386-
for (uint8_t i = st; i <= en; i++) // set the LEDs to current depth
387-
Max7219_LED_On(i/2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
372+
for (uint8_t i = st; i <= en; i++) // set the LEDs to current depth
373+
Max7219_LED_On(i/2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
388374

389375
last_depth = current_depth;
390376
}

Marlin/configuration_store.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ MarlinSettings settings;
215215
#endif
216216

217217
/**
218-
* Post-process after Retrieve or Reset
219-
*/
218+
* Post-process after Retrieve or Reset
219+
*/
220220
void MarlinSettings::postprocess() {
221221
// steps per s2 needs to be updated to agree with units per s2
222222
planner.reset_acceleration_rates();

Marlin/planner.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,7 @@ void Planner::check_axes_activity() {
528528
}
529529

530530
inline float calculate_volumetric_multiplier(const float &diameter) {
531-
if (!parser.volumetric_enabled || diameter == 0) return 1.0;
532-
return 1.0 / CIRCLE_AREA(diameter * 0.5);
531+
return (parser.volumetric_enabled && diameter) ? 1.0 / CIRCLE_AREA(diameter * 0.5) : 1.0;
533532
}
534533

535534
void Planner::calculate_volumetric_multipliers() {

0 commit comments

Comments
 (0)