mirror of
https://github.com/holub/mame
synced 2025-05-22 21:58:57 +03:00
Merge pull request #44 from ramiropolla/steppers
steppers: add absolute position
This commit is contained in:
commit
970fc85e7a
@ -58,6 +58,7 @@ struct stepper
|
|||||||
type; /* reel type */
|
type; /* reel type */
|
||||||
INT16 step_pos, /* step position 0 - max_steps */
|
INT16 step_pos, /* step position 0 - max_steps */
|
||||||
max_steps; /* maximum step position */
|
max_steps; /* maximum step position */
|
||||||
|
INT32 abs_step_pos; /* absolute step position */
|
||||||
|
|
||||||
INT16 index_start, /* start position of index (in half steps) */
|
INT16 index_start, /* start position of index (in half steps) */
|
||||||
index_end, /* end position of index (in half steps) */
|
index_end, /* end position of index (in half steps) */
|
||||||
@ -125,6 +126,7 @@ void stepper_config(running_machine &machine, int which, const stepper_interface
|
|||||||
step[which].pattern = 0;
|
step[which].pattern = 0;
|
||||||
step[which].old_pattern = 0;
|
step[which].old_pattern = 0;
|
||||||
step[which].step_pos = 0;
|
step[which].step_pos = 0;
|
||||||
|
step[which].abs_step_pos= 0;
|
||||||
step[which].phase = step[which].initphase;
|
step[which].phase = step[which].initphase;
|
||||||
step[which].old_phase = step[which].initphase;
|
step[which].old_phase = step[which].initphase;
|
||||||
|
|
||||||
@ -161,6 +163,7 @@ void stepper_config(running_machine &machine, int which, const stepper_interface
|
|||||||
state_save_register_item(machine, "stepper", NULL, which, step[which].pattern);
|
state_save_register_item(machine, "stepper", NULL, which, step[which].pattern);
|
||||||
state_save_register_item(machine, "stepper", NULL, which, step[which].old_pattern);
|
state_save_register_item(machine, "stepper", NULL, which, step[which].old_pattern);
|
||||||
state_save_register_item(machine, "stepper", NULL, which, step[which].step_pos);
|
state_save_register_item(machine, "stepper", NULL, which, step[which].step_pos);
|
||||||
|
state_save_register_item(machine, "stepper", NULL, which, step[which].abs_step_pos);
|
||||||
state_save_register_item(machine, "stepper", NULL, which, step[which].max_steps);
|
state_save_register_item(machine, "stepper", NULL, which, step[which].max_steps);
|
||||||
state_save_register_item(machine, "stepper", NULL, which, step[which].type);
|
state_save_register_item(machine, "stepper", NULL, which, step[which].type);
|
||||||
}
|
}
|
||||||
@ -171,6 +174,12 @@ int stepper_get_position(int which)
|
|||||||
return step[which].step_pos;
|
return step[which].step_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
int stepper_get_absolute_position(int which)
|
||||||
|
{
|
||||||
|
return step[which].abs_step_pos;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int stepper_get_max(int which)
|
int stepper_get_max(int which)
|
||||||
@ -216,6 +225,7 @@ static void update_optic(int which)
|
|||||||
void stepper_reset_position(int which)
|
void stepper_reset_position(int which)
|
||||||
{
|
{
|
||||||
step[which].step_pos = 0x00;
|
step[which].step_pos = 0x00;
|
||||||
|
step[which].abs_step_pos= 0x00;
|
||||||
step[which].pattern = 0x00;
|
step[which].pattern = 0x00;
|
||||||
step[which].old_pattern = 0x00;
|
step[which].old_pattern = 0x00;
|
||||||
step[which].phase = step[which].initphase;
|
step[which].phase = step[which].initphase;
|
||||||
@ -551,6 +561,7 @@ int stepper_update(int which, UINT8 pattern)
|
|||||||
|
|
||||||
if (max!=0)
|
if (max!=0)
|
||||||
{
|
{
|
||||||
|
step[which].abs_step_pos += steps;
|
||||||
pos = (step[which].step_pos + steps + max) % max;
|
pos = (step[which].step_pos + steps + max) % max;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -59,5 +59,7 @@ int stepper_update(int id, UINT8 pattern); /* update a motor */
|
|||||||
|
|
||||||
int stepper_get_position(int id); /* get current position in half steps */
|
int stepper_get_position(int id); /* get current position in half steps */
|
||||||
|
|
||||||
|
int stepper_get_absolute_position(int id); /* get current absolute position in half steps */
|
||||||
|
|
||||||
int stepper_get_max(int id); /* get maximum position in half steps */
|
int stepper_get_max(int id); /* get maximum position in half steps */
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user