mirror of
https://gitlab.com/lander-team/tvc-test-code.git
synced 2025-06-17 07:26:51 +00:00
fixed terminal reading
This commit is contained in:
parent
644fcc0931
commit
e29cf9224f
36
src/main.cpp
36
src/main.cpp
@ -9,12 +9,15 @@ double PITCH_MAX = 7;
|
|||||||
|
|
||||||
double zero_height;
|
double zero_height;
|
||||||
|
|
||||||
void setup() {
|
float read_float();
|
||||||
yaw.attach(9); // CHANGE MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
|
||||||
pitch.attach(10); // CHANGE MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
|
||||||
|
|
||||||
Serial.println("Level the TVC and press enter.");
|
void setup() {
|
||||||
Serial.readString();
|
delay(1000);
|
||||||
|
// yaw.attach(9); // CHANGE MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
||||||
|
// pitch.attach(10); // CHANGE MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
||||||
|
|
||||||
|
Serial.println("Level the TVC and press 1.");
|
||||||
|
read_float();
|
||||||
|
|
||||||
// Do a full range of movement of the servos
|
// Do a full range of movement of the servos
|
||||||
for (double pct = -100.0; pct <= 100.0; pct += 1.0) {
|
for (double pct = -100.0; pct <= 100.0; pct += 1.0) {
|
||||||
@ -22,27 +25,27 @@ void setup() {
|
|||||||
double pitch_pos = pct * PITCH_MAX;
|
double pitch_pos = pct * PITCH_MAX;
|
||||||
|
|
||||||
yaw.write(yaw_pos);
|
yaw.write(yaw_pos);
|
||||||
pitch.write(pitch_pos);
|
// pitch.write(pitch_pos);
|
||||||
delay(15);
|
delay(15);
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.print("Please input the point height in millimeters: ");
|
Serial.print("Please input the point height in millimeters: ");
|
||||||
String zero_string = Serial.readString();
|
String zero_string = read_float();
|
||||||
zero_height = zero_string.toFloat();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
Serial.print("Enter Yaw Coord: ");
|
Serial.print("Enter Yaw Coord: ");
|
||||||
float yaw_pos = Serial.readString().toFloat();
|
float yaw_pos = read_float();
|
||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.print("Enter Pitch Coord: ");
|
Serial.print("Enter Pitch Coord: ");
|
||||||
float pitch_pos = Serial.readString().toFloat();
|
float pitch_pos = read_float();
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|
||||||
Serial.println("Moving servos...");
|
Serial.println("Moving servos...");
|
||||||
|
|
||||||
yaw.write(yaw_pos);
|
// yaw.write(yaw_pos);
|
||||||
pitch.write(pitch_pos);
|
// pitch.write(pitch_pos);
|
||||||
|
|
||||||
Serial.print("Calculating current height");
|
Serial.print("Calculating current height");
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
@ -56,3 +59,12 @@ void loop() {
|
|||||||
Serial.println("Please verify current height is correct: " + String(height) +
|
Serial.println("Please verify current height is correct: " + String(height) +
|
||||||
"\n\n\n\n\n");
|
"\n\n\n\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float read_float() {
|
||||||
|
while (Serial.available() == 0) {
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
float num = Serial.parseFloat();
|
||||||
|
Serial.print(num);
|
||||||
|
return num;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user