Looks good, just a lil' bit hacked ( var _this = this; and later var ht = this;). I'd keep it the same variable in both lines - I like to use "var self = this;" as it works without underscore.
Maybe a disconnect function would be nice, to remove the watch when no longer needed. But memory is limited, and I don't think that anyone would ever use it. Unless trying to connect different devices to the same pin, which would be a bad design, better using I2C instead.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Looks good, just a lil' bit hacked (
var _this = this;
and latervar ht = this;
). I'd keep it the same variable in both lines - I like to use "var self = this;" as it works without underscore.Maybe a disconnect function would be nice, to remove the watch when no longer needed. But memory is limited, and I don't think that anyone would ever use it. Unless trying to connect different devices to the same pin, which would be a bad design, better using I2C instead.