Merge in com port switching from sangaboard v4
I've refactored the use of the serial port, to store the current serial port in a global variable in a module. This is set to the most recent port to receive data, and so we should always be replying to the port that was used to initiate a command. If SECONDARY_SERIAL_PORT is not defined, this should result in no change - if it is, we should be able to communicate on either port.
This commit is contained in:
parent
e65c290ae6
commit
3997d66cde
12 changed files with 180 additions and 145 deletions
4
lib/ComPort/ComPort.cpp
Normal file
4
lib/ComPort/ComPort.cpp
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include <ComPort.h>
|
||||||
|
|
||||||
|
// Actually define the variable and default to the USB Serial port
|
||||||
|
HardwareSerial* comPort = (HardwareSerial*) &Serial;
|
||||||
9
lib/ComPort/ComPort.h
Normal file
9
lib/ComPort/ComPort.h
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef COMPORT_H
|
||||||
|
#define COMPORT_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
// comPort is a Serial-like object that we can switch.
|
||||||
|
extern HardwareSerial* comPort;
|
||||||
|
|
||||||
|
#endif
|
||||||
17
src/boards.h
17
src/boards.h
|
|
@ -28,7 +28,7 @@
|
||||||
#define ENDSTOPS_PULLUPS true
|
#define ENDSTOPS_PULLUPS true
|
||||||
#define WIRING_ENDSTOPS_MIN {A0,A1,A2}
|
#define WIRING_ENDSTOPS_MIN {A0,A1,A2}
|
||||||
#define WIRING_ENDSTOPS_MAX {A3,A4,A5}
|
#define WIRING_ENDSTOPS_MAX {A3,A4,A5}
|
||||||
#define SERIAL_PORT Serial
|
#define PRIMARY_SERIAL_PORT Serial
|
||||||
#define PWM_NUM 0
|
#define PWM_NUM 0
|
||||||
#define WIRING_PWM_LEDS {}
|
#define WIRING_PWM_LEDS {}
|
||||||
#elif defined(BOARD_SANGABOARDv2)
|
#elif defined(BOARD_SANGABOARDv2)
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
#define ENDSTOPS_PULLUPS true
|
#define ENDSTOPS_PULLUPS true
|
||||||
#define WIRING_ENDSTOPS_MIN {A0,A1,A2}
|
#define WIRING_ENDSTOPS_MIN {A0,A1,A2}
|
||||||
#define WIRING_ENDSTOPS_MAX {A3,A4,A5}
|
#define WIRING_ENDSTOPS_MAX {A3,A4,A5}
|
||||||
#define SERIAL_PORT Serial
|
#define PRIMARY_SERIAL_PORT Serial
|
||||||
#define PWM_NUM 0
|
#define PWM_NUM 0
|
||||||
#define WIRING_PWM_LEDS {}
|
#define WIRING_PWM_LEDS {}
|
||||||
#elif defined(BOARD_CUSTOM_BLUEPILL)
|
#elif defined(BOARD_CUSTOM_BLUEPILL)
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
#define ENDSTOPS_PULLUPS true
|
#define ENDSTOPS_PULLUPS true
|
||||||
#define WIRING_ENDSTOPS_MIN {A0,A1,A2}
|
#define WIRING_ENDSTOPS_MIN {A0,A1,A2}
|
||||||
#define WIRING_ENDSTOPS_MAX {A3,A4,A5}
|
#define WIRING_ENDSTOPS_MAX {A3,A4,A5}
|
||||||
#define SERIAL_PORT Serial
|
#define PRIMARY_SERIAL_PORT Serial
|
||||||
#define PWM_NUM 0
|
#define PWM_NUM 0
|
||||||
#define WIRING_PWM_LEDS {}
|
#define WIRING_PWM_LEDS {}
|
||||||
#elif defined(BOARD_CUSTOM_PICO)
|
#elif defined(BOARD_CUSTOM_PICO)
|
||||||
|
|
@ -67,7 +67,7 @@
|
||||||
#define ADDITIONAL_STEPPERS 1
|
#define ADDITIONAL_STEPPERS 1
|
||||||
#define WIRING_ADDITIONAL_STEPPERS = {{0, 1, 22, 23}}
|
#define WIRING_ADDITIONAL_STEPPERS = {{0, 1, 22, 23}}
|
||||||
#define WIRING_STEPSTICK {13,14,15} //enable, step, dir todo: move to boards.h
|
#define WIRING_STEPSTICK {13,14,15} //enable, step, dir todo: move to boards.h
|
||||||
#define SERIAL_PORT Serial
|
#define PRIMARY_SERIAL_PORT Serial
|
||||||
#define PWM_NUM 0
|
#define PWM_NUM 0
|
||||||
#define WIRING_PWM_LEDS {}
|
#define WIRING_PWM_LEDS {}
|
||||||
#elif defined(BOARD_SANGABOARDv5)
|
#elif defined(BOARD_SANGABOARDv5)
|
||||||
|
|
@ -85,9 +85,10 @@
|
||||||
#define WIRING_SERIAL_TX 8
|
#define WIRING_SERIAL_TX 8
|
||||||
#define WIRING_SERIAL_RX 9
|
#define WIRING_SERIAL_RX 9
|
||||||
#ifdef USB_SERIAL
|
#ifdef USB_SERIAL
|
||||||
#define SERIAL_PORT Serial
|
#define PRIMARY_SERIAL_PORT Serial
|
||||||
#else
|
#else
|
||||||
#define SERIAL_PORT Serial2
|
#define PRIMARY_SERIAL_PORT Serial
|
||||||
|
#define SECONDARY_SERIAL_PORT Serial2
|
||||||
#endif
|
#endif
|
||||||
#define PWM_NUM 2
|
#define PWM_NUM 2
|
||||||
#define WIRING_PWM_LEDS {25, 29}
|
#define WIRING_PWM_LEDS {25, 29}
|
||||||
|
|
@ -103,7 +104,7 @@
|
||||||
#define WIRING_ENDSTOPS_MIN {A0,A1,A2}
|
#define WIRING_ENDSTOPS_MIN {A0,A1,A2}
|
||||||
#define WIRING_ENDSTOPS_MAX {A3,A4,A5}
|
#define WIRING_ENDSTOPS_MAX {A3,A4,A5}
|
||||||
#define WIRING_STEPSTICK {13,12,27}
|
#define WIRING_STEPSTICK {13,12,27}
|
||||||
#define SERIAL_PORT Serial
|
#define PRIMARY_SERIAL_PORT Serial
|
||||||
#define PWM_NUM 0
|
#define PWM_NUM 0
|
||||||
#define WIRING_PWM_LEDS {}
|
#define WIRING_PWM_LEDS {}
|
||||||
#elif defined(BOARD_CUSTOM)
|
#elif defined(BOARD_CUSTOM)
|
||||||
|
|
@ -118,7 +119,7 @@
|
||||||
#define ADDITIONAL_STEPPERS 1
|
#define ADDITIONAL_STEPPERS 1
|
||||||
#define WIRING_ADDITIONAL_STEPPERS = {{0, 1, 22, 23}}
|
#define WIRING_ADDITIONAL_STEPPERS = {{0, 1, 22, 23}}
|
||||||
#define WIRING_STEPSTICK {8,9,10} //enable, step, dir todo: move to boards.h
|
#define WIRING_STEPSTICK {8,9,10} //enable, step, dir todo: move to boards.h
|
||||||
#define SERIAL_PORT Serial
|
#define PRIMARY_SERIAL_PORT Serial
|
||||||
#define PWM_NUM 0
|
#define PWM_NUM 0
|
||||||
#define WIRING_PWM_LEDS {}
|
#define WIRING_PWM_LEDS {}
|
||||||
#endif
|
#endif
|
||||||
46
src/main.cpp
46
src/main.cpp
|
|
@ -19,6 +19,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <ComPort.h>
|
||||||
|
|
||||||
#ifdef HELP
|
#ifdef HELP
|
||||||
#include "modules/help/help.h"
|
#include "modules/help/help.h"
|
||||||
|
|
@ -73,9 +74,9 @@ void handle_command(String received_command)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HELP
|
#ifdef HELP
|
||||||
SERIAL_PORT.println(F("Type 'help' for a list of commands."));
|
comPort->println(F("Type 'help' for a list of commands."));
|
||||||
#else
|
#else
|
||||||
SERIAL_PORT.println(F("Invalid command"));
|
comPort->println(F("Invalid command"));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,32 +105,32 @@ uint8_t parse_arguments(char **arguments, String command, uint8_t max_args)
|
||||||
|
|
||||||
void get_version(String)
|
void get_version(String)
|
||||||
{
|
{
|
||||||
SERIAL_PORT.println(F(VERSION_STRING));
|
comPort->println(F(VERSION_STRING));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_modules(String)
|
void get_modules(String)
|
||||||
{
|
{
|
||||||
#if defined(LIGHTSENSOR) && defined(LIGHT_SENSOR_ADAFRUIT_TSL2591)
|
#if defined(LIGHTSENSOR) && defined(LIGHT_SENSOR_ADAFRUIT_TSL2591)
|
||||||
SERIAL_PORT.println(F("Light Sensor: TSL2591"));
|
comPort->println(F("Light Sensor: TSL2591"));
|
||||||
#elif defined(LIGHTSENSOR) && defined(LIGHT_SENSOR_ADAFRUIT_ADS1115)
|
#elif defined(LIGHTSENSOR) && defined(LIGHT_SENSOR_ADAFRUIT_ADS1115)
|
||||||
SERIAL_PORT.println(F("Light Sensor: ADS1115"));
|
comPort->println(F("Light Sensor: ADS1115"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENDSTOPS)
|
#if defined(ENDSTOPS)
|
||||||
SERIAL_PORT.print("Endstops:");
|
comPort->print("Endstops:");
|
||||||
#ifdef ENDSTOPS_MIN
|
#ifdef ENDSTOPS_MIN
|
||||||
SERIAL_PORT.print(" min");
|
comPort->print(" min");
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENDSTOPS_MAX
|
#ifdef ENDSTOPS_MAX
|
||||||
SERIAL_PORT.print(" max");
|
comPort->print(" max");
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENDSTOPS_SOFT
|
#ifdef ENDSTOPS_SOFT
|
||||||
SERIAL_PORT.print(" soft");
|
comPort->print(" soft");
|
||||||
#endif
|
#endif
|
||||||
SERIAL_PORT.println();
|
comPort->println();
|
||||||
#endif
|
#endif
|
||||||
SERIAL_PORT.println("--END--");
|
comPort->println("--END--");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef UNIT_TEST
|
#ifndef UNIT_TEST
|
||||||
|
|
@ -141,9 +142,15 @@ void setup()
|
||||||
Serial2.setRX(WIRING_SERIAL_RX);
|
Serial2.setRX(WIRING_SERIAL_RX);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SERIAL_PORT.begin(115200);
|
comPort = (HardwareSerial*) &PRIMARY_SERIAL_PORT;
|
||||||
while (!SERIAL_PORT)
|
PRIMARY_SERIAL_PORT->begin(115200);
|
||||||
|
while (!PRIMARY_SERIAL_PORT)
|
||||||
delay(1);
|
delay(1);
|
||||||
|
#if defined(SECONDARY_SERIAL_PORT)
|
||||||
|
SECONDARY_SERIAL_PORT->begin(115200);
|
||||||
|
while (!SECONDARY_SERIAL_PORT)
|
||||||
|
delay(1);
|
||||||
|
#endif
|
||||||
|
|
||||||
register_module(core_commands, NULL);
|
register_module(core_commands, NULL);
|
||||||
|
|
||||||
|
|
@ -173,14 +180,21 @@ void setup()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
registered_commands[registered_commands_count] = &end_command;
|
registered_commands[registered_commands_count] = &end_command;
|
||||||
SERIAL_PORT.println(F(VERSION_STRING));
|
comPort->println(F(VERSION_STRING));
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
if (SERIAL_PORT.available())
|
if (PRIMARY_SERIAL_PORT.available())
|
||||||
{
|
{
|
||||||
handle_command(SERIAL_PORT.readStringUntil('\n'));
|
comPort = (HardwareSerial*) &PRIMARY_SERIAL_PORT;
|
||||||
|
handle_command(comPort->readStringUntil('\n'));
|
||||||
|
}
|
||||||
|
#if defined(SECONDARY_SERIAL_PORT)
|
||||||
|
if (SECONDARY_SERIAL_PORT.available())
|
||||||
|
{
|
||||||
|
comPort = (HardwareSerial*) &SECONDARY_SERIAL_PORT;
|
||||||
|
handle_command(comPort->readStringUntil('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < registered_loop_fn_count; i++)
|
for (int i = 0; i < registered_loop_fn_count; i++)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
#ifndef MAIN_H
|
#ifndef MAIN_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <ComPort.h>
|
||||||
#ifdef DEBUG_ON
|
#ifdef DEBUG_ON
|
||||||
#define D(x) Serial.println(x)
|
#define D(x) comPort->println(x)
|
||||||
#else
|
#else
|
||||||
#define D(x)
|
#define D(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#ifdef ENDSTOPS
|
#ifdef ENDSTOPS
|
||||||
#include "endstops.h"
|
#include "endstops.h"
|
||||||
#include "../stage/stage.h"
|
#include "../stage/stage.h"
|
||||||
|
#include <ComPort.h>
|
||||||
#ifdef SUPPORT_EEPROM
|
#ifdef SUPPORT_EEPROM
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#else
|
#else
|
||||||
|
|
@ -99,7 +100,7 @@ void endstops_loop()
|
||||||
homing_final = false;
|
homing_final = false;
|
||||||
min_step_delay = previous_step_delay;
|
min_step_delay = previous_step_delay;
|
||||||
home_retreat();
|
home_retreat();
|
||||||
SERIAL_PORT.println("done.");
|
comPort->println("done.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -121,8 +122,8 @@ int8_t endstops_check()
|
||||||
|
|
||||||
if (endstop_break != 0 && stage_moving)
|
if (endstop_break != 0 && stage_moving)
|
||||||
{
|
{
|
||||||
SERIAL_PORT.print(F("Endstop hit:"));
|
comPort->print(F("Endstop hit:"));
|
||||||
SERIAL_PORT.println(endstop_break);
|
comPort->println(endstop_break);
|
||||||
//if we have both min/max endstops, axis_max is adjusted to the correct value
|
//if we have both min/max endstops, axis_max is adjusted to the correct value
|
||||||
//if we only have min, we go from 0 -> predefined axis_max
|
//if we only have min, we go from 0 -> predefined axis_max
|
||||||
//if we only have max, we go from 0 -> predefined axis_max
|
//if we only have max, we go from 0 -> predefined axis_max
|
||||||
|
|
@ -154,16 +155,16 @@ void endstops_status(String command)
|
||||||
EACH_MOTOR
|
EACH_MOTOR
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
SERIAL_PORT.print(" ");
|
comPort->print(" ");
|
||||||
if (endstop_triggered(i, -1))
|
if (endstop_triggered(i, -1))
|
||||||
SERIAL_PORT.print("-1");
|
comPort->print("-1");
|
||||||
else if (endstop_triggered(i, 1))
|
else if (endstop_triggered(i, 1))
|
||||||
SERIAL_PORT.print("1");
|
comPort->print("1");
|
||||||
else
|
else
|
||||||
SERIAL_PORT.print("0");
|
comPort->print("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
SERIAL_PORT.println();
|
comPort->println();
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_axes_max(String command)
|
void print_axes_max(String command)
|
||||||
|
|
@ -171,10 +172,10 @@ void print_axes_max(String command)
|
||||||
EACH_MOTOR
|
EACH_MOTOR
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
SERIAL_PORT.print(" ");
|
comPort->print(" ");
|
||||||
SERIAL_PORT.print(axis_max[i]);
|
comPort->print(axis_max[i]);
|
||||||
}
|
}
|
||||||
SERIAL_PORT.println();
|
comPort->println();
|
||||||
}
|
}
|
||||||
|
|
||||||
void home_start(uint8_t axes, int8_t direction)
|
void home_start(uint8_t axes, int8_t direction)
|
||||||
|
|
@ -226,7 +227,7 @@ void home_final()
|
||||||
void endstops_home_min(String command)
|
void endstops_home_min(String command)
|
||||||
{
|
{
|
||||||
#ifndef ENDSTOPS_MIN
|
#ifndef ENDSTOPS_MIN
|
||||||
SERIAL_PORT.println(F("Min endstops not installed"));
|
comPort->println(F("Min endstops not installed"));
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
if (command.equals("home_min"))
|
if (command.equals("home_min"))
|
||||||
|
|
@ -241,7 +242,7 @@ void endstops_home_min(String command)
|
||||||
void endstops_home_max(String command)
|
void endstops_home_max(String command)
|
||||||
{
|
{
|
||||||
#ifndef ENDSTOPS_MAX
|
#ifndef ENDSTOPS_MAX
|
||||||
SERIAL_PORT.println(F("Max endstops not installed"));
|
comPort->println(F("Max endstops not installed"));
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
if (command.equals("home_max"))
|
if (command.equals("home_max"))
|
||||||
|
|
@ -293,10 +294,10 @@ void endstops_setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
//endstops? - get triggered endstops in (1,0,-1) format for max, none, min"));
|
//endstops? - get triggered endstops in (1,0,-1) format for max, none, min"));
|
||||||
// SERIAL_PORT.println(F("home_min <axes?> - home given (00000zyx byte, e.g. 1 for x) or all axes to their min position"));
|
// comPort->println(F("home_min <axes?> - home given (00000zyx byte, e.g. 1 for x) or all axes to their min position"));
|
||||||
// SERIAL_PORT.println(F("home_max <axes?> - home given (00000zyx byte, e.g. 3 for x and y) or all axes to their max position"));
|
// comPort->println(F("home_max <axes?> - home given (00000zyx byte, e.g. 3 for x and y) or all axes to their max position"));
|
||||||
// SERIAL_PORT.println(F("max_p? - return positions of max endstops"));
|
// comPort->println(F("max_p? - return positions of max endstops"));
|
||||||
// SERIAL_PORT.println(F("max <d> <d> <d>
|
// comPort->println(F("max <d> <d> <d>
|
||||||
extern const Command endstops_commands[] = {
|
extern const Command endstops_commands[] = {
|
||||||
{"endstops?", endstops_status},
|
{"endstops?", endstops_status},
|
||||||
{"home_min", endstops_home_min},
|
{"home_min", endstops_home_min},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#ifdef HELP
|
#ifdef HELP
|
||||||
#include "help.h"
|
#include "help.h"
|
||||||
|
#include <ComPort.h>
|
||||||
|
|
||||||
void help_setup()
|
void help_setup()
|
||||||
{
|
{
|
||||||
|
|
@ -9,78 +10,78 @@ void help_setup()
|
||||||
|
|
||||||
void help(String command)
|
void help(String command)
|
||||||
{
|
{
|
||||||
SERIAL_PORT.println("");
|
comPort->println("");
|
||||||
SERIAL_PORT.print("Board: ");
|
comPort->print("Board: ");
|
||||||
SERIAL_PORT.println(F(BOARD_STRING));
|
comPort->println(F(BOARD_STRING));
|
||||||
|
|
||||||
#ifdef LIGHT_SENSOR
|
#ifdef LIGHT_SENSOR
|
||||||
#if defined ADAFRUIT_TSL2591
|
#if defined ADAFRUIT_TSL2591
|
||||||
SERIAL_PORT.println(F("Compiled with Adafruit TSL2591 support"));
|
comPort->println(F("Compiled with Adafruit TSL2591 support"));
|
||||||
#elif defined ADAFRUIT_ADS1115
|
#elif defined ADAFRUIT_ADS1115
|
||||||
SERIAL_PORT.println(F("Compiled with Adafruit ADS1115 support"));
|
comPort->println(F("Compiled with Adafruit ADS1115 support"));
|
||||||
#endif
|
#endif
|
||||||
#endif //LIGHT_SENSOR
|
#endif //LIGHT_SENSOR
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENDSTOPS
|
#ifdef ENDSTOPS
|
||||||
#ifdef ENDSTOPS_MIN
|
#ifdef ENDSTOPS_MIN
|
||||||
SERIAL_PORT.println(F("Compiled with min endstops support"));
|
comPort->println(F("Compiled with min endstops support"));
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENDSTOPS_MAX
|
#ifdef ENDSTOPS_MAX
|
||||||
SERIAL_PORT.println(F("Compiled with max endstops support"));
|
comPort->println(F("Compiled with max endstops support"));
|
||||||
#endif
|
#endif
|
||||||
#endif //ENDSTOPS
|
#endif //ENDSTOPS
|
||||||
|
|
||||||
|
|
||||||
SERIAL_PORT.println("");
|
comPort->println("");
|
||||||
SERIAL_PORT.println(F("Commands (terminated by a newline character):"));
|
comPort->println(F("Commands (terminated by a newline character):"));
|
||||||
#ifdef STAGE
|
#ifdef STAGE
|
||||||
SERIAL_PORT.println(F("mrx <d> - relative move in x"));
|
comPort->println(F("mrx <d> - relative move in x"));
|
||||||
SERIAL_PORT.println(F("mry <d> - relative move in y"));
|
comPort->println(F("mry <d> - relative move in y"));
|
||||||
SERIAL_PORT.println(F("mrz <d> - relative move in z"));
|
comPort->println(F("mrz <d> - relative move in z"));
|
||||||
SERIAL_PORT.println(F("mr <d> <d> <d> - relative move in all 3 axes"));
|
comPort->println(F("mr <d> <d> <d> - relative move in all 3 axes"));
|
||||||
SERIAL_PORT.println(F("release - de-energise all motors"));
|
comPort->println(F("release - de-energise all motors"));
|
||||||
SERIAL_PORT.println(F("p? - print position (3 space-separated integers"));
|
comPort->println(F("p? - print position (3 space-separated integers"));
|
||||||
SERIAL_PORT.println(F("ramp_time <d> - set the time taken to accelerate/decelerate in us"));
|
comPort->println(F("ramp_time <d> - set the time taken to accelerate/decelerate in us"));
|
||||||
SERIAL_PORT.println(F("min_step_delay <d> - set the minimum time between steps in us."));
|
comPort->println(F("min_step_delay <d> - set the minimum time between steps in us."));
|
||||||
SERIAL_PORT.println(F("dt <d> - set the minimum time between steps in us."));
|
comPort->println(F("dt <d> - set the minimum time between steps in us."));
|
||||||
SERIAL_PORT.println(F("ramp_time? - get the time taken to accelerate/decelerate in us"));
|
comPort->println(F("ramp_time? - get the time taken to accelerate/decelerate in us"));
|
||||||
SERIAL_PORT.println(F("min_step_delay? - get the minimum time between steps in us."));
|
comPort->println(F("min_step_delay? - get the minimum time between steps in us."));
|
||||||
SERIAL_PORT.println(F("zero - set the current position to zero."));
|
comPort->println(F("zero - set the current position to zero."));
|
||||||
SERIAL_PORT.println(F("stop - stop a move in progress."));
|
comPort->println(F("stop - stop a move in progress."));
|
||||||
SERIAL_PORT.println(F("blocking_moves? - get blocking moves enabled"));
|
comPort->println(F("blocking_moves? - get blocking moves enabled"));
|
||||||
SERIAL_PORT.println(F("blocking_moves <bool> - enable/disable blocking moves"));
|
comPort->println(F("blocking_moves <bool> - enable/disable blocking moves"));
|
||||||
SERIAL_PORT.println(F("moving? - check if a move is in progress"));
|
comPort->println(F("moving? - check if a move is in progress"));
|
||||||
SERIAL_PORT.println(F("notify_on_stop - respond with stopped when current move finishes"));
|
comPort->println(F("notify_on_stop - respond with stopped when current move finishes"));
|
||||||
#endif //STAGE
|
#endif //STAGE
|
||||||
|
|
||||||
#ifdef LIGHT_SENSOR
|
#ifdef LIGHT_SENSOR
|
||||||
SERIAL_PORT.println(F("light_sensor_gain <d> - set the gain of the light sensor"));
|
comPort->println(F("light_sensor_gain <d> - set the gain of the light sensor"));
|
||||||
SERIAL_PORT.println(F("light_sensor_gain? - get the gain of the light sensor"));
|
comPort->println(F("light_sensor_gain? - get the gain of the light sensor"));
|
||||||
SERIAL_PORT.println(F("light_sensor_gain_values? - get the allowable gain values of the light sensor"));
|
comPort->println(F("light_sensor_gain_values? - get the allowable gain values of the light sensor"));
|
||||||
SERIAL_PORT.println(F("light_sensor_integration_time? - get the integration time in milliseconds"));
|
comPort->println(F("light_sensor_integration_time? - get the integration time in milliseconds"));
|
||||||
SERIAL_PORT.println(F("light_sensor_intensity? - read the current value from the full spectrum diode"));
|
comPort->println(F("light_sensor_intensity? - read the current value from the full spectrum diode"));
|
||||||
#endif //LIGHT_SENSOR
|
#endif //LIGHT_SENSOR
|
||||||
|
|
||||||
#if defined(ENDSTOPS_MIN) || defined(ENDSTOPS_MAX)
|
#if defined(ENDSTOPS_MIN) || defined(ENDSTOPS_MAX)
|
||||||
SERIAL_PORT.println(F("endstops? - get triggered endstops in (1,0,-1) format for max, none, min"));
|
comPort->println(F("endstops? - get triggered endstops in (1,0,-1) format for max, none, min"));
|
||||||
SERIAL_PORT.println(F("home_min <axes?> - home given (00000zyx byte, e.g. 1 for x) or all axes to their min position"));
|
comPort->println(F("home_min <axes?> - home given (00000zyx byte, e.g. 1 for x) or all axes to their min position"));
|
||||||
SERIAL_PORT.println(F("home_max <axes?> - home given (00000zyx byte, e.g. 3 for x and y) or all axes to their max position"));
|
comPort->println(F("home_max <axes?> - home given (00000zyx byte, e.g. 3 for x and y) or all axes to their max position"));
|
||||||
SERIAL_PORT.println(F("max_p? - return positions of max endstops"));
|
comPort->println(F("max_p? - return positions of max endstops"));
|
||||||
SERIAL_PORT.println(F("max <d> <d> <d> - set maximum positions"));
|
comPort->println(F("max <d> <d> <d> - set maximum positions"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STEPSTICK
|
#ifdef STEPSTICK
|
||||||
SERIAL_PORT.println(F("stepstick_move <f> <d> - move stepper by <d> with max speed <f>"));
|
comPort->println(F("stepstick_move <f> <d> - move stepper by <d> with max speed <f>"));
|
||||||
SERIAL_PORT.println(F("stepstick_release - release stepstick stepper"));
|
comPort->println(F("stepstick_release - release stepstick stepper"));
|
||||||
SERIAL_PORT.println(F("stepstick_stop - abort stepstick move"));
|
comPort->println(F("stepstick_stop - abort stepstick move"));
|
||||||
#endif
|
#endif
|
||||||
//SERIAL_PORT.println(F("test_mode <s> - set test_mode <on> <off>"));
|
//comPort->println(F("test_mode <s> - set test_mode <on> <off>"));
|
||||||
SERIAL_PORT.println(F("version - get firmware version string"));
|
comPort->println(F("version - get firmware version string"));
|
||||||
SERIAL_PORT.println("");
|
comPort->println("");
|
||||||
SERIAL_PORT.println("Input Key:");
|
comPort->println("Input Key:");
|
||||||
SERIAL_PORT.println(F("<d> - a decimal integer."));
|
comPort->println(F("<d> - a decimal integer."));
|
||||||
SERIAL_PORT.println("");
|
comPort->println("");
|
||||||
SERIAL_PORT.println("--END--");
|
comPort->println("--END--");
|
||||||
}
|
}
|
||||||
#endif //HELP
|
#endif //HELP
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#ifdef ILLUMINATION
|
#ifdef ILLUMINATION
|
||||||
#include "illumination.h"
|
#include "illumination.h"
|
||||||
|
#include <ComPort.h>
|
||||||
#ifdef SUPPORT_EEPROM
|
#ifdef SUPPORT_EEPROM
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#else
|
#else
|
||||||
|
|
@ -16,11 +17,11 @@ void illumination_pwm_freq(String command)
|
||||||
analogWriteFreq(atol(args[0]));//32khz seems sensible
|
analogWriteFreq(atol(args[0]));//32khz seems sensible
|
||||||
analogWriteRange(65535);
|
analogWriteRange(65535);
|
||||||
|
|
||||||
SERIAL_PORT.print("Frequency set: ");
|
comPort->print("Frequency set: ");
|
||||||
SERIAL_PORT.print(atol(args[0]));
|
comPort->print(atol(args[0]));
|
||||||
SERIAL_PORT.println("Hz");
|
comPort->println("Hz");
|
||||||
#else
|
#else
|
||||||
SERIAL_PORT.println("Feature not supported");
|
comPort->println("Feature not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
free(args[0]);
|
free(args[0]);
|
||||||
|
|
@ -35,7 +36,7 @@ void illumination_pwm(String command)
|
||||||
uint8_t index = atoi(args[0]);
|
uint8_t index = atoi(args[0]);
|
||||||
if (index >= PWM_NUM)
|
if (index >= PWM_NUM)
|
||||||
{
|
{
|
||||||
Serial.println("Invalid index");
|
comPort->println("Invalid index");
|
||||||
}
|
}
|
||||||
float val = atof(args[1]);
|
float val = atof(args[1]);
|
||||||
|
|
||||||
|
|
@ -50,8 +51,8 @@ void illumination_pwm(String command)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
analogWrite(pwm_led_pins[index], pwm_val);
|
analogWrite(pwm_led_pins[index], pwm_val);
|
||||||
SERIAL_PORT.print("Illumination set");
|
comPort->print("Illumination set");
|
||||||
SERIAL_PORT.println(pwm_val);
|
comPort->println(pwm_val);
|
||||||
|
|
||||||
free(args[0]);
|
free(args[0]);
|
||||||
free(args[1]);
|
free(args[1]);
|
||||||
|
|
@ -117,10 +118,10 @@ void cc_set(String command)
|
||||||
delayMicroseconds(stepd);
|
delayMicroseconds(stepd);
|
||||||
digitalWrite(WIRING_CC_LED, HIGH);
|
digitalWrite(WIRING_CC_LED, HIGH);
|
||||||
delayMicroseconds(td);
|
delayMicroseconds(td);
|
||||||
Serial.println("Stepping CC"); //TODO remove debug print
|
comPort->println("Stepping CC"); //TODO remove debug print
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
SERIAL_PORT.println("CC LED not supported");
|
comPort->println("CC LED not supported");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <ComPort.h>
|
||||||
#ifdef LIGHT_SENSOR
|
#ifdef LIGHT_SENSOR
|
||||||
#include "light_sensor.h"
|
#include "light_sensor.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
@ -54,35 +55,35 @@ void setup_light_sensor_device()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SERIAL_PORT.println(F("No light sensor found. NB your board will start up faster if you recompile without light sensor support."));
|
comPort->println(F("No light sensor found. NB your board will start up faster if you recompile without light sensor support."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_light_sensor_gain()
|
void print_light_sensor_gain()
|
||||||
{
|
{
|
||||||
// Print the current gain value of the light sensor
|
// Print the current gain value of the light sensor
|
||||||
SERIAL_PORT.print(F("light sensor gain "));
|
comPort->print(F("light sensor gain "));
|
||||||
tsl2591Gain_t gain = tsl.getGain();
|
tsl2591Gain_t gain = tsl.getGain();
|
||||||
switch (gain)
|
switch (gain)
|
||||||
{
|
{
|
||||||
case TSL2591_GAIN_LOW:
|
case TSL2591_GAIN_LOW:
|
||||||
SERIAL_PORT.println(F("1x (Low)"));
|
comPort->println(F("1x (Low)"));
|
||||||
break;
|
break;
|
||||||
case TSL2591_GAIN_MED:
|
case TSL2591_GAIN_MED:
|
||||||
SERIAL_PORT.println(F("25x (Medium)"));
|
comPort->println(F("25x (Medium)"));
|
||||||
break;
|
break;
|
||||||
case TSL2591_GAIN_HIGH:
|
case TSL2591_GAIN_HIGH:
|
||||||
SERIAL_PORT.println(F("428x (High)"));
|
comPort->println(F("428x (High)"));
|
||||||
break;
|
break;
|
||||||
case TSL2591_GAIN_MAX:
|
case TSL2591_GAIN_MAX:
|
||||||
SERIAL_PORT.println(F("9876x (Max)"));
|
comPort->println(F("9876x (Max)"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void light_sensor_gain_values(String command)
|
void light_sensor_gain_values(String command)
|
||||||
{
|
{
|
||||||
// Print the allowable gain values of the light sensor
|
// Print the allowable gain values of the light sensor
|
||||||
SERIAL_PORT.println(F("light sensor gains: 1x, 25x, 428x, 9876x"));
|
comPort->println(F("light sensor gains: 1x, 25x, 428x, 9876x"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_light_sensor_gain(int newgain)
|
void set_light_sensor_gain(int newgain)
|
||||||
|
|
@ -103,7 +104,7 @@ void set_light_sensor_gain(int newgain)
|
||||||
tsl.setGain(TSL2591_GAIN_MAX);
|
tsl.setGain(TSL2591_GAIN_MAX);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SERIAL_PORT.println(F("Error: gain may only be 1, 25, 428, or 9876."));
|
comPort->println(F("Error: gain may only be 1, 25, 428, or 9876."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print_light_sensor_gain();
|
print_light_sensor_gain();
|
||||||
|
|
@ -112,16 +113,16 @@ void set_light_sensor_gain(int newgain)
|
||||||
void light_sensor_integration_time(String command)
|
void light_sensor_integration_time(String command)
|
||||||
{
|
{
|
||||||
// Print the current integration time in milliseconds.
|
// Print the current integration time in milliseconds.
|
||||||
SERIAL_PORT.print(F("light sensor integration time "));
|
comPort->print(F("light sensor integration time "));
|
||||||
SERIAL_PORT.print((tsl.getTiming() + 1) * 100, DEC);
|
comPort->print((tsl.getTiming() + 1) * 100, DEC);
|
||||||
SERIAL_PORT.println(F(" ms"));
|
comPort->println(F(" ms"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void light_sensor_intensity(String command)
|
void light_sensor_intensity(String command)
|
||||||
{
|
{
|
||||||
// Print the current light value
|
// Print the current light value
|
||||||
uint16_t x = tsl.getLuminosity(TSL2591_FULLSPECTRUM);
|
uint16_t x = tsl.getLuminosity(TSL2591_FULLSPECTRUM);
|
||||||
SERIAL_PORT.println(x, DEC);
|
comPort->println(x, DEC);
|
||||||
}
|
}
|
||||||
#endif // ADAFRUIT_TSL2591
|
#endif // ADAFRUIT_TSL2591
|
||||||
|
|
||||||
|
|
@ -137,34 +138,34 @@ void setup_light_sensor_device()
|
||||||
void print_light_sensor_gain()
|
void print_light_sensor_gain()
|
||||||
{
|
{
|
||||||
// Print the current gain value of the light sensor
|
// Print the current gain value of the light sensor
|
||||||
SERIAL_PORT.print(F("light sensor gain "));
|
comPort->print(F("light sensor gain "));
|
||||||
adsGain_t gain = ads.getGain();
|
adsGain_t gain = ads.getGain();
|
||||||
switch (gain)
|
switch (gain)
|
||||||
{
|
{
|
||||||
case GAIN_TWOTHIRDS:
|
case GAIN_TWOTHIRDS:
|
||||||
SERIAL_PORT.println(F("0.66x (specify 0)"));
|
comPort->println(F("0.66x (specify 0)"));
|
||||||
break;
|
break;
|
||||||
case GAIN_ONE:
|
case GAIN_ONE:
|
||||||
SERIAL_PORT.println(F("1x"));
|
comPort->println(F("1x"));
|
||||||
break;
|
break;
|
||||||
case GAIN_TWO:
|
case GAIN_TWO:
|
||||||
SERIAL_PORT.println(F("2x"));
|
comPort->println(F("2x"));
|
||||||
break;
|
break;
|
||||||
case GAIN_FOUR:
|
case GAIN_FOUR:
|
||||||
SERIAL_PORT.println(F("4x"));
|
comPort->println(F("4x"));
|
||||||
break;
|
break;
|
||||||
case GAIN_EIGHT:
|
case GAIN_EIGHT:
|
||||||
SERIAL_PORT.println(F("8x"));
|
comPort->println(F("8x"));
|
||||||
break;
|
break;
|
||||||
case GAIN_SIXTEEN:
|
case GAIN_SIXTEEN:
|
||||||
SERIAL_PORT.println(F("16x"));
|
comPort->println(F("16x"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void light_sensor_gain_values(String command)
|
void light_sensor_gain_values(String command)
|
||||||
{
|
{
|
||||||
// Print the allowable gain values of the light sensor
|
// Print the allowable gain values of the light sensor
|
||||||
SERIAL_PORT.println(F("light sensor gains: 0.66x (specify 0), 1x, 2x, 4x, 8x, 16x"));
|
comPort->println(F("light sensor gains: 0.66x (specify 0), 1x, 2x, 4x, 8x, 16x"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_light_sensor_gain(int newgain)
|
void set_light_sensor_gain(int newgain)
|
||||||
|
|
@ -191,7 +192,7 @@ void set_light_sensor_gain(int newgain)
|
||||||
ads.setGain(GAIN_SIXTEEN);
|
ads.setGain(GAIN_SIXTEEN);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SERIAL_PORT.println(F("Error: gain may only be 0, 1, 2, 4, 8, 16 (0 means 2/3)."));
|
comPort->println(F("Error: gain may only be 0, 1, 2, 4, 8, 16 (0 means 2/3)."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print_light_sensor_gain();
|
print_light_sensor_gain();
|
||||||
|
|
@ -200,7 +201,7 @@ void set_light_sensor_gain(int newgain)
|
||||||
void light_sensor_integration_time(String command)
|
void light_sensor_integration_time(String command)
|
||||||
{
|
{
|
||||||
// Print the current integration time in milliseconds.
|
// Print the current integration time in milliseconds.
|
||||||
SERIAL_PORT.println(F("integration time not supported for ADS1115"));
|
comPort->println(F("integration time not supported for ADS1115"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void light_sensor_intensity(String command)
|
void light_sensor_intensity(String command)
|
||||||
|
|
@ -215,7 +216,7 @@ void light_sensor_intensity(String command)
|
||||||
uint16_t x = ads.readADC_SingleEnded(ch); //single ended measurement on pin ch (0-3)
|
uint16_t x = ads.readADC_SingleEnded(ch); //single ended measurement on pin ch (0-3)
|
||||||
//uint16_t x = ads.readADC_Differential_0_1(); //differential measurement on pins 0,1
|
//uint16_t x = ads.readADC_Differential_0_1(); //differential measurement on pins 0,1
|
||||||
|
|
||||||
SERIAL_PORT.println(x, DEC);
|
comPort->println(x, DEC);
|
||||||
}
|
}
|
||||||
#endif // ADAFRUIT_ADS1115
|
#endif // ADAFRUIT_ADS1115
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include "dummyEEPROM.h"
|
#include "dummyEEPROM.h"
|
||||||
#endif
|
#endif
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include <ComPort.h>
|
||||||
|
|
||||||
// The array below has 3 stepper objects, for X,Y,Z respectively
|
// The array below has 3 stepper objects, for X,Y,Z respectively
|
||||||
const uint8_t n_motors = STAGE_N_MOTORS;
|
const uint8_t n_motors = STAGE_N_MOTORS;
|
||||||
|
|
@ -76,10 +77,10 @@ void print_position()
|
||||||
EACH_MOTOR
|
EACH_MOTOR
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
SERIAL_PORT.print(" ");
|
comPort->print(" ");
|
||||||
SERIAL_PORT.print(current_pos[i]);
|
comPort->print(current_pos[i]);
|
||||||
}
|
}
|
||||||
SERIAL_PORT.println();
|
comPort->println();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long move_start_time = 0;
|
unsigned long move_start_time = 0;
|
||||||
|
|
@ -124,7 +125,7 @@ void start_move(long displ[n_motors])
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SERIAL_PORT.println("done.");
|
comPort->println("done.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,7 +184,7 @@ void stage_loop()
|
||||||
|
|
||||||
if (!stage_moving && notify_on_stop)
|
if (!stage_moving && notify_on_stop)
|
||||||
{
|
{
|
||||||
SERIAL_PORT.println("stopped");
|
comPort->println("stopped");
|
||||||
notify_on_stop = false;
|
notify_on_stop = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +234,7 @@ void stage_release(String command)
|
||||||
{
|
{
|
||||||
releaseMotor(i);
|
releaseMotor(i);
|
||||||
}
|
}
|
||||||
SERIAL_PORT.println("done");
|
comPort->println("done");
|
||||||
}
|
}
|
||||||
|
|
||||||
void stage_p(String command)
|
void stage_p(String command)
|
||||||
|
|
@ -247,14 +248,14 @@ void stage_min_step_delay(String command)
|
||||||
parse_arguments(args, command, 1);
|
parse_arguments(args, command, 1);
|
||||||
if (args[0][0] == '?')
|
if (args[0][0] == '?')
|
||||||
{
|
{
|
||||||
SERIAL_PORT.print("minimum step delay ");
|
comPort->print("minimum step delay ");
|
||||||
SERIAL_PORT.println(min_step_delay);
|
comPort->println(min_step_delay);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
min_step_delay = atol(args[0]);
|
min_step_delay = atol(args[0]);
|
||||||
EEPROM.put(min_step_delay_eeprom, min_step_delay);
|
EEPROM.put(min_step_delay_eeprom, min_step_delay);
|
||||||
SERIAL_PORT.println("done.");
|
comPort->println("done.");
|
||||||
}
|
}
|
||||||
free(args[0]);
|
free(args[0]);
|
||||||
}
|
}
|
||||||
|
|
@ -265,14 +266,14 @@ void stage_ramp_time(String command)
|
||||||
parse_arguments(args, command, 1);
|
parse_arguments(args, command, 1);
|
||||||
if (args[0][0] == '?')
|
if (args[0][0] == '?')
|
||||||
{
|
{
|
||||||
SERIAL_PORT.print("ramp_time ");
|
comPort->print("ramp_time ");
|
||||||
SERIAL_PORT.println(ramp_time);
|
comPort->println(ramp_time);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ramp_time = atol(args[0]);
|
ramp_time = atol(args[0]);
|
||||||
EEPROM.put(ramp_time_eeprom, ramp_time);
|
EEPROM.put(ramp_time_eeprom, ramp_time);
|
||||||
SERIAL_PORT.println("done.");
|
comPort->println("done.");
|
||||||
}
|
}
|
||||||
free(args[0]);
|
free(args[0]);
|
||||||
}
|
}
|
||||||
|
|
@ -283,41 +284,41 @@ void update_blocking_moves(String command)
|
||||||
parse_arguments(args, command, 1);
|
parse_arguments(args, command, 1);
|
||||||
if (args[0][0] == '?')
|
if (args[0][0] == '?')
|
||||||
{
|
{
|
||||||
SERIAL_PORT.print("blocking_moves ");
|
comPort->print("blocking_moves ");
|
||||||
SERIAL_PORT.println(non_blocking_moves ? "false" : "true");
|
comPort->println(non_blocking_moves ? "false" : "true");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
non_blocking_moves = !(args[0][0] == 't');
|
non_blocking_moves = !(args[0][0] == 't');
|
||||||
EEPROM.put(non_blocking_moves_eeprom, non_blocking_moves);
|
EEPROM.put(non_blocking_moves_eeprom, non_blocking_moves);
|
||||||
SERIAL_PORT.println("done.");
|
comPort->println("done.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void stage_zero(String command)
|
void stage_zero(String command)
|
||||||
{
|
{
|
||||||
EACH_MOTOR current_pos[i] = 0;
|
EACH_MOTOR current_pos[i] = 0;
|
||||||
SERIAL_PORT.println(F("position reset to 0 0 0"));
|
comPort->println(F("position reset to 0 0 0"));
|
||||||
EEPROM.put(0, current_pos);
|
EEPROM.put(0, current_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stage_stop(String command)
|
void stage_stop(String command)
|
||||||
{
|
{
|
||||||
stage_moving = false;
|
stage_moving = false;
|
||||||
SERIAL_PORT.println("Move aborted");
|
comPort->println("Move aborted");
|
||||||
}
|
}
|
||||||
|
|
||||||
void is_stage_moving(String command)
|
void is_stage_moving(String command)
|
||||||
{
|
{
|
||||||
//TODO: should I bother checking for a ?
|
//TODO: should I bother checking for a ?
|
||||||
SERIAL_PORT.println(stage_moving ? "true" : "false");
|
comPort->println(stage_moving ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
void activate_notify_on_stop(String command)
|
void activate_notify_on_stop(String command)
|
||||||
{
|
{
|
||||||
if (!stage_moving)
|
if (!stage_moving)
|
||||||
{
|
{
|
||||||
SERIAL_PORT.println("Error: stage is not moving");
|
comPort->println("Error: stage is not moving");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#ifdef STEPSTICK
|
#ifdef STEPSTICK
|
||||||
#include "stepstick.h"
|
#include "stepstick.h"
|
||||||
|
#include <ComPort.h>
|
||||||
#ifdef SUPPORT_EEPROM
|
#ifdef SUPPORT_EEPROM
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#else
|
#else
|
||||||
|
|
@ -16,13 +17,13 @@ bool moving = false;
|
||||||
void stepstick_release(String command)
|
void stepstick_release(String command)
|
||||||
{
|
{
|
||||||
digitalWrite(stepstick_pins[0], HIGH);//start with motor disabled
|
digitalWrite(stepstick_pins[0], HIGH);//start with motor disabled
|
||||||
SERIAL_PORT.println("Stepstick released");
|
comPort->println("Stepstick released");
|
||||||
}
|
}
|
||||||
|
|
||||||
void stepstick_stop(String command)
|
void stepstick_stop(String command)
|
||||||
{
|
{
|
||||||
stepper.stop();
|
stepper.stop();
|
||||||
SERIAL_PORT.println("Stepstick stopping");
|
comPort->println("Stepstick stopping");
|
||||||
}
|
}
|
||||||
|
|
||||||
void stepstick_move(String command)
|
void stepstick_move(String command)
|
||||||
|
|
@ -37,7 +38,7 @@ void stepstick_move(String command)
|
||||||
stepper.moveTo(stepper.currentPosition() + distance);
|
stepper.moveTo(stepper.currentPosition() + distance);
|
||||||
free(args[0]);
|
free(args[0]);
|
||||||
free(args[1]);
|
free(args[1]);
|
||||||
SERIAL_PORT.println("Stepstick started");
|
comPort->println("Stepstick started");
|
||||||
moving = true;
|
moving = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +56,7 @@ void stepstick_loop()
|
||||||
if (stepper.distanceToGo() == 0 && moving)
|
if (stepper.distanceToGo() == 0 && moving)
|
||||||
{
|
{
|
||||||
moving = false;
|
moving = false;
|
||||||
SERIAL_PORT.println("Stepstick stopped");
|
comPort->println("Stepstick stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,9 @@ void test_multiple_argument_parsing(void)
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
Serial.begin(115200);
|
comPort->begin(115200);
|
||||||
// NOTE!!! Wait for >2 secs
|
// NOTE!!! Wait for >2 secs
|
||||||
// if board doesn't support software reset via Serial.DTR/RTS
|
// if board doesn't support software reset via comPort->DTR/RTS
|
||||||
delay(2000);
|
delay(2000);
|
||||||
UNITY_BEGIN(); // IMPORTANT LINE!
|
UNITY_BEGIN(); // IMPORTANT LINE!
|
||||||
//bizzare string issues caused this to fail in specific sequences, so we run it multiple times
|
//bizzare string issues caused this to fail in specific sequences, so we run it multiple times
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue