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

Function onReadyx

examples/io/firmata/client/main.js:78–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76 i2c.read(1); // read one byte
77 },
78 onReadyx() {
79 const poco = new this.Poco;
80 // const white = poco.makeColor(255, 255, 255);
81 const black = poco.makeColor(0, 0, 0);
82 const gray = poco.makeColor(128, 128, 128);
83 const red = poco.makeColor(255, 0, 0);
84 const green = poco.makeColor(0, 255, 0);
85 poco.begin();
86 poco.fillRectangle(black, 0, 0, poco.width, poco.height);
87 poco.end();
88
89// let led = new this.Digital({
90// pin: 2,
91// mode: this.Digital.Output,
92// });
93//
94// let value = 0;
95// System.setInterval(() => {
96// led.write(value);
97// value ^= 1;
98// }, 500);
99
100// let analog = new this.Analog({
101// pin: 17,
102// onReadable() {
103// const value = this.read();
104// trace(`Analog: ${value}\n`);
105// if (value > 1023)
106// this.close();
107// }
108// });
109
110 /* let remoteButton = */ new this.DigitalBank({
111 pins: 0x01,
112 bank: 0,
113 mode: this.Digital.Input,
114 onReadable() {
115 trace(`Remote Button: ${this.read()}\n`);
116 const size = 80;
117 poco.begin((poco.width - size) >> 1, (poco.height >> 2) - (size >> 1), size, size);
118 poco.fillRectangle(this.read() ? gray : green, 0, 0, poco.width, poco.height);
119 poco.end();
120 }
121 });
122
123 /* let localButton = */ new Digital({
124 pin: 0,
125 mode: Digital.Input,
126 edge: Digital.Rising | Digital.Falling,
127 onReadable() {
128 const size = 80;
129 trace(`Local Button: ${this.read()}\n`);
130 poco.begin((poco.width - size) >> 1, ((poco.height >> 2) * 3) - (size >> 1), size, size);
131 poco.fillRectangle(this.read() ? gray : red, 0, 0, poco.width, poco.height);
132 poco.end();
133 }
134 });
135

Callers

nothing calls this directly

Calls 4

makeColorMethod · 0.95
beginMethod · 0.95
fillRectangleMethod · 0.95
endMethod · 0.95

Tested by

no test coverage detected