Skip to content

Commit

Permalink
add readNBits method
Browse files Browse the repository at this point in the history
  • Loading branch information
duart38 committed Mar 20, 2022
1 parent 7a1df00 commit c96552d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
x.ts
x.sh
sandbox.ts
dump.ts
test
Expand Down
12 changes: 11 additions & 1 deletion mod.ts
Expand Up @@ -240,5 +240,15 @@ export class Pin {
);
}

// TODO: read 'n' bits and pipe to file for
/**
* queues up an instruction to request a number of bits while sleeping in between each fetch.
* @param n number of bits to read
* @param toFile file to pipe the bits to
* @param sleep how much to sleep in between each bit fetch.
*/
readNBits(n: number, toFile: string, sleep = 0){
instructionsQueue.getInstance().add(
`for ((i = 0 ; i < ${n} ; i++)); do head -n 1 /sys/class/gpio/gpio${this.number}/value >> ${toFile}; sleep ${sleep}; done`
);
}
}

0 comments on commit c96552d

Please sign in to comment.