Skip to content

Commit

Permalink
Merge pull request #8 from angrycompany16/elisa_branch
Browse files Browse the repository at this point in the history
Elisa branch
  • Loading branch information
angrycompany16 authored Mar 4, 2024
2 parents fcb4d3c + 86bc93e commit e44b4dc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
3 changes: 3 additions & 0 deletions skeleton_project/source/FSM.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 4 additions & 21 deletions skeleton_project/source/lamp.c
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
9 changes: 2 additions & 7 deletions skeleton_project/source/lamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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!
11 changes: 11 additions & 0 deletions skeleton_project/source/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit e44b4dc

Please sign in to comment.