diff --git a/skeleton_project/source/FSM.c b/skeleton_project/source/FSM.c index 93c6da5..03e5469 100644 --- a/skeleton_project/source/FSM.c +++ b/skeleton_project/source/FSM.c @@ -79,10 +79,13 @@ void FSM_behaviour(FSM* p_fsm, time_t* p_timer, Queue* p_main_queue){ elevio_motorDirection(DIRN_STOP); break; case BLOCKED_EMPTY: +<<<<<<< HEAD +======= if (time_limit(p_timer)){ printf("Blocked empty elevator, timer ran out\n"); FSM_transition(p_fsm, TIMER, p_main_queue, p_timer); } +>>>>>>> 7149ce90f57c397a32f4a367495aa6813fcdd36a p_fsm->moving = false; p_fsm->direction = DIR_NONE; elevio_motorDirection(DIRN_STOP); diff --git a/skeleton_project/source/lamp.c b/skeleton_project/source/lamp.c index 0f21022..9127a38 100644 --- a/skeleton_project/source/lamp.c +++ b/skeleton_project/source/lamp.c @@ -1,28 +1,11 @@ #include "lamp.h" -/* -Lamp* lamp_init(){ - Lamp* p_lamp = (Lamp*)malloc(sizeof(Lamp)); - - if (p_lamp!= NULL) { - *p_lamp = BUTTON_HALL_DOWN; - // *p_lamp = ; Lyse i etasjen heisen starter i? - } else { - printf("Error allocating memory for button\n"); - } - - return p_lamp; -} - -void lamp_deinit(Lamp* p_lamp) { - free(p_lamp); -} -*/ - -void toggle(Lamp_2 m_lamp, int floor, bool enable){ +void lamp_toggle(Lamp m_lamp, int floor, bool enable){ switch(m_lamp){ case LAMP_CURRENT: - // hvordan håndtere disse lysene? + while (elevio_floorSensor() != -1) { + elevio_floorIndicator(floor); + } break; case LAMP_UP: elevio_buttonLamp(floor, BUTTON_HALL_UP, enable); diff --git a/skeleton_project/source/lamp.h b/skeleton_project/source/lamp.h index b75f24e..9b94ba6 100644 --- a/skeleton_project/source/lamp.h +++ b/skeleton_project/source/lamp.h @@ -12,13 +12,8 @@ typedef enum{ LAMP_CAB, LAMP_STOP, LAMP_DOOR -} Lamp_2; +} Lamp; -//Lamp* lamp_init(void); -//void lamp_deinit(Lamp* p_lamp); - -void lamp_toggle(Lamp_2 m_lamp, int floor, bool enable); - -// ikke pointers pga kun enums?? +void lamp_toggle(Lamp m_lamp, int floor, bool enable); // L3 og L4! \ No newline at end of file diff --git a/skeleton_project/source/run.c b/skeleton_project/source/run.c index 53c8b19..37105dd 100644 --- a/skeleton_project/source/run.c +++ b/skeleton_project/source/run.c @@ -81,6 +81,17 @@ void run( // printf("Floor sensor: %d\n", elevio_floorSensor()); if (elevio_floorSensor() != -1) { p_fsm->current_floor = elevio_floorSensor(); + // Oppdatere current-lys (cursed løsning? hehe) + lamp_toggle(LAMP_CURRENT, p_fsm->current_floor, true); + + if (*target_floor > p_fsm->current_floor){ // beveger seg oppover + lamp_toggle(LAMP_CURRENT, p_fsm->current_floor - 1, false); + } else { + lamp_toggle(LAMP_CURRENT, p_fsm->current_floor + 1, false); + } + // evt: + // lamp_toggle(LAMP_CURRENT, p_fsm->current_floor + 1, false); + // lamp_toggle(LAMP_CURRENT, p_fsm->current_floor - 1, false); if (queue_query(p_main_queue, elevio_floorSensor(), p_fsm->direction, ANY)) { FSM_transition(p_fsm, ENTERED_FLOOR, p_main_queue, p_timer); }