1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-05-04 05:01:45 +00:00
cdf2018-principal/chef/src/testUpDown.c
2018-05-02 05:51:14 +02:00

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);
}
}