-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
67 lines (52 loc) · 1.53 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include "driver/elevio.h"
#include "driver/elev_controller.h"
#include "driver/elevator.h"
int main(){
elevio_init();
/*
//Dette er eksempelkode som var i main fra før.
printf("=== Example Program ===\n");
printf("Press the stop button on the elevator panel to exit\n");
elevio_motorDirection(DIRN_UP);
while(1){
int floor = elevio_floorSensor();
printf("floor: %d \n",floor);
if(floor == 0){
elevio_motorDirection(DIRN_UP);
}
if(floor == N_FLOORS-1){
elevio_motorDirection(DIRN_DOWN);
}
for(int f = 0; f < N_FLOORS; f++){
for(int b = 0; b < N_BUTTONS; b++){
int btnPressed = elevio_callButton(f, b);
elevio_buttonLamp(f, b, btnPressed);
}
}
if(elevio_obstruction()){
elevio_stopLamp(1);
} else {
elevio_stopLamp(0);
}
if(elevio_stopButton()){
elevio_motorDirection(DIRN_STOP);
break;
}
nanosleep(&(struct timespec){0, 20*1000*1000}, NULL);
}
*/
init();
while (1){
int floor = elevio_floorSensor();
printf("floor: %d \n",floor);
update_state(&new_state);
printf("State: %d \n", new_state);
printf("curr_motor_dir: %d \n", curr_motor_dir);
nanosleep(&(struct timespec){0, 20*1000*1000}, NULL);
}
return 0;
}