Select Git revision
wheel.c 930 B
// #include "display.h"
#include "utilities.h"
#include "wheel.h"
int set_speed(int s){
return -1;
}
int get_current_px(){
return -1;
}
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);
wheel_spin_1_tick(id);
wait_until(wheel_delay_ms(*id));
}
}
int wheel_spin_1_tick(wheel* this){
if (this->speed) {
pthread_mutex_lock(&this->lock);
this->current_px = (this->current_px + 2) % 896 ;
pthread_mutex_unlock(&this->lock);
}
}
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
wheel_spin_1_tick(&this);
wait_until(wheel_delay_ms(this));
}
this.speed = 0;
}