Looking at this now - seems everything is working but there's an issue with the ordering of module initialisation. Easiest solution for now is to just do:
require("HC-SR04");
var mymodule = require("mymodule")...;
... Or, I guess you're doing something like this in your module:
var foo = require("HC-SR04");
exports.abc = function() {
};
But if you did this, it'd all work:
exports.abc = function() {
var foo = require("HC-SR04");
};
... just to add, I don't think there's anything different with the projects code at all - all modules are handled the same right now. It's just that if modules use other modules, they're generally written not to use them in the global scope.
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.
Looking at this now - seems everything is working but there's an issue with the ordering of module initialisation. Easiest solution for now is to just do:
... Or, I guess you're doing something like this in your module:
But if you did this, it'd all work:
... just to add, I don't think there's anything different with the projects code at all - all modules are handled the same right now. It's just that if modules use other modules, they're generally written not to use them in the global scope.