3 ms·
Creating an entire HTML page structure just to get to the code because you need a <script> tag? Oh god.
by cguess 11y ago
Creating an entire HTML page structure just to get to the code because you need a <script> tag? Oh god.
- ju-st 11y agoStill better than binary created by an obscure toolchain. [wrote the comment before I realized we're not talking about µC stuff]
- geonnave 11y agoExactly what I thought. I think they could even use the package.json-file approach of nodejs for defining an entry point for the program..
- cguess 11y agoI'm not 100% against Javascript for things like this. It does make it much easier for non-C coders to get involved (although, to be honest, beginning C isn't that hard, and if you're going down this path you should try and learn it anyways). It's the pretense of putting it all in an HTML document. The point of HTML is not anywhere close to the use case here. Javascript is way beyond its browser origins, why would it still need to be coupled? I can't imagine tossing in an HTML parser simplifies anything either. Oh the memory though... GC's on embedded devices scare the hell out of me.
- 0x4a42 11y agoYou don't need to create the whole page structure like in the example though. html, head and body tags are optional under certains conditions. [1] I guess you could just write the example code like this : <!doctype html> <script src="gpio.js"></script> <script> var v = 0; GPIO.getPort(196).then( function(port) { setInterval(toggleLight, 1000, port); } ); function toggleLight(port){ v = v ? 0 : 1; port.write(v); } </script> Just having the script tags would also probably works in most browsers but it wouldn't be standard compliant (if you care about it...). [1] http://www.w3.org/TR/html-markup/ http://www.w3.org/TR/html-markup/
- mhandley 11y agoThe equivalent stock Arduino demo is blink: void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); } From my experience of teaching many non-programmers how to use this sort of device, I think I'll stick with Arduino for now.
- MatthewPhillips 11y agoJust using script tags will work in every modern browser. I can't even remember how far back in IE you have to go for it not to work there.