diff --git a/Services/DCMotor.c b/Services/DCMotor.c index bf33cd8..f65bcc8 100644 --- a/Services/DCMotor.c +++ b/Services/DCMotor.c @@ -1,16 +1,13 @@ #include "DCMotor.h" -void DCMotor_conf(double speed) { +void DCMotor_conf() { - double speedAbs = (speed > 0.) ? speed : -speed; - int sens = (speed > 0.) ? 1 : 0; + //On règle la vitesse en valeur absolue, ici à 0 + Timer_pwmo_conf(TIM2, LL_TIM_CHANNEL_CH2, 50, 0); - //On règle la vitesse en valeur absolue - Timer_pwmo_conf(TIM2, LL_TIM_CHANNEL_CH2, 50, speedAbs); - - //On règle le sens du moteur + //On règle le sens du moteur, ici sens direct (?) GPIO_conf(GPIOA, LL_GPIO_PIN_2, LL_GPIO_MODE_OUTPUT, LL_GPIO_OUTPUT_OPENDRAIN, LL_GPIO_PULL_DOWN); - GPIO_setPin(GPIOA, LL_GPIO_PIN_2, sens); + GPIO_setPin(GPIOA, LL_GPIO_PIN_2, 0); } void DCMotor_setSpeed(double speed) { diff --git a/Services/DCMotor.h b/Services/DCMotor.h index 417a320..1305ee9 100644 --- a/Services/DCMotor.h +++ b/Services/DCMotor.h @@ -4,7 +4,7 @@ #include "GPIO.h" #include "Timer.h" -void DCMotor_conf(double duty_cycle); +void DCMotor_conf(void); void DCMotor_setSpeed(double speed); diff --git a/Src/Orientation.c b/Src/Orientation.c index 020f22b..ea05c7c 100644 --- a/Src/Orientation.c +++ b/Src/Orientation.c @@ -1 +1,19 @@ #include "Orientation.h" +#define SEUIL 30 + +void Orientation_conf() { + + DCMotor_conf(); + RFReceiver_conf(); + +} + +void Orientation_background(){ + + double speed = RFReceiver_getData(); + + //Si la vitesse (en valeur absolue) ne dépasse pas un certain seuil, on ne démarre pas le moteur + if (-SEUILspeed) DCMotor_setSpeed(0); + else DCMotor_setSpeed(speed); + +} diff --git a/Src/Orientation.h b/Src/Orientation.h index d6c0abd..fdba2d4 100644 --- a/Src/Orientation.h +++ b/Src/Orientation.h @@ -1,4 +1,11 @@ #ifndef ORIENTATION_H #define ORIENTATION_H +#include "DCMotor.h" +#include "RFReceiver.h" + +void Orientation_conf(void); + +void Orientation_background(void); + #endif