Apply loop shorthand macros (#17159)

This commit is contained in:
Scott Lahteine
2020-03-13 23:18:16 -05:00
committed by GitHub
parent a96be32fae
commit 118bd2f8b2
93 changed files with 465 additions and 505 deletions

View File

@ -124,7 +124,7 @@ inline void park_above_object(measurements_t &m, const float uncertainty) {
#if HAS_HOTEND_OFFSET
inline void normalize_hotend_offsets() {
for (uint8_t e = 1; e < HOTENDS; e++)
LOOP_S_L_N(e, 1, HOTENDS)
hotend_offset[e] -= hotend_offset[0];
hotend_offset[0].reset();
}
@ -393,7 +393,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
// This function requires normalize_hotend_offsets() to be called
//
inline void report_hotend_offsets() {
for (uint8_t e = 1; e < HOTENDS; e++)
LOOP_S_L_N(e, 1, HOTENDS)
SERIAL_ECHOLNPAIR_P(PSTR("T"), int(e), PSTR(" Hotend Offset X"), hotend_offset[e].x, SP_Y_STR, hotend_offset[e].y, SP_Z_STR, hotend_offset[e].z);
}
#endif

View File

@ -158,14 +158,14 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
while (start_free_memory < end_free_memory) {
print_hex_address(start_free_memory); // Print the address
SERIAL_CHAR(':');
for (uint8_t i = 0; i < 16; i++) { // and 16 data bytes
LOOP_L_N(i, 16) { // and 16 data bytes
if (i == 8) SERIAL_CHAR('-');
print_hex_byte(start_free_memory[i]);
SERIAL_CHAR(' ');
}
serial_delay(25);
SERIAL_CHAR('|'); // Point out non test bytes
for (uint8_t i = 0; i < 16; i++) {
LOOP_L_N(i, 16) {
char ccc = (char)start_free_memory[i]; // cast to char before automatically casting to char on assignment, in case the compiler is broken
ccc = (ccc == TEST_BYTE) ? ' ' : '?';
SERIAL_CHAR(ccc);

View File

@ -126,7 +126,7 @@ void GcodeSuite::M48() {
if (probing_good) {
randomSeed(millis());
for (uint8_t n = 0; n < n_samples; n++) {
LOOP_L_N(n, n_samples) {
#if HAS_SPI_LCD
// Display M48 progress in the status bar
ui.status_printf_P(0, PSTR(S_FMT ": %d/%d"), GET_TEXT(MSG_M48_POINT), int(n + 1), int(n_samples));
@ -149,7 +149,7 @@ void GcodeSuite::M48() {
SERIAL_ECHOLNPGM("CW");
}
for (uint8_t l = 0; l < n_legs - 1; l++) {
LOOP_L_N(l, n_legs - 1) {
float delta_angle;
if (schizoid_flag) {
@ -204,7 +204,7 @@ void GcodeSuite::M48() {
* Get the current mean for the data points we have so far
*/
float sum = 0.0;
for (uint8_t j = 0; j <= n; j++) sum += sample_set[j];
LOOP_LE_N(j, n) sum += sample_set[j];
mean = sum / (n + 1);
NOMORE(min, sample_set[n]);
@ -215,7 +215,7 @@ void GcodeSuite::M48() {
* data points we have so far
*/
sum = 0.0;
for (uint8_t j = 0; j <= n; j++)
LOOP_LE_N(j, n)
sum += sq(sample_set[j] - mean);
sigma = SQRT(sum / (n + 1));