feat: add ids for xshut, gpio and servos
This commit is contained in:
parent
814eff498a
commit
2598f523d0
@ -179,7 +179,8 @@ void init_tube(struct tube *tube, char id, char servo_pin, char gpio, char xshut
|
||||
tube->height = 250.0;
|
||||
tube->target = 250.0;
|
||||
|
||||
if (!tofs_talk_through[id].begin()) {
|
||||
digitalWrite(xshut, HIGH);
|
||||
if (!tofs_talk_through[id].begin(0x30 + id)) {
|
||||
Serial.println(F("Failed to boot VL53L0X"));
|
||||
while(1);
|
||||
}
|
||||
@ -187,13 +188,13 @@ void init_tube(struct tube *tube, char id, char servo_pin, char gpio, char xshut
|
||||
tube->servo.hard.write(minServo);
|
||||
delay(5000);
|
||||
Serial.println("Setuping downards");
|
||||
float h = mesureHeight(tube->tof.hard);
|
||||
float h = mesureHeight(tofs_talk_through[id]);
|
||||
int angle = minServo;
|
||||
while (h > maxHeight) {
|
||||
++angle;
|
||||
tube->servo.hard.write(angle);
|
||||
delay(100);
|
||||
h = mesureHeight(tube->tof.hard);
|
||||
h = mesureHeight(tofs_talk_through[id]);
|
||||
}
|
||||
angle -= 2;
|
||||
tube->servo.hard.write(angle);
|
||||
@ -201,8 +202,26 @@ void init_tube(struct tube *tube, char id, char servo_pin, char gpio, char xshut
|
||||
Serial.println("Done.");
|
||||
}
|
||||
|
||||
const int ACTIVES = 1;
|
||||
|
||||
void setup_all_tubes() {
|
||||
init_tube(all_tubes, 1, 32, 5, 17);
|
||||
const int all_xshuts[6] = {17, 0, 0, 0, 0, 0};
|
||||
const int all_gpios[6] = {23, 22, 21, 0, 0, 0};
|
||||
const int all_servos[6] = {32, 33, 23, 16, 4, 2};
|
||||
for (int i = 0; i < ACTIVES; ++i) {
|
||||
digitalWrite(all_xshuts[i], LOW);
|
||||
}
|
||||
delay(10);
|
||||
for (int i = 0; i < ACTIVES; ++i) {
|
||||
digitalWrite(all_xshuts[i], HIGH);
|
||||
}
|
||||
delay(10);
|
||||
for (int i = 0; i < ACTIVES; ++i) {
|
||||
digitalWrite(all_xshuts[i], LOW);
|
||||
}
|
||||
for (int i = 0; i < ACTIVES; ++i) {
|
||||
init_tube(all_tubes, i, all_servos[i], all_gpios[i], all_xshuts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
@ -228,9 +247,9 @@ int servoPosition(float ratio){
|
||||
|
||||
void loop() {
|
||||
|
||||
for (int i = 0; i < 1; i++) {
|
||||
for (int i = 0; i < ACTIVES; i++) {
|
||||
struct tube tube = all_tubes[i];
|
||||
tube.height = mesureHeight(tube.tof.hard);
|
||||
tube.height = mesureHeight(tofs_talk_through[tube.id]);
|
||||
Serial.print("Measure = ");
|
||||
Serial.println(tube.height);
|
||||
int angle = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user