#include "stm32f10x.h"
#include "gpio.h"
#include "servo.h"
#include "motoreducteur.h"
#include "rtc.h"
#include "remote.h"
#include "accelerometer.h"
#include "battery.h"
#include "timer.h"
#include "girouette.h"

void initImplementation(void);

float GX, GY, GZ;
int Angle_Girouette=0;
int actualMinutes=-1;
uint32_t oldAdc=0;

int main (void)
{

	//MyGPIO_Struct_TypeDef led = {GPIOA,5,Out_PullUp};	//led
	//MyGPIO_Init(&led);																//test des leds pour ignorer les contraintes li�es aux diff�rents ports
	initImplementation();
	MyServo_ChangeAngle(90);
	//MyRTC_GetTime(&sec, &min, &hour, &day, &date, &month, &year);
 	while(1){
	Lecture_accelerometre(&GX,&GY,&GZ);
		if(GZ < 5.5)
			MyServo_ChangeAngle(179);
		Angle_Girouette=MyGirouette_Angle(TIM4);
	};	
}

void initImplementation(void)
{
	initRemote();
	MyServo_Init();
	MyServo_ChangeAngle(179);
	Init_accelerometre();
	MyGirouette_Init(TIM4);
	MyGirouette_Init_IT_Z(0);
	MyMotor_Init();
	MyMotor_ChangeSpeed(0);
	MyMotor_ChangeDirection(HORAIRE);
	MyRTC_Init();
	initBattery();
}

