mirror of
https://gitlab.com/lander-team/tvc-test-code.git
synced 2025-06-17 07:26:51 +00:00
terminal input working
This commit is contained in:
parent
e29cf9224f
commit
fc987e89cc
36
src/main.cpp
36
src/main.cpp
@ -10,13 +10,14 @@ double PITCH_MAX = 7;
|
|||||||
double zero_height;
|
double zero_height;
|
||||||
|
|
||||||
float read_float();
|
float read_float();
|
||||||
|
float calc_height(float yaw, float pitch);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
delay(1000);
|
delay(5000);
|
||||||
// yaw.attach(9); // CHANGE MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
// yaw.attach(9); // CHANGE MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
||||||
// pitch.attach(10); // CHANGE MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
// pitch.attach(10); // CHANGE MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
||||||
|
|
||||||
Serial.println("Level the TVC and press 1.");
|
Serial.println("Level the TVC and press enter.");
|
||||||
read_float();
|
read_float();
|
||||||
|
|
||||||
// Do a full range of movement of the servos
|
// Do a full range of movement of the servos
|
||||||
@ -30,19 +31,23 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Serial.print("Please input the point height in millimeters: ");
|
Serial.print("Please input the point height in millimeters: ");
|
||||||
String zero_string = read_float();
|
zero_height = read_float();
|
||||||
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
Serial.print("Enter Yaw Coord: ");
|
Serial.print("Enter Yaw Coord: ");
|
||||||
float yaw_pos = read_float();
|
float yaw_pos = read_float();
|
||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Serial.print("Enter Pitch Coord: ");
|
Serial.print("Enter Pitch Coord: ");
|
||||||
float pitch_pos = read_float();
|
float pitch_pos = read_float();
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Serial.println("Moving servos...");
|
Serial.println("Moving servos to [" + String(yaw_pos) + ", " +
|
||||||
|
String(pitch_pos) + "]");
|
||||||
|
|
||||||
// yaw.write(yaw_pos);
|
// yaw.write(yaw_pos);
|
||||||
// pitch.write(pitch_pos);
|
// pitch.write(pitch_pos);
|
||||||
@ -57,14 +62,23 @@ void loop() {
|
|||||||
float height = sin(yaw_pos) + sin(pitch_pos) + zero_height;
|
float height = sin(yaw_pos) + sin(pitch_pos) + zero_height;
|
||||||
|
|
||||||
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");
|
||||||
|
Serial.println("Press enter to continue.");
|
||||||
|
read_float();
|
||||||
}
|
}
|
||||||
|
|
||||||
float read_float() {
|
float read_float() {
|
||||||
while (Serial.available() == 0) {
|
char line[80];
|
||||||
delay(100);
|
int count = 0;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
if (Serial.available() > 0) {
|
||||||
|
line[count] = (char)Serial.read(); // store the char
|
||||||
|
Serial.print(line[count]);
|
||||||
|
if (line[count++] == '\r') { // if its a CR,
|
||||||
|
line[count] = '\0'; // zero-terminate it
|
||||||
|
return String(line).toFloat();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
float num = Serial.parseFloat();
|
|
||||||
Serial.print(num);
|
|
||||||
return num;
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user