MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fill

Function fill

examples/io/spi/ili9341/main.js:81–94  ·  view source on GitHub ↗
(color, xMin, xMax, yMin, yMax)

Source from the content-addressed store, hash-verified

79fill(0x07FF, 120, 240, 160, 320);
80
81function fill(color, xMin, xMax, yMin, yMax) {
82 doCmd(0x2a, xMin >> 8, xMin & 0xff, xMax >> 8, xMax & 0xff);
83 doCmd(0x2b, yMin >> 8, yMin & 0xff, yMax >> 8, yMax & 0xff);
84 doCmd(0x2c);
85
86 dc.write(1);
87
88 const lines = 4;
89 const pixels = new Uint16Array((xMax - xMin) * lines);
90 pixels.fill((color >> 8) | (color << 8)); // big endian
91
92 for (yMax -= yMin; yMax > 0; yMax -= lines)
93 spi.write(pixels.buffer);
94}
95
96function doCmd(register, ...data) {
97 spi.flush(true);

Callers 1

main.jsFile · 0.70

Calls 3

doCmdFunction · 0.70
writeMethod · 0.65
fillMethod · 0.65

Tested by

no test coverage detected