2023-04-04 14:34:09 +02:00
|
|
|
#include "remote.h"
|
2023-04-07 13:21:27 +02:00
|
|
|
#include "gpio.h"
|
2023-04-07 14:13:00 +02:00
|
|
|
#include "motoreducteur.h"
|
2023-04-04 14:34:09 +02:00
|
|
|
|
|
|
|
MyUART_Struct_Typedef uartCool = {USART1,9600,lengthBit8,parityNone,stopBit1};
|
|
|
|
|
2023-04-07 13:21:27 +02:00
|
|
|
void remote(uint8_t data)
|
2023-04-04 14:34:09 +02:00
|
|
|
{
|
2023-04-07 13:21:27 +02:00
|
|
|
MyUART_Send(&uartCool,data);
|
|
|
|
int8_t signedData = (int8_t)data;
|
2023-04-07 14:13:00 +02:00
|
|
|
if(signedData >= 0)
|
2023-04-04 15:26:37 +02:00
|
|
|
{
|
2023-04-07 14:13:00 +02:00
|
|
|
MyMotor_ChangeDirection(HORAIRE);
|
|
|
|
MyMotor_ChangeSpeed(signedData*100);
|
2023-04-04 15:26:37 +02:00
|
|
|
}
|
2023-04-07 13:21:27 +02:00
|
|
|
else {
|
2023-04-07 14:13:00 +02:00
|
|
|
MyMotor_ChangeDirection(ANTIHOR);
|
|
|
|
MyMotor_ChangeSpeed((-signedData)*100);
|
2023-04-07 13:21:27 +02:00
|
|
|
}
|
2023-04-04 14:34:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void initRemote(void)
|
|
|
|
{
|
|
|
|
MyUART_InitGPIO(&uartCool);
|
|
|
|
MyUART_Init(&uartCool);
|
|
|
|
MyUART_Init_Periph(remote);
|
|
|
|
}
|
2023-03-31 12:18:42 +02:00
|
|
|
|
2023-04-04 15:26:37 +02:00
|
|
|
void testRemote(void)
|
|
|
|
{
|
|
|
|
MyUART_Send(&uartCool,'s');
|
|
|
|
MyUART_Send(&uartCool,'a');
|
|
|
|
MyUART_Send(&uartCool,'l');
|
|
|
|
MyUART_Send(&uartCool,'u');
|
|
|
|
MyUART_Send(&uartCool,'t');
|
|
|
|
}
|