Script has been re-written but does NOT have behaviors for handling unexpected states.
This commit is contained in:
parent
1f8fb60fc1
commit
3d8a23fd2f
|
|
@ -91,9 +91,7 @@ void Intval2::Exposure (unsigned long ms) {
|
|||
if (ms < 600) {
|
||||
timed_exposure_ms = 0;
|
||||
timed_exposure = false;
|
||||
//timed_open = OpenTiming();
|
||||
} else {
|
||||
//timed_delay = timed_exposure_val - BOLEX_C;
|
||||
timed_exposure_ms = ms;
|
||||
timed_exposure = true;
|
||||
}
|
||||
|
|
@ -106,12 +104,11 @@ void Intval2::Camera () {
|
|||
timed_exposure_opening = true;
|
||||
open_start = millis();
|
||||
if (direction) {
|
||||
open_stop = round((float) avg * MOTOR_OPEN_FORWARD);
|
||||
timed_exposure_delay = 0;
|
||||
open_stop = round( (float) avg * MOTOR_OPEN_FORWARD );
|
||||
} else {
|
||||
open_stop = round((float) avg * MOTOR_OPEN_BACKWARD);
|
||||
timed_exposure_delay = 0;//
|
||||
}
|
||||
timed_exposure_delay = timed_exposure_ms - round( (float) avg * MOTOR_OPEN_ANGLE );
|
||||
}
|
||||
MotorStart();
|
||||
running = true;
|
||||
|
|
@ -230,6 +227,8 @@ void Intval2::TimedExposurePause () {
|
|||
open_avg = round(((timer - open_start) + open_avg) / 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Intval2::TimedExposureWatch () {
|
||||
if (timed_exposure_opening) {
|
||||
if (timer - frame_start >= open_stop) {
|
||||
|
|
@ -327,4 +326,16 @@ String Intval2::State () {
|
|||
return String(timed_exposure_avg);
|
||||
}
|
||||
return String(avg);
|
||||
}
|
||||
}
|
||||
|
||||
boolean Intval2::IsOpening() {
|
||||
return opening;
|
||||
}
|
||||
|
||||
boolean Intval2::IsClosing() {
|
||||
return closing;
|
||||
}
|
||||
|
||||
boolean Intval2::IsRunning() {
|
||||
return running;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class Intval2 {
|
|||
const uint16_t MOTOR_RPM = 120;
|
||||
const float MOTOR_OPEN_FORWARD = 0.25;
|
||||
const float MOTOR_OPEN_BACKWARD = 0.75;
|
||||
const float MOTOR_OPEN_ANGLE = 0.3694; // 133deg
|
||||
const uint8_t MOTOR_PWM = 255; // Not varying this for now
|
||||
const uint16_t MICROSWITCH_DELAY = 50;
|
||||
|
||||
|
|
@ -97,6 +98,10 @@ class Intval2 {
|
|||
void Direction(boolean state);
|
||||
void Exposure(unsigned long ms);
|
||||
String State();
|
||||
boolean IsOpening();
|
||||
boolean IsClosing();
|
||||
boolean IsRunning();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,12 +22,30 @@ void loop () {
|
|||
cmd(cmd_char);
|
||||
|
||||
intval2.loop();
|
||||
|
||||
if (camera_running && !intval2.IsRunning()) {
|
||||
mc.confirm(mc.CAMERA);
|
||||
mc.log("Camera completed");
|
||||
//mc.log(String(timed_exposure_last));
|
||||
camera_running = false;
|
||||
}
|
||||
|
||||
if (open_running && !intval2.IsOpening()) {
|
||||
|
||||
open_running = false;
|
||||
}
|
||||
|
||||
if (close_running && !intval2.IsClosing()) {
|
||||
|
||||
close_running = false;
|
||||
}
|
||||
}
|
||||
|
||||
void cmd (char val) {
|
||||
if (val == mc.CAMERA) {
|
||||
camera_running = true;
|
||||
intval2.Camera();
|
||||
camera_running = true;
|
||||
} else if (val == mc.CAMERA_FORWARD) {
|
||||
SetDirection(true);
|
||||
} else if (val == mc.CAMERA_BACKWARD) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue