From 7398f7993d4db573b0a38b74ed66e1c159dbed1a Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Mon, 25 Feb 2019 18:14:19 -0500 Subject: [PATCH] Start work on secondary projector feature --- app/data/cfg.json | 3 +- app/lib/arduino/index.js | 2 + app/main.js | 12 +- hardware/RelayShield.fzz | Bin 2538 -> 4598 bytes .../mcopy_projector_second.ino | 120 ++++++++++++++++++ scad/connectors.scad | 7 + 6 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 ino/components/mcopy_projector_second/mcopy_projector_second.ino diff --git a/app/data/cfg.json b/app/data/cfg.json index 64736d0..5d8d19f 100644 --- a/app/data/cfg.json +++ b/app/data/cfg.json @@ -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" } } } \ No newline at end of file diff --git a/app/lib/arduino/index.js b/app/lib/arduino/index.js index d2a27b3..9819d57 100644 --- a/app/lib/arduino/index.js +++ b/app/lib/arduino/index.js @@ -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) } diff --git a/app/main.js b/app/main.js index 143e6b7..4029cbf 100644 --- a/app/main.js +++ b/app/main.js @@ -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 = [] diff --git a/hardware/RelayShield.fzz b/hardware/RelayShield.fzz index 60f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he2f3cq-*-0T1`gWvVYi+RkNq?c_3{O5drd zldIg){&_l+pUd-cg0-`%E5{grJ#TWb3*llq$p@qos`S$G z;>4h5b5kzg59K1qasM69xtwj9xx?zB@GbIcCedgU?><-_1E=cItcfMFXr{BRdsw~D zRw)dNLpe5j$}bHly_kQVH8f#hLYy~^(+ONI&xH*s!e@d zCoFaq#356ER-QfvVLW@$Q_O=vs&lv_gWdE@#vVG`)SU%io0^3otDUfM7UOL6E8x0< zk=KfX>!vUcADi{W@gBIKJ|BdL8C-x2P-@0#M19~fT7?e`5J4%);XzVQPmS*fVgv?Q z9!sF0h!2ONWuVwgjhpJU4Jt}Z%|f&|BPH*|i^?s3j%)yrBf0eLzSP2N7eWN^R}loN zKP@B3URvDLrfmqa46G~!kTcTpP5?QrlC4`cVV3Gx72O>wPbs=f^@;%2>|5X2X~%jOZX0!rxe_Y7J|Dxy7S?#=nhdp z1n+`7i;`)y3+|f4THXbBE5RK%u)q*NoafAp0){G?8G(T6HTeo2CZAAzg4+a~y#nU2t~-0D1SpUG4vWfP3QL?qGSA!JXg421wr<++hR39^Mt) zVWKx_?jk!&GHG38*C^2XU1YZs*_pN4SW+?Jv7DAM0M&q0LCZMc9?#){LO=*bU1Vn= zRCJNuDe$6;?AnEpF0!jRjzEwuvO58Qy!*(`w`wOD2064$9;v{>KlPRe)vC7O927^02BZK g00;mFfL2agO*t!U2><|%jsTOt5itgs2><{90J*x_GXMYp diff --git a/ino/components/mcopy_projector_second/mcopy_projector_second.ino b/ino/components/mcopy_projector_second/mcopy_projector_second.ino new file mode 100644 index 0000000..fff995b --- /dev/null +++ b/ino/components/mcopy_projector_second/mcopy_projector_second.ino @@ -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); + } +} diff --git a/scad/connectors.scad b/scad/connectors.scad index 099b626..3a57cd2 100644 --- a/scad/connectors.scad +++ b/scad/connectors.scad @@ -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(); +