113 lines
1.6 KiB
C
113 lines
1.6 KiB
C
#include "stm32f10x.h"
|
|
#include <Driver_GPIO.h>
|
|
#include <MyTimer.h>
|
|
#include <MyADC.h>
|
|
#include <Plateau.h>
|
|
#include <Telecommande.h>
|
|
#include <Batterie.h>
|
|
#include <MyGirouette.h>
|
|
#include <MyVoile.h>
|
|
|
|
|
|
/* Declarations */
|
|
int droite;
|
|
int b;
|
|
int testBatterie ;
|
|
int bat;
|
|
|
|
int counter = 0;
|
|
char* visuBatterie = "[-----]";
|
|
|
|
MyTimer_Struct_TypeDef TIM;
|
|
MyTimer_Struct_TypeDef * Data = &TIM;
|
|
|
|
|
|
|
|
void handler() {
|
|
counter ++;
|
|
|
|
/*fonctions joel gwen*/
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
|
|
|
|
if (counter == 10) {
|
|
bat = Get_Batterie();
|
|
if (bat < 20) {
|
|
visuBatterie = "[-----]";
|
|
} else if (bat < 40) {
|
|
visuBatterie = "[##---]";
|
|
} else if (bat < 60) {
|
|
visuBatterie = "[###--]";
|
|
} else if (bat < 80) {
|
|
visuBatterie = "[####-]";
|
|
} else {
|
|
visuBatterie = "[#####]";
|
|
}
|
|
|
|
Send_Message("Batterie : ");
|
|
Send_Message(visuBatterie);
|
|
Send_Message("\r");
|
|
|
|
|
|
counter = 0;
|
|
}
|
|
}
|
|
|
|
|
|
void f (char a) {
|
|
|
|
|
|
if (a>> 7 & 1) {
|
|
droite = 1;
|
|
b = 256 - a;
|
|
Set_Moteur_Plateau(HORRAIRE, b);
|
|
}
|
|
else {
|
|
droite = 0;
|
|
b = a;
|
|
Set_Moteur_Plateau(ANTI_HORRAIRE, b);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int main (void)
|
|
{
|
|
|
|
/* Configuration du Timer */
|
|
Data->Timer = TIM1;
|
|
Data->ARR = 65535;
|
|
Data->PSC = 548;
|
|
MyTimer_Base_Init(Data);
|
|
MyTimer_Base_Start(TIM1);
|
|
MyTimer_ActiveIT(TIM1, 1, &handler);
|
|
|
|
/* Pour la telecommande */
|
|
Init_USART(USART1);
|
|
Init_Message_Reception(&f);
|
|
Init_Plateau();
|
|
Init_Girouette();
|
|
MyVoile_Init();
|
|
|
|
/* Batterie */
|
|
Init_Batterie();
|
|
while (1) {
|
|
Set_Voile(Get_Angle());
|
|
}
|
|
}
|
|
|