From 7b659607998de01d500eb55dd25ab4cba83c84e5 Mon Sep 17 00:00:00 2001 From: isaac879 Date: Thu, 30 Apr 2020 06:05:40 +0100 Subject: [PATCH] Add files via upload --- pan_tilt_mount_nano_code/panTiltMount.cpp | 15 +++++++++++++++ pan_tilt_mount_nano_code/panTiltMount.h | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pan_tilt_mount_nano_code/panTiltMount.cpp b/pan_tilt_mount_nano_code/panTiltMount.cpp index 83ce4d6..07bf04e 100644 --- a/pan_tilt_mount_nano_code/panTiltMount.cpp +++ b/pan_tilt_mount_nano_code/panTiltMount.cpp @@ -886,6 +886,21 @@ void timelapse(unsigned int numberOfPictures, unsigned long msDelay){ void serialData(void){ char instruction = Serial.read(); + if(instruction == INSTRUCTION_BYTES_PAN_SPEED){ + int count = 0; + while(Serial.available() < 2){//Wait for six bytes to be available. Breaks after ~200ms if bytes are not received. + delayMicroseconds(200); + count++; + if(count > 1000){ + serialFlush();//Clear the serial buffer + break; + } + } + int panStepSpeed = (Serial.read() << 8) + Serial.read(); + stepper_pan.setSpeed(panStepSpeed); + stepper_pan.runSpeed(); + } + delay(2); //wait to make sure all data in the serial message has arived ledBatteryLevel(getBatteryPercentage()); memset(&stringText[0], 0, sizeof(stringText)); //clear the array diff --git a/pan_tilt_mount_nano_code/panTiltMount.h b/pan_tilt_mount_nano_code/panTiltMount.h index 1e8be18..a2c5908 100644 --- a/pan_tilt_mount_nano_code/panTiltMount.h +++ b/pan_tilt_mount_nano_code/panTiltMount.h @@ -50,6 +50,7 @@ #define SHUTTER_DELAY 200 +#define INSTRUCTION_BYTES_PAN_SPEED 1 #define INSTRUCTION_STEP_MODE 'm' #define INSTRUCTION_PAN_STEPS 'P' #define INSTRUCTION_TILT_STEPS 'T' @@ -132,7 +133,7 @@ #define NUM_LEDS 1 #define BRIGHTNESS 255 -#define VERSION_NUMBER "2.1.1" +#define VERSION_NUMBER "2.2.1" /*------------------------------------------------------------------------------------------------------------------------------------------------------*/