Modification des arguments de DCMotor_conf et ecriture de Orientation

This commit is contained in:
Marino Benassai 2020-11-11 17:58:17 +01:00
parent 92945a99af
commit c973c13ba5
4 changed files with 31 additions and 9 deletions

View file

@ -1,16 +1,13 @@
#include "DCMotor.h" #include "DCMotor.h"
void DCMotor_conf(double speed) { void DCMotor_conf() {
double speedAbs = (speed > 0.) ? speed : -speed; //On règle la vitesse en valeur absolue, ici à 0
int sens = (speed > 0.) ? 1 : 0; Timer_pwmo_conf(TIM2, LL_TIM_CHANNEL_CH2, 50, 0);
//On règle la vitesse en valeur absolue //On règle le sens du moteur, ici sens direct (?)
Timer_pwmo_conf(TIM2, LL_TIM_CHANNEL_CH2, 50, speedAbs);
//On règle le sens du moteur
GPIO_conf(GPIOA, LL_GPIO_PIN_2, LL_GPIO_MODE_OUTPUT, LL_GPIO_OUTPUT_OPENDRAIN, LL_GPIO_PULL_DOWN); 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) { void DCMotor_setSpeed(double speed) {

View file

@ -4,7 +4,7 @@
#include "GPIO.h" #include "GPIO.h"
#include "Timer.h" #include "Timer.h"
void DCMotor_conf(double duty_cycle); void DCMotor_conf(void);
void DCMotor_setSpeed(double speed); void DCMotor_setSpeed(double speed);

View file

@ -1 +1,19 @@
#include "Orientation.h" #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 (-SEUIL<speed && SEUIL>speed) DCMotor_setSpeed(0);
else DCMotor_setSpeed(speed);
}

View file

@ -1,4 +1,11 @@
#ifndef ORIENTATION_H #ifndef ORIENTATION_H
#define ORIENTATION_H #define ORIENTATION_H
#include "DCMotor.h"
#include "RFReceiver.h"
void Orientation_conf(void);
void Orientation_background(void);
#endif #endif