1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-05-17 04:26:00 +02:00
cdf2018-principal/chef/src/testUpDown.c

84 lines
2 KiB
C
Raw Normal View History

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 "buttons.h"
2018-05-11 15:58:18 +02:00
#include "debug.h"
2018-05-11 05:34:06 +02:00
#include "dimensions.h"
2018-05-11 15:58:18 +02:00
#include "lcd.h"
#include "motor.h"
#include "position.h"
2018-05-02 05:51:14 +02:00
#define UP_TIME 1000
#define HIGH_TIME 3000
#define DOWN_TIME 1000
#define LOW_TIME 2000
2018-05-11 05:34:06 +02:00
#define MAXI MOTOR_SATURATION_MAX
2018-05-02 05:51:14 +02:00
#define INTERVAL 10
2018-05-11 15:58:18 +02:00
void changerMoteursWrapper(float l, float r)
{
2018-05-02 05:51:14 +02:00
/* 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();
2018-05-11 15:58:18 +02:00
configureDebug();
2018-05-02 05:51:14 +02:00
configureButtons();
2018-05-09 09:57:11 +02:00
configureMotor();
2018-05-11 15:58:18 +02:00
configurePosition();
startDebug();
debugSetActive(true);
2018-05-02 05:51:14 +02:00
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);
2018-05-09 09:57:11 +02:00
for (int i = 0; i < UP_TIME; i += INTERVAL) {
float p = (float)i / (float)UP_TIME;
changerMoteursWrapper(-p * MAXI, -p * MAXI);
delay(INTERVAL);
}
changerMoteursWrapper(-MAXI, -MAXI);
delay(HIGH_TIME);
for (int i = 0; i < DOWN_TIME; i += INTERVAL) {
float p = (float)i / (float)DOWN_TIME;
p = 1 - p;
changerMoteursWrapper(-p * MAXI, -p * MAXI);
delay(INTERVAL);
}
changerMoteursWrapper(0, 0);
delay(LOW_TIME);
2018-05-02 05:51:14 +02:00
}
}