Start work on secondary projector feature

This commit is contained in:
mmcwilliams 2019-02-25 18:14:19 -05:00
parent 48b86ebc93
commit 7398f7993d
6 changed files with 142 additions and 2 deletions

View File

@ -101,7 +101,8 @@
"light_identifier" : "o",
"proj_light_identifier" : "q",
"proj_cam_light_identifier" : "r",
"proj_cam_identifier" : "s"
"proj_cam_identifier" : "s",
"proj_second_identifier" : "t"
}
}
}

View File

@ -301,6 +301,8 @@ mcopy.arduino.distinguish = async function () {
type = 'projector,camera,light'
} else if (data === mcopy.cfg.arduino.cmd.proj_cam_identifier) {
type = 'projector,camera'
} else if (data === mcopy.cfg.ardino.cmd.proj_second_identifier) {
type = 'projector_second'
}
return resolve(type)
}

View File

@ -250,6 +250,15 @@ dev.connectDevice = async function (device, type) {
return false
}
log.info(`Connected to ${device} as PROJECTOR`, 'SERIAL', true, true)
} else if (type === 'projector_second') {
dev.connected.projector_second = device
arduino.alias('projector_second', device)
try {
connectSuccess = await arduino.connect('projector_second', device, false)
} catch (err) {
console.error(err)
return false
}
}
return connectSuccess
}
@ -266,7 +275,8 @@ dev.all = async function (devices) {
dev.connected = {
projector : false,
camera : false,
light : false
light : false,
projector_second : false
}
let checklist = []

Binary file not shown.

View File

@ -0,0 +1,120 @@
boolean debug_state = false;
//const int proj_pin = 5; //relay 4
//const int proj_time = {{proj.time}};
//const int proj_delay = {{proj.delay}};
boolean proj_dir = true;
const char cmd_projector = 'p';
const char cmd_proj_forward = 'g';
const char cmd_proj_backward = 'h';
const char cmd_debug = 'd';
const char cmd_connect = 'i';
volatile char cmd_char = 'z';
const char cmd_mcopy_identifier = 'm';
const char cmd_proj_identifier = 't'; //projector second
const int serialDelay = 5;
void setup() {
Serial.begin(57600);
Serial.flush();
Serial.setTimeout(serialDelay);
}
void loop() {
if (Serial.available()) {
/* read the most recent byte */
cmd_char = (char)Serial.read();
}
if (cmd_char != 'z') {
cmd(cmd_char);
cmd_char = 'z';
}
}
void cmd (char val) {
if (val == cmd_debug) {
debug();
} else if (val == cmd_connect) {
connect();
} else if (val == cmd_mcopy_identifier) {
identify();
} else if (val == cmd_projector) {
proj_start();
} else if (val == cmd_proj_forward) {
proj_direction(true);
} else if (val == cmd_proj_backward) {
proj_direction(false);
}
}
void debug () {
debug_state = true;
Serial.println(cmd_debug);
log("debugging enabled");
}
void connect () {
Serial.println(cmd_connect);
log("connect()");
}
void identify () {
Serial.println(cmd_proj_identifier);
log("identify()");
}
void proj_start () {
if (proj_dir) {
digitalWrite(proj_fwd_pin, HIGH);
digitalWrite(proj_bwd_pin, LOW);
} else {
digitalWrite(proj_bwd_pin, HIGH);
digitalWrite(proj_fwd_pin, LOW);
}
proj_running = true;
delay(500); // Let bump pass out of microswitch
//delay(1300); //TEMPORARY DELAY FOR TESTING TIMING
}
void proj_reading () {
proj_micro_raw = digitalRead(proj_micro_pin);
if (proj_micro_raw == 1) {
//do nothing
} else if (proj_micro_raw == 0) {
proj_stop();
}
//delay(1); //needed?
}
void proj_stop () {
digitalWrite(proj_bwd_pin, LOW);
digitalWrite(proj_fwd_pin, LOW);
proj_running = false;
Serial.println(cmd_projector);
log("projector()");
}
void proj_direction (boolean state) {
proj_dir = state;
if (state) {
Serial.println(cmd_proj_forward);
log("proj_direction -> true");
} else {
Serial.println(cmd_proj_backward);
log("proj_direction -> false");
}
//delay(50); //delay after direction change to account for slippage of the belt
}
void log (String msg) {
if (debug_state) {
Serial.println(msg);
}
}

View File

@ -79,6 +79,13 @@ module female_jk103 () {
difference () {
body();
translate([0, 0, 25]) rotate([0, 180, 0]) jk_pins(0.5, 25);
translate([0, 0, -3]) rotate([0, 0, 180]) male_jk103_neg();
//bolt
translate([15, 0, 5]) rotate([0,90,0]) cylinder(r = 1, h = 20, center = true, $fn = 40);
}
}
//rotate([180, 0, 0]) male_jk103();
//male_jk103_back();
female_jk103();