Work on bulb feature. Currently works but is not reflected in the statistics reported by H/state
This commit is contained in:
parent
ebf4c1d719
commit
dac2c98d24
|
|
@ -20,10 +20,10 @@ void Intval2::begin () {
|
|||
void Intval2::loop () {
|
||||
timer = millis();
|
||||
|
||||
Button(0);
|
||||
Button(1);
|
||||
Button(2);
|
||||
Button(3);
|
||||
Button(TRIGGER);
|
||||
Button(DIRECTION);
|
||||
Button(SPEED);
|
||||
Button(DELAY);
|
||||
|
||||
if (timelapse && delaying) {
|
||||
TimelapseWatchDelay();
|
||||
|
|
@ -97,12 +97,13 @@ void Intval2::Direction (boolean state) {
|
|||
}
|
||||
|
||||
void Intval2::Exposure (unsigned long ms) {
|
||||
if (ms < 600) {
|
||||
if (ms < TIMED_EXPOSURE_CUTOFF) {
|
||||
timed_exposure_ms = 0;
|
||||
timed_exposure = false;
|
||||
} else {
|
||||
timed_exposure_ms = ms;
|
||||
timed_exposure_ms = ms + 379;
|
||||
timed_exposure = true;
|
||||
timed_exposure_avg = ms + 379;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -256,6 +257,7 @@ void Intval2::Button (uint8_t index) {
|
|||
if (val == LOW) {
|
||||
// pressed
|
||||
button_times[index] = millis();
|
||||
ButtonStart(index);
|
||||
} else if (val == HIGH) {
|
||||
// not pressed
|
||||
button_time = millis() - button_times[index]; //time?
|
||||
|
|
@ -265,23 +267,46 @@ void Intval2::Button (uint8_t index) {
|
|||
button_states[index] = val;
|
||||
}
|
||||
|
||||
void Intval2::ButtonStart (uint8_t index) {
|
||||
if (index == TRIGGER) {
|
||||
if (bulb && !bulb_running) {
|
||||
bulb_running = true;
|
||||
Open();
|
||||
}
|
||||
} else if (index == SPEED) {
|
||||
if (millis() - button_times[index] < 1000) {
|
||||
bulb = true;
|
||||
Output(OUTPUT_ONE, OUTPUT_LONG);
|
||||
} else {
|
||||
bulb = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Intval2::ButtonEnd (uint8_t index, long time) {
|
||||
if (index == 0) {
|
||||
if (index == TRIGGER) {
|
||||
if (time > 1000) {
|
||||
if (!timelapse && !running) {
|
||||
if (!bulb && !timelapse && !running) {
|
||||
timelapse = true;
|
||||
Output(OUTPUT_TWO, OUTPUT_SHORT);
|
||||
Camera();
|
||||
} else if (bulb && bulb_running) {
|
||||
Close();
|
||||
bulb_running = false;
|
||||
}
|
||||
} else {
|
||||
if (timelapse) {
|
||||
timelapse = false;
|
||||
//Output(2, 75);
|
||||
} else {
|
||||
Camera();
|
||||
if (bulb) {
|
||||
Close();
|
||||
} else {
|
||||
Camera();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (index == 1) { //set delay
|
||||
} else if (index == DELAY) { //set delay
|
||||
if (time < 42) {
|
||||
timelapse_delay = 42;
|
||||
Output(OUTPUT_ONE, OUTPUT_LONG);
|
||||
|
|
@ -289,17 +314,14 @@ void Intval2::ButtonEnd (uint8_t index, long time) {
|
|||
timelapse_delay = time;
|
||||
Output(OUTPUT_TWO, OUTPUT_MEDIUM);
|
||||
}
|
||||
} else if (index == 2) { // set speed
|
||||
if (time >= 1000) {
|
||||
//timed_delay = time - BOLEX_C;
|
||||
timed_exposure = true;
|
||||
} else if (index == SPEED) { // set speed
|
||||
Exposure(time);
|
||||
if (time >= TIMED_EXPOSURE_CUTOFF) {
|
||||
Output(OUTPUT_TWO, OUTPUT_MEDIUM);
|
||||
} else if (time < 1000) {
|
||||
//timed_delay = 0;
|
||||
timed_exposure = false;
|
||||
Output(OUTPUT_ONE, OUTPUT_LONG);
|
||||
} else {
|
||||
Output(OUTPUT_ONE, OUTPUT_LONG);
|
||||
}
|
||||
} else if (index == 3) { //set direction
|
||||
} else if (index == DIRECTION) { //set direction
|
||||
if (time < 1000) {
|
||||
direction = true;
|
||||
Output(OUTPUT_ONE, OUTPUT_LONG);
|
||||
|
|
@ -328,8 +350,6 @@ void Intval2::Indicator (boolean state) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
String Intval2::State () {
|
||||
if (timed_exposure) {
|
||||
return String(timed_exposure_avg);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ class Intval2 {
|
|||
const uint8_t PIN_MOTOR_BACKWARD = 10;
|
||||
const uint8_t PIN_MICROSWITCH = 19; //A5
|
||||
const uint8_t BUTTONS[4] = {3, 4, 5, 6}; //trigger, delay, speed, direction
|
||||
const uint8_t TRIGGER = 0;
|
||||
const uint8_t DELAY = 1;
|
||||
const uint8_t SPEED = 2;
|
||||
const uint8_t DIRECTION = 3;
|
||||
|
||||
const uint16_t OUTPUT_SHORT = 75;
|
||||
const uint16_t OUTPUT_MEDIUM = 250;
|
||||
|
|
@ -20,6 +24,8 @@ class Intval2 {
|
|||
const uint8_t OUTPUT_ONE = 1;
|
||||
const uint8_t OUTPUT_TWO = 2;
|
||||
|
||||
const unsigned long TIMED_EXPOSURE_CUTOFF = 1000;
|
||||
|
||||
//MOTOR CONST
|
||||
const uint16_t MOTOR_RPM = 120;
|
||||
const float MOTOR_OPEN_FORWARD = 0.275; // 99deg
|
||||
|
|
@ -42,6 +48,8 @@ class Intval2 {
|
|||
volatile boolean delaying = false;
|
||||
volatile boolean open = false;
|
||||
volatile boolean closed = true;
|
||||
volatile boolean bulb = false;
|
||||
volatile boolean bulb_running = false;
|
||||
|
||||
volatile boolean timed_exposure_open = false; //is the shutter open only during a timed exposure
|
||||
volatile boolean timed_exposure_opening = false;
|
||||
|
|
@ -50,30 +58,34 @@ class Intval2 {
|
|||
volatile uint8_t microswitch_position = 0;
|
||||
volatile boolean microswitch_primed = false;
|
||||
|
||||
|
||||
//BUTTON VAR
|
||||
volatile int button_states[4] = {1, 1, 1, 1};
|
||||
volatile long button_times[4] = {0, 0, 0, 0};
|
||||
volatile long button_time = 0;
|
||||
volatile uint8_t button_states[4] = {1, 1, 1, 1};
|
||||
volatile unsigned long button_times[4] = {0, 0, 0, 0};
|
||||
volatile unsigned long button_time = 0;
|
||||
|
||||
//TIME VAR
|
||||
volatile unsigned long timer;
|
||||
volatile unsigned long frame_start = 0;
|
||||
volatile unsigned long delay_start = 0;
|
||||
volatile unsigned long open_start = 0;
|
||||
volatile unsigned long open_stop = 100; //ms to stop running after when camera is fully-opened
|
||||
volatile unsigned long open_avg = 300;
|
||||
volatile unsigned long close_start = 0;
|
||||
volatile unsigned long close_avg = 300;
|
||||
volatile unsigned long timelapse_delay = 42; //time between frames during timelapse
|
||||
volatile unsigned long timed_exposure_ms = 0;
|
||||
volatile unsigned long open_stop = 100; //ms to stop when camera is opened
|
||||
volatile unsigned long timed_exposure_delay = 0; //ms to delay once camera is open
|
||||
volatile unsigned long timed_exposure_avg = 600;
|
||||
volatile unsigned long exposure = 0;
|
||||
volatile unsigned long avg = 600;
|
||||
volatile unsigned long timed_exposure_avg = 600;
|
||||
volatile unsigned long open_avg = 300;
|
||||
volatile unsigned long close_avg = 300;
|
||||
|
||||
|
||||
|
||||
void PinsInit();
|
||||
void ButtonsInit();
|
||||
void Button (uint8_t index);
|
||||
void ButtonStart (uint8_t index);
|
||||
void ButtonEnd (uint8_t index, long time);
|
||||
|
||||
void TimelapseWatchDelay();
|
||||
|
|
|
|||
Loading…
Reference in New Issue