parser changes in progress
This commit is contained in:
parent
ec57c5ba56
commit
85bd9810b8
12
deploy.sh
12
deploy.sh
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
rsync -av --exclude='build/' ~/code/FireWatchTower_2axis/host/ ggs@10.11.12.111:/home/ggs/projects/FireWatchTower_2axis/host
|
||||
ssh ggs@10.11.12.111 "
|
||||
mkdir -p /home/ggs/projects/FireWatchTower_2axis/host/build &&
|
||||
cd /home/ggs/projects/FireWatchTower_2axis/host/build &&
|
||||
cmake .. &&
|
||||
make -j\$(nproc)
|
||||
rsync -av --exclude='build/' ~/code/FireWatchTower_2axis/ ggs@10.11.12.111:/home/ggs/projects/FireWatchTower_2axis
|
||||
#ssh ggs@10.11.12.111 "
|
||||
# mkdir -p /home/ggs/projects/FireWatchTower_2axis/build &&
|
||||
# cd /home/ggs/projects/FireWatchTower_2axis/build &&
|
||||
# cmake .. &&
|
||||
# make -j\$(nproc)
|
||||
"
|
||||
|
|
@ -25,8 +25,7 @@ void loop() {
|
|||
endstop_routine();
|
||||
|
||||
if (Serial.available()) {
|
||||
char in = Serial.read();
|
||||
parser(in);
|
||||
read_command()
|
||||
}
|
||||
|
||||
if (millis() - s_last_loop > INFO_PRINT_INTERVAL_MS) {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,43 @@
|
|||
|
||||
#include "TMC5160.h"
|
||||
|
||||
void parser(char &c) {
|
||||
void read_command() {
|
||||
// Command format: <cmd>[y|p][d]<arg1>,<arg2>,...
|
||||
// Axis specifier: y=Yaw only, p=Pitch only
|
||||
// Base specifier: d=decimal (default hex)
|
||||
|
||||
// Get first character of recieved command
|
||||
char c = Serial.read();
|
||||
|
||||
// Parse optional axis specifier: y (yaw) or p (pitch)
|
||||
uint8_t target_yaw = 1;
|
||||
uint8_t target_pitch = 1;
|
||||
const __FlashStringHelper* axis_str; // string to hold the suffix for terminal messages
|
||||
if (Serial.peek() == 'y') {
|
||||
Serial.read();
|
||||
target_pitch = 0;
|
||||
axis_str = F(" [YAW]");
|
||||
}
|
||||
else if (Serial.peek() == 'p') {
|
||||
Serial.read();
|
||||
target_yaw = 0;
|
||||
axis_str = F(" [PITCH]")
|
||||
}
|
||||
else {
|
||||
axis_str = F(" [YAW+PITCH]");
|
||||
}
|
||||
|
||||
// Check if a "d" follows, for decimal values instead of hex
|
||||
uint8_t base = 16;
|
||||
if (Serial.peek() == 'd') {
|
||||
Serial.read();
|
||||
base = 10;
|
||||
}
|
||||
|
||||
// Create a stactic buffer for reading the rest of the command
|
||||
static char buffer[32];
|
||||
size_t len = Serial.readBytesUntil('\n', buffer, sizeof(buffer) - 1);
|
||||
buffer[len] = '\0';
|
||||
buffer[len] = '\0'; // Add termination character to string
|
||||
|
||||
int32_t args[4] = {0};
|
||||
uint8_t argc = 0;
|
||||
|
|
@ -25,27 +58,40 @@ void parser(char &c) {
|
|||
switch (c) {
|
||||
|
||||
case 'r': // power cycle the motors
|
||||
init_motor_params();
|
||||
motor_power_on(MotorPitch);
|
||||
Serial.print(F("Reseting"));
|
||||
Serial.println(axis_str); // targeted motor axis
|
||||
|
||||
if (target_yaw) {
|
||||
write_regs_yaw();
|
||||
motor_power_on(MotorYaw);
|
||||
ax_pitch.driver_status = GIMBAL_STATUS_RESET;
|
||||
ax_yaw.driver_status = GIMBAL_STATUS_RESET;
|
||||
Serial.println(F("Reset"));
|
||||
}
|
||||
if (target_pitch) {
|
||||
write_regs_pitch();
|
||||
motor_power_on(MotorPitch);
|
||||
ax_pitch.driver_status = GIMBAL_STATUS_RESET;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'q': // find endstop
|
||||
do_endstop(MotorYaw);
|
||||
do_endstop(MotorPitch);
|
||||
Serial.print(F("Finding endstops"));
|
||||
Serial.println(axis_str); // targeted motor axis
|
||||
if (target_yaw) do_endstop(MotorYaw);
|
||||
if (target_pitch) do_endstop(MotorPitch);
|
||||
break;
|
||||
|
||||
case '!': // turn motors off
|
||||
motor_power_off(MotorPitch);
|
||||
motor_power_off(MotorYaw);
|
||||
Serial.print(F("Turning motors off"));
|
||||
Serial.println(axis_str); // targeted motor axis
|
||||
if (target_yaw) motor_power_off(MotorPitch);
|
||||
if (target_pitch) motor_power_off(MotorYaw);
|
||||
break;
|
||||
|
||||
case '*': // turn motors on
|
||||
motor_power_on(MotorPitch);
|
||||
motor_power_on(MotorYaw);
|
||||
Serial.print(F("Turning motors on"));
|
||||
Serial.println(axis_str); // targeted motor axis
|
||||
if (target_yaw) motor_power_on(MotorPitch);
|
||||
if (target_pitch) motor_power_on(MotorYaw);
|
||||
break;
|
||||
|
||||
case 'm': // move to a specific position in yawl
|
||||
|
|
@ -94,7 +140,7 @@ void parser(char &c) {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'h': {
|
||||
case 'h':
|
||||
if (args[0] == MotorYaw) {
|
||||
ax_yaw.c_hdg = (float)args[1];
|
||||
ax_yaw.hdg_constant = ax_yaw.X_enc;
|
||||
|
|
@ -106,7 +152,6 @@ void parser(char &c) {
|
|||
EEPROM.put(ee, dist);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'y': {
|
||||
if (args[0] == MotorYaw) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
void parser(char &c);
|
||||
void read_command();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Reference in New Issue