Skip to content

Commit

Permalink
update JavaScript ECMA-419 touch driver to sync with #1065. Also, cle…
Browse files Browse the repository at this point in the history
…an-up.
  • Loading branch information
phoddie committed Mar 16, 2023
1 parent 7d1a6eb commit 9107526
Showing 1 changed file with 38 additions and 30 deletions.
68 changes: 38 additions & 30 deletions modules/drivers/sensors/ft6206/ft6206.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,49 @@ class FT6206 {
address: 0x38,
...sensor
});
io.buffer = new Uint8Array(12); // two touch points

if (reset) {
io.reset = new reset.io({
...reset
});

try {
io.buffer = new Uint8Array(12); // two touch points

if (reset) {
io.reset = new reset.io({
...reset
});

io.reset.write(0);
Timer.delay(5);
io.reset.write(1);
Timer.delay(150);
}

io.reset.write(0);
Timer.delay(5);
io.reset.write(1);
Timer.delay(150);
}
const vendor = io.readUint8(0xA8);
if ((17 !== vendor) && (1 !== vendor))
throw new Error("unexpected vendor");

if (17 !== io.readUint8(0xA8))
throw new Error("unexpected vendor");
const id = io.readUint8(0xA3);
if ((6 !== id) && (100 !== id))
throw new Error("unexpected chip");

const id = io.readUint8(0xA3);
if ((6 !== id) && (100 !== id))
throw new Error("unexpected chip");
if (interrupt && onSample) {
io.interrupt = new interrupt.io({
...interrupt,
edge: interrupt.io.Falling,
onReadable: onSample.bind(this)
});
}
if (target)
this.target = target;

if (interrupt && onSample) {
io.interrupt = new interrupt.io({
...interrupt,
edge: interrupt.io.Falling,
onReadable: onSample.bind(this)
this.configure({
active: false,
threshold: 128,
timeout: 10
});
}
if (target)
this.target = target;

this.configure({
active: false,
threshold: 128,
timeout: 10
});
catch (e) {
this.close();
throw e;
}
}
close() {
this.#io?.reset?.close();
Expand Down Expand Up @@ -125,7 +133,7 @@ class FT6206 {
delete io.none;

const data = io.buffer;
const count = io.readBuffer(0x03, data);
io.readBuffer(0x03, data);
const result = new Array(length);
for (let i = 0; i < length; i++) {
const offset = i * 6;
Expand Down

0 comments on commit 9107526

Please sign in to comment.