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

wheel_stop fault

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