Skip to content
Snippets Groups Projects
Commit f658e23e authored by benjamin.sitbon's avatar benjamin.sitbon
Browse files

wheel_stop fault

parent 25f95f13
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@
int main()
{
int wheel_turn = 0;
pthread_t threads[4];
machine mas;
......@@ -59,6 +59,7 @@ int main()
break;
case SDLK_SPACE:
wait_key_release();
stop_wheel(&mas.wheels[wheel_turn]);
break;
case SDLK_s:
wait_key_release();
......
......@@ -22,10 +22,7 @@ void *wheel_func(void *param){
printf("\nwheel_func");
wheel* id = (wheel *) (param);
while(1){
// for(double a = 0; a<8.0; a +=0.1){
// wheel_spin(a,id.current_px,id.speed);
while(id->speed > 0){
wheel_spin_1_tick(id);
wait_until(wheel_delay_ms(*id));
}
......@@ -42,13 +39,13 @@ int wheel_spin_1_tick(wheel* this){
int wheel_delay_ms(wheel this){
if (this.speed) {
return this.speed * 2;
} return 2;
}
}
int stop_wheel(wheel this){
while (this.current_px % 128 != 32) { // 32 is the offset to center the item
int stop_wheel(wheel* this){
while (this->current_px % 128 != 32) { // 32 is the offset to center the item
wheel_spin_1_tick(&this);
wait_until(wheel_delay_ms(this));
wait_until(wheel_delay_ms(*this));
}
this.speed = 0;
this->speed = 0;
}
......@@ -15,7 +15,7 @@ int get_current_px();
void *wheel_func(void *param);
int wheel_spin_1_tick(wheel* this);
int wheel_delay_ms(wheel this);
int stop_wheel(wheel this);
int stop_wheel(wheel* this);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment