Provide the source code of a microcontroller or tiny computer in JavaScript. Node.js-based computers are supported. Require f3js package and use its API to design the device enclosure.
var iw = 69 // 幅[mm][10,200]
, ih = 54 // 高さ[mm][10, 200]
, id = 15 // 奥行[mm][10, 200]
, dw = 7
, dh = 2
, w = iw + dh*2
, h = ih + dh*2
, d = id + dh*2;
var f3js = require('f3js')
, c = f3js.createContainer()
, p = c.drawJointRectangle(0, 0, w, h, dw, dh);
c.x = 10;
c.y = 10;
// 基板を固定する穴4つ
c.drawCircle(iw - 15.234 + dh, 2.539 + dh, 1.6);
c.c(iw - 13.965 + dh, 50.761 + dh, 1.6); // shorthand for drawCircle
c.c(iw - 65.995 + dh, 17.774 + dh, 1.6);
c.c(iw - 65.995 + dh, 45.683 + dh, 1.6);
var planes = p.extrude(d);
planes[0].x = w;
planes[0].y = 0;
planes[1].x = w;
planes[1].y = d * 2;
planes[2].x = w;
planes[2].y = d;
planes[3].x = w + h;
planes[3].y = d * 2;
for (var i = 0; i < planes.length-1; i ++) {
c.add(planes[i]);
}
var c2 = f3js.cc(); // shorthand for createContainer
c2.x = 10;
c2.y = h + 10;
c2.add(planes[4]);
var c3 = c2.cc();
c3.x = dh;
c3.y = dh;
// ピンヘッダを通す穴の並び4箇所
c3.pln(iw - 18.80, ih - 2.54, iw - 41.65, ih - 2.54);
c3.pln(iw - 45.73, ih - 2.54, iw - 63.50, ih - 2.54);
c3.pln(iw - 27.95, ih - 50.8, iw - 45.73, ih - 50.8);
c3.pln(iw - 50.8, ih -50.8, iw - 63.49, ih - 50.8);
// ピンヘッダ6本ぶんのまとまりを通す大きめの穴1箇所
c3.rc(iw - 61, ih - 21, -7, -9);
// USBポートと電源を通す穴2箇所
c3.rc(iw + 6.35, ih - 8.525, -16.875, -13.43);
c3.rc(iw + 2.905, ih - 40.275, -15.34, -10.9);
var c4 = c.cc();
c4.x = planes[1].x + dh;
c4.y = planes[1].y;
c4.rc(8.525, -dh, 13.43, 12);
c4.rc(40.275, -dh, 10.9, 12);