<div dir="ltr">Hi James,<div><br></div><div>I thought the docs for digital.input mentioned that only input 2 or 3 can be used that way. The reason is that we actually use Arduino hardware interrupts there. There is code that, someday, we want to integrate into the runtime to handle all interrupts on all pins, but it grows the firmware, and we haven't done it yet. </div>
<div><br></div><div style>So, yes, your solution of polling the pin is the alternative. In future revs of the library, we'll either 1) try and support more pins for real interrupts, or 2) improve the error handling. That might be tricky, though; it is equivalent to, in C, trying to handle an interrupt that doesn't exist.</div>
<div style><br></div><div style>Feedback:</div><div style>It is very, very awesome to see someone hacking things with the tools we helped develop, even if the documentation needs work, etc. Very nice.</div><div style><br>
</div><div style>Trivial Tweaks:</div><div style>At a glance, you don't have anything grossly un-occamish in there. The use of the ALT makes sense; it is how you handle multiple channels in a non-deterministic way. You could, for example, create another named PROC perhaps, which would let you pull the code around line 50ish into its own space. Pass that PROC the channels it needs, which might make it easier to read what happens when things timeout in the outer ALT of flap.state.</div>
<div style><br></div><div style>(Or, if you prefer: the code in flap.state is the "least obvious" in the program. That doesn't make it "bad," but it might make it more confusing as you try and maintain/update the code later.)</div>
<div style><br></div><div style>Pulling out your pin states into a PROC setup() might make sense, which would also shorten your main(). Making a named proc for the block under line 124 might also make sense; then, your entire "main()" (or "motion.pir") would be a PAR block with a few named PROCs. </div>
<div style><br></div><div style>These are all, though, details, and easy edits. Like I started out, this is really cool. </div><div style><br></div><div style>Cheers,</div><div style>Matt</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Sat, Dec 22, 2012 at 4:53 AM, James Brown <span dir="ltr"><<a href="mailto:james.brown4994@gmail.com" target="_blank">james.brown4994@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-GB" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Again many thanks. I will work through this library now.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Here is the (nearly) completed code. Thanks to the assistance I have had I have made rapid progress after a slow start.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">In words this is what it does.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Monitors the cat flap: if my cat goes out, disarms. Comes back in, rearms.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">If the back door is opened, terminates the programme and indicates a lockout.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">When armed, if PIR is detected, fires the sprayer valve.<u></u><u></u></span></p><p class="MsoNormal">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Next steps will be:<u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>-<span style="font:7.0pt "Times New Roman""> </span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">A more elegant “bistable” for the flap.state process (i.e. not relying on the PRI ALT, although this works fine)<u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>-<span style="font:7.0pt "Times New Roman""> </span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Another lockout condition based on a timed flow monitor (to avoid flood in case of a malfunction) which will drive a close off valve<u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>-<span style="font:7.0pt "Times New Roman""> </span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Rewrite programme using approved styles<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">p.s. I have found that digital.input crashes my arduino uno if using any pin other than 2 or 3. Hence my own monitor.pin proc. I will have a look at what is going on here.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">James<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:jadudm@gmail.com" target="_blank">jadudm@gmail.com</a> [mailto:<a href="mailto:jadudm@gmail.com" target="_blank">jadudm@gmail.com</a>] <b>On Behalf Of </b>Matt Jadud<br>
<b>Sent:</b> 22 December 2012 01:04<br><b>To:</b> James Brown<br><b>Cc:</b> C.CC USERS<br><b>Subject:</b> Re: [C.CC USERS] Question about writing messages to serial port<u></u><u></u></span></p><div><div class="h5"><p class="MsoNormal">
<u></u> <u></u></p><div><p class="MsoNormal">Hi James,<u></u><u></u></p><div><p class="MsoNormal"><br>serial.write.string(TX0, "Hello*n")<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div>
<p class="MsoNormal"><a href="http://www.rockalypse.org/courses/cs220f11/resources/occamdoc/printing.html" target="_blank">http://www.rockalypse.org/courses/cs220f11/resources/occamdoc/printing.html</a><u></u><u></u></p></div>
<div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">The occamdocs for the Plumbing modules should be reasonably up-to-date.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div>
<div><p class="MsoNormal"><a href="http://www.rockalypse.org/courses/cs220f11/resources/occamdoc/index.html" target="_blank">http://www.rockalypse.org/courses/cs220f11/resources/occamdoc/index.html</a><u></u><u></u></p></div>
<div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Cheers,<u></u><u></u></p></div><div><p class="MsoNormal">Matt<u></u><u></u></p></div></div></div><div><p class="MsoNormal" style="margin-bottom:12.0pt">
<u></u> <u></u></p><div><p class="MsoNormal">On Fri, Dec 21, 2012 at 6:28 PM, James Brown <<a href="mailto:james.brown4994@gmail.com" target="_blank">james.brown4994@gmail.com</a>> wrote:<u></u><u></u></p><p class="MsoNormal">
Hi<br><br>On arduino, how do I write a message out to the serial port so that it<br>appears in the occplug screen? Would be useful for debugging.<br><br>James Brown<br><br><br>_______________________________________________<br>
users mailing list<br><a href="mailto:users@concurrency.cc" target="_blank">users@concurrency.cc</a><br><a href="http://lists.concurrency.cc/mailman/listinfo/users" target="_blank">http://lists.concurrency.cc/mailman/listinfo/users</a><u></u><u></u></p>
</div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div></blockquote></div><br></div>