mirror of
https://github.com/chirimen-oh/node-web-gpio.git
synced 2025-01-18 16:08:00 +00:00
パフォーマンスの改善: GPIOPortMapSizeMaxを設ける (1023)
This commit is contained in:
parent
90f36eb6f1
commit
95c5572819
2 changed files with 5 additions and 2 deletions
3
index.js
3
index.js
|
@ -8,6 +8,7 @@ const path = require("path");
|
|||
*/
|
||||
const PollingInterval = 100;
|
||||
const SysfsGPIOPath = "/sys/class/gpio";
|
||||
const GPIOPortMapSizeMax = 1023;
|
||||
const Uint16Max = 65535;
|
||||
function parseUint16(string) {
|
||||
const n = Number.parseInt(string, 10);
|
||||
|
@ -150,7 +151,7 @@ class OperationError extends Error {
|
|||
}
|
||||
exports.OperationError = OperationError;
|
||||
async function requestGPIOAccess() {
|
||||
const ports = new GPIOPortMap([...Array(Uint16Max + 1).keys()].map(portNumber => [
|
||||
const ports = new GPIOPortMap([...Array(GPIOPortMapSizeMax + 1).keys()].map(portNumber => [
|
||||
portNumber,
|
||||
new GPIOPort(portNumber)
|
||||
]));
|
||||
|
|
4
index.ts
4
index.ts
|
@ -9,6 +9,8 @@ const PollingInterval = 100;
|
|||
|
||||
const SysfsGPIOPath = "/sys/class/gpio";
|
||||
|
||||
const GPIOPortMapSizeMax = 1023;
|
||||
|
||||
const Uint16Max = 65535;
|
||||
|
||||
function parseUint16(string: string) {
|
||||
|
@ -227,7 +229,7 @@ export class OperationError extends Error {}
|
|||
|
||||
export async function requestGPIOAccess(): Promise<GPIOAccess> {
|
||||
const ports = new GPIOPortMap(
|
||||
[...Array(Uint16Max + 1).keys()].map(portNumber => [
|
||||
[...Array(GPIOPortMapSizeMax + 1).keys()].map(portNumber => [
|
||||
portNumber,
|
||||
new GPIOPort(portNumber)
|
||||
])
|
||||
|
|
Loading…
Add table
Reference in a new issue