mirror of
https://github.com/modelec/MarcelMoteurSTM32.git
synced 2026-01-18 16:47:23 +01:00
fix merge conflicts
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* functions.h
|
||||
*
|
||||
* Created on: Feb 17, 2025
|
||||
* Author: CHAUVEAU Maxime
|
||||
*/
|
||||
|
||||
#ifndef FUNCTIONS_H_
|
||||
#define FUNCTIONS_H_
|
||||
|
||||
#include "main.h"
|
||||
#include "motors.h"
|
||||
|
||||
bool isDelayPassed(uint32_t delay);
|
||||
void handleEncoderProgression(uint16_t totalDistance, uint16_t newDistance, bool direction);
|
||||
|
||||
|
||||
#endif /* FUNCTIONS_H_ */
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
void tournerDroite(int speed);
|
||||
void tournerGauche(int speed);
|
||||
void update();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef SRC_FUNCTIONS_C_
|
||||
#define SRC_FUNCTIONS_C_
|
||||
|
||||
#include "functions.h"
|
||||
#include "motors.h"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
extern UART_HandleTypeDef huart2;
|
||||
|
||||
uint32_t lastTick = 0; // Variable pour mémoriser l'heure de la dernière action
|
||||
uint32_t delayTime = 0; // Variable pour définir le délai de la prochaine action
|
||||
|
||||
// Fonction pour vérifier si le délai est passé (permet de ne pas bloquer l'exécution)
|
||||
bool isDelayPassed(uint32_t delay) {
|
||||
if (HAL_GetTick() - lastTick >= delay) {
|
||||
lastTick = HAL_GetTick(); // Met à jour lastTick
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void handleEncoderProgression(uint16_t totalDistance, uint16_t newDistance, bool direction){
|
||||
char msg[128];
|
||||
if(direction == 0){
|
||||
sprintf(msg, "Encodeur recule de %d mm, distance totale parcourue : %d mm.\r\n", newDistance, totalDistance);
|
||||
} else if(direction == 1){
|
||||
sprintf(msg, "Encodeur avance de %d mm, distance totale parcourue : %d mm.\r\n", newDistance, totalDistance);
|
||||
}
|
||||
HAL_UART_Transmit(&huart2, (uint8_t *)msg, strlen(msg), HAL_MAX_DELAY);
|
||||
}
|
||||
|
||||
|
||||
#endif /* SRC_FUNCTIONS_C_ */
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
|
||||
#include "motors.h"
|
||||
#include "functions.h"
|
||||
#include "main.h"
|
||||
#include "stm32l0xx_hal.h"
|
||||
#include <cstdio>
|
||||
@@ -37,6 +36,16 @@ extern "C" {
|
||||
extern TIM_HandleTypeDef htim21;
|
||||
extern UART_HandleTypeDef huart2;
|
||||
|
||||
uint32_t lastTick = 0; // Variable pour mémoriser l'heure de la dernière action
|
||||
// Fonction pour vérifier si le délai est passé (permet de ne pas bloquer l'exécution)
|
||||
bool isDelayPassed(uint32_t delay) {
|
||||
if (HAL_GetTick() - lastTick >= delay) {
|
||||
lastTick = HAL_GetTick(); // Met à jour lastTick
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fonction de setup appelee au debut du main.c
|
||||
void ModelecOdometrySetup(){
|
||||
HAL_UART_Transmit(&huart2, (uint8_t *)"SETUP COMPLETE\n", 15, HAL_MAX_DELAY);
|
||||
|
||||
@@ -27,6 +27,7 @@ void Motor::stop() {
|
||||
bool Motor::isStopped() {
|
||||
return currentSpeed == 0;
|
||||
}
|
||||
|
||||
void Motor::tournerDroite(int speed) {
|
||||
targetSpeed = (speed <= 626) ? speed : 626;
|
||||
isTurningRight = true;
|
||||
|
||||
Reference in New Issue
Block a user