Welcome! Log In Create A New Profile

Advanced

Ayuda por favor

Posted by fedesm77 
Ayuda por favor
August 26, 2019 05:06PM
Hola buenas tardes estoy con un proyecto de hacer un cnc con arduino mega + ramps + lcd + marlin. Ya pude hacer muchas cosas pero estoy teniendo un inconveniente con el menu, quiero hacer que cuando se entre a mover ejes me de directamente la opcion del eje X y el eje Y sin tener que elegircuanto quiere desplazar (0.01 o 1 o 10) aca pego el codigo que estoy usando.

////////////////////////////////////////////////////
// Move Axis
//
MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);


/**
*
* "Prepare" > "Move Axis" submenu
*
*/

void _lcd_move_xyz(const char* name, AxisEnum axis) {
if (lcd_clicked) { return lcd_goto_previous_menu(); }
ENCODER_DIRECTION_NORMAL();
if (encoderPosition) {
refresh_cmd_timeout();

// Limit to software endstops, if enabled
float min = (soft_endstops_enabled && min_software_endstops) ? soft_endstop_min[axis] : current_position[axis] - 1000,
max = (soft_endstops_enabled && max_software_endstops) ? soft_endstop_max[axis] : current_position[axis] + 1000;

// Get the new position
current_position[axis] += float((int32_t)encoderPosition) * move_menu_scale;

// Delta limits XY based on the current offset from center
// This assumes the center is 0,0
#if ENABLED(DELTA)
if (axis != Z_AXIS) {
max = sqrt(sq(DELTA_PRINTABLE_RADIUS) - sq(current_position[Y_AXIS - axis]));
min = -max;
}
#endif

// Limit only when trying to move towards the limit
if ((int32_t)encoderPosition < 0) NOLESS(current_position[axis], min);
if ((int32_t)encoderPosition > 0) NOMORE(current_position[axis], max);

manual_move_to_current(axis);

encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
}
if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr41sign(current_position[axis]));
}
void lcd_move_x() { _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS); }
void lcd_move_y() { _lcd_move_xyz(PSTR(MSG_MOVE_Y), Y_AXIS); }
void _lcd_move_e(
#if E_MANUAL > 1
int8_t eindex=-1
#endif
) {
if (lcd_clicked) { return lcd_goto_previous_menu(); }
ENCODER_DIRECTION_NORMAL();
if (encoderPosition) {
current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
encoderPosition = 0;
manual_move_to_current(E_AXIS
#if E_MANUAL > 1
, eindex
#endif
);
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
}
if (lcdDrawUpdate) {
PGM_P pos_label;
#if E_MANUAL == 1
// pos_label = PSTR(MSG_MOVE_E);
#else
switch (eindex) {
default: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E1); break;
case 1: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E2); break;
#if E_MANUAL > 2
case 2: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E3); break;
#if E_MANUAL > 3
case 3: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E4); break;
#endif
#endif
}
#endif
lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS]));
}
}

void lcd_move_e() { _lcd_move_e(); }
#if E_MANUAL > 1
void lcd_move_e0() { _lcd_move_e(0); }
void lcd_move_e1() { _lcd_move_e(1); }
#if E_MANUAL > 2
void lcd_move_e2() { _lcd_move_e(2); }
#if E_MANUAL > 3
void lcd_move_e3() { _lcd_move_e(3); }
#endif
#endif
#endif

/**
*
* "Prepare" > "Move Xmm" > "Move XYZ" submenu
*
*/

#define _MOVE_XYZ_ALLOWED true


void _lcd_move_menu_axis() {
START_MENU();
MENU_BACK(MSG_PREPARE);

if (_MOVE_XYZ_ALLOWED) {
MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x);
MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y);
}

if (move_menu_scale < 10.0) {
// if (_MOVE_XYZ_ALLOWED) MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z);



// MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e);
#if E_MANUAL > 1
MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E1, lcd_move_e0);
MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E2, lcd_move_e1);
#if E_MANUAL > 2
MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E3, lcd_move_e2);
#if E_MANUAL > 3
MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E4, lcd_move_e3);
#endif
#endif
#endif
}
END_MENU();
}

void lcd_move_menu_10mm() {
move_menu_scale = 10.0;
_lcd_move_menu_axis();
}
void lcd_move_menu_1mm() {
move_menu_scale = 1.0;
_lcd_move_menu_axis();
}
void lcd_move_menu_01mm() {
move_menu_scale = 0.1;
_lcd_move_menu_axis();
}

/**
*
* "Prepare" > "Move Axis" submenu
*
*/

void lcd_move_menu() {
START_MENU();
MENU_BACK(MSG_PREPARE);

if (_MOVE_XYZ_ALLOWED)
//MENU_ITEM(submenu, MSG_MOVE_10MM, lcd_move_menu_10mm);
MENU_ITEM(submenu, MSG_MOVE_1MM, lcd_move_menu_1mm);
END_MENU();
}


Desde ya gracias al que me pueda ayudar.
Sorry, only registered users may post in this forum.

Click here to login