function LCD() { this.DC = B6; this.CE = B7; this.RST = B8; digitalPulse(this.RST, 0, 10); // pulse reset low SPI1.setup({ baud: 1000000, sck:B3, mosi:B5 }); } LCD.prototype.cmd = function (cmd) { digitalWrite(this.DC,0); SPI1.send(cmd, this.CE); }; LCD.prototype.data = function (data) { digitalWrite(this.DC,1); SPI1.send(data, this.CE); }; LCD.prototype.init = function () { this.cmd(0x21); // fnset extended this.cmd(0x80 | 0x40); // setvop (experiment with 2nd val to get the right contrast) this.cmd(0x14); // setbias 4 this.cmd(0x04 | 0x02); // temp control this.cmd(0x20); // fnset normal this.cmd(0x08 | 0x04); // dispctl normal this.pixels = new Uint8Array(6*84); }; LCD.prototype.setPixel = function (x,y,c) { var yp = y&7; y>>=3; this.cmd(0x40 | y); // Y addr this.cmd(0x80 | x); // X addr var p = x+y*84; if (c) this.pixels[p] |= 1<