mirror of
https://github.com/RobotechLille/cdf2018-principal
synced 2024-07-01 07:15:24 +02:00
63 lines
1.3 KiB
C
63 lines
1.3 KiB
C
|
/* 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"
|
||
|
#include "movement.h"
|
||
|
#include "buttons.h"
|
||
|
|
||
|
#define UP_TIME 1000
|
||
|
#define HIGH_TIME 3000
|
||
|
#define DOWN_TIME 1000
|
||
|
#define LOW_TIME 2000
|
||
|
#define MAXI 3.3
|
||
|
#define INTERVAL 10
|
||
|
|
||
|
void changerMoteursWrapper(float l, float r) {
|
||
|
/* clearLCD(); */
|
||
|
printfToLCD(LCD_LINE_1, "L: %f", l);
|
||
|
printfToLCD(LCD_LINE_2, "R: %f", r);
|
||
|
changerMoteurs(l, r);
|
||
|
}
|
||
|
|
||
|
int main(int argc, char* argv[])
|
||
|
{
|
||
|
|
||
|
(void)argc;
|
||
|
(void)argv;
|
||
|
|
||
|
wiringPiSetup();
|
||
|
|
||
|
initI2C();
|
||
|
initLCD();
|
||
|
configureCF();
|
||
|
configureButtons();
|
||
|
configureMovement();
|
||
|
|
||
|
for (;;) {
|
||
|
for (int i = 0; i < UP_TIME; i += INTERVAL) {
|
||
|
float p = (float)i / (float)UP_TIME;
|
||
|
changerMoteursWrapper(p * MOT_MAX_V, p * MOT_MAX_V);
|
||
|
delay(INTERVAL);
|
||
|
}
|
||
|
changerMoteursWrapper(MOT_MAX_V, MOT_MAX_V);
|
||
|
delay(HIGH_TIME);
|
||
|
|
||
|
for (int i = 0; i < DOWN_TIME; i += INTERVAL) {
|
||
|
float p = (float)i / (float)DOWN_TIME;
|
||
|
p = 1 - p;
|
||
|
changerMoteursWrapper(p * MOT_MAX_V, p * MOT_MAX_V);
|
||
|
delay(INTERVAL);
|
||
|
}
|
||
|
changerMoteursWrapper(0, 0);
|
||
|
delay(LOW_TIME);
|
||
|
}
|
||
|
|
||
|
}
|