Browse Source

Modification des arguments de DCMotor_conf et ecriture de Orientation

Marino Benassai 3 years ago
parent
commit
c973c13ba5
4 changed files with 31 additions and 9 deletions
  1. 5
    8
      Services/DCMotor.c
  2. 1
    1
      Services/DCMotor.h
  3. 18
    0
      Src/Orientation.c
  4. 7
    0
      Src/Orientation.h

+ 5
- 8
Services/DCMotor.c View File

@@ -1,16 +1,13 @@
1 1
 #include "DCMotor.h"
2 2
 
3
-void DCMotor_conf(double speed) {
3
+void DCMotor_conf() {
4 4
 	
5
-	double speedAbs = (speed > 0.) ? speed : -speed;
6
-	int sens = (speed > 0.) ? 1 : 0;
5
+	//On règle la vitesse en valeur absolue, ici à 0
6
+	Timer_pwmo_conf(TIM2, LL_TIM_CHANNEL_CH2, 50, 0);
7 7
 	
8
-	//On règle la vitesse en valeur absolue
9
-	Timer_pwmo_conf(TIM2, LL_TIM_CHANNEL_CH2, 50, speedAbs);
10
-	
11
-	//On règle le sens du moteur
8
+	//On règle le sens du moteur, ici sens direct (?)
12 9
 	GPIO_conf(GPIOA, LL_GPIO_PIN_2, LL_GPIO_MODE_OUTPUT, LL_GPIO_OUTPUT_OPENDRAIN, LL_GPIO_PULL_DOWN);
13
-	GPIO_setPin(GPIOA, LL_GPIO_PIN_2, sens);
10
+	GPIO_setPin(GPIOA, LL_GPIO_PIN_2, 0);
14 11
 }
15 12
 
16 13
 void DCMotor_setSpeed(double speed) {

+ 1
- 1
Services/DCMotor.h View File

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

+ 18
- 0
Src/Orientation.c View File

@@ -1 +1,19 @@
1 1
 #include "Orientation.h"
2
+#define SEUIL 30
3
+
4
+void Orientation_conf() {
5
+	
6
+	DCMotor_conf();
7
+	RFReceiver_conf();
8
+	
9
+}
10
+
11
+void Orientation_background(){
12
+	
13
+	double speed = RFReceiver_getData();
14
+	
15
+	//Si la vitesse (en valeur absolue) ne dépasse pas un certain seuil, on ne démarre pas le moteur
16
+	if (-SEUIL<speed && SEUIL>speed) DCMotor_setSpeed(0);
17
+	else DCMotor_setSpeed(speed);
18
+	
19
+}

+ 7
- 0
Src/Orientation.h View File

@@ -1,4 +1,11 @@
1 1
 #ifndef ORIENTATION_H
2 2
 #define ORIENTATION_H
3 3
 
4
+#include "DCMotor.h"
5
+#include "RFReceiver.h"
6
+
7
+void Orientation_conf(void);
8
+
9
+void Orientation_background(void);
10
+
4 11
 #endif

Loading…
Cancel
Save