-
Notifications
You must be signed in to change notification settings - Fork 234
/
main.js
34 lines (29 loc) · 912 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Copyright (c) 2021 Satoshi Tanaka
*
* This file is part of the Moddable SDK.
*
* This work is licensed under the
* Creative Commons Attribution 4.0 International License.
* To view a copy of this license, visit
* <https://creativecommons.org/licenses/by/4.0>.
* or send a letter to Creative Commons, PO Box 1866,
* Mountain View, CA 94042, USA.
*
*/
import RMT from "pins/rmt";
import Timer from "timer";
const IrReceivePin = 33;
let inputRMT = new RMT({pin: IrReceivePin, channel: 0, divider: 80, direction: "rx", filter: 255, timeout: 30000, ringbufferSize: 512});
const data = new Uint16Array(512);
Timer.repeat(() => {
let result = inputRMT.read(data.buffer);
if (result.count) {
trace(`rawData[${result.count}] =\n[`);
for (let i = 0; i < result.count; i++) {
trace(`${data[i]}`);
if(i != result.count -1) trace(", ");
}
trace(`]\n`);
}
}, 100);