Merge pull request #7144 from thinkyhead/bf_ubl_g26_p4_surface

Added option 'H' to G29 P4.
This commit is contained in:
Scott Lahteine 2017-06-26 16:34:48 -05:00 committed by GitHub
commit 89c6e92b66
3 changed files with 139 additions and 153 deletions

View file

@ -115,7 +115,7 @@
#endif #endif
static float measure_point_with_encoder(); static float measure_point_with_encoder();
static float measure_business_card_thickness(float&); static float measure_business_card_thickness(float);
static bool g29_parameter_parsing(); static bool g29_parameter_parsing();
static void find_mean_mesh_height(); static void find_mean_mesh_height();
static void shift_mesh_height(); static void shift_mesh_height();

View file

@ -84,25 +84,23 @@
* *
* A Activate Activate the Unified Bed Leveling system. * A Activate Activate the Unified Bed Leveling system.
* *
* B # Business Use the 'Business Card' mode of the Manual Probe subsystem. This is invoked as * B # Business Use the 'Business Card' mode of the Manual Probe subsystem with P2.
* G29 P2 B. The mode of G29 P2 allows you to use a business card or recipe card * Note: A non-compressible Spark Gap feeler gauge is recommended over a business card.
* as a shim that the nozzle will pinch as it is lowered. The idea is that you * In this mode of G29 P2, a business or index card is used as a shim that the nozzle can
* can easily feel the nozzle getting to the same height by the amount of resistance * grab onto as it is lowered. In principle, the nozzle-bed distance is the same when the
* the business card exhibits to movement. You should try to achieve the same amount * same resistance is felt in the shim. You can omit the numerical value on first invocation
* of resistance on each probed point to facilitate accurate and repeatable measurements. * of G29 P2 B to measure shim thickness. Subsequent use of 'B' will apply the previously-
* You should be very careful not to drive the nozzle into the business card with a * measured thickness by default.
* lot of force as it is very possible to cause damage to your printer if your are
* careless. If you use the B option with G29 P2 B you can omit the numeric value
* on first use to measure the business card's thickness. Subsequent usage of 'B'
* will apply the previously-measured thickness as the default.
* Note: A non-compressible Spark Gap feeler gauge is recommended over a Business Card.
* *
* C Continue Continue, Constant, Current Location. This is not a primary command. C is used to * C Continue G29 P1 C continues the generation of a partially-constructed Mesh without invalidating
* further refine the behaviour of several other commands. Issuing a G29 P1 C will * previous measurements.
* continue the generation of a partially constructed Mesh without invalidating what has *
* been done. Issuing a G29 P2 C will tell the Manual Probe subsystem to use the current * C Constant G29 P2 C specifies a Constant and tells the Manual Probe subsystem to use the current
* location in its search for the closest unmeasured Mesh Point. When used with a G29 Z C * location in its search for the closest unmeasured Mesh Point.
* it indicates to use the current location instead of defaulting to the center of the print bed. *
* G29 P3 C specifies the Constant for the fill. Otherwise, uses a "reasonable" value.
*
* C Current G29 Z C uses the Current location (instead of bed center or nearest edge).
* *
* D Disable Disable the Unified Bed Leveling system. * D Disable Disable the Unified Bed Leveling system.
* *
@ -112,17 +110,18 @@
* specified height, no correction is applied and natural printer kenimatics take over. If no * specified height, no correction is applied and natural printer kenimatics take over. If no
* number is specified for the command, 10mm is assumed to be reasonable. * number is specified for the command, 10mm is assumed to be reasonable.
* *
* H # Height Specify the Height to raise the nozzle after each manual probe of the bed. The * H # Height With P2, 'H' specifies the Height to raise the nozzle after each manual probe of the bed.
* default is 5mm. * If omitted, the nozzle will raise by Z_CLEARANCE_BETWEEN_PROBES.
* *
* I # Invalidate Invalidate specified number of Mesh Points. The nozzle location is used unless * H # Offset With P4, 'H' specifies the Offset above the mesh height to place the nozzle.
* the X and Y parameter are used. If no number is specified, only the closest Mesh * If omitted, Z_CLEARANCE_BETWEEN_PROBES will be used.
* point to the location is invalidated. The 'T' parameter is also available to produce *
* a map after the operation. This command is useful to invalidate a portion of the * I # Invalidate Invalidate the specified number of Mesh Points near the given 'X' 'Y'. If X or Y are omitted,
* Mesh so it can be adjusted using other tools in the Unified Bed Leveling System. When * the nozzle location is used. If no 'I' value is given, only the point nearest to the location
* attempting to invalidate an isolated bad point in the mesh, the 'T' option will indicate * is invalidated. Use 'T' to produce a map afterward. This command is useful to invalidate a
* where the nozzle is positioned in the Mesh with (#). You can move the nozzle around on * portion of the Mesh so it can be adjusted using other UBL tools. When attempting to invalidate
* the bed and use this feature to select the center of the area (or cell) you want to * an isolated bad mesh point, the 'T' option shows the nozzle position in the Mesh with (#). You
* can move the nozzle around and use this feature to select the center of the area (or cell) to
* invalidate. * invalidate.
* *
* J # Grid Perform a Grid Based Leveling of the current Mesh using a grid with n points on a side. * J # Grid Perform a Grid Based Leveling of the current Mesh using a grid with n points on a side.
@ -151,95 +150,81 @@
* area cannot be automatically probed. For Delta printers the area in which DELTA_PROBEABLE_RADIUS * area cannot be automatically probed. For Delta printers the area in which DELTA_PROBEABLE_RADIUS
* and DELTA_PRINTABLE_RADIUS do not overlap will not be automatically probed. * and DELTA_PRINTABLE_RADIUS do not overlap will not be automatically probed.
* *
* These points will be handled in Phase 2 and Phase 3. If the Phase 1 command is given the * Unreachable points will be handled in Phase 2 and Phase 3.
* C (Continue) parameter it does not invalidate the Mesh prior to automatically
* probing needed locations. This allows you to invalidate portions of the Mesh but still
* use the automatic probing capabilities of the Unified Bed Leveling System. An X and Y
* parameter can be given to prioritize where the command should be trying to measure points.
* If the X and Y parameters are not specified the current probe position is used.
* P1 accepts a 'T' (Topology) parameter so you can observe mesh generation.
* P1 also watches for the LCD Panel Encoder Switch to be held down (assuming you have one),
* and will suspend generation of the Mesh in that case. (Note: This check is only done
* between probe points, so you must press and hold the switch until the Phase 1 command
* detects it.)
* *
* P2 Phase 2 Probe areas of the Mesh that can't be automatically handled. Phase 2 respects an H * Use 'C' to leave the previous mesh intact and automatically probe needed points. This allows you
* parameter to control the height between Mesh points. The default height for movement * to invalidate parts of the Mesh but still use Automatic Probing.
* between Mesh points is 5mm. A smaller number can be used to make this part of the
* calibration less time consuming. You will be running the nozzle down until it just barely
* touches the glass. You should have the nozzle clean with no plastic obstructing your view.
* Use caution and move slowly. It is possible to damage your printer if you are careless.
* Note that this command will use the configuration #define SIZE_OF_LITTLE_RAISE if the
* nozzle is moving a distance of less than BIG_RAISE_NOT_NEEDED.
* *
* The H parameter can be set negative if your Mesh dips in a large area. You can press * The 'X' and 'Y' parameters prioritize where to try and measure points. If omitted, the current
* and hold the LCD Panel's encoder wheel to terminate the current Phase 2 command. You * probe position is used.
* can then re-issue the G29 P 2 command with an H parameter that is more suitable for the
* area you are manually probing. Note that the command tries to start you in a corner
* of the bed where movement will be predictable. You can force the location to be used in
* the distance calculations by using the X and Y parameters. You may find it is helpful to
* print out a Mesh Map (G29 T) to understand where the mesh is invalidated and where
* the nozzle will need to move in order to complete the command. The C parameter is
* available on the Phase 2 command also and indicates the search for points to measure should
* be done based on the current location of the nozzle.
* *
* A B parameter is also available for this command and described up above. It places the * Use 'T' (Topology) to generate a report of mesh generation.
* manual probe subsystem into Business Card mode where the thickness of a business card is
* measured and then used to accurately set the nozzle height in all manual probing for the
* duration of the command. (S for Shim mode would be a better parameter name, but S is needed
* for Save or Store of the Mesh to EEPROM) A Business card can be used, but you will have
* better results if you use a flexible Shim that does not compress very much. That makes it
* easier for you to get the nozzle to press with similar amounts of force against the shim so you
* can get accurate measurements. As you are starting to touch the nozzle against the shim try
* to get it to grasp the shim with the same force as when you measured the thickness of the
* shim at the start of the command.
* *
* Phase 2 allows the T (Map) parameter to be specified. This helps the user see the progression * P1 will suspend Mesh generation if the controller button is held down. Note that you may need
* of the Mesh being built. * to press and hold the switch for several seconds if moves are underway.
* *
* NOTE: P2 is not available unless you have LCD support enabled! * P2 Phase 2 Probe unreachable points.
* *
* P3 Phase 3 Fill the unpopulated regions of the Mesh with a fixed value. There are two different paths the * Use 'H' to set the height between Mesh points. If omitted, Z_CLEARANCE_BETWEEN_PROBES is used.
* user can go down. If the user specifies the value using the C parameter, the closest invalid * Smaller values will be quicker. Move the nozzle down till it barely touches the bed. Make sure the
* mesh points to the nozzle will be filled. The user can specify a repeat count using the R * nozzle is clean and unobstructed. Use caution and move slowly. This can damage your printer!
* parameter with the C version of the command. * (Uses SIZE_OF_LITTLE_RAISE mm if the nozzle is moving less than BIG_RAISE_NOT_NEEDED mm.)
* *
* A second version of the fill command is available if no C constant is specified. Not * The 'H' value can be negative if the Mesh dips in a large area. Press and hold the
* specifying a C constant will invoke the 'Smart Fill' algorithm. The G29 P3 command will search * controller button to terminate the current Phase 2 command. You can then re-issue "G29 P 2"
* from the edges of the mesh inward looking for invalid mesh points. It will look at the next * with an 'H' parameter more suitable for the area you're manually probing. Note that the command
* several mesh points to determine if the print bed is sloped up or down. If the bed is sloped * tries to start in a corner of the bed where movement will be predictable. Override the distance
* upward from the invalid mesh point, it will be replaced with the value of the nearest mesh point. * calculation location with the X and Y parameters. You can print a Mesh Map (G29 T) to see where
* If the bed is sloped downward from the invalid mesh point, it will be replaced with a value that * the mesh is invalidated and where the nozzle needs to move to complete the command. Use 'C' to
* puts all three points in a line. The second version of the G29 P3 command is a quick, easy and * indicate that the search should be based on the current position.
* usually safe way to populate the unprobed regions of your mesh so you can continue to the G26
* Mesh Validation Pattern phase. Please note that you are populating your mesh with unverified
* numbers. You should use some scrutiny and caution.
* *
* P4 Phase 4 Fine tune the Mesh. The Delta Mesh Compensation System assume the existence of * The 'B' parameter for this command is described above. It places the manual probe subsystem into
* an LCD Panel. It is possible to fine tune the mesh without the use of an LCD Panel using * Business Card mode where the thickness of a business card is measured and then used to accurately
* G42 and M421; see the UBL documentation for further details. * set the nozzle height in all manual probing for the duration of the command. A Business card can
* be used, but you'll get better results with a flexible Shim that doesn't compress. This makes it
* easier to produce similar amounts of force and get more accurate measurements. Google if you're
* not sure how to use a shim.
* *
* The System will search for the closest Mesh Point to the nozzle. It will move the * The 'T' (Map) parameter helps track Mesh building progress.
* nozzle to this location. The user can use the LCD Panel to carefully adjust the nozzle
* so it is just barely touching the bed. When the user clicks the control, the System
* will lock in that height for that point in the Mesh Compensation System.
* *
* Phase 4 has several additional parameters that the user may find helpful. Phase 4 * NOTE: P2 requires an LCD controller!
* can be started at a specific location by specifying an X and Y parameter. Phase 4
* can be requested to continue the adjustment of Mesh Points by using the R(epeat)
* parameter. If the Repetition count is not specified, it is assumed the user wishes
* to adjust the entire matrix. The nozzle is moved to the Mesh Point being edited.
* The command can be terminated early (or after the area of interest has been edited) by
* pressing and holding the encoder wheel until the system recognizes the exit request.
* Phase 4's general form is G29 P4 [R # of points] [X position] [Y position]
* *
* Phase 4 is intended to be used with the G26 Mesh Validation Command. Using the * P3 Phase 3 Fill the unpopulated regions of the Mesh with a fixed value. There are two different paths to
* information left on the printer's bed from the G26 command it is very straight forward * go down:
* and easy to fine tune the Mesh. One concept that is important to remember and that *
* will make using the Phase 4 command easy to use is this: You are editing the Mesh Points. * - If a 'C' constant is specified, the closest invalid mesh points to the nozzle will be filled,
* If you have too little clearance and not much plastic was extruded in an area, you want to * and a repeat count can then also be specified with 'R'.
* LOWER the Mesh Point at the location. If you did not get good adheasion, you want to *
* RAISE the Mesh Point at that location. * - Leaving out 'C' invokes Smart Fill, which scans the mesh from the edges inward looking for
* invalid mesh points. Adjacent points are used to determine the bed slope. If the bed is sloped
* upward from the invalid point, it takes the value of the nearest point. If sloped downward, it's
* replaced by a value that puts all three points in a line. This version of G29 P3 is a quick, easy
* and (usually) safe way to populate unprobed mesh regions before continuing to G26 Mesh Validation
* Pattern. Note that this populates the mesh with unverified values. Pay attention and use caution.
*
* P4 Phase 4 Fine tune the Mesh. The Delta Mesh Compensation System assumes the existence of
* an LCD Panel. It is possible to fine tune the mesh without an LCD Panel using
* G42 and M421. See the UBL documentation for further details.
*
* Phase 4 is meant to be used with G26 Mesh Validation to fine tune the mesh by direct editing
* of Mesh Points. Raise and lower points to fine tune the mesh until it gives consistently reliable
* adhesion.
*
* P4 moves to the closest Mesh Point (and/or the given X Y), raises the nozzle above the mesh height
* by the given 'H' offset (or default Z_CLEARANCE_BETWEEN_PROBES), and waits while the controller is
* used to adjust the nozzle height. On click the displayed height is saved in the mesh.
*
* Start Phase 4 at a specific location with X and Y. Adjust a specific number of Mesh Points with
* the 'R' (Repeat) parameter. (If 'R' is left out, the whole matrix is assumed.) This command can be
* terminated early (e.g., after editing the area of interest) by pressing and holding the encoder button.
*
* The general form is G29 P4 [R points] [X position] [Y position]
*
* The H [offset] parameter is useful if a shim is used to fine-tune the mesh. For a 0.4mm shim the
* command would be G29 P4 H0.4. The nozzle is moved to the shim height, you adjust height to the shim,
* and on click the height minus the shim thickness will be saved in the mesh.
*
* !!Use with caution, as a very poor mesh could cause the nozzle to crash into the bed!!
* *
* NOTE: P4 is not available unless you have LCD support enabled! * NOTE: P4 is not available unless you have LCD support enabled!
* *
@ -494,28 +479,29 @@
g29_y_pos = current_position[Y_AXIS]; g29_y_pos = current_position[Y_AXIS];
} }
float height = Z_CLEARANCE_BETWEEN_PROBES;
if (parser.seen('B')) { if (parser.seen('B')) {
g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness(height); g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness(Z_CLEARANCE_BETWEEN_PROBES);
if (FABS(g29_card_thickness) > 1.5) { if (FABS(g29_card_thickness) > 1.5) {
SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement."); SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement.");
return; return;
} }
} }
if (parser.seen('H') && parser.has_value()) height = parser.value_float();
if (!position_is_reachable_xy(g29_x_pos, g29_y_pos)) { if (!position_is_reachable_xy(g29_x_pos, g29_y_pos)) {
SERIAL_PROTOCOLLNPGM("XY outside printable radius."); SERIAL_PROTOCOLLNPGM("XY outside printable radius.");
return; return;
} }
const float height = parser.seen('H') && parser.has_value() ? parser.value_float() : Z_CLEARANCE_BETWEEN_PROBES;
manually_probe_remaining_mesh(g29_x_pos, g29_y_pos, height, g29_card_thickness, parser.seen('T')); manually_probe_remaining_mesh(g29_x_pos, g29_y_pos, height, g29_card_thickness, parser.seen('T'));
SERIAL_PROTOCOLLNPGM("G29 P2 finished."); SERIAL_PROTOCOLLNPGM("G29 P2 finished.");
#else #else
SERIAL_PROTOCOLLNPGM("?P2 is only available when an LCD is present."); SERIAL_PROTOCOLLNPGM("?P2 is only available when an LCD is present.");
return; return;
#endif #endif
} break; } break;
@ -537,19 +523,17 @@
if (location.x_index < 0) { if (location.x_index < 0) {
// No more REACHABLE INVALID mesh points to populate, so we ASSUME // No more REACHABLE INVALID mesh points to populate, so we ASSUME
// user meant to populate ALL INVALID mesh points to value // user meant to populate ALL INVALID mesh points to value
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
if ( isnan(z_values[x][y])) { if (isnan(z_values[x][y]))
z_values[x][y] = g29_constant; z_values[x][y] = g29_constant;
}
}
}
break; // No more invalid Mesh Points to populate break; // No more invalid Mesh Points to populate
} }
z_values[location.x_index][location.y_index] = g29_constant; z_values[location.x_index][location.y_index] = g29_constant;
} }
} }
} else { }
else {
const float cvf = parser.value_float(); const float cvf = parser.value_float();
switch((int)truncf(cvf * 10.0) - 30) { // 3.1 -> 1 switch((int)truncf(cvf * 10.0) - 30) { // 3.1 -> 1
#if ENABLED(UBL_G29_P31) #if ENABLED(UBL_G29_P31)
@ -967,7 +951,7 @@
static void echo_and_take_a_measurement() { SERIAL_PROTOCOLLNPGM(" and take a measurement."); } static void echo_and_take_a_measurement() { SERIAL_PROTOCOLLNPGM(" and take a measurement."); }
float unified_bed_leveling::measure_business_card_thickness(float &in_height) { float unified_bed_leveling::measure_business_card_thickness(float in_height) {
has_control_of_lcd_panel = true; has_control_of_lcd_panel = true;
save_ubl_active_state_and_disable(); // Disable bed level correction for probing save_ubl_active_state_and_disable(); // Disable bed level correction for probing
@ -1466,12 +1450,21 @@
} }
#if ENABLED(NEWPANEL) #if ENABLED(NEWPANEL)
void unified_bed_leveling::fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map) { void unified_bed_leveling::fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map) {
if (!parser.seen('R')) // fine_tune_mesh() is special. If no repetition count flag is specified if (!parser.seen('R')) // fine_tune_mesh() is special. If no repetition count flag is specified
g29_repetition_cnt = 1; // do exactly one mesh location. Otherwise use what the parser decided. g29_repetition_cnt = 1; // do exactly one mesh location. Otherwise use what the parser decided.
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
const bool is_offset = parser.seen('H');
const float h_offset = is_offset ? parser.value_linear_units() : Z_CLEARANCE_BETWEEN_PROBES;
if (is_offset && !WITHIN(h_offset, 0, 10)) {
SERIAL_PROTOCOLLNPGM("Offset out of bounds. (0 to 10mm)\n");
return;
}
#endif
mesh_index_pair location; mesh_index_pair location;
uint16_t not_done[16];
if (!position_is_reachable_xy(lx, ly)) { if (!position_is_reachable_xy(lx, ly)) {
SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius."); SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
@ -1480,12 +1473,13 @@
save_ubl_active_state_and_disable(); save_ubl_active_state_and_disable();
memset(not_done, 0xFF, sizeof(not_done));
LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH); LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES); do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
do_blocking_move_to_xy(lx, ly); do_blocking_move_to_xy(lx, ly);
uint16_t not_done[16];
memset(not_done, 0xFF, sizeof(not_done));
do { do {
location = find_closest_mesh_point_of_type(SET_IN_BITMAP, lx, ly, USE_NOZZLE_AS_REFERENCE, not_done, false); location = find_closest_mesh_point_of_type(SET_IN_BITMAP, lx, ly, USE_NOZZLE_AS_REFERENCE, not_done, false);
@ -1521,8 +1515,8 @@
do { do {
new_z = lcd_mesh_edit(); new_z = lcd_mesh_edit();
#ifdef UBL_MESH_EDIT_MOVES_Z #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES + new_z); // Move the nozzle as the point is edited do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
#endif #endif
idle(); idle();
} while (!ubl_lcd_clicked()); } while (!ubl_lcd_clicked());
@ -1581,7 +1575,8 @@
} }
else lcd_return_to_status(); else lcd_return_to_status();
} }
#endif
#endif // NEWPANEL
/** /**
* 'Smart Fill': Scan from the outward edges of the mesh towards the center. * 'Smart Fill': Scan from the outward edges of the mesh towards the center.

View file

@ -4026,44 +4026,34 @@ void kill_screen(const char* lcd_msg) {
*/ */
#if ENABLED(ADC_KEYPAD) #if ENABLED(ADC_KEYPAD)
inline void handle_adc_keypad() { inline bool handle_adc_keypad() {
static uint8_t adc_steps = 0; static uint8_t adc_steps = 0;
if (buttons_reprapworld_keypad) { if (buttons_reprapworld_keypad) {
adc_steps++; if (adc_steps < 20) ++adc_steps;
NOMORE(adc_steps, 20);
lcd_quick_feedback(); lcd_quick_feedback();
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
return_to_status_ms = millis() + LCD_TIMEOUT_TO_STATUS;
if (encoderDirection == -1) { // side effect which signals we are inside a menu if (encoderDirection == -1) { // side effect which signals we are inside a menu
if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM; else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT) menu_action_back();
encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) lcd_return_to_status();
else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)
menu_action_back();
else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT)
// enqueue_and_echo_commands_P(PSTR("M0 Pause"));
lcd_return_to_status();
} }
else { else {
const int8_t step = adc_steps > 19 ? 100 : adc_steps > 10 ? 10 : 1; const int8_t step = adc_steps > 19 ? 100 : adc_steps > 10 ? 10 : 1;
if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) encoderPosition += ENCODER_PULSES_PER_STEP * step;
encoderPosition += ENCODER_PULSES_PER_STEP * step; else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) encoderPosition -= ENCODER_PULSES_PER_STEP * step;
else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) encoderPosition = 0;
encoderPosition -= ENCODER_PULSES_PER_STEP * step;
else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT)
encoderPosition = 0;
} }
#if ENABLED(ADC_KEYPAD_DEBUG) #if ENABLED(ADC_KEYPAD_DEBUG)
SERIAL_PROTOCOLLNPAIR("buttons_reprapworld_keypad = ", (uint32_t)buttons_reprapworld_keypad); SERIAL_PROTOCOLLNPAIR("buttons_reprapworld_keypad = ", (uint32_t)buttons_reprapworld_keypad);
SERIAL_PROTOCOLLNPAIR("encoderPosition = ", (uint32_t)encoderPosition); SERIAL_PROTOCOLLNPAIR("encoderPosition = ", (uint32_t)encoderPosition);
#endif #endif
return true;
} }
else if (!thermalManager.current_ADCKey_raw) { else if (!thermalManager.current_ADCKey_raw)
// reset stepping acceleration adc_steps = 0; // reset stepping acceleration
adc_steps = 0;
} return false;
} }
#elif ENABLED(REPRAPWORLD_KEYPAD) #elif ENABLED(REPRAPWORLD_KEYPAD)
@ -4360,7 +4350,8 @@ void lcd_update() {
#if ENABLED(ADC_KEYPAD) #if ENABLED(ADC_KEYPAD)
handle_adc_keypad(); if (handle_adc_keypad())
return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
#elif ENABLED(REPRAPWORLD_KEYPAD) #elif ENABLED(REPRAPWORLD_KEYPAD)
@ -4792,7 +4783,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
uint8_t ADCKeyNo; uint8_t ADCKeyNo;
} _stADCKeypadTable_; } _stADCKeypadTable_;
static const _stADCKeypadTable_ stADCKeyTable[] = PROGMEM { static const _stADCKeypadTable_ stADCKeyTable[] PROGMEM = {
// VALUE_MIN, VALUE_MAX, KEY // VALUE_MIN, VALUE_MAX, KEY
{ 4000, 4096, BLEN_REPRAPWORLD_KEYPAD_F1 + 1 }, // F1 { 4000, 4096, BLEN_REPRAPWORLD_KEYPAD_F1 + 1 }, // F1
{ 4000, 4096, BLEN_REPRAPWORLD_KEYPAD_F2 + 1 }, // F2 { 4000, 4096, BLEN_REPRAPWORLD_KEYPAD_F2 + 1 }, // F2