2018-05-02 05:51:14 +02:00
|
|
|
/* Teste si une broche est connecté à une autre */
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <wiringPi.h>
|
|
|
|
#include <wiringPiI2C.h>
|
|
|
|
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "CF.h"
|
2018-05-06 08:14:51 +02:00
|
|
|
#include "motor.h"
|
2018-05-02 05:51:14 +02:00
|
|
|
#include "buttons.h"
|
|
|
|
|
|
|
|
#define UP_TIME 1000
|
|
|
|
#define HIGH_TIME 3000
|
|
|
|
#define DOWN_TIME 1000
|
|
|
|
#define LOW_TIME 2000
|
2018-05-06 12:50:03 +02:00
|
|
|
#define MAXI 12
|
2018-05-02 05:51:14 +02:00
|
|
|
#define INTERVAL 10
|
|
|
|
|
|
|
|
void changerMoteursWrapper(float l, float r) {
|
|
|
|
/* clearLCD(); */
|
|
|
|
printfToLCD(LCD_LINE_1, "L: %f", l);
|
|
|
|
printfToLCD(LCD_LINE_2, "R: %f", r);
|
2018-05-06 12:50:03 +02:00
|
|
|
setMoteurTension(l, r);
|
2018-05-02 05:51:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
|
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
|
|
|
|
|
|
|
wiringPiSetup();
|
|
|
|
|
|
|
|
initI2C();
|
|
|
|
initLCD();
|
|
|
|
configureCF();
|
|
|
|
configureButtons();
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
for (int i = 0; i < UP_TIME; i += INTERVAL) {
|
|
|
|
float p = (float)i / (float)UP_TIME;
|
2018-05-06 08:14:51 +02:00
|
|
|
changerMoteursWrapper(p * MAXI, p * MAXI);
|
2018-05-02 05:51:14 +02:00
|
|
|
delay(INTERVAL);
|
|
|
|
}
|
2018-05-06 08:14:51 +02:00
|
|
|
changerMoteursWrapper(MAXI, MAXI);
|
2018-05-02 05:51:14 +02:00
|
|
|
delay(HIGH_TIME);
|
|
|
|
|
|
|
|
for (int i = 0; i < DOWN_TIME; i += INTERVAL) {
|
|
|
|
float p = (float)i / (float)DOWN_TIME;
|
|
|
|
p = 1 - p;
|
2018-05-06 08:14:51 +02:00
|
|
|
changerMoteursWrapper(p * MAXI, p * MAXI);
|
2018-05-02 05:51:14 +02:00
|
|
|
delay(INTERVAL);
|
|
|
|
}
|
|
|
|
changerMoteursWrapper(0, 0);
|
|
|
|
delay(LOW_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|