void Mixer::normalize(const uint8_t tool_index) { float cmax = 0; #ifdef MIXER_NORMALIZER_DEBUG float csum = 0; #endif MIXER_STEPPER_LOOP(i) { const float v = collector[i]; NOLESS(cmax, v); #ifdef MIXER_NORMALIZER_DEBUG csum += v; #endif } #ifdef MIXER_NORMALIZER_DEBUG SERIAL_ECHOPGM("Mixer: Old relation : [ "); MIXER_STEPPER_LOOP(i) { SERIAL_ECHO_F(collector[i] / csum, 3); SERIAL_CHAR(' '); } SERIAL_ECHOLNPGM("]"); #endif // Scale all values so their maximum is COLOR_A_MASK const float scale = float(COLOR_A_MASK) / cmax; MIXER_STEPPER_LOOP(i) color[tool_index][i] = collector[i] * scale; #ifdef MIXER_NORMALIZER_DEBUG csum = 0; SERIAL_ECHOPGM("Mixer: Normalize to : [ "); MIXER_STEPPER_LOOP(i) { SERIAL_ECHO(uint16_t(color[tool_index][i])); SERIAL_CHAR(' '); csum += color[tool_index][i]; } SERIAL_ECHOLNPGM("]"); SERIAL_ECHOPGM("Mixer: New relation : [ "); MIXER_STEPPER_LOOP(i) { SERIAL_ECHO_F(uint16_t(color[tool_index][i]) / csum, 3); SERIAL_CHAR(' '); } SERIAL_ECHOLNPGM("]"); #endif #if ENABLED(GRADIENT_MIX) refresh_gradient(); #endif }
void debug_current_and_destination(const char *title) { // if the title message starts with a '!' it is so important, we are going to // ignore the status of the g26_debug_flag if (*title != '!' && !g26_debug_flag) return; const float de = destination[E_AXIS] - current_position[E_AXIS]; if (de == 0.0) return; // Printing moves only const float dx = destination[X_AXIS] - current_position[X_AXIS], dy = destination[Y_AXIS] - current_position[Y_AXIS], xy_dist = HYPOT(dx, dy); if (xy_dist == 0.0) return; SERIAL_ECHOPGM(" fpmm="); const float fpmm = de / xy_dist; SERIAL_ECHO_F(fpmm, 6); SERIAL_ECHOPGM(" current=( "); SERIAL_ECHO_F(current_position[X_AXIS], 6); SERIAL_ECHOPGM(", "); SERIAL_ECHO_F(current_position[Y_AXIS], 6); SERIAL_ECHOPGM(", "); SERIAL_ECHO_F(current_position[Z_AXIS], 6); SERIAL_ECHOPGM(", "); SERIAL_ECHO_F(current_position[E_AXIS], 6); SERIAL_ECHOPGM(" ) destination=( "); debug_echo_axis(X_AXIS); SERIAL_ECHOPGM(", "); debug_echo_axis(Y_AXIS); SERIAL_ECHOPGM(", "); debug_echo_axis(Z_AXIS); SERIAL_ECHOPGM(", "); debug_echo_axis(E_AXIS); SERIAL_ECHOPGM(" ) "); SERIAL_ECHO(title); SERIAL_EOL(); }
static void debug_echo_axis(const AxisEnum axis) { if (current_position[axis] == destination[axis]) SERIAL_ECHOPGM("-------------"); else SERIAL_ECHO_F(destination[X_AXIS], 6); }
/** * Produce one of these mesh maps: * 0: Human-readable * 1: CSV format for spreadsheet import * 2: TODO: Display on Graphical LCD * 4: Compact Human-Readable */ void unified_bed_leveling::display_map(const int map_type) { #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE) suspend_auto_report = true; #endif constexpr uint8_t eachsp = 1 + 6 + 1, // [-3.567] twixt = eachsp * (GRID_MAX_POINTS_X) - 9 * 2; // Leading 4sp, Coordinates 9sp each const bool human = !(map_type & 0x3), csv = map_type == 1, lcd = map_type == 2, comp = map_type & 0x4; SERIAL_ECHOPGM("\nBed Topography Report"); if (human) { SERIAL_ECHOLNPGM(":\n"); serial_echo_xy(4, MESH_MIN_X, MESH_MAX_Y); serial_echo_xy(twixt, MESH_MAX_X, MESH_MAX_Y); SERIAL_EOL(); serial_echo_column_labels(eachsp - 2); } else { SERIAL_ECHOPGM(" for "); serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n")); } const float current_xi = get_cell_index_x(current_position[X_AXIS] + (MESH_X_DIST) / 2.0), current_yi = get_cell_index_y(current_position[Y_AXIS] + (MESH_Y_DIST) / 2.0); if (!lcd) SERIAL_EOL(); for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) { // Row Label (J index) if (human) { if (j < 10) SERIAL_CHAR(' '); SERIAL_ECHO(j); SERIAL_ECHOPGM(" |"); } // Row Values (I indexes) for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) { // Opening Brace or Space const bool is_current = i == current_xi && j == current_yi; if (human) SERIAL_CHAR(is_current ? '[' : ' '); // Z Value at current I, J const float f = z_values[i][j]; if (lcd) { // TODO: Display on Graphical LCD } else if (isnan(f)) serialprintPGM(human ? PSTR(" . ") : PSTR("NAN")); else if (human || csv) { if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Space for positive ('-' for negative) SERIAL_ECHO_F(f, 3); // Positive: 5 digits, Negative: 6 digits } if (csv && i < GRID_MAX_POINTS_X - 1) SERIAL_CHAR('\t'); // Closing Brace or Space if (human) SERIAL_CHAR(is_current ? ']' : ' '); SERIAL_FLUSHTX(); idle(); } if (!lcd) SERIAL_EOL(); // A blank line between rows (unless compact) if (j && human && !comp) SERIAL_ECHOLNPGM(" |"); } if (human) { serial_echo_column_labels(eachsp - 2); SERIAL_EOL(); serial_echo_xy(4, MESH_MIN_X, MESH_MIN_Y); serial_echo_xy(twixt, MESH_MAX_X, MESH_MIN_Y); SERIAL_EOL(); SERIAL_EOL(); } #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE) suspend_auto_report = false; #endif }