Skip to content
Snippets Groups Projects
Commit b38fc259 authored by Oliver Ljungberg's avatar Oliver Ljungberg
Browse files

Blinky added

parent 2849fca5
No related branches found
No related tags found
No related merge requests found
blinky.c 0 → 100644
/*
* blinky.c
*
* Created on: 12 mai 2022
* Author: oliver
*/
// Standard includes
#include <ch.h>
#include <hal.h>
#include <leds.h>
// Project files includes
#include "blinky.h"
#include "check_collision.h"
#include "compute_case.h"
static THD_WORKING_AREA(waBlinky, 128);
static THD_FUNCTION(Blinky, arg) {
chRegSetThreadName(__FUNCTION__);
(void)arg;
while(1){
// Blink the back LED when the robot moves backward
if( ((get_acc_case() == 2) | (get_acc_case() == 4)) &
(get_wall_detection() != 2) ){
set_led(LED5, 1);
chThdSleepMilliseconds(300);
set_led(LED5, 0);
chThdSleepMilliseconds(200);
}else if( ((get_acc_case() == 0) | (get_acc_case() == 1) | (get_acc_case() == 3)) &
(get_wall_detection() != 2) & (get_check_back_wall() == 1) ){
set_led(LED5, 0);
clear_check_back_wall();
}
// 10Hz
chThdSleepMilliseconds(100);
}
}
void blinky_start(void){
chThdCreateStatic(waBlinky, sizeof(waBlinky), NORMALPRIO, Blinky, NULL);
}
blinky.h 0 → 100644
/*
* blinky.h
*
* Created on: 12 mai 2022
* Author: oliver
*/
#ifndef BLINKY_H_
#define BLINKY_H_
void blinky_start(void);
#endif /* BLINKY_H_ */
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <selector.h> #include <selector.h>
#include <audio/audio_thread.h> #include <audio/audio_thread.h>
// project files includes // Project files includes
#include "check_collision.h" #include "check_collision.h"
#include "compute_case.h" #include "compute_case.h"
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <hal.h> #include <hal.h>
#include <sensors/imu.h> #include <sensors/imu.h>
// project files includes // Project files includes
#include "compute_case.h" #include "compute_case.h"
#define XAXIS 0 #define XAXIS 0
......
/*
* main.c
*
* Created on: 14 avr. 2022
* Author: Corentin Jossi
*/
// Standard includes // Standard includes
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -15,11 +21,12 @@ ...@@ -15,11 +21,12 @@
#include <audio/audio_thread.h> #include <audio/audio_thread.h>
// project files includes // Project files includes
#include "main.h" #include "main.h"
#include "compute_case.h" #include "compute_case.h"
#include "check_collision.h" #include "check_collision.h"
#include "motor_speed.h" #include "motor_speed.h"
#include "blinky.h"
messagebus_t bus; messagebus_t bus;
MUTEX_DECL(bus_lock); MUTEX_DECL(bus_lock);
...@@ -82,6 +89,7 @@ int main(void) ...@@ -82,6 +89,7 @@ int main(void)
check_collision_start(); check_collision_start();
select_case_start(); select_case_start();
motor_speed_start(); motor_speed_start();
blinky_start();
// Front LED indicates that the calibration is completed // Front LED indicates that the calibration is completed
for(uint8_t i = 0 ; i < 3; ++i){ for(uint8_t i = 0 ; i < 3; ++i){
...@@ -95,22 +103,7 @@ int main(void) ...@@ -95,22 +103,7 @@ int main(void)
/* Infinite loop. */ /* Infinite loop. */
while (1) { while (1) {
// Blink the back LED when the robot moves backward chThdSleepMilliseconds(1000);
if( ((get_acc_case() == 2) | (get_acc_case() == 4)) &
(get_wall_detection() != 2) ){
set_led(LED5, 1);
chThdSleepMilliseconds(300);
set_led(LED5, 0);
chThdSleepMilliseconds(200);
}else if( ((get_acc_case() == 0) | (get_acc_case() == 1) | (get_acc_case() == 3)) &
(get_wall_detection() != 2) & (get_check_back_wall() == 1) ){
set_led(LED5, 0);
clear_check_back_wall();
}
// 10Hz
chThdSleepMilliseconds(100);
} }
} }
......
/*
* main.h
*
* Created on: 14 avr. 2022
* Author: Corentin Jossi
*/
#ifndef MAIN_H #ifndef MAIN_H
#define MAIN_H #define MAIN_H
......
...@@ -13,6 +13,7 @@ CSRC += ./main.c \ ...@@ -13,6 +13,7 @@ CSRC += ./main.c \
./compute_case.c \ ./compute_case.c \
./motor_speed.c \ ./motor_speed.c \
./check_collision.c \ ./check_collision.c \
./blinky.c \
#Header folders to include #Header folders to include
INCDIR += INCDIR +=
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <motors.h> #include <motors.h>
#include <selector.h> #include <selector.h>
// project files includes // Project files includes
#include "motor_speed.h" #include "motor_speed.h"
#include "compute_case.h" #include "compute_case.h"
#include "check_collision.h" #include "check_collision.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment